lustre/mdc: Check for all attributes validity in revalidate
authorOleg Drokin <green@linuxhacker.ru>
Sat, 1 Mar 2014 02:16:31 +0000 (21:16 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 1 Mar 2014 03:04:49 +0000 (19:04 -0800)
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

Signed-off-by: Alexey Lyashkov <alexey_lyashkov@xyratex.com>
Signed-off-by: Oleg Drokin <oleg.drokin@intel.com>
Reviewed-on: http://review.whamcloud.com/6460
Xyratex-bug-id: MRP-1052
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3240
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: wangdi <di.wang@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/mdc/mdc_locks.c

index 288a41ec60c9153c1feadeaddf9aba7e9398692b..1336d4750c377ff1621af78bd2c8be36f7eabe93 100644 (file)
@@ -1061,7 +1061,20 @@ int mdc_revalidate_lock(struct obd_export *exp, struct lookup_intent *it,
                fid_build_reg_res_name(fid, &res_id);
                switch (it->it_op) {
                case IT_GETATTR:
-                       policy.l_inodebits.bits = MDS_INODELOCK_UPDATE;
+                       /* 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;
@@ -1070,6 +1083,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,