xfs_repair: Fix root inode's parent when it's bogus for sf directory
PATCH 1/1 xfs_repair: Fix root inode's parent when it's bogus for sf directory
Currently when root inode is in short-form and its parent ino has an invalid value, process_sf_dir2() ends up not fixing it, because if verify_inum() fails we never get to the next case which would fix the root inode's parent pointer.
This behavior triggers the following assert on process_dir2():
ASSERT((ino != mp->m_sb.sb_rootino && ino != *parent) ||
(ino == mp->m_sb.sb_rootino &&
(ino == *parent || need_root_dotdot == 1)));This patch fixes this behavior by making sure we always properly handle rootino parent pointer in process_sf_dir2()
--- repair/dir2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
repair/dir2.c +3 -1
@@ -495,8 +495,10 @@ _("corrected entry offsets in directory %" PRIu64 "\n"),/* * if parent entry is bogus, null it out. we'll fix it later . +* If the validation fails for the root inode we fix it in +* the next else case. */ -if (verify_inum (mp, *parent)) { +if (verify_inum (mp, *parent) && ino != mp->m_sb.sb_rootino) { do_warn( _("bogus .. inode number (%" PRIu64 ") in directory inode %" PRIu64 ", "),
Signature · 1 line
2.9.5
Quoted 7 lines · Marco Benatto
Currently when root inode is in short-form and its parent ino has an invalid value,
process_sf_dir2()ends up not fixing it, because ifverify_inum()fails we never get to the next case which would fix the root inode's parent pointer.This behavior triggers the following assert on
process_dir2():
Quoted 8 lines
ASSERT((ino != mp->m_sb.sb_rootino && ino != *parent) || (ino == mp->m_sb.sb_rootino && (ino == *parent || need_root_dotdot == 1)));This patch fixes this behavior by making sure we always properly handle rootino parent pointer in
process_sf_dir2()Signed-off-by Marco Benatto <[email protected]>
This looks correct to me, thanks.
FWIW the problem can be demonstrated by setting the root inode's parent to 0 on a freshly made fs:
# mkfs.xfs -f -dfile,name=fsfile,size=1g # xfs_db -x -c "sb 0" -c "addr rootino" -c "write u3.sfdir3.hdr.parent.i4 0" fsfile # xfs_repair fsfile
Quoted 21 lines
--- repair/dir2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)repair/dir2.c +3
-1@@ -495,8 +495,10 @@ _("corrected entry offsets in directory %" PRIu64 "\n"),/* * if parent entry is bogus, null it out. we'll fix it later . +* If the validation fails for the root inode we fix it in +* the next else case. */ -if (verify_inum (mp, *parent)) { +if (verify_inum (mp, *parent) && ino != mp->m_sb.sb_rootino) { do_warn( _("bogus .. inode number (%" PRIu64 ") in directory inode %" PRIu64 ", "),
Quoted 17 lines · Eric Sandeen
Quoted 7 lines · Marco Benatto
Currently when root inode is in short-form and its parent ino has an invalid value,
process_sf_dir2()ends up not fixing it, because ifverify_inum()fails we never get to the next case which would fix the root inode's parent pointer.This behavior triggers the following assert on
process_dir2():Quoted 8 lines
ASSERT((ino != mp->m_sb.sb_rootino && ino != *parent) || (ino == mp->m_sb.sb_rootino && (ino == *parent || need_root_dotdot == 1)));This patch fixes this behavior by making sure we always properly handle rootino parent pointer in
process_sf_dir2()Signed-off-by Marco Benatto <[email protected]>
Quoted 8 lines
This looks correct to me, thanks.
FWIW the problem can be demonstrated by setting the root inode's parent to 0 on a freshly made fs:
# mkfs.xfs -f -dfile,name=fsfile,size=1g # xfs_db -x -c "sb 0" -c "addr rootino" -c "write u3.sfdir3.hdr.parent.i4 0" fsfile # xfs_repair fsfile
xfstest please (also to check that xfs_scrub detects it)?
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 20 lines · Dave Chinner
Quoted 19 lines · Eric Sandeen
Quoted 7 lines · Marco Benatto
Currently when root inode is in short-form and its parent ino has an invalid value,
process_sf_dir2()ends up not fixing it, because ifverify_inum()fails we never get to the next case which would fix the root inode's parent pointer.This behavior triggers the following assert on
process_dir2():Quoted 8 lines
ASSERT((ino != mp->m_sb.sb_rootino && ino != *parent) || (ino == mp->m_sb.sb_rootino && (ino == *parent || need_root_dotdot == 1)));This patch fixes this behavior by making sure we always properly handle rootino parent pointer in
process_sf_dir2()Signed-off-by Marco Benatto <[email protected]>This looks correct to me, thanks.
Quoted 8 lines
Quoted 6 lines
FWIW the problem can be demonstrated by setting the root inode's parent to 0 on a freshly made fs:
# mkfs.xfs -f -dfile,name=fsfile,size=1g # xfs_db -x -c "sb 0" -c "addr rootino" -c "write u3.sfdir3.hdr.parent.i4 0" fsfile # xfs_repair fsfilexfstest please (also to check that
xfs_scrubdetects it)?
Sure, working on this. I'll send you once it's done.
Quoted 7 lines
Cheers,
Dave.
--
Dave Chinner
[email protected]
Cheers,
Signature · 1 line
Marco Benatto
FYI,
just sent out "[PATCH] xfstests: Teste root inode parent pointer repairing"
Quoted 46 lines · Marco Benatto
Quoted 20 lines · Dave Chinner
Quoted 19 lines · Eric Sandeen
Quoted 7 lines · Marco Benatto
Currently when root inode is in short-form and its parent ino has an invalid value,
process_sf_dir2()ends up not fixing it, because ifverify_inum()fails we never get to the next case which would fix the root inode's parent pointer.This behavior triggers the following assert on
process_dir2():Quoted 8 lines
ASSERT((ino != mp->m_sb.sb_rootino && ino != *parent) || (ino == mp->m_sb.sb_rootino && (ino == *parent || need_root_dotdot == 1)));This patch fixes this behavior by making sure we always properly handle rootino parent pointer in
process_sf_dir2()Signed-off-by Marco Benatto <[email protected]>This looks correct to me, thanks.
Quoted 8 lines
Quoted 6 lines
FWIW the problem can be demonstrated by setting the root inode's parent to 0 on a freshly made fs:
# mkfs.xfs -f -dfile,name=fsfile,size=1g # xfs_db -x -c "sb 0" -c "addr rootino" -c "write u3.sfdir3.hdr.parent.i4 0" fsfile # xfs_repair fsfilexfstest please (also to check that
xfs_scrubdetects it)?Sure, working on this. I'll send you once it's done.
Quoted 7 lines
Cheers,
Dave.
--
Dave Chinner
[email protected]Cheers,
--
Marco Benatto
Signature · 5 lines
Marco Benatto Senior Software Maintenance Engineer | Red Hat Brasil T: +55 11 35246161 | M: +55 41 9 88504051 Av. Brigadeiro Faria Lima 3900, 8° Andar. São Paulo, Brasil. RED HAT | TRIED. TESTED. TRUSTED. Saiba porque em redhat.com