All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Eric Sandeen <sandeen@redhat.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 6/7] xfs_db: write values into dir/attr blocks and recalculate CRCs
Date: Thu, 3 Aug 2017 09:40:45 -0700	[thread overview]
Message-ID: <20170803164045.GS4477@magnolia> (raw)
In-Reply-To: <b024574b-7cb4-c0d7-3c8c-d586b1d46c47@redhat.com>

On Thu, Aug 03, 2017 at 11:02:15AM -0500, Eric Sandeen wrote:
> On 7/31/17 4:07 PM, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Extend typ_t to (optionally) store a pointer to a function to calculate
> > the CRC of the block, provide functions to do this for the dir3 and
> > attr3 types, and then wire up the write command so that we can modify
> > directory and extended attribute block fields.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  db/attr.c  |   32 ++++++++++++++++++++++++++++++++
> >  db/attr.h  |    1 +
> >  db/dir2.c  |   37 +++++++++++++++++++++++++++++++++++++
> >  db/dir2.h  |    1 +
> >  db/type.c  |    8 ++++----
> >  db/type.h  |    2 ++
> >  db/write.c |    3 +++
> >  7 files changed, 80 insertions(+), 4 deletions(-)
> > 
> > 
> > diff --git a/db/attr.c b/db/attr.c
> > index 98fb069..2fa6690 100644
> > --- a/db/attr.c
> > +++ b/db/attr.c
> > @@ -602,6 +602,38 @@ const struct field	attr3_remote_crc_flds[] = {
> >  	{ NULL }
> >  };
> >  
> > +/* Set the CRC. */
> > +void
> > +xfs_attr3_set_crc(
> > +	struct xfs_buf		*bp)
> > +{
> > +	__be32			magic32;
> > +	__be16			magic16;
> > +
> > +	magic32 = *(__be32 *)bp->b_addr;
> > +	magic16 = ((struct xfs_da_blkinfo *)bp->b_addr)->magic;
> > +
> > +	switch (magic16) {
> > +	case cpu_to_be16(XFS_ATTR3_LEAF_MAGIC):
> 
> Isn't it more typical to endian-swap magic16 and not have the
> swap in each case statement?  *shrug*

cpu_to_be*() will do constant folding so we don't have to do any byte
swapping at run time.

(I doubt it matters much here, but a fair amount of xfs code follows
that paradigm...)

> > +		xfs_buf_update_cksum(bp, XFS_ATTR3_LEAF_CRC_OFF);
> > +		return;
> > +	case cpu_to_be16(XFS_DA3_NODE_MAGIC):
> > +		xfs_buf_update_cksum(bp, XFS_DA3_NODE_CRC_OFF);
> > +		return;
> > +	default:
> > +		break;
> > +	}
> 
> ...
> 
> >  
> > diff --git a/db/write.c b/db/write.c
> > index d24ea05..266bde4 100644
> > --- a/db/write.c
> > +++ b/db/write.c
> > @@ -173,6 +173,9 @@ write_f(
> >  	} else if (iocur_top->dquot_buf) {
> >  		local_ops.verify_write = xfs_verify_recalc_dquot_crc;
> >  		dbprintf(_("Allowing write of corrupted dquot with good CRC\n"));
> > +	} else if (iocur_top->typ->crc_off == TYP_F_CRC_FUNC) {
> > +		local_ops.verify_write = iocur_top->typ->set_crc;
> > +		dbprintf(_("Allowing write of corrupted data with good CRC\n"));
> >  	} else { /* invalid data */
> >  		local_ops.verify_write = xfs_verify_recalc_crc;
> >  		dbprintf(_("Allowing write of corrupted data with good CRC\n"));
> 
> looking at this else if else if else if gunk makes me think that this has
> grown a bit out of control.
> 
> We have other special types that require unique crc setting functions - dquots
> and inodes.  In those cases, we have TYP_F_NO_CRC_OFF but a special indicator
> that they are of this type (ino_buf, dquot_buf), with a hard-coded recalculation
> routine (xfs_verify_recalc_dquot_crc, xfs_verify_recalc_inode_crc).  Now for /other/
> types you've extended typ_t and put the function in there as an op, which makes
> sense.
> 
> It seems to me that it would be logical to move the existing crc recalculation
> routines for dquots & inodes into this new op as well, and locate & name everything
> consistently, no?

Yep.  New patch!

--D

> 
> Thanks,
> -Eric
> 
> 
> --
> 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

  reply	other threads:[~2017-08-03 16:40 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-31 21:06 [PATCH 0/7] xfsprogs: 4.13 rollup Darrick J. Wong
2017-07-31 21:06 ` [PATCH 1/7] xfs: remove double-underscore integer types Darrick J. Wong
2017-07-31 21:23   ` Eric Sandeen
2017-07-31 21:25     ` Darrick J. Wong
2017-08-02  9:13   ` Carlos Maiolino
2017-08-02 16:01     ` Darrick J. Wong
2017-07-31 21:07 ` [PATCH 2/7] xfs_repair: fix symlink target length checks by changing MAXPATHLEN to XFS_SYMLINK_MAXLEN Darrick J. Wong
2017-07-31 21:42   ` Eric Sandeen
2017-08-02  9:14   ` Carlos Maiolino
2017-07-31 21:07 ` [PATCH 3/7] xfs_db: fix metadump redirection (again) Darrick J. Wong
2017-07-31 21:57   ` Eric Sandeen
2017-08-01 16:23   ` [PATCH v2 " Darrick J. Wong
2017-08-02  9:17     ` Carlos Maiolino
2017-07-31 21:07 ` [PATCH 4/7] xfs_db: dump dir/attr btrees Darrick J. Wong
2017-07-31 22:05   ` Eric Sandeen
2017-08-01 14:59     ` Darrick J. Wong
2017-08-01 15:40   ` [PATCH v2 " Darrick J. Wong
2017-08-01 16:21     ` Eric Sandeen
2017-08-02  9:22     ` Carlos Maiolino
2017-08-02  9:24     ` Carlos Maiolino
2017-08-02 16:03       ` Darrick J. Wong
2017-07-31 21:07 ` [PATCH 5/7] xfs_db: print attribute remote value blocks Darrick J. Wong
2017-08-01 17:15   ` Eric Sandeen
2017-08-01 20:29     ` Darrick J. Wong
2017-08-01 21:04   ` [PATCH v2 " Darrick J. Wong
2017-08-02  9:36     ` Carlos Maiolino
2017-07-31 21:07 ` [PATCH 6/7] xfs_db: write values into dir/attr blocks and recalculate CRCs Darrick J. Wong
2017-08-02  9:40   ` Carlos Maiolino
2017-08-03 16:02   ` Eric Sandeen
2017-08-03 16:40     ` Darrick J. Wong [this message]
2017-07-31 21:07 ` [PATCH 7/7] xfs_db: introduce fuzz command Darrick J. Wong
2017-08-02 11:06   ` Carlos Maiolino
2017-08-03 16:47   ` [PATCH 8/7] xfs_db: use TYP_F_CRC_FUNC for inodes & dquots Eric Sandeen
2017-08-03 16:58     ` Darrick J. Wong
2017-08-03 17:15     ` [PATCH 8/7 V2] " Eric Sandeen
2017-08-03 18:05       ` Darrick J. Wong
2017-08-03 17:04 ` [PATCH 9/7] xfs_db: btdump should avoid eval for push and pop of cursor Darrick J. Wong
2017-08-03 17:18   ` Eric Sandeen

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=20170803164045.GS4477@magnolia \
    --to=darrick.wong@oracle.com \
    --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.