Commit 9fdd1601 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David Sterba

btrfs: return bool from lock_extent_buffer_for_io

lock_extent_buffer_for_io never returns a negative error value, so switch
the return value to a simple bool.
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
[ keep noinline_for_stack ]
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 3d66b4b2
......@@ -1629,18 +1629,17 @@ static void end_extent_buffer_writeback(struct extent_buffer *eb)
*
* May try to flush write bio if we can't get the lock.
*
* Return 0 if the extent buffer doesn't need to be submitted.
* (E.g. the extent buffer is not dirty)
* Return >0 is the extent buffer is submitted to bio.
* Return <0 if something went wrong, no page is locked.
* Return %false if the extent buffer doesn't need to be submitted (e.g. the
* extent buffer is not dirty)
* Return %true is the extent buffer is submitted to bio.
*/
static noinline_for_stack int lock_extent_buffer_for_io(struct extent_buffer *eb,
static noinline_for_stack bool lock_extent_buffer_for_io(struct extent_buffer *eb,
struct btrfs_bio_ctrl *bio_ctrl)
{
struct btrfs_fs_info *fs_info = eb->fs_info;
int i, num_pages;
int flush = 0;
int ret = 0;
bool ret = false;
if (!btrfs_try_tree_write_lock(eb)) {
submit_write_bio(bio_ctrl, 0);
......@@ -1651,7 +1650,7 @@ static noinline_for_stack int lock_extent_buffer_for_io(struct extent_buffer *eb
if (test_bit(EXTENT_BUFFER_WRITEBACK, &eb->bflags)) {
btrfs_tree_unlock(eb);
if (bio_ctrl->wbc->sync_mode != WB_SYNC_ALL)
return 0;
return false;
if (!flush) {
submit_write_bio(bio_ctrl, 0);
flush = 1;
......@@ -1678,7 +1677,7 @@ static noinline_for_stack int lock_extent_buffer_for_io(struct extent_buffer *eb
percpu_counter_add_batch(&fs_info->dirty_metadata_bytes,
-eb->len,
fs_info->dirty_metadata_batch);
ret = 1;
ret = true;
} else {
spin_unlock(&eb->refs_lock);
}
......@@ -2012,7 +2011,6 @@ static int submit_eb_subpage(struct page *page, struct btrfs_bio_ctrl *bio_ctrl)
u64 page_start = page_offset(page);
int bit_start = 0;
int sectors_per_node = fs_info->nodesize >> fs_info->sectorsize_bits;
int ret;
/* Lock and write each dirty extent buffers in the range */
while (bit_start < fs_info->subpage_info->bitmap_nr_bits) {
......@@ -2058,25 +2056,13 @@ static int submit_eb_subpage(struct page *page, struct btrfs_bio_ctrl *bio_ctrl)
if (!eb)
continue;
ret = lock_extent_buffer_for_io(eb, bio_ctrl);
if (ret == 0) {
free_extent_buffer(eb);
continue;
if (lock_extent_buffer_for_io(eb, bio_ctrl)) {
write_one_subpage_eb(eb, bio_ctrl);
submitted++;
}
if (ret < 0) {
free_extent_buffer(eb);
goto cleanup;
}
write_one_subpage_eb(eb, bio_ctrl);
free_extent_buffer(eb);
submitted++;
}
return submitted;
cleanup:
/* We hit error, end bio for the submitted extent buffers */
submit_write_bio(bio_ctrl, ret);
return ret;
}
/*
......@@ -2155,8 +2141,7 @@ static int submit_eb_page(struct page *page, struct btrfs_bio_ctrl *bio_ctrl,
*eb_context = eb;
ret = lock_extent_buffer_for_io(eb, bio_ctrl);
if (ret <= 0) {
if (!lock_extent_buffer_for_io(eb, bio_ctrl)) {
btrfs_revert_meta_write_pointer(cache, eb);
if (cache)
btrfs_put_block_group(cache);
......
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