linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/3] xfs: add a xfs_valid_startblock helper
Date: Sun, 1 Sep 2019 13:31:40 -0700	[thread overview]
Message-ID: <20190901203140.GP5354@magnolia> (raw)
In-Reply-To: <20190901073634.GA11777@lst.de>

On Sun, Sep 01, 2019 at 09:36:34AM +0200, Christoph Hellwig wrote:
> On Fri, Aug 30, 2019 at 05:32:53PM +0200, Christoph Hellwig wrote:
> > On Fri, Aug 30, 2019 at 08:06:50AM -0700, Darrick J. Wong wrote:
> > > > --- a/fs/xfs/libxfs/xfs_bmap.h
> > > > +++ b/fs/xfs/libxfs/xfs_bmap.h
> > > > @@ -171,6 +171,9 @@ static inline bool xfs_bmap_is_real_extent(struct xfs_bmbt_irec *irec)
> > > >  		!isnullstartblock(irec->br_startblock);
> > > >  }
> > > >  
> > > > +#define xfs_valid_startblock(ip, startblock) \
> > > > +	((startblock) != 0 || XFS_IS_REALTIME_INODE(ip))
> > > 
> > > We have more robust validators for data/rtdev fsblock_t, so why not:
> > > 
> > > #define xfs_valid_startblock(ip, startblock) \
> > > 	(XFS_IS_REALTIME_INODE(ip) ? xfs_verify_rtbno(startblock) : \
> > > 				     xfs_verify_fsbno(startblock))
> > > 
> > > and why not make it a static inline function too?
> > 
> > I tried an inline function, but I could not find a header to place
> > it that would actually easily compile everywhere...  Maybe we should
> > just make that a xfs_verify_bno(mp, startblock) and move that out of
> > line such in a way that a smart compiler avoids the function call
> > overhead for xfs_verify_rtbno / xfs_verify_fsbno.  I'll take another
> > stab at this.
> 
> So I looked into your suggestion, but xfs_verify_rtbno / xfs_verify_fsbno
> do a lot of validity checking, but they don't actually contain the
> check that was in the existing code.  The bmap code just checks that
> there is a startblock of 0 for non-rt devices, probably this was added
> to find some old bug where a irec structure that was zeroed was returned.
> 
> So replacing it with xfs_verify_rtbno / xfs_verify_fsbno would not help
> in any way.  But the big question is if keeping the 0 check is even
> worth it.

It's been mildly helpful for noticing when my online/offline repair
prototype code totally screws up, but at that point so much magic smoke
is already pouring out everywhere that it's hard not to notice. :)

--D

  reply	other threads:[~2019-09-01 20:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-30 10:24 misc cleanups Christoph Hellwig
2019-08-30 10:24 ` [PATCH 1/3] xfs: add a xfs_valid_startblock helper Christoph Hellwig
2019-08-30 15:06   ` Darrick J. Wong
2019-08-30 15:32     ` Christoph Hellwig
2019-09-01  7:36       ` Christoph Hellwig
2019-09-01 20:31         ` Darrick J. Wong [this message]
2019-09-02  7:59           ` Christoph Hellwig
2019-09-02 17:04             ` Darrick J. Wong
2019-09-02 17:07               ` Christoph Hellwig
2019-08-30 10:24 ` [PATCH 2/3] xfs: cleanup xfs_fsb_to_db Christoph Hellwig
2019-08-30 15:07   ` Darrick J. Wong
2019-08-30 10:24 ` [PATCH 3/3] xfs: remove the unused XFS_ALLOC_USERDATA flag Christoph Hellwig
2019-08-30 15:08   ` 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=20190901203140.GP5354@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=hch@lst.de \
    --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;
as well as URLs for NNTP newsgroup(s).