kernel-jbd.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * linux/include/linux/jbd.h
  4. *
  5. * Written by Stephen C. Tweedie <sct@redhat.com>
  6. *
  7. * Copyright 1998-2000 Red Hat, Inc --- All Rights Reserved
  8. *
  9. * This file is part of the Linux kernel and is made available under
  10. * the terms of the GNU General Public License, version 2, or at your
  11. * option, any later version, incorporated herein by reference.
  12. *
  13. * Definitions for transaction data structures for the buffer cache
  14. * filesystem journaling support.
  15. */
  16. #ifndef LINUX_JBD_H
  17. #define LINUX_JBD_H 1
  18. #include <sys/types.h>
  19. #include <linux/types.h>
  20. #include "ext2fs.h"
  21. /*
  22. * Standard header for all descriptor blocks:
  23. */
  24. typedef struct journal_header_s
  25. {
  26. __u32 h_magic;
  27. __u32 h_blocktype;
  28. __u32 h_sequence;
  29. } journal_header_t;
  30. /*
  31. * This is the global e2fsck structure.
  32. */
  33. typedef struct e2fsck_struct *e2fsck_t;
  34. struct inode {
  35. e2fsck_t i_ctx;
  36. ext2_ino_t i_ino;
  37. struct ext2_inode i_ext2;
  38. };
  39. /*
  40. * The journal superblock. All fields are in big-endian byte order.
  41. */
  42. typedef struct journal_superblock_s
  43. {
  44. /* 0x0000 */
  45. journal_header_t s_header;
  46. /* 0x000C */
  47. /* Static information describing the journal */
  48. __u32 s_blocksize; /* journal device blocksize */
  49. __u32 s_maxlen; /* total blocks in journal file */
  50. __u32 s_first; /* first block of log information */
  51. /* 0x0018 */
  52. /* Dynamic information describing the current state of the log */
  53. __u32 s_sequence; /* first commit ID expected in log */
  54. __u32 s_start; /* blocknr of start of log */
  55. /* 0x0020 */
  56. /* Error value, as set by journal_abort(). */
  57. __s32 s_errno;
  58. /* 0x0024 */
  59. /* Remaining fields are only valid in a version-2 superblock */
  60. __u32 s_feature_compat; /* compatible feature set */
  61. __u32 s_feature_incompat; /* incompatible feature set */
  62. __u32 s_feature_ro_compat; /* readonly-compatible feature set */
  63. /* 0x0030 */
  64. __u8 s_uuid[16]; /* 128-bit uuid for journal */
  65. /* 0x0040 */
  66. __u32 s_nr_users; /* Nr of filesystems sharing log */
  67. __u32 s_dynsuper; /* Blocknr of dynamic superblock copy*/
  68. /* 0x0048 */
  69. __u32 s_max_transaction; /* Limit of journal blocks per trans.*/
  70. __u32 s_max_trans_data; /* Limit of data blocks per trans. */
  71. /* 0x0050 */
  72. __u32 s_padding[44];
  73. /* 0x0100 */
  74. __u8 s_users[16*48]; /* ids of all fs'es sharing the log */
  75. /* 0x0400 */
  76. } journal_superblock_t;
  77. extern int journal_blocks_per_page(struct inode *inode);
  78. extern int jbd_blocks_per_page(struct inode *inode);
  79. #define JFS_MIN_JOURNAL_BLOCKS 1024
  80. /*
  81. * Internal structures used by the logging mechanism:
  82. */
  83. #define JFS_MAGIC_NUMBER 0xc03b3998U /* The first 4 bytes of /dev/random! */
  84. /*
  85. * Descriptor block types:
  86. */
  87. #define JFS_DESCRIPTOR_BLOCK 1
  88. #define JFS_COMMIT_BLOCK 2
  89. #define JFS_SUPERBLOCK_V1 3
  90. #define JFS_SUPERBLOCK_V2 4
  91. #define JFS_REVOKE_BLOCK 5
  92. /*
  93. * The block tag: used to describe a single buffer in the journal
  94. */
  95. typedef struct journal_block_tag_s
  96. {
  97. __u32 t_blocknr; /* The on-disk block number */
  98. __u32 t_flags; /* See below */
  99. } journal_block_tag_t;
  100. /*
  101. * The revoke descriptor: used on disk to describe a series of blocks to
  102. * be revoked from the log
  103. */
  104. typedef struct journal_revoke_header_s
  105. {
  106. journal_header_t r_header;
  107. int r_count; /* Count of bytes used in the block */
  108. } journal_revoke_header_t;
  109. /* Definitions for the journal tag flags word: */
  110. #define JFS_FLAG_ESCAPE 1 /* on-disk block is escaped */
  111. #define JFS_FLAG_SAME_UUID 2 /* block has same uuid as previous */
  112. #define JFS_FLAG_DELETED 4 /* block deleted by this transaction */
  113. #define JFS_FLAG_LAST_TAG 8 /* last tag in this descriptor block */
  114. #define JFS_HAS_COMPAT_FEATURE(j,mask) \
  115. ((j)->j_format_version >= 2 && \
  116. ((j)->j_superblock->s_feature_compat & cpu_to_be32((mask))))
  117. #define JFS_HAS_RO_COMPAT_FEATURE(j,mask) \
  118. ((j)->j_format_version >= 2 && \
  119. ((j)->j_superblock->s_feature_ro_compat & cpu_to_be32((mask))))
  120. #define JFS_HAS_INCOMPAT_FEATURE(j,mask) \
  121. ((j)->j_format_version >= 2 && \
  122. ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask))))
  123. #define JFS_FEATURE_INCOMPAT_REVOKE 0x00000001
  124. /* Features known to this kernel version: */
  125. #define JFS_KNOWN_COMPAT_FEATURES 0
  126. #define JFS_KNOWN_ROCOMPAT_FEATURES 0
  127. #define JFS_KNOWN_INCOMPAT_FEATURES JFS_FEATURE_INCOMPAT_REVOKE
  128. /* Comparison functions for transaction IDs: perform comparisons using
  129. * modulo arithmetic so that they work over sequence number wraps. */
  130. /*
  131. * Definitions which augment the buffer_head layer
  132. */
  133. /* journaling buffer types */
  134. #define BJ_None 0 /* Not journaled */
  135. #define BJ_SyncData 1 /* Normal data: flush before commit */
  136. #define BJ_AsyncData 2 /* writepage data: wait on it before commit */
  137. #define BJ_Metadata 3 /* Normal journaled metadata */
  138. #define BJ_Forget 4 /* Buffer superceded by this transaction */
  139. #define BJ_IO 5 /* Buffer is for temporary IO use */
  140. #define BJ_Shadow 6 /* Buffer contents being shadowed to the log */
  141. #define BJ_LogCtl 7 /* Buffer contains log descriptors */
  142. #define BJ_Reserved 8 /* Buffer is reserved for access by journal */
  143. #define BJ_Types 9
  144. struct kdev_s {
  145. e2fsck_t k_ctx;
  146. int k_dev;
  147. };
  148. typedef struct kdev_s *kdev_t;
  149. typedef unsigned int tid_t;
  150. struct journal_s
  151. {
  152. unsigned long j_flags;
  153. int j_errno;
  154. struct buffer_head * j_sb_buffer;
  155. struct journal_superblock_s *j_superblock;
  156. int j_format_version;
  157. unsigned long j_head;
  158. unsigned long j_tail;
  159. unsigned long j_free;
  160. unsigned long j_first, j_last;
  161. kdev_t j_dev;
  162. kdev_t j_fs_dev;
  163. int j_blocksize;
  164. unsigned int j_blk_offset;
  165. unsigned int j_maxlen;
  166. struct inode * j_inode;
  167. tid_t j_tail_sequence;
  168. tid_t j_transaction_sequence;
  169. __u8 j_uuid[16];
  170. struct jbd_revoke_table_s *j_revoke;
  171. };
  172. typedef struct journal_s journal_t;
  173. extern int journal_recover (journal_t *journal);
  174. extern int journal_skip_recovery (journal_t *);
  175. /* Primary revoke support */
  176. extern int journal_init_revoke(journal_t *, int);
  177. extern void journal_destroy_revoke_caches(void);
  178. extern int journal_init_revoke_caches(void);
  179. /* Recovery revoke support */
  180. extern int journal_set_revoke(journal_t *, unsigned long, tid_t);
  181. extern int journal_test_revoke(journal_t *, unsigned long, tid_t);
  182. extern void journal_clear_revoke(journal_t *);
  183. extern void journal_brelse_array(struct buffer_head *b[], int n);
  184. extern void journal_destroy_revoke(journal_t *);
  185. #endif