From: Bill O'Donnell <bodonnel@redhat.com>
To: "user.mail" <sandeen@redhat.com>
Cc: linux-xfs@vger.kernel.org, aalbersh@kernel.org, djwong@kernel.org
Subject: Re: [PATCH] xfs_repair: Bump link count if longform_dir2_rebuild yields shortform dir
Date: Tue, 15 Apr 2025 13:23:04 -0500 [thread overview]
Message-ID: <Z_6kCAHGNoSnPc27@redhat.com> (raw)
In-Reply-To: <20250415180923.264941-1-sandeen@redhat.com>
On Tue, Apr 15, 2025 at 01:09:23PM -0500, user.mail wrote:
> From: Eric Sandeen <sandeen@redhat.com>
>
> If longform_dir2_rebuild() has so few entries in *hashtab that it results
> in a short form directory, bump the link count manually as shortform
> directories have no explicit "." entry.
>
> Without this, repair will end with i.e.:
>
> resetting inode 131 nlinks from 2 to 1
>
> in this case, because it thinks this directory inode only has 1 link
> discovered, and then a 2nd repair will fix it:
>
> resetting inode 131 nlinks from 1 to 2
>
> because shortform_dir2_entry_check() explicitly adds the extra ref when
> the (newly-created)shortform directory is checked:
>
> /*
> * no '.' entry in shortform dirs, just bump up ref count by 1
> * '..' was already (or will be) accounted for and checked when
> * the directory is reached or will be taken care of when the
> * directory is moved to orphanage.
> */
> add_inode_ref(current_irec, current_ino_offset);
>
> Avoid this by adding the extra ref if we convert from longform to
> shortform.
>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> Signed-off-by: user.mail <sandeen@redhat.com>
> ---
I was about to send a v3 of my patch to handle this (fix link counts
update...) based on djwong's review. This looks cleaner. Thanks!
Reviewed-by: Bill O'Donnell <bodonnel@redhat.com>
> repair/phase6.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/repair/phase6.c b/repair/phase6.c
> index dbc090a5..8804278a 100644
> --- a/repair/phase6.c
> +++ b/repair/phase6.c
> @@ -1392,6 +1392,13 @@ _("name create failed in ino %" PRIu64 " (%d)\n"), ino, error);
> _("name create failed (%d) during rebuild\n"), error);
> }
>
> + /*
> + * If we added too few entries to retain longform, add the extra
> + * ref for . as this is now a shortform directory.
> + */
> + if (ip->i_df.if_format == XFS_DINODE_FMT_LOCAL)
> + add_inode_ref(irec, ino_offset);
> +
> return;
>
> out_bmap_cancel:
> --
> 2.49.0
>
next prev parent reply other threads:[~2025-04-15 18:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-15 18:09 [PATCH] xfs_repair: Bump link count if longform_dir2_rebuild yields shortform dir user.mail
2025-04-15 18:20 ` Eric Sandeen
2025-04-15 18:23 ` Bill O'Donnell [this message]
2025-04-15 18:44 ` Eric Sandeen
2025-04-15 18:56 ` Bill O'Donnell
2025-04-16 1:32 ` Darrick J. Wong
2025-04-16 8:27 ` Andrey Albershteyn
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=Z_6kCAHGNoSnPc27@redhat.com \
--to=bodonnel@redhat.com \
--cc=aalbersh@kernel.org \
--cc=djwong@kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox