Whamcloud - gitweb
LU-11014 mdc: remove obsolete intent opcodes
[fs/lustre-release.git] / lustre / mdc / mdc_locks.c
index bb1d0a3..32587cf 100644 (file)
@@ -256,6 +256,8 @@ mdc_intent_open_pack(struct obd_export *exp, struct lookup_intent *it,
        int                      count = 0;
        enum ldlm_mode           mode;
        int                      rc;
+       int repsize;
+
        ENTRY;
 
        it->it_create_mode = (it->it_create_mode & ~S_IFMT) | S_IFREG;
@@ -338,8 +340,34 @@ mdc_intent_open_pack(struct obd_export *exp, struct lookup_intent *it,
        req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
                             obddev->u.cli.cl_max_mds_easize);
        req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER, acl_bufsize);
-        ptlrpc_request_set_replen(req);
-        return req;
+
+       /**
+        * Inline buffer for possible data from Data-on-MDT files.
+        */
+       req_capsule_set_size(&req->rq_pill, &RMF_NIOBUF_INLINE, RCL_SERVER,
+                            sizeof(struct niobuf_remote));
+       ptlrpc_request_set_replen(req);
+
+       /* Get real repbuf allocated size as rounded up power of 2 */
+       repsize = size_roundup_power2(req->rq_replen +
+                                     lustre_msg_early_size());
+
+       /* Estimate free space for DoM files in repbuf */
+       repsize -= req->rq_replen - obddev->u.cli.cl_max_mds_easize +
+                  sizeof(struct lov_comp_md_v1) +
+                  sizeof(struct lov_comp_md_entry_v1) +
+                  lov_mds_md_size(0, LOV_MAGIC_V3);
+
+       if (repsize < obddev->u.cli.cl_dom_min_inline_repsize) {
+               repsize = obddev->u.cli.cl_dom_min_inline_repsize - repsize;
+               req_capsule_set_size(&req->rq_pill, &RMF_NIOBUF_INLINE,
+                                    RCL_SERVER,
+                                    sizeof(struct niobuf_remote) + repsize);
+               ptlrpc_request_set_replen(req);
+               CDEBUG(D_INFO, "Increase repbuf by %d bytes, total: %d\n",
+                      repsize, req->rq_replen);
+       }
+       return req;
 }
 
 #define GA_DEFAULT_EA_NAME_LEN 20
@@ -355,6 +383,7 @@ mdc_intent_getxattr_pack(struct obd_export *exp,
        struct ldlm_intent      *lit;
        int                     rc, count = 0;
        struct list_head        cancels = LIST_HEAD_INIT(cancels);
+       u32 min_buf_size = 0;
 
        ENTRY;
 
@@ -373,19 +402,36 @@ mdc_intent_getxattr_pack(struct obd_export *exp,
        lit = req_capsule_client_get(&req->rq_pill, &RMF_LDLM_INTENT);
        lit->opc = IT_GETXATTR;
 
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0)
+       /* If the supplied buffer is too small then the server will
+        * return -ERANGE and llite will fallback to using non cached
+        * xattr operations. On servers before 2.10.1 a (non-cached)
+        * listxattr RPC for an orphan or dead file causes an oops. So
+        * let's try to avoid sending too small a buffer to too old a
+        * server. This is effectively undoing the memory conservation
+        * of LU-9417 when it would be *more* likely to crash the
+        * server. See LU-9856. */
+       if (exp->exp_connect_data.ocd_version < OBD_OCD_VERSION(2, 10, 1, 0))
+               min_buf_size = exp->exp_connect_data.ocd_max_easize;
+#endif
+
        /* pack the intended request */
        mdc_pack_body(req, &op_data->op_fid1, op_data->op_valid,
-                     GA_DEFAULT_EA_NAME_LEN * GA_DEFAULT_EA_NUM,
+                     max_t(u32, min_buf_size,
+                           GA_DEFAULT_EA_VAL_LEN * GA_DEFAULT_EA_NUM),
                      -1, 0);
 
        req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_SERVER,
-                            GA_DEFAULT_EA_NAME_LEN * GA_DEFAULT_EA_NUM);
+                            max_t(u32, min_buf_size,
+                                GA_DEFAULT_EA_NAME_LEN * GA_DEFAULT_EA_NUM));
 
        req_capsule_set_size(&req->rq_pill, &RMF_EAVALS, RCL_SERVER,
-                            GA_DEFAULT_EA_VAL_LEN * GA_DEFAULT_EA_NUM);
+                            max_t(u32, min_buf_size,
+                                GA_DEFAULT_EA_VAL_LEN * GA_DEFAULT_EA_NUM));
 
        req_capsule_set_size(&req->rq_pill, &RMF_EAVALS_LENS, RCL_SERVER,
-                            sizeof(__u32) * GA_DEFAULT_EA_NUM);
+                            max_t(u32, min_buf_size,
+                                sizeof(__u32) * GA_DEFAULT_EA_NUM));
 
        req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER, 0);
 
