Journaling block device
{{redirect|JBD|Jernbanedirektoratet|Norwegian Railway Directorate}}
JBD, or journaling block device, is a generic block device journaling layer in the Linux kernel written by Stephen Tweedie from Red Hat. JBD is filesystem-independent. ext3, ext4 and OCFS2 are known to use JBD.{{cite web |title=The Linux Journalling API |url=https://www.kernel.org/doc/html/latest/filesystems/journalling.html |website=The Linux Kernel documentation}}{{cite web|archive-url=https://web.archive.org/web/20070926223043/http://kerneltrap.org/node/6741|archive-date=2007-09-26|url=http://kerneltrap.org/node/6741|title=Linux: The Journaling Block Device |author=Kedar Sovani |work=KernelTrap|date=June 20, 2006}}
JBD exists in two versions, JBD and JBD2. JBD was created with ext3 in 1998.{{cite journal | author = Stephen C. Tweedie | url = http://e2fsprogs.sourceforge.net/journal-design.pdf | title = Journaling the Linux ext2fs Filesystem | journal = Proceedings of the 4th Annual LinuxExpo, Durham, NC |date=May 1998 | accessdate=2007-06-23|format=PDF}} JBD2 was forked from JBD in 2006 with ext4, with the goal of supporting a 64-bit (as opposed to 32-bit-only in JBD) block number. As a result, the maximum volume size in ext4 is increased to 1 EiB compared to 16 TiB in ext3 (assuming 4 KiB blocks).{{cite mailing list |author=Mingming Cao |date=9 August 2006 |title=Forking ext4 filesystem and JBD2 |publisher=Linux kernel mailing list |url=https://lkml.org/lkml/2006/8/9/434 }} JBD2 is backward-compatible. OCFS2 starting from Linux 2.6.28 uses JBD2.{{cite web|url=http://kernelnewbies.org/Linux_2_6_28#Filesystems|title=Linux 2.6.28|website=kernelnewbies.org|date=2008}} The old JBD was removed with the dedicated ext3 driver in Linux 4.3 (2015).{{cite web |last1=Corbet |first1=Jonathan |title=rm -r fs/ext3 |url=https://lwn.net/Articles/651645/ |website=LWN.net}}
JBD structures
=Atomic handle=
An atomic handle is 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=
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
Sources
{{reflist}}
Category:Linux kernel features
Category:Linux file system-related software
{{linux-stub}}