From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [bug report] xfs: scrub directory freespace
Date: Mon, 6 Nov 2017 11:34:47 -0800 [thread overview]
Message-ID: <20171106193447.GA6244@magnolia> (raw)
In-Reply-To: <20171104075457.izv6ylypgjwhf6uy@mwanda>
On Sat, Nov 04, 2017 at 10:54:57AM +0300, Dan Carpenter wrote:
> Hello Darrick J. Wong,
>
> The patch df481968f33b: "xfs: scrub directory freespace" from Oct 17,
> 2017, leads to the following static checker warning:
>
> fs/xfs/scrub/dir.c:446 xfs_scrub_directory_check_freesp()
> info: ignoring unreachable code.
>
> fs/xfs/scrub/dir.c
> 431 STATIC void
> 432 xfs_scrub_directory_check_freesp(
> 433 struct xfs_scrub_context *sc,
> 434 xfs_dablk_t lblk,
> 435 struct xfs_buf *dbp,
> 436 unsigned int len)
> 437 {
> 438 struct xfs_dir2_data_free *bf;
> 439 struct xfs_dir2_data_free *dfp;
> 440 int offset;
> 441
> 442 if (len == 0)
> 443 return;
> 444
> 445 bf = sc->ip->d_ops->data_bestfree_p(dbp->b_addr);
> 446 for (dfp = &bf[0]; dfp < &bf[XFS_DIR2_DATA_FD_COUNT]; dfp++) {
> ^^^^^
> This looks like a loop
>
> 447 offset = be16_to_cpu(dfp->offset);
> 448 if (offset == 0)
> 449 break;
> 450 if (len == be16_to_cpu(dfp->length))
> 451 return;
> 452 /* Didn't find the best length in the bestfree data */
> 453 break;
> ^^^^^^
> but we always either break or return on the first iteration. What's
> going on?
I think this is a broken refactoring of the bestfree checker --
previously we'd examine every slot in a directory's bestfree data block,
read the corresponding directory data block, and check that the slot
matches any of the data block's bestfree entries. Then Dave pointed out
that the slot must match the /first/ entry in the dir data block, so we
only need to examine bf[0], and this loop can be unrolled.
Thanks for catching this!
--D
> 454 }
> 455
> 456 xfs_scrub_fblock_set_corrupt(sc, XFS_DATA_FORK, lblk);
> 457 }
>
> regards,
> dan carpenter
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2017-11-06 19:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-04 7:54 [bug report] xfs: scrub directory freespace Dan Carpenter
2017-11-06 19:34 ` Darrick J. Wong [this message]
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=20171106193447.GA6244@magnolia \
--to=darrick.wong@oracle.com \
--cc=dan.carpenter@oracle.com \
--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