Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * include/linux/journal-head.h
0004  *
0005  * buffer_head fields for JBD
0006  *
0007  * 27 May 2001 Andrew Morton
0008  *  Created - pulled out of fs.h
0009  */
0010 
0011 #ifndef JOURNAL_HEAD_H_INCLUDED
0012 #define JOURNAL_HEAD_H_INCLUDED
0013 
0014 #include <linux/spinlock.h>
0015 
0016 typedef unsigned int        tid_t;      /* Unique transaction ID */
0017 typedef struct transaction_s    transaction_t;  /* Compound transaction type */
0018 
0019 
0020 struct buffer_head;
0021 
0022 struct journal_head {
0023     /*
0024      * Points back to our buffer_head. [jbd_lock_bh_journal_head()]
0025      */
0026     struct buffer_head *b_bh;
0027 
0028     /*
0029      * Protect the buffer head state
0030      */
0031     spinlock_t b_state_lock;
0032 
0033     /*
0034      * Reference count - see description in journal.c
0035      * [jbd_lock_bh_journal_head()]
0036      */
0037     int b_jcount;
0038 
0039     /*
0040      * Journalling list for this buffer [b_state_lock]
0041      * NOTE: We *cannot* combine this with b_modified into a bitfield
0042      * as gcc would then (which the C standard allows but which is
0043      * very unuseful) make 64-bit accesses to the bitfield and clobber
0044      * b_jcount if its update races with bitfield modification.
0045      */
0046     unsigned b_jlist;
0047 
0048     /*
0049      * This flag signals the buffer has been modified by
0050      * the currently running transaction
0051      * [b_state_lock]
0052      */
0053     unsigned b_modified;
0054 
0055     /*
0056      * Copy of the buffer data frozen for writing to the log.
0057      * [b_state_lock]
0058      */
0059     char *b_frozen_data;
0060 
0061     /*
0062      * Pointer to a saved copy of the buffer containing no uncommitted
0063      * deallocation references, so that allocations can avoid overwriting
0064      * uncommitted deletes. [b_state_lock]
0065      */
0066     char *b_committed_data;
0067 
0068     /*
0069      * Pointer to the compound transaction which owns this buffer's
0070      * metadata: either the running transaction or the committing
0071      * transaction (if there is one).  Only applies to buffers on a
0072      * transaction's data or metadata journaling list.
0073      * [j_list_lock] [b_state_lock]
0074      * Either of these locks is enough for reading, both are needed for
0075      * changes.
0076      */
0077     transaction_t *b_transaction;
0078 
0079     /*
0080      * Pointer to the running compound transaction which is currently
0081      * modifying the buffer's metadata, if there was already a transaction
0082      * committing it when the new transaction touched it.
0083      * [t_list_lock] [b_state_lock]
0084      */
0085     transaction_t *b_next_transaction;
0086 
0087     /*
0088      * Doubly-linked list of buffers on a transaction's data, metadata or
0089      * forget queue. [t_list_lock] [b_state_lock]
0090      */
0091     struct journal_head *b_tnext, *b_tprev;
0092 
0093     /*
0094      * Pointer to the compound transaction against which this buffer
0095      * is checkpointed.  Only dirty buffers can be checkpointed.
0096      * [j_list_lock]
0097      */
0098     transaction_t *b_cp_transaction;
0099 
0100     /*
0101      * Doubly-linked list of buffers still remaining to be flushed
0102      * before an old transaction can be checkpointed.
0103      * [j_list_lock]
0104      */
0105     struct journal_head *b_cpnext, *b_cpprev;
0106 
0107     /* Trigger type */
0108     struct jbd2_buffer_trigger_type *b_triggers;
0109 
0110     /* Trigger type for the committing transaction's frozen data */
0111     struct jbd2_buffer_trigger_type *b_frozen_triggers;
0112 };
0113 
0114 #endif      /* JOURNAL_HEAD_H_INCLUDED */