From 236a337d37bc5e4a7cf674d6f0100401232ee694 Mon Sep 17 00:00:00 2001 From: bobijam Date: Mon, 10 Aug 2009 02:27:28 +0000 Subject: [PATCH] Branch b1_8 b=19640 i=johann i=adilger Avoid calling vfs_link upon a file with link count of 0 in mds_orphan_add_link(). --- lustre/mds/mds_reint.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c index ea39e68..9b2f964 100644 --- a/lustre/mds/mds_reint.c +++ b/lustre/mds/mds_reint.c @@ -1752,6 +1752,8 @@ static int mds_orphan_add_link(struct mds_update_record *rec, * for linking and return real mode back then -bzzz */ mode = inode->i_mode; inode->i_mode = S_IFREG; + /* avoid vfs_link upon 0 nlink inode */ + ++inode->i_nlink; rc = ll_vfs_link(dentry, mds->mds_vfsmnt, pending_dir, pending_child, mds->mds_vfsmnt); if (rc) @@ -1762,14 +1764,17 @@ static int mds_orphan_add_link(struct mds_update_record *rec, /* return mode and correct i_nlink if inode is directory */ inode->i_mode = mode; - LASSERTF(inode->i_nlink == 1, "%s nlink == %d\n", + LASSERTF(inode->i_nlink == 2, "%s nlink == %d\n", S_ISDIR(mode) ? "dir" : S_ISREG(mode) ? "file" : "other", inode->i_nlink); if (S_ISDIR(mode)) { - inode->i_nlink++; pending_dir->i_nlink++; - mark_inode_dirty(inode); - mark_inode_dirty(pending_dir); + if (pending_dir->i_sb->s_op->dirty_inode) + pending_dir->i_sb->s_op->dirty_inode(pending_dir); + } else { + --inode->i_nlink; + if (inode->i_sb->s_op->dirty_inode) + inode->i_sb->s_op->dirty_inode(inode); } GOTO(out_dput, rc = 1); -- 1.8.3.1