Re: [PATCH] xfs: shutdown on failure to add page to log bio

Christoph Hellwig
2020-03-25T11:41:56Z

On Wed, Mar 25, 2020 at 07:25:02AM -0400, Brian Foster wrote:
> diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> index 2a90a483c2d6..92a58a6bc32b 100644
> --- a/fs/xfs/xfs_log.c
> +++ b/fs/xfs/xfs_log.c
> @@ -1703,7 +1703,7 @@ xlog_bio_end_io(
> &iclog->ic_end_io_work);
> }
>
> -static void
> +static int
> xlog_map_iclog_data(
> struct bio *bio,
> void *data,
> @@ -1714,11 +1714,14 @@ xlog_map_iclog_data(
> unsigned int off = offset_in_page(data);
> size_t len = min_t(size_t, count, PAGE_SIZE - off);
>
> - WARN_ON_ONCE(bio_add_page(bio, page, len, off) != len);
> + if (bio_add_page(bio, page, len, off) != len)
> + break;

I'd just return -EIO here.

>
> data += len;
> count -= len;
> } while (count);
> +
> + return count;

And 0 here. Returning the remaining count obviously works as well,
but it feels a little unintuitive to me and would warrant a comment.