From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: Eric Sandeen <sandeen@redhat.com>, xfs <linux-xfs@vger.kernel.org>
Subject: Re: [PATCH] xfs_repair: fix totally broken unit conversion in directory invalidation
Date: Tue, 24 Dec 2019 08:52:14 -0800 [thread overview]
Message-ID: <20191224165214.GA7489@magnolia> (raw)
In-Reply-To: <20191224083843.GA1739@infradead.org>
On Tue, Dec 24, 2019 at 12:38:43AM -0800, Christoph Hellwig wrote:
> On Tue, Dec 17, 2019 at 08:24:02PM -0800, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> >
> > Your humble author forgot that xfs_dablk_t has the same units as
> > xfs_fileoff_t, and totally screwed up the directory buffer invalidation
> > loop in dir_binval. Not only is there an off-by-one error in the loop
> > conditional, but the unit conversions are wrong.
>
> Can we kill off xfs_dablk_t? I found the concept very, very confusing
> when touching the dir code.
I personally wouldn't mind if that happened (as a separate patch).
> > --- a/libxfs/xfs_dir2.h
> > +++ b/libxfs/xfs_dir2.h
> > @@ -308,6 +308,16 @@ xfs_dir2_leaf_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_leaf *lp)
> > sizeof(struct xfs_dir2_leaf_tail));
> > }
> >
> > +/*
> > + * For a given dir/attr geometry and extent mapping record, walk every file
> > + * offset block (xfs_dablk_t) in the mapping that corresponds to the start
> > + * of a logical directory block (xfs_dir2_db_t).
> > + */
> > +#define for_each_xfs_bmap_dabno(geo, irec, dabno) \
> > + for ((dabno) = round_up((irec)->br_startoff, (geo)->fsbcount); \
> > + (dabno) < (irec)->br_startoff + (irec)->br_blockcount; \
> > + (dabno) += (geo)->fsbcount)
>
> I think not having the magic for macro would be cleaner..
Eh, yeah, we don't really need it...
--D
>
> > + xfs_dablk_t dabno;
> > int error = 0;
> >
> > if (ip->i_d.di_format != XFS_DINODE_FMT_EXTENTS &&
> > @@ -1286,11 +1286,7 @@ dir_binval(
> > geo = tp->t_mountp->m_dir_geo;
> > ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
> > for_each_xfs_iext(ifp, &icur, &rec) {
> > - dabno = xfs_dir2_db_to_da(geo, rec.br_startoff +
> > - geo->fsbcount - 1);
> > - end_dabno = xfs_dir2_db_to_da(geo, rec.br_startoff +
> > - rec.br_blockcount);
> > - for (; dabno <= end_dabno; dabno += geo->fsbcount) {
> > + for_each_xfs_bmap_dabno(geo, &rec, dabno) {
> > bp = NULL;
> > error = -libxfs_da_get_buf(tp, ip, dabno, -2, &bp,
> > whichfork);
>
> But either way, the fix looks good.
prev parent reply other threads:[~2019-12-24 16:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-18 4:24 [PATCH] xfs_repair: fix totally broken unit conversion in directory invalidation Darrick J. Wong
2019-12-18 4:26 ` Darrick J. Wong
2019-12-24 8:38 ` Christoph Hellwig
2019-12-24 16:52 ` 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=20191224165214.GA7489@magnolia \
--to=darrick.wong@oracle.com \
--cc=hch@infradead.org \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.