为什么在使用 DFSR 复制后文件最终被完全填充为空字节?

cke*_*rth 6 dfs-r windows-server-2008-r2 windows-server-2003-r2

我们使用 Microsoft 的分布式文件系统进行复制。在我们的场景中,我们有一个创建/覆盖/删除文件的编写器和几个分布式读取器。编写器运行 Windows Server 2008 R2 Enterprise x64 SP 1,读取器运行 Windows Server 2003 R2 Standard Edition x86 SP 2。一些读取器运行版本为 5.2.3790.4656 的 DFSR,而其他一些则运行补丁版本为 5.2.3790.4799。

文件是使用System.IO.File.WriteAllText写入的,写入可以快速连续发生在同一个文件上。

大多数时候复制工作正常,但有时文件在复制后最终被完全填充为空字节。我们检查了所有相关机器上的 DFSR 日志,并在读者上发现了以下类型的 usn 日志条目报告:

20150302 11:05:00.498 2512 USNC  2202 UsnConsumer::UpdateIdRecord ID record updated from USN_RECORD:
+    USN_RECORD:
+    RecordLength:        80
+    MajorVersion:        2
+    MinorVersion:        0
+    FileRefNumber:       0x800000000f7c8
+    ParentFileRefNumber: 0x31000000152806
+    USN:                 0x872e876720
+    TimeStamp:           20150302 11:05:00.498 CET
+    Reason:              Basic Info Change Close Rename New Name
+    SourceInfo:          0x4
+    SecurityId:          0xebe
+    FileAttributes:      0x2220
+    FileNameLength:      18
+    FileNameOffset:      60
+    FileName:            xyz.txt
Run Code Online (Sandbox Code Playgroud)

让我们想知道的是,根本没有我们的日记条目报告(读者应该只阅读但不能修改任何内容)以及设置了 sparse 属性的事实。

为了查明是否有某个进程在执行意外写入或做一些可疑的事情,我们使用Process Monitor监视文件系统活动。下一次出现在阅读器上的空字节文件给我们带来了以下信息:

