STRUCT JOURNAL_S(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ¦‹ NAME πŸ¦‹

struct journal_s β€” okay so bestie, this is the whole vibe of the page: the journal_s type is the concrete type associated with journal_t. That's it, that's the name section, periodt. πŸ’…

Like, journal_t is the name you keep seeing everywhere, and journal_s is the actual real-life struct behind it. main character energy fr fr. πŸ‘‘


✨ SYNOPSIS ✨

Okay so here it is, the whole entire struct, and ngl it's giving a lot 😭 β€” I'm not summarising a single field because that would be a crime against humanity. Every member is right here, exactly as it lives, no cap:

struct journal_s {
    unsigned long           j_flags;
    int j_errno;
    struct mutex            j_abort_mutex;
    struct buffer_head      *j_sb_buffer;
    journal_superblock_t *j_superblock;
    rwlock_t j_state_lock;
    int j_barrier_count;
    struct mutex            j_barrier;
    transaction_t *j_running_transaction;
    transaction_t *j_committing_transaction;
    transaction_t *j_checkpoint_transactions;
    wait_queue_head_t j_wait_transaction_locked;
    wait_queue_head_t j_wait_done_commit;
    wait_queue_head_t j_wait_commit;
    wait_queue_head_t j_wait_updates;
    wait_queue_head_t j_wait_reserved;
    wait_queue_head_t j_fc_wait;
    struct mutex            j_checkpoint_mutex;
    struct buffer_head      *j_chkpt_bhs[JBD2_NR_BATCH];
    struct shrinker         *j_shrinker;
    struct percpu_counter   j_checkpoint_jh_count;
    transaction_t *j_shrink_transaction;
    unsigned long           j_head;
    unsigned long           j_tail;
    unsigned long           j_free;
    unsigned long           j_first;
    unsigned long           j_last;
    unsigned long           j_fc_first;
    unsigned long           j_fc_off;
    unsigned long           j_fc_last;
    struct block_device     *j_dev;
    int j_blocksize;
    unsigned long long      j_blk_offset;
    char j_devname[BDEVNAME_SIZE+24];
    struct block_device     *j_fs_dev;
    errseq_t j_fs_dev_wb_err;
    unsigned int            j_total_len;
    atomic_t j_reserved_credits;
    spinlock_t j_list_lock;
    struct inode            *j_inode;
    tid_t j_tail_sequence;
    tid_t j_transaction_sequence;
    tid_t j_commit_sequence;
    tid_t j_commit_request;
    __u8 j_uuid[16];
    struct task_struct      *j_task;
    int j_max_transaction_buffers;
    int j_revoke_records_per_block;
    int j_transaction_overhead_buffers;
    unsigned long           j_commit_interval;
    struct timer_list       j_commit_timer;
    spinlock_t j_revoke_lock;
    struct jbd2_revoke_table_s *j_revoke;
    struct jbd2_revoke_table_s *j_revoke_table[2];
    struct buffer_head      **j_wbuf;
    struct buffer_head      **j_fc_wbuf;
    int j_wbufsize;
    int j_fc_wbufsize;
    pid_t j_last_sync_writer;
    u64 j_average_commit_time;
    u32 j_min_batch_time;
    u32 j_max_batch_time;
    void (*j_commit_callback)(journal_t *, transaction_t *);
    int (*j_submit_inode_data_buffers) (struct jbd2_inode *);
    int (*j_finish_inode_data_buffers) (struct jbd2_inode *);
    spinlock_t j_history_lock;
    struct proc_dir_entry   *j_proc_entry;
    struct transaction_stats_s j_stats;
    unsigned int            j_failed_commit;
    void *j_private;
    __u32 j_csum_seed;
  #ifdef CONFIG_DEBUG_LOCK_ALLOC;
    struct lockdep_map      j_trans_commit_map;
  #endif;
    struct lock_class_key   jbd2_trans_commit_key;
    void (*j_fc_cleanup_callback)(struct journal_s *journal, int full,
tid_t tid);
    int (*j_fc_replay_callback)(struct journal_s *journal, struct
buffer_head *bh, enum passtype pass, int off, tid_t expected_commit_id);
    int (*j_bmap)(struct journal_s *journal, sector_t *block);
 };
🫢 bestie note: those last three function-pointer members are wrapped across lines in the source, so they're wrapped here too β€” I did not touch a single character. copy-paste safe, iykyk πŸ’–

Also lowkey obsessed with the fact that j_fc_cleanup_callback and j_fc_replay_callback and j_bmap are all just sitting there at the bottom of this absolute unit of a struct, like the last three people at the party. 🌸

There's more coming in the next part, so don't go anywhere β€” this icon isn't done slaying yet βœ¨πŸ¦‹

πŸ’– Members πŸ’–

okay bestie, this is the whole member lineup for struct journal_s, and every single field is getting its moment. no skipping, no β€œwe’ll come back to it,” periodt. ✨


  • j_flags β€” general journaling state flags. [j_state_lock, no lock for quick racy checks]
  • j_errno β€” is there an outstanding uncleared error on the journal (from a prior abort)? [j_state_lock]
  • j_abort_mutex β€” locks the whole aborting procedure. πŸ’…
  • j_sb_buffer β€” the first part of the superblock buffer.
  • j_superblock β€” the second part of the superblock buffer.
  • j_state_lock β€” protects the various scalars in the journal. πŸ”’
  • j_barrier_count β€” number of processes waiting to create a barrier lock. [j_state_lock, no lock for quick racy checks]
  • j_barrier β€” the barrier lock itself.
  • j_running_transaction β€” transactions: the current running transaction... [j_state_lock, no lock for quick racy checks] [caller holding open handle]
  • j_committing_transaction β€” the transaction we are pushing to disk. [j_state_lock] [caller holding open handle]
  • j_checkpoint_transactions β€” ...and a linked circular list of all transactions waiting for checkpointing. [j_list_lock]
  • j_wait_transaction_locked β€” wait queue for waiting for a locked transaction to start committing, or for a barrier lock to be released.
  • j_wait_done_commit β€” wait queue for waiting for commit to complete.
  • j_wait_commit β€” wait queue to trigger commit.
  • j_wait_updates β€” wait queue to wait for updates to complete.
  • j_wait_reserved β€” wait queue to wait for reserved buffer credits to drop.
  • j_fc_wait β€” wait queue to wait for completion of async fast commits.
  • j_checkpoint_mutex β€” semaphore for locking against concurrent checkpoints.
  • j_chkpt_bhs β€” list of buffer heads used by the checkpoint routine. This was moved from jbd2_log_do_checkpoint to reduce stack usage. Access to this array is controlled by the j_checkpoint_mutex. [j_checkpoint_mutex]
  • j_shrinker β€” journal head shrinker, reclaims the buffer’s journal head which has been written back. 🧚
  • j_checkpoint_jh_count β€” number of journal buffers on the checkpoint list. [j_list_lock]
  • j_shrink_transaction β€” records the next transaction that will shrink on the checkpoint list. [j_list_lock]
  • j_head β€” journal head: identifies the first unused block in the journal. [j_state_lock]
  • j_tail β€” journal tail: identifies the oldest still-used block in the journal. [j_state_lock]
  • j_free β€” journal free: how many free blocks are there in the journal? [j_state_lock]
  • j_first β€” the block number of the first usable block in the journal. [j_state_lock]
  • j_last β€” the block number one beyond the last usable block in the journal. [j_state_lock]
  • j_fc_first β€” the block number of the first fast commit block in the journal. [j_state_lock]
  • j_fc_off β€” number of fast commit blocks currently allocated. Accessed only during fast commit. Currently only process can do fast commit, so this field is not protected by any lock.
  • j_fc_last β€” the block number one beyond the last fast commit block in the journal. [j_state_lock]
  • j_dev β€” device where we store the journal.
  • j_blocksize β€” block size for the location where we store the journal.
  • j_blk_offset β€” starting block offset into the device where we store the journal.
  • j_devname β€” journal device name.
  • j_fs_dev β€” device which holds the client fs. For internal journal this will be equal to j_dev.
  • j_fs_dev_wb_err β€” records the errseq of the client fs’s backing block device.
  • j_total_len β€” total maximum capacity of the journal region on disk.
  • j_reserved_credits β€” number of buffers reserved from the running transaction.
  • j_list_lock β€” protects the buffer lists and internal buffer state. πŸ›‘οΈ
  • j_inode β€” optional inode where we store the journal. If present, all journal block numbers are mapped into this inode via bmap.
  • j_tail_sequence β€” sequence number of the oldest transaction in the log. [j_state_lock]
  • j_transaction_sequence β€” sequence number of the next transaction to grant. [j_state_lock]
  • j_commit_sequence β€” sequence number of the most recently committed transaction. [j_state_lock, no lock for quick racy checks]
  • j_commit_request β€” sequence number of the most recent transaction wanting commit. [j_state_lock, no lock for quick racy checks]
  • j_uuid β€” journal uuid: identifies the object (filesystem, LVM volume etc) backed by this journal. This will eventually be replaced by an array of uuids, allowing us to index multiple devices within a single journal and to perform atomic updates across them. 🌈
  • j_task β€” pointer to the current commit thread for this journal.
  • j_max_transaction_buffers β€” maximum number of metadata buffers to allow in a single compound commit transaction.
  • j_revoke_records_per_block β€” number of revoke records that fit in one descriptor block.
  • j_transaction_overhead_buffers β€” number of blocks each transaction needs for its own bookkeeping.
  • j_commit_interval β€” what is the maximum transaction lifetime before we begin a commit?
  • j_commit_timer β€” the timer used to wakeup the commit thread. ⏰
  • j_revoke_lock β€” protects the revoke table.
  • j_revoke β€” the revoke table β€” maintains the list of revoked blocks in the current transaction.
  • j_revoke_table β€” alternate revoke tables for j_revoke.
  • j_wbuf β€” array of bhs for jbd2_journal_commit_transaction.
  • j_fc_wbuf β€” array of fast commit bhs for fast commit. Accessed only during a fast commit. Currently only process can do fast commit, so this field is not protected by any lock.
  • j_wbufsize β€” size of j_wbuf array.
  • j_fc_wbufsize β€” size of j_fc_wbuf array.
  • j_last_sync_writer β€” the pid of the last person to run a synchronous operation through the journal.
  • j_average_commit_time β€” the average amount of time in nanoseconds it takes to commit a transaction to disk. [j_state_lock]
  • j_min_batch_time β€” minimum time that we should wait for additional filesystem operations to get batched into a synchronous handle in microseconds.
  • j_max_batch_time β€” maximum time that we should wait for additional filesystem operations to get batched into a synchronous handle in microseconds.
  • j_commit_callback β€” this function is called when a transaction is closed.
  • j_submit_inode_data_buffers β€” this function is called for all inodes associated with the committing transaction marked with JI_WRITE_DATA flag before we start to write out the transaction to the journal.
  • j_finish_inode_data_buffers β€” this function is called for all inodes associated with the committing transaction marked with JI_WAIT_DATA flag after we have written the transaction to the journal but before we write out the commit block.
  • j_history_lock β€” protects the transactions statistics history.
  • j_proc_entry β€” procfs entry for the jbd statistics directory.
  • j_stats β€” overall statistics. πŸ“Š
  • j_failed_commit β€” failed journal commit ID.
  • j_private β€” an opaque pointer to fs-private information. ext3 puts its superblock pointer here.
  • j_csum_seed β€” precomputed journal UUID checksum for seeding other checksums.
  • j_trans_commit_map β€” lockdep entity to track transaction commit dependencies. Handles hold this "lock" for read, when we wait for commit, we acquire the "lock" for writing. This matches the properties of jbd2 journalling where the running transaction has to wait for all handles to be dropped to commit that transaction and also acquiring a handle may require transaction commit to finish.
  • jbd2_trans_commit_key β€” "struct lock_class_key" for j_trans_commit_map.
  • j_fc_cleanup_callback β€” clean-up after fast commit or full commit. JBD2 calls this function after every commit operation.
  • j_fc_replay_callback β€” file-system specific function that performs replay of a fast commit. JBD2 calls this function for each fast commit block found in the journal. This function should return JBD2_FC_REPLAY_CONTINUE to indicate that the block was processed correctly and more fast commit replay should continue. Return value of JBD2_FC_REPLAY_STOP indicates the end of replay (no more blocks remaining). A negative return value indicates error. 😭
  • j_bmap β€” bmap function that should be used instead of the generic VFS bmap function.

πŸ’« SEE ALSO πŸ’«


source/version/date tea, bestie: ./include/linux Β· October 2026 Β· struct journal_s(9) β€” and that’s the whole page, mwah πŸ’‹πŸ‘‘

πŸ“¦ where this page comes from