Journaling Block Device
   HOME

TheInfoList



OR:

JBD, or journaling block device, is a generic block device journaling layer in the
Linux kernel The Linux kernel is a free and open-source, monolithic, modular, multitasking, Unix-like operating system kernel. It was originally authored in 1991 by Linus Torvalds for his i386-based PC, and it was soon adopted as the kernel for the GNU ope ...
written by
Stephen Tweedie Stephen C. Tweedie is a Scottish software developer who is known for his work on the Linux kernel, in particular his work on filesystems. After becoming involved with the development of the ext2 filesystem working on performance issues, he led ...
from
Red Hat Red Hat, Inc. is an American software company that provides open source software products to enterprises. Founded in 1993, Red Hat has its corporate headquarters in Raleigh, North Carolina, with other offices worldwide. Red Hat has become ass ...
. JBD is filesystem-independent.
ext3 ext3, or third extended filesystem, is a journaled file system that is commonly used by the Linux kernel. It used to be the default file system for many popular Linux distributions. Stephen Tweedie first revealed that he was working on extend ...
,
ext4 ext4 (fourth extended filesystem) is a journaling file system for Linux, developed as the successor to ext3. ext4 was initially a series of backward-compatible extensions to ext3, many of them originally developed by Cluster File Systems for ...
and
OCFS2 The Oracle Cluster File System (OCFS, in its second version OCFS2) is a shared disk file system developed by Oracle Corporation and released under the GNU General Public License. The first version of OCFS was developed with the main focus to accom ...
are known to use JBD. JBD exists in two versions, JBD and JBD2. JBD was created with ext3 in 1998. 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). JBD2 is backward-compatible. OCFS2 starting from Linux 2.6.28 uses JBD2. The old JBD was removed with the dedicated ext3 driver in Linux 4.3 (2015).


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

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


Sources

Linux kernel features Linux file system-related software Disk file systems {{linux-stub