.. | .. |
---|
23 | 23 | int len; |
---|
24 | 24 | struct list_head list; |
---|
25 | 25 | /* last field is a variable length array of csums */ |
---|
26 | | - u32 sums[]; |
---|
| 26 | + u8 sums[]; |
---|
27 | 27 | }; |
---|
28 | 28 | |
---|
29 | 29 | /* |
---|
.. | .. |
---|
37 | 37 | * rbtree, just before waking any waiters. It is used to indicate the |
---|
38 | 38 | * IO is done and any metadata is inserted into the tree. |
---|
39 | 39 | */ |
---|
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 | +}; |
---|
62 | 66 | |
---|
63 | 67 | struct btrfs_ordered_extent { |
---|
64 | 68 | /* logical offset in the file */ |
---|
65 | 69 | u64 file_offset; |
---|
66 | 70 | |
---|
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; |
---|
75 | 78 | |
---|
76 | 79 | /* number of bytes that still need writing */ |
---|
77 | 80 | u64 bytes_left; |
---|
.. | .. |
---|
95 | 98 | /* compression algorithm */ |
---|
96 | 99 | int compress_type; |
---|
97 | 100 | |
---|
| 101 | + /* Qgroup reserved space */ |
---|
| 102 | + int qgroup_rsv; |
---|
| 103 | + |
---|
98 | 104 | /* reference count */ |
---|
99 | 105 | refcount_t refs; |
---|
100 | 106 | |
---|
.. | .. |
---|
104 | 110 | /* list of checksums for insertion when the extent io is done */ |
---|
105 | 111 | struct list_head list; |
---|
106 | 112 | |
---|
107 | | - /* If we need to wait on this to be done */ |
---|
| 113 | + /* used for fast fsyncs */ |
---|
108 | 114 | struct list_head log_list; |
---|
109 | | - |
---|
110 | | - /* If the transaction needs to wait on this ordered extent */ |
---|
111 | | - struct list_head trans_list; |
---|
112 | 115 | |
---|
113 | 116 | /* used to wait for the BTRFS_ORDERED_COMPLETE bit */ |
---|
114 | 117 | wait_queue_head_t wait; |
---|
.. | .. |
---|
148 | 151 | } |
---|
149 | 152 | |
---|
150 | 153 | 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, |
---|
152 | 155 | 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, |
---|
154 | 157 | struct btrfs_ordered_extent **cached, |
---|
155 | 158 | 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, |
---|
157 | 160 | struct btrfs_ordered_extent **cached, |
---|
158 | 161 | u64 *file_offset, u64 io_size, |
---|
159 | 162 | 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, |
---|
169 | 174 | 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, |
---|
171 | 176 | 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); |
---|
174 | 178 | int btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len); |
---|
175 | 179 | 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); |
---|
177 | 181 | struct btrfs_ordered_extent *btrfs_lookup_ordered_range( |
---|
178 | 182 | struct btrfs_inode *inode, |
---|
179 | 183 | u64 file_offset, |
---|
180 | 184 | 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); |
---|
185 | 189 | u64 btrfs_wait_ordered_extents(struct btrfs_root *root, u64 nr, |
---|
186 | 190 | 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, |
---|
188 | 192 | 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); |
---|
189 | 196 | int __init ordered_data_init(void); |
---|
190 | 197 | void __cold ordered_data_exit(void); |
---|
191 | 198 | |
---|