summaryrefslogtreecommitdiff
path: root/fs/btrfs/zoned.c
diff options
context:
space:
mode:
authorNaohiro Aota <naohiro.aota@wdc.com>2023-08-08 01:12:33 +0900
committerDavid Sterba <dsterba@suse.com>2023-08-21 14:52:19 +0200
commit2ad8c0510a965113404cfe670b41ddc34fb66100 (patch)
tree73cec012133aea622938982b8e6a1d54bbc52fd6 /fs/btrfs/zoned.c
parent7db94301a980c9da4168ac7ce61e7bde297306ba (diff)
btrfs: zoned: return int from btrfs_check_meta_write_pointer
Now that we have writeback_control passed to btrfs_check_meta_write_pointer(), we can move the wbc condition in submit_eb_page() to btrfs_check_meta_write_pointer() and return int. Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/zoned.c')
-rw-r--r--fs/btrfs/zoned.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index da6bdbe68c7b..c8ff94176381 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -1747,14 +1747,23 @@ out:
}
}
-bool btrfs_check_meta_write_pointer(struct btrfs_fs_info *fs_info,
- struct btrfs_eb_write_context *ctx)
+/*
+ * Check if @ctx->eb is aligned to the write pointer.
+ *
+ * Return:
+ * 0: @ctx->eb is at the write pointer. You can write it.
+ * -EAGAIN: There is a hole. The caller should handle the case.
+ * -EBUSY: There is a hole, but the caller can just bail out.
+ */
+int btrfs_check_meta_write_pointer(struct btrfs_fs_info *fs_info,
+ struct btrfs_eb_write_context *ctx)
{
+ const struct writeback_control *wbc = ctx->wbc;
const struct extent_buffer *eb = ctx->eb;
struct btrfs_block_group *block_group = ctx->zoned_bg;
if (!btrfs_is_zoned(fs_info))
- return true;
+ return 0;
if (block_group) {
if (block_group->start > eb->start ||
@@ -1768,15 +1777,20 @@ bool btrfs_check_meta_write_pointer(struct btrfs_fs_info *fs_info,
if (!block_group) {
block_group = btrfs_lookup_block_group(fs_info, eb->start);
if (!block_group)
- return true;
+ return 0;
ctx->zoned_bg = block_group;
}
- if (block_group->meta_write_pointer != eb->start)
- return false;
- block_group->meta_write_pointer = eb->start + eb->len;
+ if (block_group->meta_write_pointer == eb->start) {
+ block_group->meta_write_pointer = eb->start + eb->len;
- return true;
+ return 0;
+ }
+
+ /* If for_sync, this hole will be filled with trasnsaction commit. */
+ if (wbc->sync_mode == WB_SYNC_ALL && !wbc->for_sync)
+ return -EAGAIN;
+ return -EBUSY;
}
void btrfs_revert_meta_write_pointer(struct btrfs_block_group *cache,