hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/fs/btrfs/ordered-data.h
....@@ -23,7 +23,7 @@
2323 int len;
2424 struct list_head list;
2525 /* last field is a variable length array of csums */
26
- u32 sums[];
26
+ u8 sums[];
2727 };
2828
2929 /*
....@@ -37,41 +37,44 @@
3737 * rbtree, just before waking any waiters. It is used to indicate the
3838 * IO is done and any metadata is inserted into the tree.
3939 */
40
-#define BTRFS_ORDERED_IO_DONE 0 /* set when all the pages are written */
41
-
42
-#define BTRFS_ORDERED_COMPLETE 1 /* set when removed from the tree */
43
-
44
-#define BTRFS_ORDERED_NOCOW 2 /* set when we want to write in place */
45
-
46
-#define BTRFS_ORDERED_COMPRESSED 3 /* writing a zlib compressed extent */
47
-
48
-#define BTRFS_ORDERED_PREALLOC 4 /* set when writing to preallocated extent */
49
-
50
-#define BTRFS_ORDERED_DIRECT 5 /* set when we're doing DIO with this extent */
51
-
52
-#define BTRFS_ORDERED_IOERR 6 /* We had an io error when writing this out */
53
-
54
-#define BTRFS_ORDERED_UPDATED_ISIZE 7 /* indicates whether this ordered extent
55
- * has done its due diligence in updating
56
- * the isize. */
57
-#define BTRFS_ORDERED_TRUNCATED 8 /* Set when we have to truncate an extent */
58
-
59
-#define BTRFS_ORDERED_PENDING 9 /* We are waiting for this ordered extent to
60
- * complete in the current transaction. */
61
-#define BTRFS_ORDERED_REGULAR 10 /* Regular IO for COW */
40
+enum {
41
+ /* set when all the pages are written */
42
+ BTRFS_ORDERED_IO_DONE,
43
+ /* set when removed from the tree */
44
+ BTRFS_ORDERED_COMPLETE,
45
+ /* set when we want to write in place */
46
+ BTRFS_ORDERED_NOCOW,
47
+ /* writing a zlib compressed extent */
48
+ BTRFS_ORDERED_COMPRESSED,
49
+ /* set when writing to preallocated extent */
50
+ BTRFS_ORDERED_PREALLOC,
51
+ /* set when we're doing DIO with this extent */
52
+ BTRFS_ORDERED_DIRECT,
53
+ /* We had an io error when writing this out */
54
+ BTRFS_ORDERED_IOERR,
55
+ /* Set when we have to truncate an extent */
56
+ BTRFS_ORDERED_TRUNCATED,
57
+ /* Regular IO for COW */
58
+ BTRFS_ORDERED_REGULAR,
59
+ /* Used during fsync to track already logged extents */
60
+ BTRFS_ORDERED_LOGGED,
61
+ /* We have already logged all the csums of the ordered extent */
62
+ BTRFS_ORDERED_LOGGED_CSUM,
63
+ /* We wait for this extent to complete in the current transaction */
64
+ BTRFS_ORDERED_PENDING,
65
+};
6266
6367 struct btrfs_ordered_extent {
6468 /* logical offset in the file */
6569 u64 file_offset;
6670
67
- /* disk byte number */
68
- u64 start;
69
-
70
- /* ram length of the extent in bytes */
71
- u64 len;
72
-
73
- /* extent length on disk */
74
- u64 disk_len;
71
+ /*
72
+ * These fields directly correspond to the same fields in
73
+ * btrfs_file_extent_item.
74
+ */
75
+ u64 disk_bytenr;
76
+ u64 num_bytes;
77
+ u64 disk_num_bytes;
7578
7679 /* number of bytes that still need writing */
7780 u64 bytes_left;
....@@ -95,6 +98,9 @@
9598 /* compression algorithm */
9699 int compress_type;
97100
101
+ /* Qgroup reserved space */
102
+ int qgroup_rsv;
103
+
98104 /* reference count */
99105 refcount_t refs;
100106
....@@ -104,11 +110,8 @@
104110 /* list of checksums for insertion when the extent io is done */
105111 struct list_head list;
106112
107
- /* If we need to wait on this to be done */
113
+ /* used for fast fsyncs */
108114 struct list_head log_list;
109
-
110
- /* If the transaction needs to wait on this ordered extent */
111
- struct list_head trans_list;
112115
113116 /* used to wait for the BTRFS_ORDERED_COMPLETE bit */
114117 wait_queue_head_t wait;
....@@ -148,44 +151,48 @@
148151 }
149152
150153 void btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry);
151
-void btrfs_remove_ordered_extent(struct inode *inode,
154
+void btrfs_remove_ordered_extent(struct btrfs_inode *btrfs_inode,
152155 struct btrfs_ordered_extent *entry);
153
-int btrfs_dec_test_ordered_pending(struct inode *inode,
156
+int btrfs_dec_test_ordered_pending(struct btrfs_inode *inode,
154157 struct btrfs_ordered_extent **cached,
155158 u64 file_offset, u64 io_size, int uptodate);
156
-int btrfs_dec_test_first_ordered_pending(struct inode *inode,
159
+int btrfs_dec_test_first_ordered_pending(struct btrfs_inode *inode,
157160 struct btrfs_ordered_extent **cached,
158161 u64 *file_offset, u64 io_size,
159162 int uptodate);
160
-int btrfs_add_ordered_extent(struct inode *inode, u64 file_offset,
161
- u64 start, u64 len, u64 disk_len, int type);
162
-int btrfs_add_ordered_extent_dio(struct inode *inode, u64 file_offset,
163
- u64 start, u64 len, u64 disk_len, int type);
164
-int btrfs_add_ordered_extent_compress(struct inode *inode, u64 file_offset,
165
- u64 start, u64 len, u64 disk_len,
166
- int type, int compress_type);
167
-void btrfs_add_ordered_sum(struct inode *inode,
168
- struct btrfs_ordered_extent *entry,
163
+int btrfs_add_ordered_extent(struct btrfs_inode *inode, u64 file_offset,
164
+ u64 disk_bytenr, u64 num_bytes, u64 disk_num_bytes,
165
+ int type);
166
+int btrfs_add_ordered_extent_dio(struct btrfs_inode *inode, u64 file_offset,
167
+ u64 disk_bytenr, u64 num_bytes,
168
+ u64 disk_num_bytes, int type);
169
+int btrfs_add_ordered_extent_compress(struct btrfs_inode *inode, u64 file_offset,
170
+ u64 disk_bytenr, u64 num_bytes,
171
+ u64 disk_num_bytes, int type,
172
+ int compress_type);
173
+void btrfs_add_ordered_sum(struct btrfs_ordered_extent *entry,
169174 struct btrfs_ordered_sum *sum);
170
-struct btrfs_ordered_extent *btrfs_lookup_ordered_extent(struct inode *inode,
175
+struct btrfs_ordered_extent *btrfs_lookup_ordered_extent(struct btrfs_inode *inode,
171176 u64 file_offset);
172
-void btrfs_start_ordered_extent(struct inode *inode,
173
- struct btrfs_ordered_extent *entry, int wait);
177
+void btrfs_start_ordered_extent(struct btrfs_ordered_extent *entry, int wait);
174178 int btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len);
175179 struct btrfs_ordered_extent *
176
-btrfs_lookup_first_ordered_extent(struct inode * inode, u64 file_offset);
180
+btrfs_lookup_first_ordered_extent(struct btrfs_inode *inode, u64 file_offset);
177181 struct btrfs_ordered_extent *btrfs_lookup_ordered_range(
178182 struct btrfs_inode *inode,
179183 u64 file_offset,
180184 u64 len);
181
-int btrfs_ordered_update_i_size(struct inode *inode, u64 offset,
182
- struct btrfs_ordered_extent *ordered);
183
-int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr,
184
- u32 *sum, int len);
185
+void btrfs_get_ordered_extents_for_logging(struct btrfs_inode *inode,
186
+ struct list_head *list);
187
+int btrfs_find_ordered_sum(struct btrfs_inode *inode, u64 offset,
188
+ u64 disk_bytenr, u8 *sum, int len);
185189 u64 btrfs_wait_ordered_extents(struct btrfs_root *root, u64 nr,
186190 const u64 range_start, const u64 range_len);
187
-u64 btrfs_wait_ordered_roots(struct btrfs_fs_info *fs_info, u64 nr,
191
+void btrfs_wait_ordered_roots(struct btrfs_fs_info *fs_info, u64 nr,
188192 const u64 range_start, const u64 range_len);
193
+void btrfs_lock_and_flush_ordered_range(struct btrfs_inode *inode, u64 start,
194
+ u64 end,
195
+ struct extent_state **cached_state);
189196 int __init ordered_data_init(void);
190197 void __cold ordered_data_exit(void);
191198