From b17d23fd01557c0e23f5c3b4eeea237c08fe2bc5 Mon Sep 17 00:00:00 2001 From: wang di Date: Fri, 11 Oct 2013 00:00:08 -0700 Subject: [PATCH] LU-3240 mdt: comments on LOOKUP and PERM lock 1. Add more comments for MDS_INODELOCK_PERM and MDS_INODELOCK_LOOKUP. 2. Add sanity 39p for checking nlink of remote directories. Signed-off-by: wang di Change-Id: I58a697f2aee02924f716333d8619873131db84f7 Reviewed-on: http://review.whamcloud.com/7937 Reviewed-by: Andreas Dilger Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/include/lustre/lustre_idl.h | 24 ++++++++++++++++++------ lustre/mdc/mdc_locks.c | 3 +++ lustre/tests/sanity.sh | 26 +++++++++++++++++++++++++- 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index 2ca8568..4ee7ccd 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -2122,12 +2122,24 @@ extern void lustre_swab_generic_32s (__u32 *val); #define DISP_OPEN_STRIPE 0x08000000 /* INODE LOCK PARTS */ -#define MDS_INODELOCK_LOOKUP 0x000001 /* dentry, mode, owner, group */ -#define MDS_INODELOCK_UPDATE 0x000002 /* size, links, timestamps */ -#define MDS_INODELOCK_OPEN 0x000004 /* For opened files */ -#define MDS_INODELOCK_LAYOUT 0x000008 /* for layout */ -#define MDS_INODELOCK_PERM 0x000010 /* for permission */ -#define MDS_INODELOCK_XATTR 0x000020 /* extended attributes */ +#define MDS_INODELOCK_LOOKUP 0x000001 /* For namespace, dentry etc, and also + * was used to protect permission (mode, + * owner, group etc) before 2.4. */ +#define MDS_INODELOCK_UPDATE 0x000002 /* size, links, timestamps */ +#define MDS_INODELOCK_OPEN 0x000004 /* For opened files */ +#define MDS_INODELOCK_LAYOUT 0x000008 /* for layout */ + +/* The PERM bit is added int 2.4, and it is used to protect permission(mode, + * owner, group, acl etc), so to separate the permission from LOOKUP lock. + * Because for remote directories(in DNE), these locks will be granted by + * different MDTs(different ldlm namespace). + * + * For local directory, MDT will always grant UPDATE_LOCK|PERM_LOCK together. + * For Remote directory, the master MDT, where the remote directory is, will + * grant UPDATE_LOCK|PERM_LOCK, and the remote MDT, where the name entry is, + * will grant LOOKUP_LOCK. */ +#define MDS_INODELOCK_PERM 0x000010 +#define MDS_INODELOCK_XATTR 0x000020 /* extended attributes */ #define MDS_INODELOCK_MAXSHIFT 5 /* This FULL lock is useful to take on unlink sort of operations */ diff --git a/lustre/mdc/mdc_locks.c b/lustre/mdc/mdc_locks.c index a9a4e42..c6763b2 100644 --- a/lustre/mdc/mdc_locks.c +++ b/lustre/mdc/mdc_locks.c @@ -1093,6 +1093,9 @@ int mdc_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, * locks, there's no easy way to match all of them here, * so an extra RPC would be performed to fetch all * of those bits at once for now. */ + /* For new MDTs(> 2.4), UPDATE|PERM should be enough, + * but for old MDTs (< 2.4), permission is covered + * by LOOKUP lock, so it needs to match all bits here.*/ policy.l_inodebits.bits = MDS_INODELOCK_UPDATE | MDS_INODELOCK_LOOKUP | MDS_INODELOCK_PERM; diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 9471531..62fec65 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -3138,7 +3138,7 @@ run_test 39n "check that O_NOATIME is honored" test_39o() { TESTDIR=$DIR/$tdir/$tfile [ -e $TESTDIR ] && rm -rf $TESTDIR - mkdir -p $TESTDIR + test_mkdir -p $TESTDIR cd $TESTDIR links1=2 ls @@ -3155,6 +3155,30 @@ test_39o() { } run_test 39o "directory cached attributes updated after create ========" +test_39p() { + [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return + local MDTIDX=1 + TESTDIR=$DIR/$tdir/$tfile + [ -e $TESTDIR ] && rm -rf $TESTDIR + test_mkdir -p $TESTDIR + cd $TESTDIR + links1=2 + ls + $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1 + $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2 + ls + links2=$(stat -c %h .) + [ $(($links1 + 2)) != $links2 ] && + error "wrong links count $(($links1 + 2)) != $links2" + rmdir remote_dir2 + links3=$(stat -c %h .) + [ $(($links1 + 1)) != $links3 ] && + error "wrong links count $links1 != $links3" + return 0 +} +run_test 39p "remote directory cached attributes updated after create ========" + + test_40() { dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile && -- 1.8.3.1