The following commit has been merged in the master branch: commit 29e8c86e883e730590b5ac7f867410f65f4f317f Author: Patrick Winnertz <win...@debian.org> Date: Wed Apr 28 14:13:50 2010 +0200
Fix an LBUG concerning open-unlinked directories Signed-off-by: Patrick Winnertz <win...@debian.org> diff --git a/debian/patches/00list b/debian/patches/00list index 91f2174..c6ebb7c 100644 --- a/debian/patches/00list +++ b/debian/patches/00list @@ -26,3 +26,6 @@ no-strict-aliasing.dpatch fix_bashisms_for_dash.dpatch configure_error_on_unstable.dpatch fix_dentry_conf_test.dpatch +LBUG_open-unlinked_bug_22177-1.dpatch +LBUG_open-unlinked_bug_22177-2.dpatch +LBUG_open-unlinked_bug_22177-3.dpatch diff --git a/debian/patches/LBUG_open-unlinked_bug_22177-1.dpatch b/debian/patches/LBUG_open-unlinked_bug_22177-1.dpatch new file mode 100644 index 0000000..b5588b9 --- /dev/null +++ b/debian/patches/LBUG_open-unlinked_bug_22177-1.dpatch @@ -0,0 +1,132 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## LBUG_open-unlinked_bug_22177-1.dpatch by Patrick Winnertz <win...@debian.org> +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Patch from bugzilla #22177 + +...@dpatch@ +diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c +index 97dc613..3c53148 100644 +--- a/lustre/mds/mds_reint.c ++++ b/lustre/mds/mds_reint.c +@@ -1755,31 +1755,37 @@ 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; ++ /* avoid vfs_link upon 0 nlink inode, inc by 2 instead of 1 because ++ * ext3_inc_count() can reset i_nlink for indexed directory */ ++ inode->i_nlink += 2; + rc = ll_vfs_link(dentry, mds->mds_vfsmnt, pending_dir, pending_child, + mds->mds_vfsmnt); + if (rc) +- CERROR("error linking orphan %s to PENDING: rc = %d\n", ++ CERROR("error linking orphan %s %s to PENDING: rc = %d\n", ++ S_ISDIR(mode) ? "dir" : S_ISREG(mode) ? "file" : "other", + rec->ur_name, rc); + else + mds_inode_set_orphan(inode); + + /* return mode and correct i_nlink if inode is directory */ + inode->i_mode = mode; +- LASSERTF(inode->i_nlink == 2, "%s nlink == %d\n", ++ LASSERTF(rc || inode->i_nlink == 3, "%s nlink == %d\n", + S_ISDIR(mode) ? "dir" : S_ISREG(mode) ? "file" : "other", + inode->i_nlink); ++ + if (S_ISDIR(mode)) { + pending_dir->i_nlink++; + 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); + } + ++ inode->i_nlink -= 2; ++ if (inode->i_sb->s_op->dirty_inode) ++ inode->i_sb->s_op->dirty_inode(inode); ++ ++ if (rc) ++ GOTO(out_dput, rc); ++ + GOTO(out_dput, rc = 1); + out_dput: + l_dput(pending_child); +@@ -2048,11 +2054,18 @@ static int mds_reint_unlink(struct mds_update_record *rec, int offset, + } + + if (rc == 0 && child_inode->i_nlink == 0) { +- if (mds_orphan_needed(obd, child_inode)) ++ if (mds_orphan_needed(obd, child_inode)) { + rc = mds_orphan_add_link(rec, obd, dchild); +- +- if (rc == 1) +- GOTO(cleanup, rc = 0); ++ if (rc == 1) ++ /* child inode was successfully linked ++ * to PENDING */ ++ GOTO(cleanup, rc = 0); ++ else ++ /* we failed to move the file to PENDING, ++ * really unlink the file as if there were ++ * no more openers */ ++ rc = 0; ++ } + + if (!S_ISREG(child_inode->i_mode)) + GOTO(cleanup, rc); +@@ -2738,11 +2751,18 @@ no_unlink: + } + + if (rc == 0 && new_inode != NULL && new_inode->i_nlink == 0) { +- if (mds_orphan_needed(obd, new_inode)) ++ if (mds_orphan_needed(obd, new_inode)) { + rc = mds_orphan_add_link(rec, obd, de_new); + +- if (rc == 1) +- GOTO(cleanup, rc = 0); ++ if (rc == 1) ++ /* inode successfully linked to PENDING */ ++ GOTO(cleanup, rc = 0); ++ else ++ /* we failed to move the file to PENDING, ++ * really unlink the file as if there were ++ * no more openers */ ++ rc = 0; ++ } + + if (!S_ISREG(new_inode->i_mode)) + GOTO(cleanup, rc); +diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh +index 4241a6b..7cefe84 100644 +--- a/lustre/tests/sanity.sh ++++ b/lustre/tests/sanity.sh +@@ -6458,6 +6458,25 @@ test_202() { + } + run_test 202 "O_APPEND+O_DIRECT multistripe write ========================" + ++test_203() { # bug 22177 ++ mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir" ++ # create enough files to index the directory ++ createmany -o $DIR/$tdir/foobar 4000 ++ # print attributes for debug purpose ++ lsattr -d . ++ # open dir ++ multiop_bg_pause $DIR/$tdir D_Sc || return 1 ++ MULTIPID=$! ++ # remove the files & current working dir ++ unlinkmany $DIR/$tdir/foobar 4000 ++ rmdir $DIR/$tdir ++ kill -USR1 $MULTIPID ++ wait $MULTIPID ++ stat $DIR/$tdir && error "open-unlinked dir was not removed!" ++ return 0 ++} ++run_test 203 "Test open-unlinked dir ========================" ++ + # + # tests that do cleanup/setup should be run at the end + # diff --git a/debian/patches/LBUG_open-unlinked_bug_22177-2.dpatch b/debian/patches/LBUG_open-unlinked_bug_22177-2.dpatch new file mode 100644 index 0000000..bec6f50 --- /dev/null +++ b/debian/patches/LBUG_open-unlinked_bug_22177-2.dpatch @@ -0,0 +1,20 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## LBUG_open-unlinked_bug_22177.dpatch by Patrick Winnertz <win...@debian.org> +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Patch from Bugzilla #22177, should be fixed in 1.8.3 + +...@dpatch@ +diff --git a/lustre/mds/mds_open.c b/lustre/mds/mds_open.c +index 4feb1d8..31e1768 100644 +--- a/lustre/mds/mds_open.c ++++ b/lustre/mds/mds_open.c +@@ -1496,7 +1496,7 @@ int mds_mfd_close(struct ptlrpc_request *req, int offset, + CDEBUG(D_INODE, "destroying orphan object %s\n", fidname); + + if ((S_ISREG(inode->i_mode) && inode->i_nlink != 1) || +- (S_ISDIR(inode->i_mode) && inode->i_nlink != 2)) ++ (S_ISDIR(inode->i_mode) && inode->i_nlink > 2)) + CERROR("found \"orphan\" %s %s with link count %d\n", + S_ISREG(inode->i_mode) ? "file" : "dir", + fidname, inode->i_nlink); diff --git a/debian/patches/LBUG_open-unlinked_bug_22177-3.dpatch b/debian/patches/LBUG_open-unlinked_bug_22177-3.dpatch new file mode 100644 index 0000000..c783a28 --- /dev/null +++ b/debian/patches/LBUG_open-unlinked_bug_22177-3.dpatch @@ -0,0 +1,49 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## LBUG_open-unlinked_bug_22177-3.dpatch by Patrick Winnertz <win...@debian.org> +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Patch from bugzilla #22177, should be fixed in 1.8.3 + +...@dpatch@ +diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c +index 97dc613..4de6d2d 100644 +--- a/lustre/mds/mds_reint.c ++++ b/lustre/mds/mds_reint.c +@@ -1755,8 +1755,9 @@ 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; ++ /* avoid vfs_link upon 0 nlink inode, inc by 2 instead of 1 because ++ * ext3_inc_count() can reset i_nlink for indexed directory */ ++ inode->i_nlink += 2; + rc = ll_vfs_link(dentry, mds->mds_vfsmnt, pending_dir, pending_child, + mds->mds_vfsmnt); + if (rc) +@@ -1767,19 +1768,21 @@ 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 == 2, "%s nlink == %d\n", ++ LASSERTF(inode->i_nlink == 3, "%s nlink == %d\n", + S_ISDIR(mode) ? "dir" : S_ISREG(mode) ? "file" : "other", + inode->i_nlink); + if (S_ISDIR(mode)) { + pending_dir->i_nlink++; + if (pending_dir->i_sb->s_op->dirty_inode) + pending_dir->i_sb->s_op->dirty_inode(pending_dir); ++ inode->i_nlink -= 1; + } else { +- --inode->i_nlink; +- if (inode->i_sb->s_op->dirty_inode) +- inode->i_sb->s_op->dirty_inode(inode); ++ inode->i_nlink -= 2; + } + ++ if (inode->i_sb->s_op->dirty_inode) ++ inode->i_sb->s_op->dirty_inode(inode); ++ + GOTO(out_dput, rc = 1); + out_dput: + l_dput(pending_child); -- Lustre Debian Packaging _______________________________________________ Pkg-lustre-svn-commit mailing list Pkg-lustre-svn-commit@lists.alioth.debian.org http://lists.alioth.debian.org/mailman/listinfo/pkg-lustre-svn-commit