public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH] xfs: shutdown on failure to add page to log bio
Date: Wed, 25 Mar 2020 07:25:02 -0400	[thread overview]
Message-ID: <20200325112502.GB10922@bfoster> (raw)
In-Reply-To: <20200325071225.GA17629@infradead.org>

On Wed, Mar 25, 2020 at 12:12:25AM -0700, Christoph Hellwig wrote:
> On Tue, Mar 24, 2020 at 12:57:00PM -0400, Brian Foster wrote:
> > Rather than warn about writing out a corrupted log buffer, shutdown
> > the fs as is done for any log I/O related error. This preserves the
> > consistency of the physical log such that log recovery succeeds on a
> > subsequent mount. Note that this was observed on a 64k page debug
> > kernel without upstream commit 59bb47985c1d ("mm, sl[aou]b:
> > guarantee natural alignment for kmalloc(power-of-two)"), which
> > demonstrated frequent iclog bio overflows due to unaligned (slab
> > allocated) iclog data buffers.
> 
> Weird..
> 
> >  static void
> >  xlog_map_iclog_data(
> > -	struct bio		*bio,
> > -	void			*data,
> > +	struct xlog_in_core	*iclog,
> >  	size_t			count)
> >  {
> > +	struct xfs_mount	*mp = iclog->ic_log->l_mp;
> > +	struct bio		*bio = &iclog->ic_bio;
> > +	void			*data = iclog->ic_data;
> > +
> >  	do {
> >  		struct page	*page = kmem_to_page(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) {
> > +			xfs_force_shutdown(mp, SHUTDOWN_LOG_IO_ERROR);
> > +			break;
> > +		}
> >  
> >  		data += len;
> >  		count -= len;
> > @@ -1762,7 +1768,7 @@ xlog_write_iclog(
> >  	if (need_flush)
> >  		iclog->ic_bio.bi_opf |= REQ_PREFLUSH;
> >  
> > -	xlog_map_iclog_data(&iclog->ic_bio, iclog->ic_data, count);
> > +	xlog_map_iclog_data(iclog, count);
> 
> Can you just return an error from xlog_map_iclog_data and shut down
> in the caller?  Besides keeping the abstraction levels similar I had
> also hoped to lift xlog_map_iclog_data into the block layer eventually.
> 

Sure. That's probably more appropriate now that I look again because it
looks like we still submit the current bio with this patch. Something
like the following..?

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;
 
 		data += len;
 		count -= len;
 	} while (count);
+
+	return count;
 }
 
 STATIC void
@@ -1762,7 +1765,10 @@ xlog_write_iclog(
 	if (need_flush)
 		iclog->ic_bio.bi_opf |= REQ_PREFLUSH;
 
-	xlog_map_iclog_data(&iclog->ic_bio, iclog->ic_data, count);
+	if (xlog_map_iclog_data(&iclog->ic_bio, iclog->ic_data, count)) {
+		xfs_force_shutdown(log->l_mp, SHUTDOWN_LOG_IO_ERROR);
+		return;
+	}
 	if (is_vmalloc_addr(iclog->ic_data))
 		flush_kernel_vmap_range(iclog->ic_data, count);
 


  reply	other threads:[~2020-03-25 11:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-24 16:57 [PATCH] xfs: shutdown on failure to add page to log bio Brian Foster
2020-03-24 17:18 ` Darrick J. Wong
2020-03-24 17:29   ` Brian Foster
2020-03-24 20:34     ` Darrick J. Wong
2020-03-24 23:24 ` Dave Chinner
2020-03-25 11:24   ` Brian Foster
2020-03-25  7:12 ` Christoph Hellwig
2020-03-25 11:25   ` Brian Foster [this message]
2020-03-25 11:41     ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200325112502.GB10922@bfoster \
    --to=bfoster@redhat.com \
    --cc=hch@infradead.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox