Linux XFS filesystem development
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: Eric Sandeen <sandeen@redhat.com>, linux-xfs <linux-xfs@vger.kernel.org>
Subject: Re: [PATCH] xfs: log proper length of superblock
Date: Tue, 24 Sep 2019 08:34:53 +1000	[thread overview]
Message-ID: <20190923223453.GD16973@dread.disaster.area> (raw)
In-Reply-To: <16c64c69-adbb-d9ec-7630-05cd44286744@sandeen.net>

On Mon, Sep 23, 2019 at 04:44:14PM -0500, Eric Sandeen wrote:
> On 9/23/19 4:18 PM, Eric Sandeen wrote:
> > xfs_trans_log_buf takes first byte, last byte as args.  In this
> > case, it should be from 0 to sizeof() - 1.
> > 
> > Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Well spotted!

> if you want, you could put a 
> 
> Fixes: 4d11a40239405 ("xfs: remove bitfield based superblock updates")
> 
> on this, I guess it was technically a regression in v4.0, even
> if it has no net effect like last time...

Yeah, it doesn't expose any issue at all. The buffer logging rounds
out to CHUNK_SIZE - 128 bytes - and when we look at the size of the
superblock w/ pahole:

struct xfs_dsb {
        __be32                     sb_magicnum;          /*     0     4 */
	__be32                     sb_blocksize;         /*     4     4 */
....
        uuid_t                     sb_meta_uuid;         /*   248    16 */

        /* size: 264, cachelines: 5, members: 55 */
        /* last cacheline: 8 bytes */
};

Well be logging the first three chunks in the sb regardless of
whether we pass 263 or 264 as the size of the modified area to
xfs_trans_log_buf() (i.e. first 384 bytes of the buffer get logged
either way).

So, yeah, the code is wrong, but it does not result in any
observable incorrect behaviour. That said, it still needs fixing.

> -Eric
> 
> > ---
> > 
> > I should have audited everything when I sent the last patch for
> > this type of error.  hch suggested changing the interface but it's
> > all pretty grotty and I'm hesitant for now.
> > 
> > I think maybe a new/separate function to take start, len might
> > make sense so that not every caller needs to be munged into a new
> > format, because some of the existing callers would then become more
> > complex...
> > 
> > diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
> > index a08dd8f40346..ac6cdca63e15 100644
> > --- a/fs/xfs/libxfs/xfs_sb.c
> > +++ b/fs/xfs/libxfs/xfs_sb.c
> > @@ -928,7 +928,7 @@ xfs_log_sb(
> >  
> >  	xfs_sb_to_disk(XFS_BUF_TO_SBP(bp), &mp->m_sb);
> >  	xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF);
> > -	xfs_trans_log_buf(tp, bp, 0, sizeof(struct xfs_dsb));
> > +	xfs_trans_log_buf(tp, bp, 0, sizeof(struct xfs_dsb) - 1);
> >  }
> >  
> >  /*

Looks good.

Reviewed-by: Dave Chinner <dchinner@redhat.com>

-Dave.
-- 
Dave Chinner
david@fromorbit.com

  reply	other threads:[~2019-09-23 22:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-23 21:18 [PATCH] xfs: log proper length of superblock Eric Sandeen
2019-09-23 21:44 ` Eric Sandeen
2019-09-23 22:34   ` Dave Chinner [this message]
2019-09-23 23:48 ` Darrick J. Wong

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=20190923223453.GD16973@dread.disaster.area \
    --to=david@fromorbit.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@redhat.com \
    --cc=sandeen@sandeen.net \
    /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