1. Which are correct for file systems?
    • Indexed allocation supports direct access, but suffers from extemal firagmentation.
    • In the UNIX system, it recognizes three classifications of users in connection with each file; that is owner, group, and universe.
    • Both sequential and direct access can be supported by contiguous allocation.
    • It is inefficient to support a direct-access capability for linked-allocation files.
詳解
  • 索引配置(indexed allocation)將檔案的所有磁碟區塊指標集中放在索引區塊(index block)中,因此支援直接存取(direct access),且 ** 不會發生外部碎片(external fragmentation)** 因為任何空閒磁碟區塊都能配置給索引區塊或資料區塊;主要問題是索引區塊本身的空間開銷與大檔案的單一索引區塊容量上限)
  • UNIX/類 UNIX 檔案系統對每個檔案區分三種使用者類別來設定權限(read、write、execute):owner(檔案擁有者)、group(所屬群組)與 universe(其他所有使用者,常稱 others /world)
  • 連續配置(contiguous allocation)將檔案存放在磁碟上連續的區塊中,只要知道起始區塊編號與檔案長度,既可依序往後讀取(sequential access),也能直接透過 start_block + offset_block 算出目標區塊位置進行直接存取(direct access)
  • 連結配置(linked allocation)中,每個磁碟區塊都包含指向下一個區塊的指標,若要存取第 nn 個邏輯區塊,必須從第一個區塊開始沿著指標循序走訪 n−1n-1 個區塊,因此支援直接存取的效率很低
  1. Consider a file system on a disk that has both logical and physical block size of 128-bvtes and the information about each file is already in memory. Assume it uses indexed allocation and no block data is cached. How many blocks must be read for access one block from the disk
    • 1
    • 2
    • 3
    • 4
詳解

在索引配置(indexed allocation)且沒有任何磁碟區塊被快取(no block data is cached)的情況下,要從磁碟讀取一個資料區塊,必須讀取 2 個區塊:

  1. 檔案基本資訊已在記憶體中: 題目說明「information about each file is already in memory」,代表該檔案的 FCB(File Control Block)或目錄項目已經載入記憶體,因此作業系統已經直接知道該檔案的索引區塊(index block)位址,不需要額外讀取目錄區塊
  2. 第 1 次磁碟區塊讀取(讀取索引區塊): 由於沒有任何區塊資料被快取,索引區塊本身仍在磁碟上。作業系統必須先從磁碟讀取 1 個索引區塊(index block),才能查出目標邏輯區塊對應的實體資料區塊位址
  3. 第 2 次磁碟區塊讀取(讀取實際資料區塊): 取得實體區塊位址後,再從磁碟讀取該 1 個資料區塊(data block)。總計需讀取 1+1=21 + 1 = \mathbf{2} 個區塊(題目給定的 128-byte 區塊大小在此題屬於干擾資訊,不影響單層索引配置的區塊讀取次數)
  1. Suppose the linked allocation strategy is used in the above question, how physical blocks must be read from the disk when we want to read 422th this file?
    • 1
    • 2
    • 3
    • 4
詳解

沿用前一題的條件:每個磁碟區塊(block)大小為 128 bytes,且檔案資訊(起始區塊指標)已在記憶體中、沒有任何區塊資料被快取,改用連結配置(linked allocation)讀取檔案的第 422 個 byte(即 422th byte of this file):

算出第 422 個 byte 位於第幾個邏輯區塊:

  1. 每個區塊大小為 128 bytes128\text{ bytes}:
    • 第 1 個區塊:bytes 0 ~ 127(若從 1 起算為 1 ~ 128)
    • 第 2 個區塊:bytes 128 ~ 255(129 ~ 256)
    • 第 3 個區塊:bytes 256 ~ 383(257 ~ 384)
    • 第 4 個區塊:bytes 384 ~ 511(385 ~ 512)
      不論位元組索引從 0 起算(422÷128=3…38→422 \div 128 = 3 \dots 38 \rightarrow 第 4 個區塊)或從 1 起算(⌈422/128⌉=4→\lceil 422 / 128 \rceil = 4 \rightarrow 第 4 個區塊),目標資料都落在檔案的第 4 個邏輯區塊。
  2. 連結配置(Linked Allocation)的讀取方式:
    在連結配置中,檔案目錄(已在記憶體中)只記錄第 1 個實體區塊的指標,而第 2、3、4 個區塊的指標分別存放在前一個區塊的尾部。因此必須依序走訪指標鏈:
    • 第 1 次讀取: 讀入第 1 個區塊,取得指向第 2 個區塊的指標
    • 第 2 次讀取: 讀入第 2 個區塊,取得指向第 3 個區塊的指標
    • 第 3 次讀取: 讀入第 3 個區塊,取得指向第 4 個區塊的指標
    • 第 4 次讀取: 讀入第 4 個區塊,取得第 422 個 byte 的資料
      總計必須從磁碟讀取 4 個實體區塊。(註:若題意考量「每個區塊需保留 4 bytes 存指標,實際可用資料空間為 124 bytes」,則 ⌈422/124⌉=4\lceil 422 / 124 \rceil = 4,同樣落在第 4 個區塊,答案依然是 4。)
  1. Which one of the following is a correct statement about disk space allocation methods?
    • a Linked allocation may suffer from the exteral fragmentation problem
    • Linked allocation can efficiently support direct accesses into a file.
    • Contiguous allocation can be enhanced by using “extents” to solve its non-sequcntial access performance problem.
    • Indexed allocation does not suffer from the external fragmentation problem.
    • None of the above
