public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs_db: don't hardcode 'type data' size at 512b
@ 2024-01-23  4:10 ` Darrick J. Wong
  2024-01-23  4:15   ` Christoph Hellwig
                     ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Darrick J. Wong @ 2024-01-23  4:10 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: cem, linux-xfs

From: Darrick J. Wong <djwong@kernel.org>

On a disk with 4096-byte LBAs, the xfs_db 'type data' subcommand doesn't
work:

# xfs_io -c 'sb' -c 'type data' /dev/sda
xfs_db: read failed: Invalid argument
no current object

The cause of this is the hardcoded initialization of bb_count when we're
setting type data -- it should be the filesystem sector size, not just 1.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 db/block.c |    7 ++++---
 db/io.c    |    3 ++-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/db/block.c b/db/block.c
index f234fcb4edcb..c847a91dd22f 100644
--- a/db/block.c
+++ b/db/block.c
@@ -149,6 +149,7 @@ daddr_f(
 	int64_t		d;
 	char		*p;
 	int		c;
+	int		bb_count = BTOBB(mp->m_sb.sb_sectsize);
 	xfs_rfsblock_t	max_daddrs = mp->m_sb.sb_dblocks;
 	enum daddr_target tgt = DT_DATA;
 
@@ -202,13 +203,13 @@ daddr_f(
 	ASSERT(typtab[TYP_DATA].typnm == TYP_DATA);
 	switch (tgt) {
 	case DT_DATA:
-		set_cur(&typtab[TYP_DATA], d, 1, DB_RING_ADD, NULL);
+		set_cur(&typtab[TYP_DATA], d, bb_count, DB_RING_ADD, NULL);
 		break;
 	case DT_RT:
-		set_rt_cur(&typtab[TYP_DATA], d, 1, DB_RING_ADD, NULL);
+		set_rt_cur(&typtab[TYP_DATA], d, bb_count, DB_RING_ADD, NULL);
 		break;
 	case DT_LOG:
-		set_log_cur(&typtab[TYP_DATA], d, 1, DB_RING_ADD, NULL);
+		set_log_cur(&typtab[TYP_DATA], d, bb_count, DB_RING_ADD, NULL);
 		break;
 	}
 	return 0;
diff --git a/db/io.c b/db/io.c
index 580d34015868..3841c0dcb86e 100644
--- a/db/io.c
+++ b/db/io.c
@@ -681,7 +681,8 @@ void
 set_iocur_type(
 	const typ_t	*type)
 {
-	int		bb_count = 1;	/* type's size in basic blocks */
+	/* type's size in basic blocks */
+	int		bb_count = BTOBB(mp->m_sb.sb_sectsize);
 	int		boff = iocur_top->boff;
 
 	/*

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] xfs_db: don't hardcode 'type data' size at 512b
  2024-01-23  4:10 ` [PATCH] xfs_db: don't hardcode 'type data' size at 512b Darrick J. Wong
@ 2024-01-23  4:15   ` Christoph Hellwig
  2024-01-23 10:38   ` Carlos Maiolino
  2024-02-22 22:04   ` [PATCH v2] " Darrick J. Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2024-01-23  4:15 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Christoph Hellwig, cem, linux-xfs

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] xfs_db: don't hardcode 'type data' size at 512b
  2024-01-23  4:10 ` [PATCH] xfs_db: don't hardcode 'type data' size at 512b Darrick J. Wong
  2024-01-23  4:15   ` Christoph Hellwig
@ 2024-01-23 10:38   ` Carlos Maiolino
  2024-02-22 22:04   ` [PATCH v2] " Darrick J. Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Carlos Maiolino @ 2024-01-23 10:38 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Christoph Hellwig, linux-xfs

On Mon, Jan 22, 2024 at 08:10:44PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> On a disk with 4096-byte LBAs, the xfs_db 'type data' subcommand doesn't
> work:
> 
> # xfs_io -c 'sb' -c 'type data' /dev/sda
> xfs_db: read failed: Invalid argument
> no current object
> 
> The cause of this is the hardcoded initialization of bb_count when we're
> setting type data -- it should be the filesystem sector size, not just 1.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>

Looks good:
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>

> ---
>  db/block.c |    7 ++++---
>  db/io.c    |    3 ++-
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/db/block.c b/db/block.c
> index f234fcb4edcb..c847a91dd22f 100644
> --- a/db/block.c
> +++ b/db/block.c
> @@ -149,6 +149,7 @@ daddr_f(
>  	int64_t		d;
>  	char		*p;
>  	int		c;
> +	int		bb_count = BTOBB(mp->m_sb.sb_sectsize);
>  	xfs_rfsblock_t	max_daddrs = mp->m_sb.sb_dblocks;
>  	enum daddr_target tgt = DT_DATA;
> 
> @@ -202,13 +203,13 @@ daddr_f(
>  	ASSERT(typtab[TYP_DATA].typnm == TYP_DATA);
>  	switch (tgt) {
>  	case DT_DATA:
> -		set_cur(&typtab[TYP_DATA], d, 1, DB_RING_ADD, NULL);
> +		set_cur(&typtab[TYP_DATA], d, bb_count, DB_RING_ADD, NULL);
>  		break;
>  	case DT_RT:
> -		set_rt_cur(&typtab[TYP_DATA], d, 1, DB_RING_ADD, NULL);
> +		set_rt_cur(&typtab[TYP_DATA], d, bb_count, DB_RING_ADD, NULL);
>  		break;
>  	case DT_LOG:
> -		set_log_cur(&typtab[TYP_DATA], d, 1, DB_RING_ADD, NULL);
> +		set_log_cur(&typtab[TYP_DATA], d, bb_count, DB_RING_ADD, NULL);
>  		break;
>  	}
>  	return 0;
> diff --git a/db/io.c b/db/io.c
> index 580d34015868..3841c0dcb86e 100644
> --- a/db/io.c
> +++ b/db/io.c
> @@ -681,7 +681,8 @@ void
>  set_iocur_type(
>  	const typ_t	*type)
>  {
> -	int		bb_count = 1;	/* type's size in basic blocks */
> +	/* type's size in basic blocks */
> +	int		bb_count = BTOBB(mp->m_sb.sb_sectsize);
>  	int		boff = iocur_top->boff;
> 
>  	/*
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] xfs_db: don't hardcode 'type data' size at 512b
  2024-01-23  4:10 ` [PATCH] xfs_db: don't hardcode 'type data' size at 512b Darrick J. Wong
  2024-01-23  4:15   ` Christoph Hellwig
  2024-01-23 10:38   ` Carlos Maiolino
@ 2024-02-22 22:04   ` Darrick J. Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Darrick J. Wong @ 2024-02-22 22:04 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: cem, linux-xfs

From: Darrick J. Wong <djwong@kernel.org>

On a disk with 4096-byte LBAs, the xfs_db 'type data' subcommand doesn't
work:

# xfs_io -c 'sb' -c 'type data' /dev/sda
xfs_db: read failed: Invalid argument
no current object

The cause of this is the hardcoded initialization of bb_count when we're
setting type data -- it should be the filesystem sector size, not just 1.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
---
v2: rebase to for-next
---
 db/block.c |    3 ++-
 db/io.c    |    3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/db/block.c b/db/block.c
index d730c7796710..22930e5a287e 100644
--- a/db/block.c
+++ b/db/block.c
@@ -124,6 +124,7 @@ daddr_f(
 {
 	int64_t		d;
 	char		*p;
+	int		bb_count = BTOBB(mp->m_sb.sb_sectsize);
 
 	if (argc == 1) {
 		xfs_daddr_t	daddr = iocur_top->off >> BBSHIFT;
@@ -144,7 +145,7 @@ daddr_f(
 		return 0;
 	}
 	ASSERT(typtab[TYP_DATA].typnm == TYP_DATA);
-	set_cur(&typtab[TYP_DATA], d, 1, DB_RING_ADD, NULL);
+	set_cur(&typtab[TYP_DATA], d, bb_count, DB_RING_ADD, NULL);
 	return 0;
 }
 
diff --git a/db/io.c b/db/io.c
index 590dd1f82f7b..9b2c6b4cf7e9 100644
--- a/db/io.c
+++ b/db/io.c
@@ -652,7 +652,8 @@ void
 set_iocur_type(
 	const typ_t	*type)
 {
-	int		bb_count = 1;	/* type's size in basic blocks */
+	/* type's size in basic blocks */
+	int		bb_count = BTOBB(mp->m_sb.sb_sectsize);
 	int		boff = iocur_top->boff;
 
 	/*

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-02-22 22:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <XHUtgxly_CH13p8M7H9gfXcYh0jkPKFUt3PdJWiUb0Zd-14mjvJntXzbO99fH1XtOezv0aqG4XSdnTZ06vmgzw==@protonmail.internalid>
2024-01-23  4:10 ` [PATCH] xfs_db: don't hardcode 'type data' size at 512b Darrick J. Wong
2024-01-23  4:15   ` Christoph Hellwig
2024-01-23 10:38   ` Carlos Maiolino
2024-02-22 22:04   ` [PATCH v2] " Darrick J. Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox