From: Bobi Jam Date: Tue, 23 Jul 2013 16:47:23 +0000 (+0800) Subject: LU-3620 mdd: missing CLF_RENAME_LAST flag in CL_RENME record X-Git-Tag: 2.4.91~24 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F95%2F7095%2F7;p=fs%2Flustre-release.git LU-3620 mdd: missing CLF_RENAME_LAST flag in CL_RENME record mdd_rename() should use target's attribute to determine add CLF_RENAME_LAST flag in changelog record. Signed-off-by: Bobi Jam Change-Id: Id9a738f1c98f0c893b125d49965354f44c257e08 Reviewed-on: http://review.whamcloud.com/7095 Tested-by: Hudson Reviewed-by: Dmitry Eremin Tested-by: Maloo Reviewed-by: Fan Yong Reviewed-by: Oleg Drokin --- diff --git a/lustre/mdd/mdd_dir.c b/lustre/mdd/mdd_dir.c index d607bba..b75ba34 100644 --- a/lustre/mdd/mdd_dir.c +++ b/lustre/mdd/mdd_dir.c @@ -2663,7 +2663,7 @@ static int mdd_rename(const struct lu_env *env, ma->ma_attr = *tg_attr; ma->ma_valid |= MA_INODE; - if (so_attr->la_nlink == 0) + if (tg_attr->la_nlink == 0) cl_flags |= CLF_RENAME_LAST; } diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index fdf7e76..b15303e 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -9477,6 +9477,85 @@ test_161b() { } run_test 161b "link ea sanity under remote directory" +test_161c() { + [ $PARALLEL == "yes" ] && skip "skip parallel run" && return + + # define CLF_RENAME_LAST 0x0001 + # rename overwrite a target having nlink = 1 (changelog flag 0x1) + local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \ + changelog_register -n) + mkdir -p $DIR/$tdir + touch $DIR/$tdir/foo_161c + touch $DIR/$tdir/bar_161c + mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c + local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \ + cut -f5 -d' ') + $LFS changelog_clear $MDT0 $USER 0 + if [ x$flags != "x0x1" ]; then + do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \ + $USER + error "flag $flags is not 0x1" + fi + echo "rename overwrite a target having nlink = 1," \ + "changelog record has flags of $flags" + + # rename overwrite a target having nlink > 1 (changelog flag 0x0) + touch $DIR/$tdir/foo_161c + touch $DIR/$tdir/bar_161c + ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c + mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c + flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ') + $LFS changelog_clear $MDT0 $USER 0 + if [ x$flags != "x0x0" ]; then + do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \ + $USER + error "flag $flags is not 0x0" + fi + echo "rename overwrite a target having nlink > 1," \ + "changelog record has flags of $flags" + + # rename doesn't overwrite a target (changelog flag 0x0) + touch $DIR/$tdir/foo_161c + mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c + flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ') + $LFS changelog_clear $MDT0 $USER 0 + if [ x$flags != "x0x0" ]; then + do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \ + $USER + error "flag $flags is not 0x0" + fi + echo "rename doesn't overwrite a target," \ + "changelog record has flags of $flags" + + # define CLF_UNLINK_LAST 0x0001 + # unlink a file having nlink = 1 (changelog flag 0x1) + rm -f $DIR/$tdir/foo2_161c + flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ') + $LFS changelog_clear $MDT0 $USER 0 + if [ x$flags != "x0x1" ]; then + do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \ + $USER + error "flag $flags is not 0x1" + fi + echo "unlink a file having nlink = 1," \ + "changelog record has flags of $flags" + + # unlink a file having nlink > 1 (changelog flag 0x0) + ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c + rm -f $DIR/$tdir/foobar_161c + flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ') + $LFS changelog_clear $MDT0 $USER 0 + if [ x$flags != "x0x0" ]; then + do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \ + $USER + error "flag $flags is not 0x0" + fi + echo "unlink a file having nlink > 1," \ + "changelog record has flags of $flags" + do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER +} +run_test 161c "check CL_RENME[UNLINK] changelog record flags" + check_path() { local expected=$1 shift