Re: [PATCH 2/2] xfs: convert open coded corruption check to use XFS_IS_CORRUPT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Nov 10, 2019 at 01:49:19PM +1100, Dave Chinner wrote:
> On Sat, Nov 09, 2019 at 04:18:03PM -0800, Darrick J. Wong wrote:
> > On Sun, Nov 10, 2019 at 09:32:38AM +1100, Dave Chinner wrote:
> > > On Thu, Nov 07, 2019 at 11:05:21PM -0800, Darrick J. Wong wrote:
> > > > From: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
> > > > -		if (unlikely(
> > > > -		       be32_to_cpu(sib_info->back) != last_blkno ||
> > > > -		       sib_info->magic != dead_info->magic)) {
> > > > -			XFS_ERROR_REPORT("xfs_da_swap_lastblock(3)",
> > > > -					 XFS_ERRLEVEL_LOW, mp);
> > > > +		if (XFS_IS_CORRUPT(mp,
> > > > +		    be32_to_cpu(sib_info->back) != last_blkno ||
> > > > +		    sib_info->magic != dead_info->magic)) {
> > 
> > They're both ugly, IMHO.  One has horrible indentation that's too close
> > to the code in the if statement body, the other is hard to read as an if
> > statement.
> 
> I was more commenting on the new code. The old code is horrible,
> yes, but I don't think the new code is much better. :(
> 
> > > >  			error = -EFSCORRUPTED;
> > > >  			goto done;
> > > >  		}
> > > 
> > > This is kind of what I mean - is it two or three  logic statments
> > > here? No, it's actually one, but it has two nested checks...
> > > 
> > > There's a few other list this that are somewhat non-obvious as to
> > > the logic...
> > 
> > I'd thought about giving it the shortest name possible, not bothering to
> > log the fsname that goes with the error report, and making the if part
> > of the macro:
> > 
> > #define IFBAD(cond) if ((unlikely(cond) ? assert(...), true : false))
> > 
> > IFBAD(be32_to_cpu(sib_info->back) != last_blkno ||
> >       sib_info->magic != dead_info->magic)) {
> > 	xfs_whatever();
> > 	return -EFSCORRUPTED;
> > }
> > 
> > Is that better?
> 
> Look at what quoting did to it - it'll look the same as above in
> patches, unfortunately, so I don't think "short as possible" works
> any better.
> 
> Perhaps s/IFBAD/XFS_CORRUPT_IF/ ?
> 
> 		XFS_CORRUPT_IF(be32_to_cpu(sib_info->back) != last_blkno ||
> 				sib_info->magic != dead_info->magic)) {
> 			xfs_error(mp, "user readable error message");
> 			return -EFSCORRUPTED;
> 		}
> 
> That solves the patch/quote indent problem, documents the code well,
> and only sacrifices a single tab for the condition statements...

...but that's one character short of two full tabs, and I dislike typing
<tab><space><space><space><space><space><space><space> and having the
alignment be off by a single column.

> /me gets back on his bike and leaves the shed coated in wet paint.

/me takes out his paint sprayer and drowns everything in paint.

XCORRUPT_WHEN(
IF_XFS_CORRUPT(
XFS_CORRUPT_LOG(
LOG_XFS_CORRUPT(
IF_XFSCORRUPTED(
XFS_CORRUPT_IFF(
if_meta_corrupt(
if_xfs_meta_bad(moo,
		whatever) {
	grumble();
}

Ok, I'll change the whole thing to if_xfs_meta_bad(test) and hopes this
is the end of bikeshedding because changing this series is a pita.

--D

> Cheers,
> 
> Dave.
> -- 
> Dave Chinner
> david@xxxxxxxxxxxxx



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux