Whamcloud - gitweb
LU-3240 mdc: Check for all attributes validity in revalidate 60/6460/8
authorAlexander.Boyko <alexander_boyko@xyratex.com>
Mon, 27 May 2013 08:25:51 +0000 (12:25 +0400)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 11 Oct 2013 22:08:32 +0000 (22:08 +0000)
GETATTR needs to return attributes protected by different bits, so
we need to ensure all we have locks with all of those bits, not
just UPDATE bit.

Xyratex-bug-id: MRP-1052
Signed-off-by: Alexey Lyashkov <alexey_lyashkov@xyratex.com>
Signed-off-by: Oleg Drokin <oleg.drokin@intel.com>
Change-Id: I0e27a33341c424a8666bdbf3cdb83b1b4fe0058f
Reviewed-on: http://review.whamcloud.com/6460
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: wangdi <di.wang@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/mdc/mdc_locks.c
lustre/tests/sanity.sh

index 65224af..1a71afb 100644 (file)
@@ -1084,9 +1084,22 @@ int mdc_revalidate_lock(struct obd_export *exp, struct lookup_intent *it,
         } else {
                 fid_build_reg_res_name(fid, &res_id);
                 switch (it->it_op) {
-                case IT_GETATTR:
-                        policy.l_inodebits.bits = MDS_INODELOCK_UPDATE;
-                        break;
+               case IT_GETATTR:
+                       /* File attributes are held under multiple bits:
+                        * nlink is under lookup lock, size and times are
+                        * under UPDATE lock and recently we've also got
+                        * a separate permissions lock for owner/group/acl that
+                        * were protected by lookup lock before.
+                        * Getattr must provide all of that information,
+                        * so we need to ensure we have all of those locks.
+                        * Unfortunately, if the bits are split across multiple
+                        * 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. */
+                       policy.l_inodebits.bits = MDS_INODELOCK_UPDATE |
+                                                 MDS_INODELOCK_LOOKUP |
+                                                 MDS_INODELOCK_PERM;
+                       break;
                 case IT_LAYOUT:
                         policy.l_inodebits.bits = MDS_INODELOCK_LAYOUT;
                         break;
@@ -1094,6 +1107,7 @@ int mdc_revalidate_lock(struct obd_export *exp, struct lookup_intent *it,
                         policy.l_inodebits.bits = MDS_INODELOCK_LOOKUP;
                         break;
                 }
+
                 mode = ldlm_lock_match(exp->exp_obd->obd_namespace,
                                        LDLM_FL_BLOCK_GRANTED, &res_id,
                                        LDLM_IBITS, &policy,
index 7d21b74..fc42bc0 100644 (file)
@@ -3127,6 +3127,26 @@ test_39n() { # LU-3832
 }
 run_test 39n "check that O_NOATIME is honored"
 
+test_39o() {
+       TESTDIR=$DIR/$tdir/$tfile
+       [ -e $TESTDIR ] && rm -rf $TESTDIR
+       mkdir -p $TESTDIR
+       cd $TESTDIR
+       links1=2
+       ls
+       mkdir a b
+       ls
+       links2=$(stat -c %h .)
+       [ $(($links1 + 2)) != $links2 ] &&
+               error "wrong links count $(($links1 + 2)) != $links2"
+       rmdir b
+       links3=$(stat -c %h .)
+       [ $(($links1 + 1)) != $links3 ] &&
+               error "wrong links count $links1 != $links3"
+       return 0
+}
+run_test 39o "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 &&