ReFS 上的區塊複製Block cloning on ReFS

適用於:Windows Server (半年度管道)、Windows Server 2016Applies to: Windows Server (Semi-Annual Channel), Windows Server 2016

區塊複製會指示檔案系統代表應用程式複製一個範圍的檔案位元組,其中目的檔案可能與來源檔案相同或不同。Block cloning instructs the file system to copy a range of file bytes on behalf of an application, where the destination file may be the same as, or different from, the source file. 然而,複製作業因為會觸發基礎實體資料昂貴的讀取與寫入,所以成本高昂。Copy operations, unfortunately, are expensive, since they trigger expensive read and writes to the underlying, physical data.

不過,ReFS 上的區塊複製能作為低成本中繼資料作業執行複製,而無須讀取或寫入檔案資料。Block cloning in ReFS, however, performs copies as a low-cost metadata operation rather than reading from and writing to file data. 因為 ReFS 可讓多個檔案共用相同的邏輯叢集 (磁碟區上的實體位置),所以複製作業只須重相對應檔案區域來分隔實體位置,進而將昂貴的實體作業轉換為快速且具邏輯的作業。Because ReFS enables multiple files to share the same logical clusters (physical locations on a volume), copy operations only need to remap a region of a file to a separate physical location, converting an expensive, physical operation to a quick, logical one. 這能更快完成複製,並產生較少的存放裝置 I/O。This allows copies to complete faster and generate less I/O to the underlying storage. 這項改善同時使虛擬工作負載受益,有鑑於使用區塊複製作業時 .vhdx 檢查點合併作業會大幅加速。This improvement also benefits virtualization workloads, as .vhdx checkpoint merge operations are dramatically accelerated when using block clone operations. 此外,因為多個檔案可共用相同的邏輯叢集,所以相同的資料便不會以實體方式多次儲存,進而改善儲存容量。Additionally, because multiple files can share the same logical clusters, identical data isn't physically stored multiple times, improving storage capacity.

運作方式How it works

ReFS 上的區塊複製將檔案資料作業轉換為中繼資料作業。Block cloning on ReFS converts a file data operation into a metadata operation. 為了達成此項最佳化,ReFS 為複製的區域將參考計數引入其中繼資料。In order to make this optimization, ReFS introduces reference counts into its metadata for copied regions. 此參考計數會記錄參考相同實體區域的相異檔案區域數。This reference count records the number of distinct file regions that reference the same physical regions. 這能讓多個檔案共用相同的實體資料:This allows multiple files to share the same physical data:

在多個檔案參考相同區域時顯示參考計數更新

ReFS 透過保留各個邏輯叢集的參考計數,讓檔案間的隔離不中斷:寫入共用區域會觸發寫入時配置機制,其中 ReFS 會為傳入的寫入配置新的區域。By keeping a reference count for each logical cluster, ReFS doesn't break the isolation between files: writes to shared regions trigger an allocate-on-write mechanism, where ReFS allocates a new region for the incoming write. 此項機制保留了共用邏輯叢集的完整性。This mechanism preserves the integrity of the shared logical clusters.

範例Example

假設有 X 和 Y 兩個檔案,其中兩個檔案都分別由三個區域組成,且各個區域都對應至不同的邏輯叢集。Suppose there are two files, X and Y, where each file is composed of three regions, and each region maps to separate logical clusters.

這兩個檔案各擁有三個相異區域且全對應至參考計數為 1 的區域

現在假設應用程式發出從檔案 X 至檔案 Y 的區塊複製作業,使區域 A 與 B 於區域 E 的位移進行複製。下列檔案系統狀態將導致:Now suppose an application issues a block clone operation from File X to File Y, for regions A and B to be copied at the offset of region E. The following file system state would result:

封鎖之複製區域的參考計數顯示為 2

此檔案系統狀態顯示區塊複製區域複製成功。This file system state reveals a successful duplication of the block cloned region. 因為 ReFS 僅透過將 VCN 更新至 LCN 對應來執行此複製作業,所以未讀取任何實體資料,且未覆寫檔案 Y 中的任何實體資料。Because ReFS performs this copy operation by only updating VCN to LCN mappings, no physical data was read, nor was the physical data in File Y overwritten. 檔案 X 與 Y 現在共用邏輯叢集,由資料表中的參考計數所反映。File X and Y now share logical clusters, reflected by the reference counts in the table. 因為未以實體方式複製任何資料,所以 ReFS 得以降低磁碟區上的容量消耗。Because no data was physically copied, ReFS reduces capacity consumption on the volume.

現在假設應用程式嘗試覆寫檔案 X 中的區域 A。ReFS 將複製共用區域、適度更新參考計數,並執行新複製區域的傳入寫入。Now suppose the application attempts to overwrite region A in File X. ReFS will duplicate the shared region, update the reference counts appropriately, and perform the incoming write to the newly duplicated region. 如此可確保維持檔案間的隔離。This ensures that isolation between the files is preserved.

透過寫入新區域 G 及更新參考計數來保留隔離

修改寫入後,區域 B 仍由這兩個檔案所共用。After the modifying write, region B is still shared by both files. 注意,若區域 A 大於叢集,便僅會複製修改的叢集,且剩餘的部分會維持為共用。Note that if region A were larger than a cluster, only the modified cluster would have been duplicated, and the remaining portion would have remained shared.

功能限制與備註Functionality restrictions and remarks

  • 來源與目的地區域必須以叢集界限作為開頭與結尾。The source and destination region must begin and end at a cluster boundary.
  • 複製的區域長度必須小於 4GB。The cloned region must be less than 4GB in length.
  • 可對應至相同實體區域的檔案區域數上限為 8175。The maximum number of file regions that can map to the same physical region is 8175.
  • 目的地區域不得延伸超過檔案結尾。The destination region must not extend past the end of the file. 若應用程式要使用複製的資料延伸目的地,其必須先呼叫 SetEndOfFileIf the application wishes to extend the destination with cloned data, it must first call SetEndOfFile.
  • 若來源與目的地區域位於相同檔案,其不得重疊。If the source and destination regions are in the same file, they must not overlap. (應用程式可繼續,方法是將區塊複製作業分割為多個不再重疊的多個區塊複製)。(The application may be able to proceed by splitting up the block clone operation into multiple block clones that no longer overlap).
  • 來源與目的檔案必須位於相同的 ReFS 磁碟區。The source and destination files must be on the same ReFS volume.
  • 來源與目的檔案必須具有相同的完整性資料流設定。The source and destination files must have the same Integrity Streams setting.
  • 若來源檔案為疏鬆,目的檔案也必須為疏鬆。If the source file is sparse, the destination file must also be sparse.
  • 區塊複製作業會中斷「共用伺服器用戶端檔案鎖」(也稱為層級 2 伺服器用戶端檔案鎖)。The block clone operation will break Shared Opportunistic Locks (also know as Level 2 Opportunistic Locks).
  • ReFS 磁碟區必須使用 Windows Server 2016 格式化,且若正在使用容錯移轉叢集,叢集功能等級的格式時間必須為 Windows Server 2016 或更新版本。The ReFS volume must have been formatted with Windows Server 2016, and if Failover Clustering is in use, the Clustering Functional Level must have been Windows Server 2016 or later at format time.

另請參閱See also