詳解

在連續配置(contiguous allocation)中使用 extents(連續區塊群組)主要是為了減少配置時的外部碎片/簡化配置與動態擴充管理,並非用來解決「非循序存取(non-sequential access)」效能問題;連續配置本身其實很適合直接/隨機存取(只要 start + offset 即可算得位置)

  1. Which of the following statements about file systems and I/O are correct?
    • A filesystem must be mounted at the root level.
    • A single write operation in RAID-5 requires two read and two write block access.
    • Data on disk can be directly moved to memory without CPU intervention through direct-memory-access (DMA) Scheme.
    • Contiguous allocation is adequate to sequential access but of poor performance for random access.
    • Linked allocation does not suffer from the external fragmentation problem.
詳解
  • 檔案系統不一定只能掛載在根目錄 /;在 UNIX/Linux 中,只要目標掛載點(mount point)是一個存在的目錄,就能掛載到任何子目錄下(例如 /mnt、/home 或 /var)
  • 在 RAID-5 中,若更新單一資料區塊而不重讀整個 stripe,會採用 Read-Modify-Write 機制:讀取舊的目標資料區塊與舊的同位檢查區塊(parity block)(2 次 read)。透過 XOR 運算算出新的 parity(new_parity=old_parity⊕old_data⊕new_data\text{new\_parity} = \text{old\_parity} \oplus \text{old\_data} \oplus \text{new\_data})。寫入新的目標資料區塊與新的 parity block(2 次 write)。總計為 2 次讀取 + 2 次寫入。
  • 連續配置(contiguous allocation)對循序存取與隨機/直接存取(random /direct access)都很有效率,因為可直接由起始區塊加上區塊位移量定位,不需要循序走訪指標。
  1. Unix-like operating systems use access permissions to control file access. Given an access permission 0751, which of the following statement is correct:

    • Both the owner and group members can read and execute the file
    • The group members can read and write the file
    • The group members can write and execute the file.
    • Others can read the file
    • Others can write the file
  2. Which of the following statements are true?

    • Smartphones normally do not have hard disk drives (HDDs).
    • Solid state drives (SSDs) are replacing HDDs where speed, power consumption and durability are more important considerations.
    • Secondary storage is normally non-volatile.
    • Cloud storage has become a popular way for data storage.
    • Wearable devices are normally equipped with hard disk drives to increase its storage space.
  3. Which of the following RAID configurations improve disk I/O performance during normal operation and also provide fault tolerance for single disk failure?

    • RAID 0
    • RAID 1
    • RAID 1+0
    • RAID 0+1
    • RAID 5
詳解
  • RAID 0(不符合): 採用區塊交錯(striping),能提升讀寫 I/O 效能,但完全沒有容錯能力(no fault tolerance),任一顆磁碟損毀就會導致整個陣列資料遺失。
  • RAID 1(視題意/通常不選作全面 I/O 提升): 採用磁碟鏡像(mirroring),具備單顆磁碟容錯能力;讀取時可從多個鏡像平行讀取而加快,但寫入時必須同時寫入兩顆磁碟,寫入效能不會比單顆磁碟快(且容量利用率僅 50%)。多數標準考題會將它與 striping 類(RAID 1+0、RAID 0+1、RAID 5)區分開來。
  • RAID 1+0(符合): 先鏡像(mirror)再交錯(stripe)。兼具 striping 的平行讀寫效能提升與 mirroring 的容錯能力,單顆磁碟損毀可正常運作。
  • RAID 0+1(符合): 先交錯(stripe)再鏡像(mirror)。同樣具備 striping 的 I/O 效能提升與單顆磁碟損毀容錯能力(若同一條 stripe 內僅壞 1 顆,另一份 mirror 仍完整)。
  • RAID 5(符合): 採用區塊交錯搭配分散式同位檢查(distributed parity)。具備單顆磁碟容錯能力(可利用 parity 重建遺失資料),讀取可平行存取提升效能;雖然單一區塊寫入需額外處理 parity(Read-Modify-Write),但在一般儲存架構選擇題中仍屬於兼具效能與單碟容錯的設定。
  1. Which of the following are true about SAN (storage area network) vs. NAS (network attached storage)?
    • Both are accessed via network
    • NAS operates at block level while SAN operates at file level
    • CIFS/SMB and NFS are examples of NAS protocols
    • For databases, SAN is often the preferred choice over NAS
    • Almost any machine running Microsoft Windows with LAN connectivity can be configured to access a NAS
