From: "Bill O'Donnell" <billodo@redhat.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH] xfs_repair: further improvement on secondary superblock search method
Date: Mon, 23 May 2016 10:27:15 -0500 [thread overview]
Message-ID: <20160523152715.GA27527@redhat.com> (raw)
In-Reply-To: <20160523145116.GE9319@infradead.org>
On Mon, May 23, 2016 at 07:51:16AM -0700, Christoph Hellwig wrote:
> On Thu, May 12, 2016 at 03:38:16PM -0500, Bill O'Donnell wrote:
> > +verify_sb_blocksize(xfs_sb_t *sb)
> > +{
> > + __uint32_t bsize;
> > + int i;
> > +
> > + /* check to make sure blocksize is legal 2^N, 9 <= N <= 16 */
> > + if (sb->sb_blocksize == 0)
> > + return(XR_BAD_BLOCKSIZE);
> > +
> > + bsize = 1;
> > +
> > + for (i = 0; bsize < sb->sb_blocksize &&
> > + i < sizeof(sb->sb_blocksize) * NBBY; i++)
> > + bsize <<= 1;
> > +
> > + if (i < XFS_MIN_BLOCKSIZE_LOG || i > XFS_MAX_BLOCKSIZE_LOG)
> > + return(XR_BAD_BLOCKSIZE);
> > +
> > + /* check sb blocksize field against sb blocklog field */
> > + if (i != sb->sb_blocklog)
> > + return(XR_BAD_BLOCKLOG);
>
> Couldn't we do this much simpler?
>
> if (sb->sb_blocksize == 0)
> return XR_BAD_BLOCKSIZE;
> if (sb->sb_blocksize != (1 << sb->sb_blocklog))
> return XR_BAD_BLOCKLOG;
> if (sb->sb_blocklog < XFS_MIN_BLOCKSIZE_LOG ||
> sb->sb_blocklog > XFS_MAX_BLOCKSIZE_LOG)
> return XR_BAD_BLOCKLOG;
Makes sense, yes.
>
> > /*
> > + * Attempt to find secondary sb with a coarse approach,
> > + * first trying agblocks and blocksize read from sb, providing
> > + * they're sane.
> > */
> > + if (verify_sb_blocksize(rsb) == 0) {
> > + skip = rsb->sb_agblocks * rsb->sb_blocksize;
> > + if ((skip >= XFS_AG_MIN_BYTES) && (skip <= XFS_AG_MAX_BYTES))
>
> no need for the inner braces here.
Check.
Thanks for the review!
-Bill
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2016-05-23 15:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-12 20:38 [PATCH] xfs_repair: further improvement on secondary superblock search method Bill O'Donnell
2016-05-23 14:51 ` Christoph Hellwig
2016-05-23 15:27 ` Bill O'Donnell [this message]
2016-05-30 5:37 ` Dave Chinner
2016-05-30 22:06 ` Eric Sandeen
2016-05-31 12:12 ` Bill O'Donnell
2016-05-31 12:10 ` Bill O'Donnell
2016-05-31 17:37 ` [PATCH V2] " Bill O'Donnell
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=20160523152715.GA27527@redhat.com \
--to=billodo@redhat.com \
--cc=hch@infradead.org \
--cc=xfs@oss.sgi.com \
/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