All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Andrey Albershteyn <aalbersh@redhat.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH] xfs_db: take BB cluster offset into account when using 'type' cmd
Date: Tue, 19 Apr 2022 08:47:50 -0700	[thread overview]
Message-ID: <20220419154750.GI17025@magnolia> (raw)
In-Reply-To: <20220419121951.50412-1-aalbersh@redhat.com>

On Tue, Apr 19, 2022 at 02:19:51PM +0200, Andrey Albershteyn wrote:
> Changing the interpretation type of data under the cursor moves the
> cursor to the beginning of BB cluster. When cursor is set to an
> inode the cursor is offset in BB buffer. However, this offset is not
> considered when type of the data is changed - the cursor points to
> the beginning of BB buffer. For example:
> 
> $ xfs_db -c "inode 131" -c "daddr" -c "type text" \
> 	-c "daddr" /dev/sdb1
> current daddr is 131
> current daddr is 128
> 
> Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
> ---
>  db/io.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/db/io.c b/db/io.c
> index df97ed91..107f2e11 100644
> --- a/db/io.c
> +++ b/db/io.c
> @@ -589,6 +589,7 @@ set_iocur_type(
>  	const typ_t	*type)
>  {
>  	int		bb_count = 1;	/* type's size in basic blocks */
> +	int boff = iocur_top->boff;

Nit: Please line up the variable names.

>  
>  	/*
>  	 * Inodes are special; verifier checks all inodes in the chunk, the
> @@ -613,6 +614,9 @@ set_iocur_type(
>  		bb_count = BTOBB(byteize(fsize(type->fields,
>  				       iocur_top->data, 0, 0)));
>  	set_cur(type, iocur_top->bb, bb_count, DB_RING_IGN, NULL);
> +	iocur_top->boff = boff;
> +	iocur_top->off = ((xfs_off_t)iocur_top->bb << BBSHIFT) + boff;
> +	iocur_top->data = (void *)((char *)iocur_top->buf + boff);

It seems reasonable to me to preserve the io cursor's boff when we're
setting /only/ the buffer type, but this function and off_cur() could
share these three lines of code that (re)set boff/off/data.

Alternately, I guess you could just call off_cur(boff, BBTOB(bb_count))
here.

--D

>  }
>  
>  static void
> -- 
> 2.27.0
> 

  reply	other threads:[~2022-04-19 15:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-19 12:19 [PATCH] xfs_db: take BB cluster offset into account when using 'type' cmd Andrey Albershteyn
2022-04-19 15:47 ` Darrick J. Wong [this message]
2022-04-19 16:56   ` Andrey Albershteyn
2022-04-19 17:10     ` 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=20220419154750.GI17025@magnolia \
    --to=djwong@kernel.org \
    --cc=aalbersh@redhat.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 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.