diff mbox series

btrfs: Record error in btree_csum_one_bio()

Message ID 20190406102005.5420-1-wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs: Record error in btree_csum_one_bio() | expand

Commit Message

Qu Wenruo April 6, 2019, 10:20 a.m. UTC
Since commit 6dc4f100c175 ("block: allow bio_for_each_segment_all() to
iterate over multi-page bvec"), break will only break the inner loop of
bio_for_each_segment_all(), unable to break the outer loop.

This patch will break out by utilizing goto command.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/disk-io.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

David Sterba April 8, 2019, 4:49 p.m. UTC | #1
On Sat, Apr 06, 2019 at 06:20:05PM +0800, Qu Wenruo wrote:
> Since commit 6dc4f100c175 ("block: allow bio_for_each_segment_all() to
> iterate over multi-page bvec"), break will only break the inner loop of
> bio_for_each_segment_all(), unable to break the outer loop.
> 
> This patch will break out by utilizing goto command.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
>  fs/btrfs/disk-io.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index 6fe9197f6ee4..e20b952d3cde 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -840,9 +840,10 @@ static blk_status_t btree_csum_one_bio(struct bio *bio)
>  		root = BTRFS_I(bvec->bv_page->mapping->host)->root;
>  		ret = csum_dirty_buffer(root->fs_info, bvec->bv_page);
>  		if (ret)
> -			break;
> +			goto out;

This being fixed in the block layer macros, but note that 'break' is not
the only thing that's broken, also 'continue' and we do have a few
instances of that in btrfs code.

Once this is fixed in the macros, this patch is not necessary.
diff mbox series

Patch

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 6fe9197f6ee4..e20b952d3cde 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -840,9 +840,10 @@  static blk_status_t btree_csum_one_bio(struct bio *bio)
 		root = BTRFS_I(bvec->bv_page->mapping->host)->root;
 		ret = csum_dirty_buffer(root->fs_info, bvec->bv_page);
 		if (ret)
-			break;
+			goto out;
 	}
 
+out:
 	return errno_to_blk_status(ret);
 }