Whamcloud - gitweb
LU-11868 mdc: Improve xattr buffer allocations 59/34059/2
authorPatrick Farrell <pfarrell@whamcloud.com>
Thu, 17 Jan 2019 20:26:09 +0000 (15:26 -0500)
committerOleg Drokin <green@whamcloud.com>
Wed, 30 Jan 2019 02:41:28 +0000 (02:41 +0000)
Many of the xattr related buffers in the mdc/mdt code are
allocated at max_easize, but they are used for normal POSIX
xattrs (primarily ACLs) and so they are guaranteed not to
exceed XATTR_SIZE_MAX.

HSM xattrs should also be less than XATTR_SIZE_MAX.

Reduce allocations to MIN(XATTR_SIZE_MAX, max_easize).

Signed-off-by: Patrick Farrell <pfarrell@whamcloud.com>
Change-Id: I228486ebd79b35358baeff490d6181cefa5a4586
Reviewed-on: https://review.whamcloud.com/34059
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Li Dongyang <dongyangli@ddn.com>
lustre/mdc/mdc_locks.c
lustre/mdc/mdc_reint.c
lustre/mdc/mdc_request.c
lustre/mdd/mdd_dir.c
lustre/mdd/mdd_object.c
lustre/mdt/mdt_handler.c

index 6e7df6b..2f87036 100644 (file)
@@ -812,7 +812,8 @@ static int mdc_enqueue_base(struct obd_export *exp,
 
        generation = obddev->u.cli.cl_import->imp_generation;
        if (!it || (it->it_op & (IT_OPEN | IT_CREAT)))
-               acl_bufsize = imp->imp_connect_data.ocd_max_easize;
+               acl_bufsize = MIN(imp->imp_connect_data.ocd_max_easize,
+                                 XATTR_SIZE_MAX);
        else
                acl_bufsize = LUSTRE_POSIX_ACL_MAX_SIZE_OLD;
 
@@ -934,10 +935,11 @@ resend:
 
        if ((int)lockrep->lock_policy_res2 == -ERANGE &&
            it->it_op & (IT_OPEN | IT_GETATTR | IT_LOOKUP) &&
-           acl_bufsize != imp->imp_connect_data.ocd_max_easize) {
+           acl_bufsize == LUSTRE_POSIX_ACL_MAX_SIZE_OLD) {
                mdc_clear_replay_flag(req, -ERANGE);
                ptlrpc_req_finished(req);
-               acl_bufsize = imp->imp_connect_data.ocd_max_easize;
+               acl_bufsize = MIN(imp->imp_connect_data.ocd_max_easize,
+                                 XATTR_SIZE_MAX);
                goto resend;
        }
 
index 3a95276..03e6aac 100644 (file)
@@ -137,7 +137,8 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data,
        mdc_setattr_pack(req, op_data, ea, ealen);
 
        req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER,
-                            req->rq_import->imp_connect_data.ocd_max_easize);
+                            MIN(req->rq_import->imp_connect_data.ocd_max_easize,
+                                XATTR_SIZE_MAX));
         ptlrpc_request_set_replen(req);
 
        rc = mdc_reint(req, LUSTRE_IMP_FULL);
index 8aa80d7..4941f06 100644 (file)
@@ -239,9 +239,9 @@ again:
 
        rc = mdc_getattr_common(exp, req);
        if (rc) {
-               if (rc == -ERANGE &&
-                   acl_bufsize != imp->imp_connect_data.ocd_max_easize) {
-                       acl_bufsize = imp->imp_connect_data.ocd_max_easize;
+               if (rc == -ERANGE) {
+                       acl_bufsize = MIN(imp->imp_connect_data.ocd_max_easize,
+                                         XATTR_SIZE_MAX);
                        mdc_reset_acl_req(req);
                        goto again;
                }
@@ -294,9 +294,9 @@ again:
 
        rc = mdc_getattr_common(exp, req);
        if (rc) {
-               if (rc == -ERANGE &&
-                   acl_bufsize != imp->imp_connect_data.ocd_max_easize) {
-                       acl_bufsize = imp->imp_connect_data.ocd_max_easize;
+               if (rc == -ERANGE) {
+                       acl_bufsize = MIN(imp->imp_connect_data.ocd_max_easize,
+                                         XATTR_SIZE_MAX);
                        mdc_reset_acl_req(req);
                        goto again;
                }
index 14d0264..0072c4a 100644 (file)
@@ -2509,7 +2509,7 @@ static int mdd_create(const struct lu_env *env, struct md_object *pobj,
                GOTO(out_free, rc = PTR_ERR(handle));
 
        lu_buf_check_and_alloc(&info->mti_xattr_buf,
-                              mdd->mdd_dt_conf.ddp_max_ea_size);
+                       MIN(mdd->mdd_dt_conf.ddp_max_ea_size, XATTR_SIZE_MAX));
        acl_buf = info->mti_xattr_buf;
        def_acl_buf.lb_buf = info->mti_key;
        def_acl_buf.lb_len = sizeof(info->mti_key);
index 1a16bf7..ea8f1b7 100644 (file)
@@ -1414,7 +1414,8 @@ static int mdd_hsm_update_locked(const struct lu_env *env,
 
        /* Read HSM attrs from disk */
        current_buf = lu_buf_check_and_alloc(&info->mti_xattr_buf,
-                               mdo2mdd(obj)->mdd_dt_conf.ddp_max_ea_size);
+                       MIN(mdd_obj2mdd_dev(mdd_obj)->mdd_dt_conf.ddp_max_ea_size,
+                           XATTR_SIZE_MAX));
        rc = mdo_xattr_get(env, mdd_obj, current_buf, XATTR_NAME_HSM);
        rc = lustre_buf2hsm(current_buf->lb_buf, rc, current_mh);
        if (rc < 0 && rc != -ENODATA)
index 4caa22a..5168791 100644 (file)
@@ -597,25 +597,26 @@ again:
                            exp_connect_large_acl(info->mti_exp) &&
                            buf->lb_buf != info->mti_big_acl) {
                                if (info->mti_big_acl == NULL) {
+                                       info->mti_big_aclsize =
+                                                       MIN(mdt->mdt_max_ea_size,
+                                                           XATTR_SIZE_MAX);
                                        OBD_ALLOC_LARGE(info->mti_big_acl,
-                                                       mdt->mdt_max_ea_size);
+                                                       info->mti_big_aclsize);
                                        if (info->mti_big_acl == NULL) {
+                                               info->mti_big_aclsize = 0;
                                                CERROR("%s: unable to grow "
                                                       DFID" ACL buffer\n",
                                                       mdt_obd_name(mdt),
                                                       PFID(mdt_object_fid(o)));
                                                RETURN(-ENOMEM);
                                        }
-
-                                       info->mti_big_aclsize =
-                                                       mdt->mdt_max_ea_size;
                                }
 
                                CDEBUG(D_INODE, "%s: grow the "DFID
                                       " ACL buffer to size %d\n",
                                       mdt_obd_name(mdt),
                                       PFID(mdt_object_fid(o)),
-                                      mdt->mdt_max_ea_size);
+                                      info->mti_big_aclsize);
 
                                buf->lb_buf = info->mti_big_acl;
                                buf->lb_len = info->mti_big_aclsize;