JBD Journaling block device

在看man mount, ext4章节关于barrier的讲解时有提到JBD.

这里摘录一下wikipedia的解释.

JBD在Linux内核中是负责记录块设备日志的, 某些文件系统会使用JBD以及它的事务特性来确保文件系统在操作系统异常DOWN机后可恢复到一致性的状态.


JBD, or journaling block device, is a generic block device journaling layer in the Linux kernel written by Stephen C. Tweedie from Red Hat.

Overview[edit]

The Journaling Block Device (JBD) provides a filesystem-independent interface for filesystem journaling. ext3ext4 and OCFS2 are known to use JBD. OCFS2starting from linux 2.6.28[1] and ext4 use a fork of JBD called JBD2.[2]

JBD structures[edit]

Atomic handle[edit]

An atomic handle as basically a collection of all the low-level changes that occur during a single high-level atomic update to the file system. The atomic handle guarantees that the high-level update either happens or not, because the actual changes to the file system are flushed only after logging the atomic handle in the journal.

Transaction[edit]

For the sake of efficiency and performance, JBD groups several atomic handles into a single transaction, which is written to the journal after a fixed amount of time elapses or there is no free space left on the journal to fit it.

The transaction has several states:

  • Running - it means that the transaction is still live and can accept more handles
  • Locked - not accepting new handles, but the existing ones are still unfinished
  • Flush - the transaction is complete and is being written to the journal
  • Commit - the transaction is written to the journal and now the changes are being applied to the file system
  • Finished - the transaction has been fully written to the journal and the block device. It can be deleted from the journal.

Recovery[edit]

Based on the transaction states, the JBD is able to determine which transactions need to be replayed (or reapplied) to the file system.

Sources[edit]


[参考]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值