All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bill O'Donnell <billodo@redhat.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: sandeen@redhat.com, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 7/8] xfs_repair: bump the irec on-disk nlink when adding lost+found
Date: Wed, 19 Dec 2018 14:30:48 -0600	[thread overview]
Message-ID: <20181219203048.GC22276@redhat.com> (raw)
In-Reply-To: <154524781732.28646.10845701241680094884.stgit@magnolia>

On Wed, Dec 19, 2018 at 11:30:17AM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> We increment the nlink of the root directory inode when creating a
> "lost+found" directory during phase 6, but we don't update the irec copy
> of the root dir nlink.  This normally gets papered over by phase 7, but
> this can fail badly if:
> 
> 1) The root directory had an entry to a busted subdirectory, so
>    that root directory will have nlink == 3, but in the ino_tree,
>    counted_nlinks == 2 and disk_nlinks == 3.
> 
> 2) Phase 6 creates lost+found to root the files that were in the busted
>    directory, we'll set nlink = 4 and counted_nlinks = 3.  The correct
>    nlink is 3 ('.', '..', 'lost+found'), not 4.
> 
> 3) During phase 7, we see that counted_nlinks == disk_nlinks and so we
>    totally fail to correct the on-disk inode.
> 
> 4) A subsequent run of xfs_repair complains about the nlink being 4
>    instead of 3.
> 
> To fix this, we have to adjust the irec's disk_nlinks in step 2 so that
> phase 7 seeds that counted_nlinks < disk_nlinks and resets nlink to
> counted_nlinks.  This can be reproduced somewhat frequently by xfs/117.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---

Makes sense.
Reviewed-by: Bill O'Donnell <billodo@redhat.com>

>  repair/phase6.c |   14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> 
> diff --git a/repair/phase6.c b/repair/phase6.c
> index 8a50b350..194cfdbf 100644
> --- a/repair/phase6.c
> +++ b/repair/phase6.c
> @@ -1019,6 +1019,7 @@ mk_orphanage(xfs_mount_t *mp)
>  	 */
>  	set_inode_used(irec, ino_offset);
>  	add_inode_ref(irec, ino_offset);
> +	add_inode_reached(irec, ino_offset);
>  
>  	/*
>  	 * now that we know the transaction will stay around,
> @@ -1037,14 +1038,14 @@ mk_orphanage(xfs_mount_t *mp)
>  
>  	/*
>  	 * bump up the link count in the root directory to account
> -	 * for .. in the new directory
> +	 * for .. in the new directory, and update the irec copy of the
> +	 * on-disk nlink so we don't fail the link count check later.
>  	 */
>  	inc_nlink(VFS_I(pip));
> -	add_inode_ref(find_inode_rec(mp,
> -				XFS_INO_TO_AGNO(mp, mp->m_sb.sb_rootino),
> -				XFS_INO_TO_AGINO(mp, mp->m_sb.sb_rootino)), 0);
> -
> -
> +	irec = find_inode_rec(mp, XFS_INO_TO_AGNO(mp, mp->m_sb.sb_rootino),
> +				  XFS_INO_TO_AGINO(mp, mp->m_sb.sb_rootino));
> +	add_inode_ref(irec, 0);
> +	set_inode_disk_nlinks(irec, 0, get_inode_disk_nlinks(irec, 0) + 1);
>  
>  	libxfs_trans_log_inode(tp, pip, XFS_ILOG_CORE);
>  	libxfs_dir_init(tp, ip, pip);
> @@ -1056,7 +1057,6 @@ mk_orphanage(xfs_mount_t *mp)
>  	}
>  	libxfs_irele(ip);
>  	libxfs_irele(pip);
> -	add_inode_reached(irec,ino_offset);
>  
>  	return(ino);
>  }
> 

  reply	other threads:[~2018-12-19 20:30 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-19 19:29 [PATCH 0/8] xfsprogs: various fixes Darrick J. Wong
2018-12-19 19:29 ` [PATCH 1/8] xfs_scrub_all: walk the lsblk device/fs hierarchy correctly Darrick J. Wong
2019-02-04 18:08   ` Eric Sandeen
2019-02-04 18:16     ` Darrick J. Wong
2019-02-04 18:27       ` Eric Sandeen
2018-12-19 19:29 ` [PATCH 2/8] xfs_scrub_all.timer: activate after most of the system is up Darrick J. Wong
2019-02-04 18:12   ` Eric Sandeen
2018-12-19 19:29 ` [PATCH 3/8] xfs_scrub: rename the global nr_threads Darrick J. Wong
2019-02-04 18:20   ` Eric Sandeen
2018-12-19 19:29 ` [PATCH 4/8] xfs_scrub: use datadev parallelization estimates for thread count Darrick J. Wong
2019-02-04 18:31   ` Eric Sandeen
2019-02-04 18:34     ` Darrick J. Wong
2018-12-19 19:30 ` [PATCH 5/8] xfs_scrub: use data/rtdev parallelization estimates for the read-verify pool Darrick J. Wong
2019-02-04 18:35   ` Eric Sandeen
2019-02-04 18:38     ` Darrick J. Wong
2019-02-05  2:23       ` Darrick J. Wong
2018-12-19 19:30 ` [PATCH 6/8] xfs_repair: reinitialize the root directory nlink correctly Darrick J. Wong
2018-12-19 20:24   ` Bill O'Donnell
2019-02-04 19:19   ` Eric Sandeen
2018-12-19 19:30 ` [PATCH 7/8] xfs_repair: bump the irec on-disk nlink when adding lost+found Darrick J. Wong
2018-12-19 20:30   ` Bill O'Donnell [this message]
2018-12-19 19:30 ` [PATCH 8/8] xfs_repair: fix uninitialized variable warnings Darrick J. Wong
2018-12-19 20:25   ` Bill O'Donnell

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=20181219203048.GC22276@redhat.com \
    --to=billodo@redhat.com \
    --cc=darrick.wong@oracle.com \
    --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 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.