From: Bob Peterson Date: Fri, 1 Jul 2016 13:10:34 -0400 (EDT) Subject: [Cluster-devel] [fsck.gfs2 PATCH] fsck.gfs2: link count checking wrong inode's formal inode number In-Reply-To: <1389216347.5514007.1467393004696.JavaMail.zimbra@redhat.com> Message-ID: <1331239316.5514032.1467393034920.JavaMail.zimbra@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi, This patch fixes a bug whereby inodes that aren't in the dirtree or the inodetree are checking the wrong formal inode number. Function incr_link_count checks the wrong inode value, and thus reports an error where there are none. Also, when the error is reported back, it reports the wrong value, using a copy of the inum value. In this case, it should look up the dentry's inode's formal inode number. This should only hurt performance in error cases. Signed-off-by: Bob Peterson diff --git a/gfs2/fsck/link.c b/gfs2/fsck/link.c index 0243d85..00636d7 100644 --- a/gfs2/fsck/link.c +++ b/gfs2/fsck/link.c @@ -112,7 +112,7 @@ int incr_link_count(struct gfs2_inum no, struct gfs2_inode *ip, link_ip = fsck_load_inode(ip->i_sbd, no.no_addr); /* Check formal ino against dinode before adding to inode tree. */ - if (no.no_formal_ino != ip->i_di.di_num.no_formal_ino) { + if (no.no_formal_ino != link_ip->i_di.di_num.no_formal_ino) { fsck_inode_put(&link_ip); return 1; } diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c index f808cea..8ac5547 100644 --- a/gfs2/fsck/pass2.c +++ b/gfs2/fsck/pass2.c @@ -195,8 +195,13 @@ static int bad_formal_ino(struct gfs2_inode *ip, struct gfs2_dirent *dent, di = dirtree_find(entry.no_addr); if (di) inum = di->dinode; - else if (link1_type(&clink1map, entry.no_addr) == 1) - inum = entry; + else if (link1_type(&clink1map, entry.no_addr) == 1) { + struct gfs2_inode *dent_ip; + + dent_ip = fsck_load_inode(ip->i_sbd, entry.no_addr); + inum = dent_ip->i_di.di_num; + fsck_inode_put(&dent_ip); + } } log_err( _("Directory entry '%s' pointing to block %llu (0x%llx) in " "directory %llu (0x%llx) has the wrong 'formal' inode "