@@ -394,43 +440,6 @@ mdc_intent_getxattr_pack(struct obd_export *exp,
        RETURN(req);
 }
 
-static struct ptlrpc_request *mdc_intent_unlink_pack(struct obd_export *exp,
-                                                     struct lookup_intent *it,
-                                                     struct md_op_data *op_data)
-{
-        struct ptlrpc_request *req;
-        struct obd_device     *obddev = class_exp2obd(exp);
-        struct ldlm_intent    *lit;
-        int                    rc;
-        ENTRY;
-
-        req = ptlrpc_request_alloc(class_exp2cliimp(exp),
-                                   &RQF_LDLM_INTENT_UNLINK);
-        if (req == NULL)
-                RETURN(ERR_PTR(-ENOMEM));
-
-        req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT,
-                             op_data->op_namelen + 1);
-
-        rc = ldlm_prep_enqueue_req(exp, req, NULL, 0);
-        if (rc) {
-                ptlrpc_request_free(req);
-                RETURN(ERR_PTR(rc));
-        }
-
-        /* pack the intent */
-        lit = req_capsule_client_get(&req->rq_pill, &RMF_LDLM_INTENT);
-        lit->opc = (__u64)it->it_op;
-
-        /* pack the intended request */
-        mdc_unlink_pack(req, op_data);
-
-       req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
-                            obddev->u.cli.cl_default_mds_easize);
-       ptlrpc_request_set_replen(req);
-       RETURN(req);
-}
-
 static struct ptlrpc_request *
 mdc_intent_getattr_pack(struct obd_export *exp, struct lookup_intent *it,
                        struct md_op_data *op_data, __u32 acl_bufsize)
@@ -781,18 +790,18 @@ static int mdc_enqueue_base(struct obd_export *exp,
                LASSERT(policy == NULL);
 
                saved_flags |= LDLM_FL_HAS_INTENT;
-               if (it->it_op & (IT_UNLINK | IT_GETATTR | IT_READDIR))
+               if (it->it_op & (IT_GETATTR | IT_READDIR))
                        policy = &update_policy;
                else if (it->it_op & IT_LAYOUT)
                        policy = &layout_policy;
-               else if (it->it_op & (IT_GETXATTR | IT_SETXATTR))
+               else if (it->it_op & IT_GETXATTR)
                        policy = &getxattr_policy;
                else
                        policy = &lookup_policy;
        }
 
        generation = obddev->u.cli.cl_import->imp_generation;
-       if (!it || (it->it_op & (IT_CREAT | IT_OPEN_CREAT)))
+       if (!it || (it->it_op & (IT_OPEN | IT_CREAT)))
                acl_bufsize = imp->imp_connect_data.ocd_max_easize;
        else
                acl_bufsize = LUSTRE_POSIX_ACL_MAX_SIZE_OLD;
@@ -806,8 +815,6 @@ resend:
                res_id.name[3] = LDLM_FLOCK;
        } else if (it->it_op & IT_OPEN) {
                req = mdc_intent_open_pack(exp, it, op_data, acl_bufsize);
-       } else if (it->it_op & IT_UNLINK) {
-               req = mdc_intent_unlink_pack(exp, it, op_data);
        } else if (it->it_op & (IT_GETATTR | IT_LOOKUP)) {
                req = mdc_intent_getattr_pack(exp, it, op_data, acl_bufsize);
        } else if (it->it_op & IT_READDIR) {