xfs_db: don't hardcode 'type data' size at 512b
PATCH 1/1 xfs_db: don't hardcode 'type data' size at 512b
From: Darrick J. Wong <[email protected]>
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.
--- db/block.c | 7 ++++--- db/io.c | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-)
db/block.c +4 -3
@@ -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 ;
db/io.c +2 -1
@@ -681,7 +681,8 @@ voidset_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;/*
Looks good:
Quoted 5 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
On a disk with 4096-byte LBAs, the
xfs_db'type data' subcommand doesn't work:
Quoted 8 lines
# xfs_io -c 'sb' -c 'type data' /dev/sda xfs_db: read failed: Invalid argument no current objectThe cause of this is the hardcoded initialization of
bb_countwhen we're setting type data -- it should be the filesystem sector size, not just 1.Signed-off-by Darrick J. Wong <[email protected]>
Looks good:
Quoted 49 lines
--- db/block.c | 7 ++++--- db/io.c | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-)db/block.c +4
-3@@ -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 ;db/io.c +2
-1@@ -681,7 +681,8 @@ voidset_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;/*
PATCH v2 1/1 xfs_db: don't hardcode 'type data' size at 512b
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
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.
---
v2: rebase to for-next
--- db/block.c | 3 ++- db/io.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
db/block.c +2 -1
@@ -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 ; }
db/io.c +2 -1
@@ -652,7 +652,8 @@ voidset_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;/*