From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: sandeen@redhat.com, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/4] xfs_repair: implement custom ifork verifiers
Date: Tue, 20 Mar 2018 14:19:30 -0700 [thread overview]
Message-ID: <20180320211930.GI1757@magnolia> (raw)
In-Reply-To: <f8a05fc0-9d82-da7f-9ac7-9be2328cf2ef@sandeen.net>
On Tue, Mar 20, 2018 at 02:54:30PM -0500, Eric Sandeen wrote:
> On 3/19/18 10:08 PM, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> >
> > There are a few cases where an early stage of xfs_repair will write an
> > invalid inode fork buffer to signal to a later stage that it needs to
> > correct the value. This happens in phase 4 when we detect an inline
> > format directory with an invalid .. pointer. To avoid triggering the
> > ifork verifiers on this, inject a custom verifier for phase 6 that lets
> > this pass for now.
> >
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> > libxfs/libxfs_api_defs.h | 2 +
> > repair/phase6.c | 66 +++++++++++++++++++++++++++++++++++++++++++++-
> > 2 files changed, 67 insertions(+), 1 deletion(-)
> >
> >
> > diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h
> > index 5d56340..78daca0 100644
> > --- a/libxfs/libxfs_api_defs.h
> > +++ b/libxfs/libxfs_api_defs.h
> > @@ -150,5 +150,7 @@
> > #define xfs_rmap_lookup_le_range libxfs_rmap_lookup_le_range
> > #define xfs_refc_block libxfs_refc_block
> > #define xfs_rmap_compare libxfs_rmap_compare
> > +#define xfs_dir_get_ops libxfs_dir_get_ops
> > +#define xfs_default_ifork_ops libxfs_default_ifork_ops
> >
> > #endif /* __LIBXFS_API_DEFS_H__ */
> > diff --git a/repair/phase6.c b/repair/phase6.c
> > index aff83bc..e9189af 100644
> > --- a/repair/phase6.c
> > +++ b/repair/phase6.c
> > @@ -39,6 +39,70 @@ static struct xfs_name xfs_name_dot = {(unsigned char *)".",
> > XFS_DIR3_FT_DIR};
> >
> > /*
> > + * When we're checking directory inodes, we're allowed to set a directory's
>
> (a shortform directory only?)
I think we do it for any directory, but it's only the shortform dirs
that require this fix.
> > + * dotdot entry to zero to signal that the parent needs to be reconnected
> > + * during phase 6. The ifork verifiers would normally fail that, but we'll
> > + * accept this canary so that we can fix the dir.
>
> hm we actually just replace it temporarily, potato/potahto?
>
> > + */
> > +static xfs_failaddr_t
> > +phase6_verify_dir(
> > + struct xfs_inode *ip)
> > +{
> > + struct xfs_mount *mp = ip->i_mount;
> > + const struct xfs_dir_ops *dops;
> > + struct xfs_ifork *ifp;
> > + struct xfs_dir2_sf_hdr *sfp;
> > + xfs_failaddr_t fa;
> > + xfs_ino_t old_parent;
> > + bool parent_bypass = false;
> > + int size;
> > +
> > + dops = libxfs_dir_get_ops(mp, NULL);
> > +
> > + ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
> > + sfp = (struct xfs_dir2_sf_hdr *)ifp->if_u1.if_data;
> > + size = ifp->if_bytes;
> > +
> > + /* Don't let the NULLFSINO .. entry blow everything up. */
>
> NULLFSINO is ((xfs_ino_t)-1) not zero, so is this comment accurate?
Oops. :)
> Maybe an explicit comment here about this being for shortform dirs?
>
> /*
> * If this is a shortform directory, phase4 may have set the parent
> * inode to zero to indicate that it must be fixed. Temporarily
> * set a valid parent so that the directory verifier will pass.
> */
Much better comment, let's go with that.
> > + if (size > offsetof(struct xfs_dir2_sf_hdr, parent) &&
> > + size >= xfs_dir2_sf_hdr_size(sfp->i8count)) {
> > + old_parent = dops->sf_get_parent_ino(sfp);
> > + if (old_parent == 0) {
> > + dops->sf_put_parent_ino(sfp, mp->m_sb.sb_rootino);
> > + parent_bypass = true;
> > + }
> > + }
> > +
> > + fa = libxfs_default_ifork_ops.verify_dir(ip);
> > +
> > + /* Put it back. */
>
> /* Put the special parent == 0 back in place */
>
> > + if (parent_bypass)
> > + dops->sf_put_parent_ino(sfp, old_parent);
> > +
> > + return fa;
> > +}
> > +
> > +static xfs_failaddr_t
> > +phase6_verify_attr(
> > + struct xfs_inode *ip)
> > +{
> > + return libxfs_default_ifork_ops.verify_attr(ip);
> > +}
>
> Is there a reason for these wrappers vs. just populating the
> custom ifork_ops with xfs_attr_shortform_verify and
> xfs_symlink_shortform_verify?
gcc whines about non-const expressions. I tried adding const to
everything that touches an ifork_ops but it still wouldn't compile.
> > +
> > +static xfs_failaddr_t
> > +phase6_verify_symlink(
> > + struct xfs_inode *ip)
> > +{
> > + return libxfs_default_ifork_ops.verify_symlink(ip);
> > +}
> > +
> > +struct xfs_ifork_ops phase6_default_ifork_ops = {
>
> Naming a "custom" verifier "default" seems counterintuitive,
> is there a reason for the "default" semantics I'm missing? Not
> a huge deal, just makes me go "hmmm...."
-EBADNAME
phase6_ifork_ops, much better.
--D
> > + .verify_attr = phase6_verify_attr,
> > + .verify_dir = phase6_verify_dir,
> > + .verify_symlink = phase6_verify_symlink,
> > +};
> > +
> > +/*
> > * Data structures used to keep track of directories where the ".."
> > * entries are updated. These must be rebuilt after the initial pass
> > */
> > @@ -2833,7 +2897,7 @@ process_dir_inode(
> >
> > ASSERT(!is_inode_refchecked(irec, ino_offset) || dotdot_update);
> >
> > - error = -libxfs_iget(mp, NULL, ino, 0, &ip, NULL);
> > + error = -libxfs_iget(mp, NULL, ino, 0, &ip, &phase6_default_ifork_ops);
> > if (error) {
> > if (!no_modify)
> > do_error(
> >
> > --
> > 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
> >
> --
> 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
next prev parent reply other threads:[~2018-03-20 21:19 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-20 3:08 [PATCH 0/4] xfsprogs: more misc fixes Darrick J. Wong
2018-03-20 3:08 ` [PATCH 1/4] xfs_repair: implement custom ifork verifiers Darrick J. Wong
2018-03-20 19:54 ` Eric Sandeen
2018-03-20 21:19 ` Darrick J. Wong [this message]
2018-03-20 21:47 ` [PATCH v2 " Darrick J. Wong
2018-03-21 18:37 ` Eric Sandeen
2018-03-22 19:35 ` [PATCH 1.5/4] xfs_repair: use custom ifork verifier in mv_orphanage Eric Sandeen
2018-03-22 19:49 ` Darrick J. Wong
2018-03-20 3:08 ` [PATCH 2/4] libfrog: fs_table_lookup_mount should realpath the argument Darrick J. Wong
2018-03-20 19:55 ` Eric Sandeen
2018-03-20 3:08 ` [PATCH 3/4] xfs_fsr: refactor mountpoint finding to use libfrog paths functions Darrick J. Wong
2018-03-20 23:14 ` Darrick J. Wong
2018-03-21 3:19 ` [PATCH v2 " Darrick J. Wong
2018-03-21 18:49 ` Eric Sandeen
2018-03-20 3:08 ` [PATCH 4/4] mkfs: enable sparse inodes by default Darrick J. Wong
2018-03-20 21:16 ` Eric Sandeen
2018-03-21 3:19 ` [PATCH 5/4] misc: remove darwin, irix, and freebsd support Darrick J. Wong
2018-03-21 18:59 ` Eric Sandeen
2018-03-21 19:01 ` Eric Sandeen
2018-03-21 21:26 ` Dave Chinner
2018-03-21 21:31 ` Darrick J. Wong
2018-03-21 23:10 ` Dave Chinner
2018-03-21 19:42 ` [PATCH 5.5/4] " Eric Sandeen
2018-03-21 20:13 ` Darrick J. Wong
2018-03-21 3:20 ` [PATCH 6/4] libfrog: absorb platform specific code Darrick J. Wong
2018-03-21 19:52 ` Eric Sandeen
2018-03-26 19:56 ` [PATCH 7/4] xfs_spaceman: remove incorrect linux/fs.h include 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=20180320211930.GI1757@magnolia \
--to=darrick.wong@oracle.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@redhat.com \
--cc=sandeen@sandeen.net \
/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).