10:59:55,2311121    Dfsr.exe    1584    760 IRP_MJ_CREATE                   path\to\xyz.txt-{GUID}-vVERSION    SUCCESS Desired Access: Generic Read/Write/Execute, Write DAC, Write Owner, Access System Security, Disposition: Create, Options: Sequential Access, Synchronous IO Non-Alert, Complete If Oplocked, Open For Backup, Open No Recall, Attributes: N, ShareMode: Read, Write, Delete, AllocationSize: 0, OpenResult: Created
10:59:55,2312485    Dfsr.exe    1584    760 IRP_MJ_CLEANUP                  path\to\xyz.txt-{GUID}-vVERSION    SUCCESS
10:59:55,2313007    Dfsr.exe    1584    760 IRP_MJ_CLOSE                    path\to\xyz.txt-{GUID}-vVERSION    SUCCESS
10:59:55,2314394    Dfsr.exe    1584    760 IRP_MJ_CREATE                   path\to\xyz.txt-{GUID}-vVERSION    SUCCESS Desired Access: Read Attributes, Write Attributes, Synchronize, Disposition: Open, Options: Sequential Access, Synchronous IO Non-Alert, Open For Backup, Open Reparse Point, Open No Recall, Attributes: N, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
10:59:55,2314626    Dfsr.exe    1584    760 IRP_MJ_FILE_SYSTEM_CONTROL      path\to\xyz.txt-{GUID}-vVERSION    SUCCESS Control: FSCTL_MARK_HANDLE
10:59:55,2314780    Dfsr.exe    1584    760 IRP_MJ_QUERY_INFORMATION        path\to\xyz.txt-{GUID}-vVERSION    SUCCESS Type: QueryNameInformationFile, Name: path\to\xyz.txt-{GUID}-vVERSION
10:59:55,2314996    Dfsr.exe    1584    760 FASTIO_QUERY_INFORMATION        path\to\xyz.txt-{GUID}-vVERSION    SUCCESS Type: QueryBasicInformationFile, CreationTime: 10.03.2015 10:59:55, LastAccessTime: 10.03.2015 10:59:55, LastWriteTime: 10.03.2015 10:59:55, ChangeTime: 10.03.2015 10:59:55, FileAttributes: ANCI
10:59:55,2315081    Dfsr.exe    1584    760 IRP_MJ_QUERY_INFORMATION        path\to\xyz.txt-{GUID}-vVERSION    SUCCESS Type: QueryAttributeTagFile, Attributes: ANCI, ReparseTag: 0x0
10:59:55,2315194    Dfsr.exe    1584    760 IRP_MJ_QUERY_INFORMATION        path\to\xyz.txt-{GUID}-vVERSION    SUCCESS Type: QueryCompressionInformationFile
10:59:55,2315391    Dfsr.exe    1584    760 IRP_MJ_QUERY_VOLUME_INFORMATION path\to\xyz.txt-{GUID}-vVERSION    BUFFER OVERFLOW Type: QueryInformationVolume, VolumeCreationTime: 14.07.2014 14:59:54, VolumeSerialNumber: 88F0-15DC, SupportsObjects: True, VolumeLabel: uvw
10:59:55,2315481    Dfsr.exe    1584    760 IRP_MJ_QUERY_INFORMATION        path\to\xyz.txt-{GUID}-vVERSION    BUFFER OVERFLOW Type: QueryAllInformationFile, CreationTime: 10.03.2015 10:59:55, LastAccessTime: 10.03.2015 10:59:55, LastWriteTime: 10.03.2015 10:59:55, ChangeTime: 10.03.2015 10:59:55, FileAttributes: ANCI, AllocationSize: 0, EndOfFile: 0, NumberOfLinks: 1, DeletePending: False, Directory: False, IndexNumber: 0xe00000001589e, EaSize: 0, Access: Read Attributes, Write Attributes, Synchronize, Position: 0, Mode: Sequential Access, Synchronous IO Non-Alert, AlignmentRequirement: Long
10:59:55,2316459    Dfsr.exe    1584    760 IRP_MJ_CREATE                   path\to\xyz.txt-{GUID}-vVERSION    SUCCESS Desired Access: Generic Read/Write/Execute, Write DAC, Write Owner, Access System Security, Disposition: Open, Options: Sequential Access, Synchronous IO Non-Alert, Complete If Oplocked, Open For Backup, Open No Recall, Attributes: N, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
10:59:55,2316691    Dfsr.exe    1584    760 IRP_MJ_FILE_SYSTEM_CONTROL      path\to\xyz.txt-{GUID}-vVERSION    SUCCESS Control: FSCTL_MARK_HANDLE
10:59:55,2316796    Dfsr.exe    1584    760 IRP_MJ_CLEANUP                  path\to\xyz.txt-{GUID}-vVERSION    SUCCESS
10:59:55,2316876    Dfsr.exe    1584    760 IRP_MJ_CLOSE                    path\to\xyz.txt-{GUID}-vVERSION    SUCCESS
10:59:55,2317891    Dfsr.exe    1584    760 IRP_MJ_SET_SECURITY             path\to\xyz.txt-{GUID}-vVERSION    SUCCESS Information: Owner, Group, DACL
10:59:55,2318748    Dfsr.exe    1584    760 IRP_MJ_FILE_SYSTEM_CONTROL      path\to\xyz.txt-{GUID}-vVERSION    SUCCESS Control: FSCTL_SET_SPARSE
10:59:55,2319307    Dfsr.exe    1584    760 IRP_MJ_WRITE                    path\to\xyz.txt-{GUID}-vVERSION    SUCCESS Offset: 0, Length: 0
10:59:55,2319442    Dfsr.exe    1584    760 IRP_MJ_SET_INFORMATION          path\to\xyz.txt-{GUID}-vVERSION    SUCCESS Type: SetEndOfFileInformationFile, EndOfFile: 240
10:59:55,2320066    Dfsr.exe    1584    760 IRP_MJ_SET_INFORMATION          path\to\xyz.txt-{GUID}-vVERSION    SUCCESS Type: SetAllocationInformationFile, AllocationSize: 240
10:59:55,2320382    Dfsr.exe    1584    760 IRP_MJ_WRITE                    path\to\xyz.txt-{GUID}-vVERSION    SUCCESS Offset: 240, Length: 0
10:59:55,2320505    Dfsr.exe    1584    760 IRP_MJ_SET_INFORMATION          path\to\xyz.txt-{GUID}-vVERSION    SUCCESS Type: SetBasicInformationFile, CreationTime: 16.12.2013 10:57:23, LastAccessTime: 19.02.2015 11:00:25, LastWriteTime: 10.03.2015 10:59:55, ChangeTime: 10.03.2015 10:59:55, FileAttributes: ANCI
10:59:55,2320688    Dfsr.exe    1584    760 IRP_MJ_FILE_SYSTEM_CONTROL      path\to\xyz.txt-{GUID}-vVERSION    SUCCESS Control: FSCTL_WRITE_USN_CLOSE_RECORD
10:59:55,2321256    Dfsr.exe    1584    760 IRP_MJ_CLEANUP                  path\to\xyz.txt-{GUID}-vVERSION    SUCCESS
10:59:55,2321506    Dfsr.exe    1584    760 IRP_MJ_CLOSE                    path\to\xyz.txt-{GUID}-vVERSION    SUCCESS
Run Code Online (Sandbox Code Playgroud)

通过这一观察,看起来 DFSR 是产生它们的人。为什么要这样做?另外,为什么它将文件标记为稀疏?除了使用上述技术编写文件之外,作者不会弄乱文件。请注意,移动 EOF 标记的偏移量与作者创建的文件大小相匹配。

到目前为止,我们无法可靠地重现该问题。有没有人知道是什么导致了这种情况,更重要的是,如何解决它?

cke*_*rth 0

将读卡器升级到最新版本的DFSR 2008 R2只是减少了问题的发生,但并没有完全解决问题。另外将读卡器配置为写保护后,不再出现该问题(距离上次升级已有半年)。