我们正在使用微软的分布式文件系统用于复制。在我们的场景中,我们有一个创建/覆盖/删除文件的单个写入器和多个分布式读取器。写入器运行 Windows Server 2008 R2 Enterprise x64 SP 1,读取器运行 Windows Server 2003 R2 Standard Edition x86 SP 2。一些读取器运行 DFSR 版本 5.2.3790.4656,另一些读取器运行修补版本 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
让我们感到疑惑的是,根本没有 USN 日记帐分录报告(读者只需阅读但不能修改任何内容)以及设置了稀疏属性的事实。
为了查明是否有某个进程执行了意外写入或做了一些可疑的事情,我们监视了文件系统活动进程监控读取器上下一次出现空字节文件时,我们得到以下结果:
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
从这个观察来看,似乎是 DFSR 生成了这些文件。为什么会这样?另外,为什么它会将文件标记为稀疏文件?除了使用上面概述的技术写入文件之外,写入器不会对文件进行任何干扰。请注意,EOF 标记移动到的偏移量与写入器创建的文件大小相匹配。
到目前为止,我们无法可靠地重现此问题。有人知道是什么原因造成的吗?更重要的是,如何解决它?
答案1
您的 DFS-R 暂存区是否与 DFS-R 文件夹位于同一卷上?出于性能原因,应该是。如果不是,则 DFS-R 必须将文件从暂存卷复制到目标卷,而不是直接移动。
这就是猜测的开始。可能是在此复制操作期间,DFS-R 正在创建一个稀疏文件,然后填充块,并在完成后将其“取消稀疏”。如果有什么东西中断了这个过程(比如防病毒软件、Undelete 或扫描 DfsrPrivate 文件夹的其他文件过滤驱动程序),那么你可能会得到一个临时的稀疏文件,该文件不会被其内容填充。
您可以使用进程监视器对正确复制的文件进行测试此行为,并查看它们在进程中的任何时候是否被标记/取消标记为稀疏。
就 DFS-R 而言,我并不喜欢将 2008 和 2003 混用。我很高兴从我们的 DFS 树上删除了最后一台 2003 机器。
答案2
将阅读器升级到最新版本DFSR 2008 R2只是减少了问题的发生,但没有完全解决。在将阅读器配置为写保护这个问题没有再出现(自上次升级以来已经半年了)。