阅读:1181回复:4
日志文件系统的日志写入时机
请问一下各位大侠,现在的日志文件系统都是把每一次文件系统操作作为一次transaction。日志文件系统在磁盘分区中保存有日志记录,写操作首先是对记录文件进行操作,若整个写操作由于某种原因(如系统掉电)而中断,系统重启时,会根据日志记录来恢复中断前的写操作。在对元数据做任何改变以前,文件系统驱动程序会向日志中写入一个条目,这个条目描述了它将要做些什么,然后它修改元数据。我有点不太理解,就是既然向日志中写入一个条目,这个条目是不是立即刷新到磁盘?如果不是,那突然断电的时候,日志还没有写入磁盘呢。这个时候怎么办?如果每次修改都刷新到磁盘,因为每次日志的修改都比较小,每次都刷新磁盘是不是对性能影响很大呀?我看代码有点没有看明白
请各位大侠指教! |
|
沙发#
发布于:2007-03-05 20:10
Ccunpinrepinnedbcb()函数解决你的所有忧虑。
|
|
|
板凳#
发布于:2007-03-06 13:27
大侠,这是什么函数?msdn上我没有查到呀,ntfs里面的函数?
谢谢! 引用第1楼liuyan1于2007-03-05 20:10发表的“”: |
|
地板#
发布于:2007-03-06 15:08
http://msdn2.microsoft.com/en-us/library/ms791431.aspx
Windows Driver Kit: Installable File System Drivers CcUnpinRepinnedBcb The CcUnpinRepinnedBcb routine unpins a repinned buffer control block (BCB). VOID CcUnpinRepinnedBcb( IN PVOID Bcb, IN BOOLEAN WriteThrough, OUT PIO_STATUS_BLOCK IoStatus ); Parameters Bcb Pointer to the repinned BCB. WriteThrough Set to TRUE if the BCB should be written through. IoStatus Pointer to an IO_STATUS_BLOCK structure. If the call to CcUnpinRepinnedBcb succeeds, IoStatus.Status is set to STATUS_SUCCESS. Otherwise, it is set to an appropriate NTSTATUS error code. IoStatus.Information is set to the actual number of bytes that were successfully flushed to disk. Return Value None Headers Declared in ntifs.h. Include ntifs.h. Comments File systems call CcUnpinRepinnedBcb to write a previously pinned buffer through to disk. Every call to CcRepinBcb must be matched by a subsequent call to CcUnpinRepinnedBcb. Because CcUnpinRepinnedBcb acquires the BCB resource exclusively, the caller must be extremely careful to avoid deadlocks. If possible, the caller should own no resources. Otherwise the caller must guarantee that it has nothing else pinned in the same cached file. Normally CcUnpinRepinnedBcb is called during request completion, after all other resources have been released. CcUnpinRepinnedBcb synchronously writes the buffer (for write-through requests) and unpins the BCB repinned by the earlier call to CcRepinBcb. See Also |
|
地下室#
发布于:2007-03-07 09:36
谢谢楼上的大侠,太感谢了!
|
|