Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 9: The Extended Filesystem Family


The JBD layer providesjournal_dirty_metadatato write modified metadata to the journal:


fs/jbd/transaction.c
int journal_dirty_metadata(handle_t *handle, struct buffer_head *bh)

The matchingjournal_dirty_datafunction writes useful data to the journal and is used indatamode.


Transactions are represented by a dedicated data structure; again a much simplified version is shown:


<jbd.h>
typedef transaction_s transaction_t;

struct transaction_s
{
journal_t *t_journal;
tid_t t_tid;

enum {
T_RUNNING,
...
T_FLUSH,
T_COMMIT,
T_FINISHED
} t_state;

struct journal_head *t_buffers;
unsigned long t_expires;
int t_handle_count;
};

❑ t_journalis a pointer to the journal to which the transaction data are written (for the sake of
simplicity, the data structure used is not discussed because it is overburdened with technical
details).
❑ Each transaction can have different states that are held int_state:

❑ T_RUNNINGindicates that new atomic handles can be added to the journal.
❑ T_FLUSHindicates that log entries are being written at the moment.
❑ T_COMMITindicates when all data have been written to disk, but the metadata still need to
be processed.
❑ T_FINISHEDindicates that all log entries have been written safely to disk.

❑ t_bufferspoints to the buffers associated with the transaction.
❑ t_expiresspecifies the time by which the transaction data must have been physically written
to the journal. The kernel uses a timer that expires by default 5 seconds after the transaction has
been generated.
❑ t_handle_countindicates the number of handles associated with the transaction.

The Ext3 code uses ‘‘checkpoints‘‘ at which a check is made to ascertain whether the changes in the
journal have been written to the filesystem. If theyhave, the data in the journal are no longer needed

Free download pdf