On Wed, Mar 20, 2019 at 02:27:41PM +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. > > This patch will introduce temporary variable, @flush_ret to keep code > change minimal in this patch. That variable will be cleaned up when > enhancing the error handling later. > > Signed-off-by: Qu Wenruo <w...@suse.com> > Reviewed-by: Johannes Thumshirn <jthumsh...@suse.de> > --- > fs/btrfs/extent_io.c | 55 +++++++++++++++++++++++++++++++++----------- > 1 file changed, 41 insertions(+), 14 deletions(-) > > diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c > index ca8b8e785cf3..58bf6ae29319 100644 > --- a/fs/btrfs/extent_io.c > +++ b/fs/btrfs/extent_io.c > @@ -170,15 +170,28 @@ 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().
Such comments are not very useful, changed to "Submit bio from extent page data via 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 */ > + /* > + * Clean up of epd->bio is handled by its endio function. > + * And endio is either triggered by successful bio execution > + * or the error handler of submit bio hook. > + * So at this point, no matter what happened, we don't need > + * to clean up epd->bio. > + */ That one is great.