On Fri, Jan 25, 2019 at 01:09:17PM +0800, Qu Wenruo wrote:
> We have a BUG_ON() in flush_write_bio() to handle the return value of
> submit_one_bio().
> 
> Move the BUG_ON() one level up to all its callers.
> 
> No functional change, just to make later BUG_ON() cleanup more obvious.
> 
> Signed-off-by: Qu Wenruo <w...@suse.com>
> ---
>  fs/btrfs/extent_io.c | 48 +++++++++++++++++++++++++++++++-------------
>  1 file changed, 34 insertions(+), 14 deletions(-)
> 
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index 8a2335713a2d..6f1982f8ad5c 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -169,15 +169,21 @@ static int __must_check submit_one_bio(struct bio *bio, 
> int mirror_num,
>       return blk_status_to_errno(ret);
>  }
>  
> -static void flush_write_bio(struct extent_page_data *epd)
> +/*
> + * A wrapper for submit_one_bio().
> + *
> + * Return 0 if everything is OK.
> + * Return <0 for error.
> + */
> +static int __must_check flush_write_bio(struct extent_page_data *epd)
>  {
> -     if (epd->bio) {
> -             int ret;
> +     int ret = 0;
>  
> +     if (epd->bio) {
>               ret = submit_one_bio(epd->bio, 0, 0);
> -             BUG_ON(ret < 0); /* -ENOMEM */
>               epd->bio = NULL;
>       }
> +     return ret;

Moving the BUG_ON one leve up is ok. I checked the callees of
submit_one_bio and it looks like the return value of btrfsic_submit_bio
is somehow missing. It should at least propagate return value of
submit_bio. This is is for another patchset though.

Reply via email to