public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Zorro Lang <zlang@redhat.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH v2] xfs_db: use correct inode to set inode type
Date: Fri, 14 Aug 2020 12:53:35 +0800	[thread overview]
Message-ID: <20200814045335.GR2937@dhcp-12-102.nay.redhat.com> (raw)
In-Reply-To: <647f04d7-1a71-2dd0-fc8b-98e3f65afd9f@sandeen.net>

On Thu, Aug 13, 2020 at 03:49:42PM -0500, Eric Sandeen wrote:
> On 8/13/20 10:30 AM, Zorro Lang wrote:
> > A test fails as:
> >   # xfs_db -c "inode 133" -c "addr" -c "p core.size" -c "type inode" -c "addr" -c "p core.size" /dev/sdb1
> >   current
> >           byte offset 68096, length 512
> >           buffer block 128 (fsbno 16), 32 bbs
> >           inode 133, dir inode -1, type inode
> >   core.size = 123142
> >   current
> >           byte offset 65536, length 512
> >           buffer block 128 (fsbno 16), 32 bbs
> >           inode 128, dir inode 128, type inode
> >   core.size = 42
> > 
> > The "type inode" command accidentally moves the io cursor because it
> > forgets to include the io cursor's buffer offset when it computes the
> > inode number from the io cursor's location.
> > 
> > Fixes: 533d1d229a88 ("xfs_db: properly set inode type")
> > 
> > Reported-by: Jianhong Yin <jiyin@redhat.com>
> > Signed-off-by: Zorro Lang <zlang@redhat.com>
> 
> This looks good to me, I'll test it.  And I think I have a cleanup
> to the whole function, after this fix...

Sure, the buffer verification code is added by:

  9ba69ce2 ("db: verify buffer on type change")

But later we turn to use set_cur() in set_iocur_type(), which looks do
buffer verification too.

Thanks,
Zorro

> 
> Reviewed-by: Eric Sandeen <sandeen@redhat.com>
> 
> > ---
> > 
> > V2 did below changes:
> > 0) git commit log is changed.
> > 1) Separate out several clear steps to calculate inode.
> > 2) Remove improper comment which describe inode calculation.
> > 
> > Thanks,
> > Zorro
> > 
> >  db/io.c | 18 ++++++++++--------
> >  1 file changed, 10 insertions(+), 8 deletions(-)
> > 
> > diff --git a/db/io.c b/db/io.c
> > index 6628d061..884da599 100644
> > --- a/db/io.c
> > +++ b/db/io.c
> > @@ -588,18 +588,20 @@ set_iocur_type(
> >  {
> >  	struct xfs_buf	*bp = iocur_top->bp;
> >  
> > -	/* Inodes are special; verifier checks all inodes in the chunk */
> > +	/*
> > +	 * Inodes are special; verifier checks all inodes in the chunk, the
> > +	 * set_cur_inode() will help that
> > +	 */
> >  	if (type->typnm == TYP_INODE) {
> >  		xfs_daddr_t	b = iocur_top->bb;
> > +		xfs_agblock_t	agbno;
> > +		xfs_agino_t	agino;
> >  		xfs_ino_t	ino;
> >  
> > -		/*
> > -		 * Note that this will back up to the beginning of the inode
> > - 		 * which contains the current disk location; daddr may change.
> > - 		 */
> > -		ino = XFS_AGINO_TO_INO(mp, xfs_daddr_to_agno(mp, b),
> > -			((b << BBSHIFT) >> mp->m_sb.sb_inodelog) %
> > -			XFS_AGB_TO_AGINO(mp, mp->m_sb.sb_agblocks));
> > +		agbno = xfs_daddr_to_agbno(mp, b);
> > +		agino = XFS_OFFBNO_TO_AGINO(mp, agbno,
> > +				iocur_top->boff / mp->m_sb.sb_inodesize);
> > +		ino = XFS_AGINO_TO_INO(mp, xfs_daddr_to_agno(mp, b), agino);
> >  		set_cur_inode(ino);
> >  		return;
> >  	}
> > 
> 


      reply	other threads:[~2020-08-14  4:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-13 17:30 [PATCH v2] xfs_db: use correct inode to set inode type Zorro Lang
2020-08-13 20:49 ` Eric Sandeen
2020-08-14  4:53   ` Zorro Lang [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=20200814045335.GR2937@dhcp-12-102.nay.redhat.com \
    --to=zlang@redhat.com \
    --cc=linux-xfs@vger.kernel.org \
    --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