fast_commit.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __FAST_COMMIT_H__
  3. #define __FAST_COMMIT_H__
  4. /* Fast commit tags */
  5. #define EXT4_FC_TAG_ADD_RANGE 0x0001
  6. #define EXT4_FC_TAG_DEL_RANGE 0x0002
  7. #define EXT4_FC_TAG_CREAT 0x0003
  8. #define EXT4_FC_TAG_LINK 0x0004
  9. #define EXT4_FC_TAG_UNLINK 0x0005
  10. #define EXT4_FC_TAG_INODE 0x0006
  11. #define EXT4_FC_TAG_PAD 0x0007
  12. #define EXT4_FC_TAG_TAIL 0x0008
  13. #define EXT4_FC_TAG_HEAD 0x0009
  14. #define EXT4_FC_SUPPORTED_FEATURES 0x0
  15. /* On disk fast commit tlv value structures */
  16. /* Fast commit on disk tag length structure */
  17. struct ext4_fc_tl {
  18. __le16 fc_tag;
  19. __le16 fc_len;
  20. };
  21. /* Value structure for tag EXT4_FC_TAG_HEAD. */
  22. struct ext4_fc_head {
  23. __le32 fc_features;
  24. __le32 fc_tid;
  25. };
  26. /* Value structure for EXT4_FC_TAG_ADD_RANGE. */
  27. struct ext4_fc_add_range {
  28. __le32 fc_ino;
  29. __u8 fc_ex[12];
  30. };
  31. /* Value structure for tag EXT4_FC_TAG_DEL_RANGE. */
  32. struct ext4_fc_del_range {
  33. __le32 fc_ino;
  34. __le32 fc_lblk;
  35. __le32 fc_len;
  36. };
  37. /*
  38. * This is the value structure for tags EXT4_FC_TAG_CREAT, EXT4_FC_TAG_LINK
  39. * and EXT4_FC_TAG_UNLINK.
  40. */
  41. struct ext4_fc_dentry_info {
  42. __le32 fc_parent_ino;
  43. __le32 fc_ino;
  44. u8 fc_dname[0];
  45. };
  46. /* Value structure for EXT4_FC_TAG_INODE and EXT4_FC_TAG_INODE_PARTIAL. */
  47. struct ext4_fc_inode {
  48. __le32 fc_ino;
  49. __u8 fc_raw_inode[0];
  50. };
  51. /* Value structure for tag EXT4_FC_TAG_TAIL. */
  52. struct ext4_fc_tail {
  53. __le32 fc_tid;
  54. __le32 fc_crc;
  55. };
  56. /*
  57. * In memory list of dentry updates that are performed on the file
  58. * system used by fast commit code.
  59. */
  60. struct ext4_fc_dentry_update {
  61. int fcd_op; /* Type of update create / unlink / link */
  62. int fcd_parent; /* Parent inode number */
  63. int fcd_ino; /* Inode number */
  64. struct qstr fcd_name; /* Dirent name */
  65. unsigned char fcd_iname[DNAME_INLINE_LEN]; /* Dirent name string */
  66. struct list_head fcd_list;
  67. };
  68. /*
  69. * Fast commit reason codes
  70. */
  71. enum {
  72. /*
  73. * Commit status codes:
  74. */
  75. EXT4_FC_REASON_OK = 0,
  76. EXT4_FC_REASON_INELIGIBLE,
  77. EXT4_FC_REASON_ALREADY_COMMITTED,
  78. EXT4_FC_REASON_FC_START_FAILED,
  79. EXT4_FC_REASON_FC_FAILED,
  80. /*
  81. * Fast commit ineligiblity reasons:
  82. */
  83. EXT4_FC_REASON_XATTR = 0,
  84. EXT4_FC_REASON_CROSS_RENAME,
  85. EXT4_FC_REASON_JOURNAL_FLAG_CHANGE,
  86. EXT4_FC_REASON_NOMEM,
  87. EXT4_FC_REASON_SWAP_BOOT,
  88. EXT4_FC_REASON_RESIZE,
  89. EXT4_FC_REASON_RENAME_DIR,
  90. EXT4_FC_REASON_FALLOC_RANGE,
  91. EXT4_FC_REASON_INODE_JOURNAL_DATA,
  92. EXT4_FC_COMMIT_FAILED,
  93. EXT4_FC_REASON_MAX
  94. };
  95. struct ext4_fc_stats {
  96. unsigned int fc_ineligible_reason_count[EXT4_FC_REASON_MAX];
  97. unsigned long fc_num_commits;
  98. unsigned long fc_ineligible_commits;
  99. unsigned long fc_numblks;
  100. };
  101. #define EXT4_FC_REPLAY_REALLOC_INCREMENT 4
  102. /*
  103. * Physical block regions added to different inodes due to fast commit
  104. * recovery. These are set during the SCAN phase. During the replay phase,
  105. * our allocator excludes these from its allocation. This ensures that
  106. * we don't accidentally allocating a block that is going to be used by
  107. * another inode.
  108. */
  109. struct ext4_fc_alloc_region {
  110. ext4_lblk_t lblk;
  111. ext4_fsblk_t pblk;
  112. int ino, len;
  113. };
  114. /*
  115. * Fast commit replay state.
  116. */
  117. struct ext4_fc_replay_state {
  118. int fc_replay_num_tags;
  119. int fc_replay_expected_off;
  120. int fc_current_pass;
  121. int fc_cur_tag;
  122. int fc_crc;
  123. struct ext4_fc_alloc_region *fc_regions;
  124. int fc_regions_size, fc_regions_used, fc_regions_valid;
  125. int *fc_modified_inodes;
  126. int fc_modified_inodes_used, fc_modified_inodes_size;
  127. };
  128. #define region_last(__region) (((__region)->lblk) + ((__region)->len) - 1)
  129. #endif /* __FAST_COMMIT_H__ */