journal-head.h 2.9 KB

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