Whamcloud - gitweb
LU-3669 xattr: separate ACL and XATTR caches
[fs/lustre-release.git] / lustre / mdc / mdc_request.c
index 26b75ad..8a0073c 100644 (file)
@@ -368,11 +368,33 @@ static int mdc_xattr_common(struct obd_export *exp,const struct req_format *fmt,
                                      input_size);
         }
 
-        rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, opcode);
-        if (rc) {
-                ptlrpc_request_free(req);
-                RETURN(rc);
-        }
+       /* Flush local XATTR locks to get rid of a possible cancel RPC */
+       if (opcode == MDS_REINT && fid_is_sane(fid) &&
+           exp->exp_connect_data.ocd_ibits_known & MDS_INODELOCK_XATTR) {
+               CFS_LIST_HEAD(cancels);
+               int count;
+
+               /* Without that packing would fail */
+               if (input_size == 0)
+                       req_capsule_set_size(&req->rq_pill, &RMF_EADATA,
+                                            RCL_CLIENT, 0);
+
+               count = mdc_resource_get_unused(exp, fid,
+                                               &cancels, LCK_EX,
+                                               MDS_INODELOCK_XATTR);
+
+               rc = mdc_prep_elc_req(exp, req, MDS_REINT, &cancels, count);
+               if (rc) {
+                       ptlrpc_request_free(req);
+                       RETURN(rc);
+               }
+       } else {
+               rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, opcode);
+               if (rc) {
+                       ptlrpc_request_free(req);
+                       RETURN(rc);
+               }
+       }
 
         if (opcode == MDS_REINT) {
                 struct mdt_rec_setxattr *rec;