From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steven Whitehouse Date: Wed, 15 May 2013 17:08:24 +0100 Subject: [Cluster-devel] [gfs2-utils PATCH 06/47] fsck.gfs2: Check for formal inode mismatch when adding to lost+found In-Reply-To: <9b5bd520e0fce30d15dfa53e3d549f34d5c8a696.1368548305.git.rpeterso@redhat.com> References: <9b5bd520e0fce30d15dfa53e3d549f34d5c8a696.1368548305.git.rpeterso@redhat.com> Message-ID: <1368634104.2732.104.camel@menhir> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi, On Tue, 2013-05-14 at 11:21 -0500, Bob Peterson wrote: > This patch adds a check to the code that adds inodes to lost+found > so that dinodes with formal inode mismatches are logged, but not added. > I'm not sure I understand what this one is doing. If there is a mismatch between the dir entry and the inode that suggests that the dir entry and inode are not related to the same thing, Steve. > rhbz#902920 > --- > gfs2/fsck/lost_n_found.c | 44 ++++++++++++++++++++++++++++---------------- > 1 file changed, 28 insertions(+), 16 deletions(-) > > diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c > index f379646..3d9acb5 100644 > --- a/gfs2/fsck/lost_n_found.c > +++ b/gfs2/fsck/lost_n_found.c > @@ -40,24 +40,36 @@ static void add_dotdot(struct gfs2_inode *ip) > (unsigned long long)ip->i_di.di_num.no_addr, > (unsigned long long)di->dotdot_parent.no_addr, > (unsigned long long)di->dotdot_parent.no_addr); > - decr_link_count(di->dotdot_parent.no_addr, > - ip->i_di.di_num.no_addr, > - _(".. unlinked, moving to lost+found")); > dip = fsck_load_inode(sdp, di->dotdot_parent.no_addr); > - if (dip->i_di.di_nlink > 0) { > - dip->i_di.di_nlink--; > - set_di_nlink(dip); /* keep inode tree in sync */ > - log_debug(_("Decrementing its links to %d\n"), > - dip->i_di.di_nlink); > - bmodified(dip->i_bh); > - } else if (!dip->i_di.di_nlink) { > - log_debug(_("Its link count is zero.\n")); > + if (dip->i_di.di_num.no_formal_ino == > + di->dotdot_parent.no_formal_ino) { > + decr_link_count(di->dotdot_parent.no_addr, > + ip->i_di.di_num.no_addr, > + _(".. unlinked, moving to lost+found")); > + if (dip->i_di.di_nlink > 0) { > + dip->i_di.di_nlink--; > + set_di_nlink(dip); /* keep inode tree in sync */ > + log_debug(_("Decrementing its links to %d\n"), > + dip->i_di.di_nlink); > + bmodified(dip->i_bh); > + } else if (!dip->i_di.di_nlink) { > + log_debug(_("Its link count is zero.\n")); > + } else { > + log_debug(_("Its link count is %d! Changing " > + "it to 0.\n"), dip->i_di.di_nlink); > + dip->i_di.di_nlink = 0; > + set_di_nlink(dip); /* keep inode tree in sync */ > + bmodified(dip->i_bh); > + } > } else { > - log_debug(_("Its link count is %d! Changing " > - "it to 0.\n"), dip->i_di.di_nlink); > - dip->i_di.di_nlink = 0; > - set_di_nlink(dip); /* keep inode tree in sync */ > - bmodified(dip->i_bh); > + log_debug(_("Directory (0x%llx)'s link to parent " > + "(0x%llx) had a formal inode discrepancy: " > + "was 0x%llx, expected 0x%llx\n"), > + (unsigned long long)ip->i_di.di_num.no_addr, > + (unsigned long long)di->dotdot_parent.no_addr, > + di->dotdot_parent.no_formal_ino, > + dip->i_di.di_num.no_formal_ino); > + log_debug(_("The parent directory was not changed.\n")); > } > fsck_inode_put(&dip); > di = NULL;