詳解
  • Both are accessed via network(正確): SAN 與 NAS 都是透過網路提供儲存服務,而非直接掛在單一主機內部的本機匯流排上(SAN 通常走 Fibre Channel 或 iSCSI 網路;NAS 則走一般 IP / Ethernet 網路)。
  • NAS operates at block level while SAN operates at file level(錯誤): 兩者恰好相反。SAN 運作在區塊層級(block level),主機看到的是像本機硬碟般的裸區塊裝置(可自行格式化檔案系統);NAS 運作在檔案層級(file level),由 NAS 裝置自行管理檔案系統,透過網路直接提供檔案/目錄共用。
  • CIFS/SMB and NFS are examples of NAS protocols(正確): NAS 常用的檔案共用協定包含 SMB/CIFS(常見於 Windows 環境與跨平台檔案分享)與 NFS(常見於 Linux / UNIX 環境)。
  • For databases, SAN is often the preferred choice over NAS(正確): 關聯式資料庫等高 IOPS、低延遲工作負載通常偏好 SAN,因為 SAN 的區塊層級存取與專用儲存網路能提供較低的傳輸延遲與較高的吞吐量。
  • Almost any machine running Microsoft Windows with LAN connectivity can be configured to access a NAS(正確): 只要 Windows 主機連上區域網路(LAN),就能透過 SMB/CIFS 掛載網路磁碟機或存取共用資料夾來使用 NAS,設定門檻低。
  1. Which of the following are correct for consistency semantics for file systems?
    • Consistent semantic specify when the ownership of a lock will be transferred to another process.
    • Consistent semantics specify when modification of data by one process will be observable by other processes.
    • UNIX semantic is supported by modern distributed file systems.
    • Session semantic requires one file to be associated with a single physical image that is accessed as an exclusive
      resource.
    • Consistent semantic specify how multiple processes of a system are to access a shared file.
詳解
  • 一致性語意的核心定義之一,就是明確規定當某個行程修改檔案資料後,其他行程何時能看到這些修改結果(例如立即生效的 UNIX 語意,或關閉檔案後才生效的 session 語意)。
  • 嚴格的 UNIX 語意要求寫入立即對所有共用該檔案的行程可見,在分散式檔案系統中若要維持嚴格 UNIX 語意會產生極高的網路與同步開銷,因此多數分散式檔案系統(如 NFS、AFS)通常採用較寬鬆的語意(如 close-to-open 或 session semantics),而非完整支援嚴格 UNIX 語意。
  • Session semantics(工作階段語意)指的是:行程開啟檔案後所做的修改,在檔案關閉前只對該 session 自己可見;關閉檔案後,修改才會對後續開啟該檔案的 session 可見(若有多個 session 同時修改,通常採最後關閉者覆蓋或特定合併規則),並非將檔案鎖定為單一實體映像的獨占資源。
  1. Which of the fallowing are correct statements about disks?
    • Low-level formating creates a file system on a disk partition.
    • A disk sector contains a header, a data area, and a trailer.
    • A file system must first be created on a disk partition before files can be stored on the disk partition.
    • In UNIX, the disk scheduling algorithm is performed in the disk controller.
    • A file system can be created across multiple disk partitions.
詳解
  • 低階格式化(low-level formatting /physical formatting)是在磁碟各磁區寫入標頭、資料區與尾端等實體資料結構,以便磁碟控制器識別;在分割區上建立檔案系統屬於高階格式化(high-level formatting /logical formatting,如 mkfs)
  • 傳統磁碟磁區(sector)結構通常包含 header(磁區編號、磁柱/磁軌資訊等)、data area(實際資料區,常見 512 bytes 或 4096 bytes)與 trailer(含錯誤修正碼 ECC,用於偵測與修正讀取錯誤)
  • 若要以一般檔案與目錄結構存放檔案,必須先在分割區上建立檔案系統並掛載(mount);若未建立檔案系統,通常只能當作 raw device 或 swap 空間使用
  • 磁碟排程演算法(如 FCFS、SSTF、SCAN、C-SCAN)主要由作業系統核心(I/O 排程器/裝置驅動程式)負責維護與排程,而非交由磁碟控制器決定
  • 透過邏輯磁區管理(LVM)或跨分割區串接/條帶化(concatenation /striping/ RAID)等機制,單一檔案系統可以跨越多個磁碟分割區建立與擴充

===
錯過的觀點總結:

  • Free space management
  • File Allocation Methods
    • Contiguous allocation:有外碎,對循序存取與隨機/直接存取(random /direct access)都很有效率
    • Linked allocation:無外碎
    • Indexed allocation:無外碎
  • RAID
    • single write operation in RAID-5 requires two read and two write block access
  • Consistency semantics(一致性語意)
    • 明確規定當某個行程修改檔案資料後,其他行程何時能看到這些修改結果
    • UNIX semantic:寫入立即對所有共用該檔案的行程可見
    • Session semantics:行程開啟檔案後所做的修改,在檔案關閉前只對該 session 自己可見;關閉檔案後,修改才會對後續開啟該檔案的 session 可見
更新於