ReFS 完整性資料流ReFS integrity streams

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

完整性資料流是 ReFS 的選用功能,可使用總和檢查碼驗證和維護資料的完整性。Integrity streams is an optional feature in ReFS that validates and maintains data integrity using checksums. 雖然 ReFS 一律會在中繼資料上使用總和檢查碼,但 ReFS 預設不會在檔案資料上產生或驗證總和檢查碼。While ReFS always uses checksums for metadata, ReFS doesn't, by default, generate or validate checksums for file data. 完整性資料流這項功能可讓使用者針對檔案資料使用總和檢查碼。Integrity streams is an optional feature that allows users to utilize checksums for file data. 啟用完整性資料流時,ReFS 可以明確判斷資料為有效或損毀。When integrity streams are enabled, ReFS can clearly determine if data is valid or corrupt. 此外,ReFS 與儲存空間可共同自動修正損毀的中繼資料及資料。Additionally, ReFS and Storage Spaces can jointly correct corrupt metadata and data automatically.

運作方式How it works

個別檔案、目錄或整個磁碟區可啟用完整性資料流,且完整性資料流設定可隨時切換。Integrity streams can be enabled for individual files, directories, or the entire volume, and integrity stream settings can be toggled at any time. 此外,檔案及目錄的完整性資料流設定繼承自其父目錄。Additionally, integrity stream settings for files and directories are inherited from their parent directories.

一旦啟用完整性資料流,ReFS 將為該檔案中繼資料夾中的特定檔案建立和維護總和檢查碼。Once integrity streams is enabled, ReFS will create and maintain a checksum for the specified file(s) in that file's metadata. 此總和檢查碼允許 ReFS 在存取之前先驗證該資料的完整性。This checksum allows ReFS to validate the integrity of the data before accessing it. 在傳回任何啟用完整性資料流的資料之前,ReFS 會先計算它的總和檢查碼:Before returning any data that has integrity streams enabled, ReFS will first calculate its checksum:

<img src=media/compute-checksum.gif alt="Compute checksum for file data"/>

然後,此總和檢查碼將會與檔案中繼資料的總和檢查碼進行比對。Then, this checksum is compared to the checksum contained in the file metadata. 如果總和檢查碼相符,則會將資料標記為有效並傳回至使用者。If the checksums match, then the data is marked as valid and returned to the user. 如果總和檢查碼不相符,則資料已損毀。If the checksums don't match, then the data is corrupt. 該磁碟區的復原功能將決定 ReFS 如何回應損毀:The resiliency of the volume determines how ReFS responds to corruptions:

  • 如果 ReFS 裝載在無復原功能的簡單儲存空間或空磁碟機上,ReFS 會將錯誤傳回給使用者,且不會傳回損毀資料。If ReFS is mounted on a non-resilient simple space or a bare drive, ReFS will return an error to the user without returning the corrupted data.
  • 如果 ReFS 裝載在有復原功能的鏡像或同位空間,ReFS 將會嘗試修正損毀。If ReFS is mounted on a resilient mirror or parity space, ReFS will attempt to correct the corruption.
    • 若嘗試成功,ReFS 將套用修正寫入以還原資料的完整性,且會將有效的資料傳回給應用程式。If the attempt is successful, ReFS will apply a corrective write to restore the integrity of the data, and it will return the valid data to the application. 應用程式將不會察覺到任何損毀。The application remains unaware of any corruptions.
    • 若嘗試失敗,ReFS 將傳回錯誤。If the attempt is unsuccessful, ReFS will return an error.

ReFS 將會在系統事件記錄檔中記錄所有損毀,而該記錄檔會反映是否已修正損毀。ReFS will record all corruptions in the System Event Log, and the log will reflect whether the corruptions were fixed.

<img src=media/corrective-write.gif alt="Corrective write restores data integrity."/>

效能Performance

