* [PATCH] xfs_repair: Fix root inode's parent when it's bogus for sf directory
@ 2018-06-14 22:16 Marco Benatto
2018-06-14 22:20 ` Eric Sandeen
0 siblings, 1 reply; 5+ messages in thread
From: Marco Benatto @ 2018-06-14 22:16 UTC (permalink / raw)
To: linux-xfs; +Cc: mbenatto, sandeen
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()
Signed-off-by: Marco Benatto <mbenatto@redhat.com>
---
repair/dir2.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/repair/dir2.c b/repair/dir2.c
index e162d2b..225f926 100644
--- a/repair/dir2.c
+++ b/repair/dir2.c
@@ -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 ", "),
--
2.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] xfs_repair: Fix root inode's parent when it's bogus for sf directory
2018-06-14 22:16 [PATCH] xfs_repair: Fix root inode's parent when it's bogus for sf directory Marco Benatto
@ 2018-06-14 22:20 ` Eric Sandeen
2018-06-14 23:35 ` Dave Chinner
0 siblings, 1 reply; 5+ messages in thread
From: Eric Sandeen @ 2018-06-14 22:20 UTC (permalink / raw)
To: Marco Benatto, linux-xfs; +Cc: sandeen
On 6/14/18 5:16 PM, Marco Benatto wrote:
> 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()
>
> Signed-off-by: Marco Benatto <mbenatto@redhat.com>
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
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
> repair/dir2.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/repair/dir2.c b/repair/dir2.c
> index e162d2b..225f926 100644
> --- a/repair/dir2.c
> +++ b/repair/dir2.c
> @@ -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 ", "),
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] xfs_repair: Fix root inode's parent when it's bogus for sf directory
2018-06-14 22:20 ` Eric Sandeen
@ 2018-06-14 23:35 ` Dave Chinner
2018-06-15 17:30 ` Marco Benatto
0 siblings, 1 reply; 5+ messages in thread
From: Dave Chinner @ 2018-06-14 23:35 UTC (permalink / raw)
To: Eric Sandeen; +Cc: Marco Benatto, linux-xfs, sandeen
On Thu, Jun 14, 2018 at 05:20:56PM -0500, Eric Sandeen wrote:
> On 6/14/18 5:16 PM, Marco Benatto wrote:
> > 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()
> >
> > Signed-off-by: Marco Benatto <mbenatto@redhat.com>
>
> 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.
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] xfs_repair: Fix root inode's parent when it's bogus for sf directory
2018-06-14 23:35 ` Dave Chinner
@ 2018-06-15 17:30 ` Marco Benatto
2018-06-15 21:15 ` Marco Benatto
0 siblings, 1 reply; 5+ messages in thread
From: Marco Benatto @ 2018-06-15 17:30 UTC (permalink / raw)
To: Dave Chinner; +Cc: Eric Sandeen, linux-xfs, Eric Sandeen
On Thu, Jun 14, 2018 at 8:35 PM, Dave Chinner <david@fromorbit.com> wrote:
> On Thu, Jun 14, 2018 at 05:20:56PM -0500, Eric Sandeen wrote:
>> On 6/14/18 5:16 PM, Marco Benatto wrote:
>> > 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()
>> >
>> > Signed-off-by: Marco Benatto <mbenatto@redhat.com>
>>
>> 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)?
Sure, working on this. I'll send you once it's done.
>
> Cheers,
>
> Dave.
> --
> Dave Chinner
> david@fromorbit.com
Cheers,
--
Marco Benatto
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] xfs_repair: Fix root inode's parent when it's bogus for sf directory
2018-06-15 17:30 ` Marco Benatto
@ 2018-06-15 21:15 ` Marco Benatto
0 siblings, 0 replies; 5+ messages in thread
From: Marco Benatto @ 2018-06-15 21:15 UTC (permalink / raw)
To: Dave Chinner; +Cc: Eric Sandeen, linux-xfs, Eric Sandeen
FYI,
just sent out "[PATCH] xfstests: Teste root inode parent pointer repairing"
On Fri, Jun 15, 2018 at 2:30 PM, Marco Benatto <mbenatto@redhat.com> wrote:
> On Thu, Jun 14, 2018 at 8:35 PM, Dave Chinner <david@fromorbit.com> wrote:
>> On Thu, Jun 14, 2018 at 05:20:56PM -0500, Eric Sandeen wrote:
>>> On 6/14/18 5:16 PM, Marco Benatto wrote:
>>> > 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()
>>> >
>>> > Signed-off-by: Marco Benatto <mbenatto@redhat.com>
>>>
>>> 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)?
>
> Sure, working on this. I'll send you once it's done.
>
>>
>> Cheers,
>>
>> Dave.
>> --
>> Dave Chinner
>> david@fromorbit.com
>
>
>
> Cheers,
>
> --
> Marco Benatto
--
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-06-15 21:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-14 22:16 [PATCH] xfs_repair: Fix root inode's parent when it's bogus for sf directory Marco Benatto
2018-06-14 22:20 ` Eric Sandeen
2018-06-14 23:35 ` Dave Chinner
2018-06-15 17:30 ` Marco Benatto
2018-06-15 21:15 ` Marco Benatto
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).