zealsoft_zhu
驱动小牛
驱动小牛
  • 注册日期2004-03-30
  • 最后登录2014-07-30
  • 粉丝2
  • 关注0
  • 积分22分
  • 威望375点
  • 贡献值0点
  • 好评度137点
  • 原创分0分
  • 专家分0分
阅读:1181回复:4

日志文件系统的日志写入时机

楼主#
更多 发布于:2007-03-05 15:51
  请问一下各位大侠,现在的日志文件系统都是把每一次文件系统操作作为一次transaction。日志文件系统在磁盘分区中保存有日志记录,写操作首先是对记录文件进行操作,若整个写操作由于某种原因(如系统掉电)而中断,系统重启时,会根据日志记录来恢复中断前的写操作。在对元数据做任何改变以前,文件系统驱动程序会向日志中写入一个条目,这个条目描述了它将要做些什么,然后它修改元数据。我有点不太理解,就是既然向日志中写入一个条目,这个条目是不是立即刷新到磁盘?如果不是,那突然断电的时候,日志还没有写入磁盘呢。这个时候怎么办?如果每次修改都刷新到磁盘,因为每次日志的修改都比较小,每次都刷新磁盘是不是对性能影响很大呀?我看代码有点没有看明白
请各位大侠指教!
liuyan1
驱动老牛
驱动老牛
  • 注册日期2001-08-27
  • 最后登录2023-04-18
  • 粉丝0
  • 关注0
  • 积分1031分
  • 威望477点
  • 贡献值0点
  • 好评度187点
  • 原创分0分
  • 专家分0分
  • 社区居民
沙发#
发布于:2007-03-05 20:10
Ccunpinrepinnedbcb()函数解决你的所有忧虑。
楼上的客,楼下的客,听我老坎说明白,要苛屎有草纸,不要扯我的麦席子,要苛尿有夜壶,不要在床上划地图。
zealsoft_zhu
驱动小牛
驱动小牛
  • 注册日期2004-03-30
  • 最后登录2014-07-30
  • 粉丝2
  • 关注0
  • 积分22分
  • 威望375点
  • 贡献值0点
  • 好评度137点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2007-03-06 13:27
大侠,这是什么函数?msdn上我没有查到呀,ntfs里面的函数?
谢谢!

引用第1楼liuyan12007-03-05 20:10发表的“”:
Ccunpinrepinnedbcb()函数解决你的所有忧虑。
nangfeng
驱动牛犊
驱动牛犊
  • 注册日期2006-06-03
  • 最后登录2014-07-23
  • 粉丝0
  • 关注0
  • 积分14分
  • 威望183点
  • 贡献值0点
  • 好评度51点
  • 原创分0分
  • 专家分0分
地板#
发布于: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
zealsoft_zhu
驱动小牛
驱动小牛
  • 注册日期2004-03-30
  • 最后登录2014-07-30
  • 粉丝2
  • 关注0
  • 积分22分
  • 威望375点
  • 贡献值0点
  • 好评度137点
  • 原创分0分
  • 专家分0分
地下室#
发布于:2007-03-07 09:36
谢谢楼上的大侠,太感谢了!
游客

返回顶部