Naohiro Aota | 5b31646 | 2020-11-10 20:26:07 +0900 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | |
| 3 | #ifndef BTRFS_ZONED_H |
| 4 | #define BTRFS_ZONED_H |
| 5 | |
| 6 | #include <linux/types.h> |
Naohiro Aota | b70f509 | 2020-11-10 20:26:08 +0900 | [diff] [blame] | 7 | #include <linux/blkdev.h> |
Naohiro Aota | 1265925 | 2020-11-10 20:26:14 +0900 | [diff] [blame] | 8 | #include "volumes.h" |
| 9 | #include "disk-io.h" |
Naohiro Aota | 40ab3be | 2021-02-04 19:22:18 +0900 | [diff] [blame] | 10 | #include "block-group.h" |
Johannes Thumshirn | 869f4cd | 2021-12-07 06:28:34 -0800 | [diff] [blame] | 11 | #include "btrfs_inode.h" |
Naohiro Aota | 5b31646 | 2020-11-10 20:26:07 +0900 | [diff] [blame] | 12 | |
Johannes Thumshirn | 18bb8bb | 2021-04-19 16:41:02 +0900 | [diff] [blame] | 13 | /* |
| 14 | * Block groups with more than this value (percents) of unusable space will be |
| 15 | * scheduled for background reclaim. |
| 16 | */ |
| 17 | #define BTRFS_DEFAULT_RECLAIM_THRESH 75 |
| 18 | |
Naohiro Aota | 5b31646 | 2020-11-10 20:26:07 +0900 | [diff] [blame] | 19 | struct btrfs_zoned_device_info { |
| 20 | /* |
| 21 | * Number of zones, zone size and types of zones if bdev is a |
| 22 | * zoned block device. |
| 23 | */ |
| 24 | u64 zone_size; |
| 25 | u8 zone_size_shift; |
| 26 | u32 nr_zones; |
Naohiro Aota | ea6f8dd | 2021-08-19 21:19:15 +0900 | [diff] [blame] | 27 | unsigned int max_active_zones; |
| 28 | atomic_t active_zones_left; |
Naohiro Aota | 5b31646 | 2020-11-10 20:26:07 +0900 | [diff] [blame] | 29 | unsigned long *seq_zones; |
| 30 | unsigned long *empty_zones; |
Naohiro Aota | ea6f8dd | 2021-08-19 21:19:15 +0900 | [diff] [blame] | 31 | unsigned long *active_zones; |
Naohiro Aota | 16beac8 | 2021-11-11 14:14:38 +0900 | [diff] [blame] | 32 | struct blk_zone *zone_cache; |
Naohiro Aota | 1265925 | 2020-11-10 20:26:14 +0900 | [diff] [blame] | 33 | struct blk_zone sb_zones[2 * BTRFS_SUPER_MIRROR_MAX]; |
Naohiro Aota | 5b31646 | 2020-11-10 20:26:07 +0900 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | #ifdef CONFIG_BLK_DEV_ZONED |
| 37 | int btrfs_get_dev_zone(struct btrfs_device *device, u64 pos, |
| 38 | struct blk_zone *zone); |
Naohiro Aota | 7365104 | 2021-02-04 19:21:42 +0900 | [diff] [blame] | 39 | int btrfs_get_dev_zone_info_all_devices(struct btrfs_fs_info *fs_info); |
Naohiro Aota | 16beac8 | 2021-11-11 14:14:38 +0900 | [diff] [blame] | 40 | int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache); |
Naohiro Aota | 5b31646 | 2020-11-10 20:26:07 +0900 | [diff] [blame] | 41 | void btrfs_destroy_dev_zone_info(struct btrfs_device *device); |
Naohiro Aota | b70f509 | 2020-11-10 20:26:08 +0900 | [diff] [blame] | 42 | int btrfs_check_zoned_mode(struct btrfs_fs_info *fs_info); |
Naohiro Aota | 5d1ab66 | 2020-11-10 20:26:10 +0900 | [diff] [blame] | 43 | int btrfs_check_mountopts_zoned(struct btrfs_fs_info *info); |
Naohiro Aota | 1265925 | 2020-11-10 20:26:14 +0900 | [diff] [blame] | 44 | int btrfs_sb_log_location_bdev(struct block_device *bdev, int mirror, int rw, |
| 45 | u64 *bytenr_ret); |
| 46 | int btrfs_sb_log_location(struct btrfs_device *device, int mirror, int rw, |
| 47 | u64 *bytenr_ret); |
Naohiro Aota | 8376d9e1 | 2021-08-19 21:19:14 +0900 | [diff] [blame] | 48 | int btrfs_advance_sb_log(struct btrfs_device *device, int mirror); |
Naohiro Aota | 1265925 | 2020-11-10 20:26:14 +0900 | [diff] [blame] | 49 | int btrfs_reset_sb_log_zones(struct block_device *bdev, int mirror); |
Naohiro Aota | 1cd6121 | 2021-02-04 19:21:48 +0900 | [diff] [blame] | 50 | u64 btrfs_find_allocatable_zones(struct btrfs_device *device, u64 hole_start, |
| 51 | u64 hole_end, u64 num_bytes); |
| 52 | int btrfs_reset_device_zone(struct btrfs_device *device, u64 physical, |
| 53 | u64 length, u64 *bytes); |
| 54 | int btrfs_ensure_empty_zones(struct btrfs_device *device, u64 start, u64 size); |
Naohiro Aota | a94794d | 2021-02-04 19:21:51 +0900 | [diff] [blame] | 55 | int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new); |
Naohiro Aota | 169e0da | 2021-02-04 19:21:52 +0900 | [diff] [blame] | 56 | void btrfs_calc_zone_unusable(struct btrfs_block_group *cache); |
Naohiro Aota | d3575156 | 2021-02-04 19:21:54 +0900 | [diff] [blame] | 57 | void btrfs_redirty_list_add(struct btrfs_transaction *trans, |
| 58 | struct extent_buffer *eb); |
| 59 | void btrfs_free_redirty_list(struct btrfs_transaction *trans); |
Johannes Thumshirn | e380adf | 2021-05-19 00:40:27 +0900 | [diff] [blame] | 60 | bool btrfs_use_zone_append(struct btrfs_inode *inode, u64 start); |
Naohiro Aota | d8e3fb1 | 2021-02-04 19:22:05 +0900 | [diff] [blame] | 61 | void btrfs_record_physical_zoned(struct inode *inode, u64 file_offset, |
| 62 | struct bio *bio); |
| 63 | void btrfs_rewrite_logical_zoned(struct btrfs_ordered_extent *ordered); |
Naohiro Aota | 0bc09ca | 2021-02-04 19:22:08 +0900 | [diff] [blame] | 64 | bool btrfs_check_meta_write_pointer(struct btrfs_fs_info *fs_info, |
| 65 | struct extent_buffer *eb, |
| 66 | struct btrfs_block_group **cache_ret); |
| 67 | void btrfs_revert_meta_write_pointer(struct btrfs_block_group *cache, |
| 68 | struct extent_buffer *eb); |
Naohiro Aota | de17add | 2021-02-04 19:22:13 +0900 | [diff] [blame] | 69 | int btrfs_zoned_issue_zeroout(struct btrfs_device *device, u64 physical, u64 length); |
Naohiro Aota | 7db1c5d | 2021-02-04 19:22:14 +0900 | [diff] [blame] | 70 | int btrfs_sync_zone_write_pointer(struct btrfs_device *tgt_dev, u64 logical, |
| 71 | u64 physical_start, u64 physical_pos); |
Johannes Thumshirn | e7ff9e6 | 2021-05-19 00:40:29 +0900 | [diff] [blame] | 72 | struct btrfs_device *btrfs_zoned_get_device(struct btrfs_fs_info *fs_info, |
| 73 | u64 logical, u64 length); |
Naohiro Aota | afba2bc | 2021-08-19 21:19:17 +0900 | [diff] [blame] | 74 | bool btrfs_zone_activate(struct btrfs_block_group *block_group); |
| 75 | int btrfs_zone_finish(struct btrfs_block_group *block_group); |
Naohiro Aota | 82187d2 | 2021-12-08 00:35:49 +0900 | [diff] [blame] | 76 | bool btrfs_can_activate_zone(struct btrfs_fs_devices *fs_devices, u64 flags); |
Naohiro Aota | be1a1d7 | 2021-08-19 21:19:23 +0900 | [diff] [blame] | 77 | void btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info, u64 logical, |
| 78 | u64 length); |
Johannes Thumshirn | c2707a2 | 2021-09-09 01:19:26 +0900 | [diff] [blame] | 79 | void btrfs_clear_data_reloc_bg(struct btrfs_block_group *bg); |
Naohiro Aota | 16beac8 | 2021-11-11 14:14:38 +0900 | [diff] [blame] | 80 | void btrfs_free_zone_cache(struct btrfs_fs_info *fs_info); |
Naohiro Aota | 5b31646 | 2020-11-10 20:26:07 +0900 | [diff] [blame] | 81 | #else /* CONFIG_BLK_DEV_ZONED */ |
| 82 | static inline int btrfs_get_dev_zone(struct btrfs_device *device, u64 pos, |
| 83 | struct blk_zone *zone) |
| 84 | { |
| 85 | return 0; |
| 86 | } |
| 87 | |
Naohiro Aota | 7365104 | 2021-02-04 19:21:42 +0900 | [diff] [blame] | 88 | static inline int btrfs_get_dev_zone_info_all_devices(struct btrfs_fs_info *fs_info) |
| 89 | { |
| 90 | return 0; |
| 91 | } |
| 92 | |
Naohiro Aota | 16beac8 | 2021-11-11 14:14:38 +0900 | [diff] [blame] | 93 | static inline int btrfs_get_dev_zone_info(struct btrfs_device *device, |
| 94 | bool populate_cache) |
Naohiro Aota | 5b31646 | 2020-11-10 20:26:07 +0900 | [diff] [blame] | 95 | { |
| 96 | return 0; |
| 97 | } |
| 98 | |
| 99 | static inline void btrfs_destroy_dev_zone_info(struct btrfs_device *device) { } |
| 100 | |
Naohiro Aota | b70f509 | 2020-11-10 20:26:08 +0900 | [diff] [blame] | 101 | static inline int btrfs_check_zoned_mode(const struct btrfs_fs_info *fs_info) |
| 102 | { |
| 103 | if (!btrfs_is_zoned(fs_info)) |
| 104 | return 0; |
| 105 | |
| 106 | btrfs_err(fs_info, "zoned block devices support is not enabled"); |
| 107 | return -EOPNOTSUPP; |
| 108 | } |
| 109 | |
Naohiro Aota | 5d1ab66 | 2020-11-10 20:26:10 +0900 | [diff] [blame] | 110 | static inline int btrfs_check_mountopts_zoned(struct btrfs_fs_info *info) |
| 111 | { |
| 112 | return 0; |
| 113 | } |
| 114 | |
Naohiro Aota | 1265925 | 2020-11-10 20:26:14 +0900 | [diff] [blame] | 115 | static inline int btrfs_sb_log_location_bdev(struct block_device *bdev, |
| 116 | int mirror, int rw, u64 *bytenr_ret) |
| 117 | { |
| 118 | *bytenr_ret = btrfs_sb_offset(mirror); |
| 119 | return 0; |
| 120 | } |
| 121 | |
| 122 | static inline int btrfs_sb_log_location(struct btrfs_device *device, int mirror, |
| 123 | int rw, u64 *bytenr_ret) |
| 124 | { |
| 125 | *bytenr_ret = btrfs_sb_offset(mirror); |
| 126 | return 0; |
| 127 | } |
| 128 | |
Naohiro Aota | 8376d9e1 | 2021-08-19 21:19:14 +0900 | [diff] [blame] | 129 | static inline int btrfs_advance_sb_log(struct btrfs_device *device, int mirror) |
| 130 | { |
| 131 | return 0; |
| 132 | } |
Naohiro Aota | 1265925 | 2020-11-10 20:26:14 +0900 | [diff] [blame] | 133 | |
| 134 | static inline int btrfs_reset_sb_log_zones(struct block_device *bdev, int mirror) |
| 135 | { |
| 136 | return 0; |
| 137 | } |
| 138 | |
Naohiro Aota | 1cd6121 | 2021-02-04 19:21:48 +0900 | [diff] [blame] | 139 | static inline u64 btrfs_find_allocatable_zones(struct btrfs_device *device, |
| 140 | u64 hole_start, u64 hole_end, |
| 141 | u64 num_bytes) |
| 142 | { |
| 143 | return hole_start; |
| 144 | } |
| 145 | |
| 146 | static inline int btrfs_reset_device_zone(struct btrfs_device *device, |
| 147 | u64 physical, u64 length, u64 *bytes) |
| 148 | { |
| 149 | *bytes = 0; |
| 150 | return 0; |
| 151 | } |
| 152 | |
| 153 | static inline int btrfs_ensure_empty_zones(struct btrfs_device *device, |
| 154 | u64 start, u64 size) |
| 155 | { |
| 156 | return 0; |
| 157 | } |
| 158 | |
Naohiro Aota | 08e11a3 | 2021-02-04 19:21:50 +0900 | [diff] [blame] | 159 | static inline int btrfs_load_block_group_zone_info( |
Naohiro Aota | a94794d | 2021-02-04 19:21:51 +0900 | [diff] [blame] | 160 | struct btrfs_block_group *cache, bool new) |
Naohiro Aota | 08e11a3 | 2021-02-04 19:21:50 +0900 | [diff] [blame] | 161 | { |
| 162 | return 0; |
| 163 | } |
| 164 | |
Naohiro Aota | 169e0da | 2021-02-04 19:21:52 +0900 | [diff] [blame] | 165 | static inline void btrfs_calc_zone_unusable(struct btrfs_block_group *cache) { } |
| 166 | |
Naohiro Aota | d3575156 | 2021-02-04 19:21:54 +0900 | [diff] [blame] | 167 | static inline void btrfs_redirty_list_add(struct btrfs_transaction *trans, |
| 168 | struct extent_buffer *eb) { } |
| 169 | static inline void btrfs_free_redirty_list(struct btrfs_transaction *trans) { } |
| 170 | |
Johannes Thumshirn | e380adf | 2021-05-19 00:40:27 +0900 | [diff] [blame] | 171 | static inline bool btrfs_use_zone_append(struct btrfs_inode *inode, u64 start) |
Johannes Thumshirn | 08f45559 | 2021-02-04 19:22:03 +0900 | [diff] [blame] | 172 | { |
| 173 | return false; |
| 174 | } |
Naohiro Aota | d8e3fb1 | 2021-02-04 19:22:05 +0900 | [diff] [blame] | 175 | |
| 176 | static inline void btrfs_record_physical_zoned(struct inode *inode, |
| 177 | u64 file_offset, struct bio *bio) |
| 178 | { |
| 179 | } |
| 180 | |
| 181 | static inline void btrfs_rewrite_logical_zoned( |
| 182 | struct btrfs_ordered_extent *ordered) { } |
| 183 | |
Naohiro Aota | 0bc09ca | 2021-02-04 19:22:08 +0900 | [diff] [blame] | 184 | static inline bool btrfs_check_meta_write_pointer(struct btrfs_fs_info *fs_info, |
| 185 | struct extent_buffer *eb, |
| 186 | struct btrfs_block_group **cache_ret) |
| 187 | { |
| 188 | return true; |
| 189 | } |
| 190 | |
| 191 | static inline void btrfs_revert_meta_write_pointer( |
| 192 | struct btrfs_block_group *cache, |
| 193 | struct extent_buffer *eb) |
| 194 | { |
| 195 | } |
| 196 | |
Naohiro Aota | de17add | 2021-02-04 19:22:13 +0900 | [diff] [blame] | 197 | static inline int btrfs_zoned_issue_zeroout(struct btrfs_device *device, |
| 198 | u64 physical, u64 length) |
| 199 | { |
| 200 | return -EOPNOTSUPP; |
| 201 | } |
| 202 | |
Naohiro Aota | 7db1c5d | 2021-02-04 19:22:14 +0900 | [diff] [blame] | 203 | static inline int btrfs_sync_zone_write_pointer(struct btrfs_device *tgt_dev, |
| 204 | u64 logical, u64 physical_start, |
| 205 | u64 physical_pos) |
| 206 | { |
| 207 | return -EOPNOTSUPP; |
| 208 | } |
| 209 | |
Johannes Thumshirn | e7ff9e6 | 2021-05-19 00:40:29 +0900 | [diff] [blame] | 210 | static inline struct btrfs_device *btrfs_zoned_get_device( |
| 211 | struct btrfs_fs_info *fs_info, |
| 212 | u64 logical, u64 length) |
| 213 | { |
| 214 | return ERR_PTR(-EOPNOTSUPP); |
| 215 | } |
| 216 | |
Naohiro Aota | afba2bc | 2021-08-19 21:19:17 +0900 | [diff] [blame] | 217 | static inline bool btrfs_zone_activate(struct btrfs_block_group *block_group) |
| 218 | { |
| 219 | return true; |
| 220 | } |
| 221 | |
| 222 | static inline int btrfs_zone_finish(struct btrfs_block_group *block_group) |
| 223 | { |
| 224 | return 0; |
| 225 | } |
| 226 | |
Naohiro Aota | a85f05e | 2021-08-19 21:19:22 +0900 | [diff] [blame] | 227 | static inline bool btrfs_can_activate_zone(struct btrfs_fs_devices *fs_devices, |
Naohiro Aota | 82187d2 | 2021-12-08 00:35:49 +0900 | [diff] [blame] | 228 | u64 flags) |
Naohiro Aota | a85f05e | 2021-08-19 21:19:22 +0900 | [diff] [blame] | 229 | { |
| 230 | return true; |
| 231 | } |
| 232 | |
Naohiro Aota | be1a1d7 | 2021-08-19 21:19:23 +0900 | [diff] [blame] | 233 | static inline void btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info, |
| 234 | u64 logical, u64 length) { } |
| 235 | |
Johannes Thumshirn | c2707a2 | 2021-09-09 01:19:26 +0900 | [diff] [blame] | 236 | static inline void btrfs_clear_data_reloc_bg(struct btrfs_block_group *bg) { } |
| 237 | |
Naohiro Aota | 16beac8 | 2021-11-11 14:14:38 +0900 | [diff] [blame] | 238 | static inline void btrfs_free_zone_cache(struct btrfs_fs_info *fs_info) { } |
Naohiro Aota | 5b31646 | 2020-11-10 20:26:07 +0900 | [diff] [blame] | 239 | #endif |
| 240 | |
| 241 | static inline bool btrfs_dev_is_sequential(struct btrfs_device *device, u64 pos) |
| 242 | { |
| 243 | struct btrfs_zoned_device_info *zone_info = device->zone_info; |
| 244 | |
| 245 | if (!zone_info) |
| 246 | return false; |
| 247 | |
| 248 | return test_bit(pos >> zone_info->zone_size_shift, zone_info->seq_zones); |
| 249 | } |
| 250 | |
| 251 | static inline bool btrfs_dev_is_empty_zone(struct btrfs_device *device, u64 pos) |
| 252 | { |
| 253 | struct btrfs_zoned_device_info *zone_info = device->zone_info; |
| 254 | |
| 255 | if (!zone_info) |
| 256 | return true; |
| 257 | |
| 258 | return test_bit(pos >> zone_info->zone_size_shift, zone_info->empty_zones); |
| 259 | } |
| 260 | |
| 261 | static inline void btrfs_dev_set_empty_zone_bit(struct btrfs_device *device, |
| 262 | u64 pos, bool set) |
| 263 | { |
| 264 | struct btrfs_zoned_device_info *zone_info = device->zone_info; |
| 265 | unsigned int zno; |
| 266 | |
| 267 | if (!zone_info) |
| 268 | return; |
| 269 | |
| 270 | zno = pos >> zone_info->zone_size_shift; |
| 271 | if (set) |
| 272 | set_bit(zno, zone_info->empty_zones); |
| 273 | else |
| 274 | clear_bit(zno, zone_info->empty_zones); |
| 275 | } |
| 276 | |
| 277 | static inline void btrfs_dev_set_zone_empty(struct btrfs_device *device, u64 pos) |
| 278 | { |
| 279 | btrfs_dev_set_empty_zone_bit(device, pos, true); |
| 280 | } |
| 281 | |
| 282 | static inline void btrfs_dev_clear_zone_empty(struct btrfs_device *device, u64 pos) |
| 283 | { |
| 284 | btrfs_dev_set_empty_zone_bit(device, pos, false); |
| 285 | } |
| 286 | |
Naohiro Aota | b70f509 | 2020-11-10 20:26:08 +0900 | [diff] [blame] | 287 | static inline bool btrfs_check_device_zone_type(const struct btrfs_fs_info *fs_info, |
| 288 | struct block_device *bdev) |
| 289 | { |
Naohiro Aota | b70f509 | 2020-11-10 20:26:08 +0900 | [diff] [blame] | 290 | if (btrfs_is_zoned(fs_info)) { |
Johannes Thumshirn | 3c9daa0 | 2021-02-04 19:21:47 +0900 | [diff] [blame] | 291 | /* |
| 292 | * We can allow a regular device on a zoned filesystem, because |
| 293 | * we will emulate the zoned capabilities. |
| 294 | */ |
| 295 | if (!bdev_is_zoned(bdev)) |
| 296 | return true; |
| 297 | |
| 298 | return fs_info->zone_size == |
| 299 | (bdev_zone_sectors(bdev) << SECTOR_SHIFT); |
Naohiro Aota | b70f509 | 2020-11-10 20:26:08 +0900 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | /* Do not allow Host Manged zoned device */ |
| 303 | return bdev_zoned_model(bdev) != BLK_ZONED_HM; |
| 304 | } |
| 305 | |
Naohiro Aota | 1265925 | 2020-11-10 20:26:14 +0900 | [diff] [blame] | 306 | static inline bool btrfs_check_super_location(struct btrfs_device *device, u64 pos) |
| 307 | { |
| 308 | /* |
| 309 | * On a non-zoned device, any address is OK. On a zoned device, |
| 310 | * non-SEQUENTIAL WRITE REQUIRED zones are capable. |
| 311 | */ |
| 312 | return device->zone_info == NULL || !btrfs_dev_is_sequential(device, pos); |
| 313 | } |
| 314 | |
Naohiro Aota | dcba6e4 | 2021-02-04 19:21:56 +0900 | [diff] [blame] | 315 | static inline bool btrfs_can_zone_reset(struct btrfs_device *device, |
| 316 | u64 physical, u64 length) |
| 317 | { |
| 318 | u64 zone_size; |
| 319 | |
| 320 | if (!btrfs_dev_is_sequential(device, physical)) |
| 321 | return false; |
| 322 | |
| 323 | zone_size = device->zone_info->zone_size; |
| 324 | if (!IS_ALIGNED(physical, zone_size) || !IS_ALIGNED(length, zone_size)) |
| 325 | return false; |
| 326 | |
| 327 | return true; |
| 328 | } |
| 329 | |
Naohiro Aota | 0bc09ca | 2021-02-04 19:22:08 +0900 | [diff] [blame] | 330 | static inline void btrfs_zoned_meta_io_lock(struct btrfs_fs_info *fs_info) |
| 331 | { |
| 332 | if (!btrfs_is_zoned(fs_info)) |
| 333 | return; |
| 334 | mutex_lock(&fs_info->zoned_meta_io_lock); |
| 335 | } |
| 336 | |
| 337 | static inline void btrfs_zoned_meta_io_unlock(struct btrfs_fs_info *fs_info) |
| 338 | { |
| 339 | if (!btrfs_is_zoned(fs_info)) |
| 340 | return; |
| 341 | mutex_unlock(&fs_info->zoned_meta_io_lock); |
| 342 | } |
| 343 | |
Naohiro Aota | 40ab3be | 2021-02-04 19:22:18 +0900 | [diff] [blame] | 344 | static inline void btrfs_clear_treelog_bg(struct btrfs_block_group *bg) |
| 345 | { |
| 346 | struct btrfs_fs_info *fs_info = bg->fs_info; |
| 347 | |
| 348 | if (!btrfs_is_zoned(fs_info)) |
| 349 | return; |
| 350 | |
| 351 | spin_lock(&fs_info->treelog_bg_lock); |
| 352 | if (fs_info->treelog_bg == bg->start) |
| 353 | fs_info->treelog_bg = 0; |
| 354 | spin_unlock(&fs_info->treelog_bg_lock); |
| 355 | } |
| 356 | |
Johannes Thumshirn | 869f4cd | 2021-12-07 06:28:34 -0800 | [diff] [blame] | 357 | static inline void btrfs_zoned_data_reloc_lock(struct btrfs_inode *inode) |
| 358 | { |
| 359 | struct btrfs_root *root = inode->root; |
| 360 | |
| 361 | if (btrfs_is_data_reloc_root(root) && btrfs_is_zoned(root->fs_info)) |
| 362 | btrfs_inode_lock(&inode->vfs_inode, 0); |
| 363 | } |
| 364 | |
| 365 | static inline void btrfs_zoned_data_reloc_unlock(struct btrfs_inode *inode) |
| 366 | { |
| 367 | struct btrfs_root *root = inode->root; |
| 368 | |
| 369 | if (btrfs_is_data_reloc_root(root) && btrfs_is_zoned(root->fs_info)) |
| 370 | btrfs_inode_unlock(&inode->vfs_inode, 0); |
| 371 | } |
| 372 | |
Naohiro Aota | 5b31646 | 2020-11-10 20:26:07 +0900 | [diff] [blame] | 373 | #endif |