雖然完整性串流能為系統提供更多的資料完整性,但是它也會產生效能成本。Though integrity streams provides greater data integrity for the system, it also incurs a performance cost. 有幾個不同原因會造成此狀況:There are a couple different reasons for this:

  • 如果已啟用完整性資料流,所有的寫入作業將成為寫入時配置作業。If integrity streams are enabled, all write operations become allocate-on-write operations. 雖然這樣會因為 ReFS 不需要讀取或修改任何現有資料而避開讀取-修改-寫入的瓶頸,但是檔案資料卻經常變得片斷不全,反而延遲讀取。Though this avoids any read-modify-write bottlenecks since ReFS doesn't need to read or modify any existing data, file data frequently becomes fragmented, which delays reads.
  • 取決於系統的工作負載及基礎存放裝置,計算及驗證總和檢查碼的計算成本可致使增加 IO 延遲。Depending on the workload and underlying storage of the system, the computational cost of computing and validating the checksum can cause IO latency to increase.

完整性資料流會背負犧牲效能的代價,因此建議您在易受效能影響的系統上停用完整性資料流。Because integrity streams carries a performance cost, we recommend leaving integrity streams disabled on performance sensitive systems.

完整性清除程式Integrity scrubber

如上所述,ReFS 會自動在存取任何資料之前驗證資料完整性。As described above, ReFS will automatically validate data integrity before accessing any data. ReFS 還會使用背景清除程式,讓 ReFS 可以驗證不常存取的資料。ReFS also uses a background scrubber, which enables ReFS to validate infrequently accessed data. 此清除程式會定期掃描磁碟區、識別隱藏的損毀,以及主動觸發修復任何毀損資料。This scrubber periodically scans the volume, identifies latent corruptions, and proactively triggers a repair of any corrupt data.

注意

資料完整性清除程式只能驗證檔案已啟用資料流完整性的檔案資料。The data integrity scrubber can only validate file data for files where integrity streams is enabled.

清除程式預設會每四週執行一次,但還是可以在 Microsoft\Windows\Data Integrity Scan 底下的 [工作排程器] 中設定此時間間隔。By default, the scrubber runs every four weeks, though this interval can be configured within Task Scheduler under Microsoft\Windows\Data Integrity Scan.

範例Examples

若要監視及變更檔案資料完整性設定,ReFS 使用 Get-FileIntegritySet-FileIntegrity Cmdlet。To monitor and change the file data integrity settings, ReFS uses the Get-FileIntegrity and Set-FileIntegrity cmdlets.

Get-FileIntegrityGet-FileIntegrity

若要查看是否已為檔案資料啟用完整性資料流,請使用 Get-FileIntegrity Cmdlet。To see if integrity streams is enabled for file data, use the Get-FileIntegrity cmdlet.

PS C:\> Get-FileIntegrity -FileName 'C:\Docs\TextDocument.txt'

您也可以使用 Get-Item Cmdlet 來取得特定目錄中所有檔案的完整性資料流設定。You can also use the Get-Item cmdlet to get the integrity stream settings for all the files in a specified directory.

PS C:\> Get-Item -Path 'C:\Docs\*' | Get-FileIntegrity

Set-FileIntegritySet-FileIntegrity

若要為檔案資料啟用/停用完整性資料流,請使用 Set-FileIntegrity Cmdlet。To enable/disable integrity streams for file data, use the Set-FileIntegrity cmdlet.

PS C:\> Set-FileIntegrity -FileName 'H:\Docs\TextDocument.txt' -Enable $True

您也可以使用 Get-Item Cmdlet 來設定特定資料夾中所有檔案的完整性資料流設定。You can also use the Get-Item cmdlet to set the integrity stream settings for all the files in a specified folder.

PS C:\> Get-Item -Path 'H\Docs\*' | Set-FileIntegrity -Enable $True 

Set-FileIntegrity Cmdlet 也可以直接在磁碟區及目錄上使用。The Set-FileIntegrity cmdlet can also be used on volumes and directories directly.

PS C:\> Set-FileIntegrity H:\ -Enable $True
PS C:\> Set-FileIntegrity H:\Docs -Enable $True

另請參閱See also