Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * include/linux/journal-head.h |
| 4 | * |
| 5 | * buffer_head fields for JBD |
| 6 | * |
Francois Cami | e1f8e87 | 2008-10-15 22:01:59 -0700 | [diff] [blame] | 7 | * 27 May 2001 Andrew Morton |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * Created - pulled out of fs.h |
| 9 | */ |
| 10 | |
| 11 | #ifndef JOURNAL_HEAD_H_INCLUDED |
| 12 | #define JOURNAL_HEAD_H_INCLUDED |
| 13 | |
| 14 | typedef unsigned int tid_t; /* Unique transaction ID */ |
| 15 | typedef struct transaction_s transaction_t; /* Compound transaction type */ |
Joel Becker | e06c822 | 2008-09-11 15:35:47 -0700 | [diff] [blame] | 16 | |
| 17 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | struct buffer_head; |
| 19 | |
| 20 | struct journal_head { |
| 21 | /* |
| 22 | * Points back to our buffer_head. [jbd_lock_bh_journal_head()] |
| 23 | */ |
| 24 | struct buffer_head *b_bh; |
| 25 | |
| 26 | /* |
| 27 | * Reference count - see description in journal.c |
| 28 | * [jbd_lock_bh_journal_head()] |
| 29 | */ |
| 30 | int b_jcount; |
| 31 | |
| 32 | /* |
| 33 | * Journalling list for this buffer [jbd_lock_bh_state()] |
Jan Kara | e2555fd | 2013-05-13 09:45:01 -0400 | [diff] [blame] | 34 | * NOTE: We *cannot* combine this with b_modified into a bitfield |
| 35 | * as gcc would then (which the C standard allows but which is |
| 36 | * very unuseful) make 64-bit accesses to the bitfield and clobber |
| 37 | * b_jcount if its update races with bitfield modification. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | */ |
Jan Kara | e2555fd | 2013-05-13 09:45:01 -0400 | [diff] [blame] | 39 | unsigned b_jlist; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | |
| 41 | /* |
| 42 | * This flag signals the buffer has been modified by |
| 43 | * the currently running transaction |
| 44 | * [jbd_lock_bh_state()] |
| 45 | */ |
Jan Kara | e2555fd | 2013-05-13 09:45:01 -0400 | [diff] [blame] | 46 | unsigned b_modified; |
Amir Goldstein | c2cc702 | 2011-03-20 20:08:48 -0400 | [diff] [blame] | 47 | |
| 48 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | * Copy of the buffer data frozen for writing to the log. |
| 50 | * [jbd_lock_bh_state()] |
| 51 | */ |
| 52 | char *b_frozen_data; |
| 53 | |
| 54 | /* |
| 55 | * Pointer to a saved copy of the buffer containing no uncommitted |
| 56 | * deallocation references, so that allocations can avoid overwriting |
| 57 | * uncommitted deletes. [jbd_lock_bh_state()] |
| 58 | */ |
| 59 | char *b_committed_data; |
| 60 | |
| 61 | /* |
| 62 | * Pointer to the compound transaction which owns this buffer's |
| 63 | * metadata: either the running transaction or the committing |
| 64 | * transaction (if there is one). Only applies to buffers on a |
| 65 | * transaction's data or metadata journaling list. |
| 66 | * [j_list_lock] [jbd_lock_bh_state()] |
Jan Kara | 932bb30 | 2012-03-13 22:45:25 -0400 | [diff] [blame] | 67 | * Either of these locks is enough for reading, both are needed for |
| 68 | * changes. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | */ |
| 70 | transaction_t *b_transaction; |
| 71 | |
| 72 | /* |
| 73 | * Pointer to the running compound transaction which is currently |
| 74 | * modifying the buffer's metadata, if there was already a transaction |
| 75 | * committing it when the new transaction touched it. |
| 76 | * [t_list_lock] [jbd_lock_bh_state()] |
| 77 | */ |
| 78 | transaction_t *b_next_transaction; |
| 79 | |
| 80 | /* |
| 81 | * Doubly-linked list of buffers on a transaction's data, metadata or |
| 82 | * forget queue. [t_list_lock] [jbd_lock_bh_state()] |
| 83 | */ |
| 84 | struct journal_head *b_tnext, *b_tprev; |
| 85 | |
| 86 | /* |
| 87 | * Pointer to the compound transaction against which this buffer |
| 88 | * is checkpointed. Only dirty buffers can be checkpointed. |
| 89 | * [j_list_lock] |
| 90 | */ |
| 91 | transaction_t *b_cp_transaction; |
| 92 | |
| 93 | /* |
| 94 | * Doubly-linked list of buffers still remaining to be flushed |
| 95 | * before an old transaction can be checkpointed. |
| 96 | * [j_list_lock] |
| 97 | */ |
| 98 | struct journal_head *b_cpnext, *b_cpprev; |
Joel Becker | e06c822 | 2008-09-11 15:35:47 -0700 | [diff] [blame] | 99 | |
| 100 | /* Trigger type */ |
| 101 | struct jbd2_buffer_trigger_type *b_triggers; |
| 102 | |
| 103 | /* Trigger type for the committing transaction's frozen data */ |
| 104 | struct jbd2_buffer_trigger_type *b_frozen_triggers; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | }; |
| 106 | |
| 107 | #endif /* JOURNAL_HEAD_H_INCLUDED */ |