Commit 2ad8c051 authored by Naohiro Aota's avatar Naohiro Aota Committed by David Sterba

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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 7db94301
...@@ -1846,14 +1846,9 @@ static int submit_eb_page(struct page *page, struct btrfs_eb_write_context *ctx) ...@@ -1846,14 +1846,9 @@ static int submit_eb_page(struct page *page, struct btrfs_eb_write_context *ctx)
ctx->eb = eb; ctx->eb = eb;
if (!btrfs_check_meta_write_pointer(eb->fs_info, ctx)) { ret = btrfs_check_meta_write_pointer(eb->fs_info, ctx);
/* if (ret) {
* If for_sync, this hole will be filled with if (ret == -EBUSY)
* trasnsaction commit.
*/
if (wbc->sync_mode == WB_SYNC_ALL && !wbc->for_sync)
ret = -EAGAIN;
else
ret = 0; ret = 0;
free_extent_buffer(eb); free_extent_buffer(eb);
return ret; return ret;
......
...@@ -1747,14 +1747,23 @@ void btrfs_finish_ordered_zoned(struct btrfs_ordered_extent *ordered) ...@@ -1747,14 +1747,23 @@ void btrfs_finish_ordered_zoned(struct btrfs_ordered_extent *ordered)
} }
} }
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; const struct extent_buffer *eb = ctx->eb;
struct btrfs_block_group *block_group = ctx->zoned_bg; struct btrfs_block_group *block_group = ctx->zoned_bg;
if (!btrfs_is_zoned(fs_info)) if (!btrfs_is_zoned(fs_info))
return true; return 0;
if (block_group) { if (block_group) {
if (block_group->start > eb->start || if (block_group->start > eb->start ||
...@@ -1768,15 +1777,20 @@ bool btrfs_check_meta_write_pointer(struct btrfs_fs_info *fs_info, ...@@ -1768,15 +1777,20 @@ bool btrfs_check_meta_write_pointer(struct btrfs_fs_info *fs_info,
if (!block_group) { if (!block_group) {
block_group = btrfs_lookup_block_group(fs_info, eb->start); block_group = btrfs_lookup_block_group(fs_info, eb->start);
if (!block_group) if (!block_group)
return true; return 0;
ctx->zoned_bg = block_group; ctx->zoned_bg = block_group;
} }
if (block_group->meta_write_pointer != eb->start) if (block_group->meta_write_pointer == eb->start) {
return false; block_group->meta_write_pointer = eb->start + eb->len;
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, void btrfs_revert_meta_write_pointer(struct btrfs_block_group *cache,
......
...@@ -58,8 +58,8 @@ void btrfs_redirty_list_add(struct btrfs_transaction *trans, ...@@ -58,8 +58,8 @@ void btrfs_redirty_list_add(struct btrfs_transaction *trans,
struct extent_buffer *eb); struct extent_buffer *eb);
bool btrfs_use_zone_append(struct btrfs_bio *bbio); bool btrfs_use_zone_append(struct btrfs_bio *bbio);
void btrfs_record_physical_zoned(struct btrfs_bio *bbio); void btrfs_record_physical_zoned(struct btrfs_bio *bbio);
bool btrfs_check_meta_write_pointer(struct btrfs_fs_info *fs_info, int btrfs_check_meta_write_pointer(struct btrfs_fs_info *fs_info,
struct btrfs_eb_write_context *ctx); struct btrfs_eb_write_context *ctx);
void btrfs_revert_meta_write_pointer(struct btrfs_block_group *cache, void btrfs_revert_meta_write_pointer(struct btrfs_block_group *cache,
struct extent_buffer *eb); struct extent_buffer *eb);
int btrfs_zoned_issue_zeroout(struct btrfs_device *device, u64 physical, u64 length); int btrfs_zoned_issue_zeroout(struct btrfs_device *device, u64 physical, u64 length);
...@@ -188,10 +188,10 @@ static inline void btrfs_record_physical_zoned(struct btrfs_bio *bbio) ...@@ -188,10 +188,10 @@ static inline void btrfs_record_physical_zoned(struct btrfs_bio *bbio)
{ {
} }
static inline bool btrfs_check_meta_write_pointer(struct btrfs_fs_info *fs_info, static inline int btrfs_check_meta_write_pointer(struct btrfs_fs_info *fs_info,
struct btrfs_eb_write_context *ctx) struct btrfs_eb_write_context *ctx)
{ {
return true; return 0;
} }
static inline void btrfs_revert_meta_write_pointer( static inline void btrfs_revert_meta_write_pointer(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment