All of lore.kernel.org
 help / color / mirror / Atom feed
From: Carlos Maiolino <cmaiolino@redhat.com>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: sandeen@sandeen.net, Dave Chinner <dchinner@redhat.com>,
	linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/2] xfs_repair: invalidate dirhash entry when junking dirent
Date: Thu, 29 Jul 2021 13:01:07 +0200	[thread overview]
Message-ID: <20210729110107.ysn6fppfgaf5vp4x@omega.lan> (raw)
In-Reply-To: <162750698605.45897.4760370429656466555.stgit@magnolia>

On Wed, Jul 28, 2021 at 02:16:26PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> In longform_dir2_entry_check_data, we add the directory entries we find
> to the incore dirent hash table after we've validated the name but
> before we're totally done checking the entry.  This sequence is
> necessary to detect all duplicated names in the directory.
> 
> Unfortunately, if we later decide to junk the ondisk dirent, we neglect
> to mark the dirhash entry, so if the directory gets rebuilt, it will get
> rebuilt with the entry that we rejected.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> Reviewed-by: Dave Chinner <dchinner@redhat.com>

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

> ---
>  repair/phase6.c |   18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> 
> diff --git a/repair/phase6.c b/repair/phase6.c
> index 0929dcdf..696a6427 100644
> --- a/repair/phase6.c
> +++ b/repair/phase6.c
> @@ -237,6 +237,21 @@ dir_hash_add(
>  	return !dup;
>  }
>  
> +/* Mark an existing directory hashtable entry as junk. */
> +static void
> +dir_hash_junkit(
> +	struct dir_hash_tab	*hashtab,
> +	xfs_dir2_dataptr_t	addr)
> +{
> +	struct dir_hash_ent	*p;
> +
> +	p = radix_tree_lookup(&hashtab->byaddr, addr);
> +	assert(p != NULL);
> +
> +	p->junkit = 1;
> +	p->namebuf[0] = '/';
> +}
> +
>  static int
>  dir_hash_check(
>  	struct dir_hash_tab	*hashtab,
> @@ -1729,6 +1744,7 @@ longform_dir2_entry_check_data(
>  				if (entry_junked(
>  	_("entry \"%s\" (ino %" PRIu64 ") in dir %" PRIu64 " is not in the the first block"), fname,
>  						inum, ip->i_ino)) {
> +					dir_hash_junkit(hashtab, addr);
>  					dep->name[0] = '/';
>  					libxfs_dir2_data_log_entry(&da, bp, dep);
>  				}
> @@ -1756,6 +1772,7 @@ longform_dir2_entry_check_data(
>  				if (entry_junked(
>  	_("entry \"%s\" in dir %" PRIu64 " is not the first entry"),
>  						fname, inum, ip->i_ino)) {
> +					dir_hash_junkit(hashtab, addr);
>  					dep->name[0] = '/';
>  					libxfs_dir2_data_log_entry(&da, bp, dep);
>  				}
> @@ -1844,6 +1861,7 @@ _("entry \"%s\" in dir inode %" PRIu64 " inconsistent with .. value (%" PRIu64 "
>  				orphanage_ino = 0;
>  			nbad++;
>  			if (!no_modify)  {
> +				dir_hash_junkit(hashtab, addr);
>  				dep->name[0] = '/';
>  				libxfs_dir2_data_log_entry(&da, bp, dep);
>  				if (verbose)
> 

-- 
Carlos


  reply	other threads:[~2021-07-29 11:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-28 21:16 [PATCHSET 0/2] xfsprogs: random fixes Darrick J. Wong
2021-07-28 21:16 ` [PATCH 1/2] xfs_repair: invalidate dirhash entry when junking dirent Darrick J. Wong
2021-07-29 11:01   ` Carlos Maiolino [this message]
2021-07-28 21:16 ` [PATCH 2/2] xfs_quota: allow users to truncate group and project quota files Darrick J. Wong
2021-07-28 23:09   ` Eric Sandeen

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=20210729110107.ysn6fppfgaf5vp4x@omega.lan \
    --to=cmaiolino@redhat.com \
    --cc=dchinner@redhat.com \
    --cc=djwong@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@sandeen.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.