Whamcloud - gitweb
LU-1887 ptlrpc: grant shrink rpc format is special
authorLai Siyao <laisiyao@whamcloud.com>
Mon, 15 Oct 2012 07:02:19 +0000 (00:02 -0700)
committerOleg Drokin <green@whamcloud.com>
Mon, 17 Dec 2012 05:24:22 +0000 (00:24 -0500)
Grant shrink rpc is packed in OST_SET_INFO request, but its format is
different from others.

Change-Id: I8b3398d534fbae683722f942403e031c68023b16
Signed-off-by: Lai Siyao <laisiyao@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/4277
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-by: Bobi Jam <bobijam@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/ofd/ofd_obd.c
lustre/osc/osc_request.c
lustre/tests/sanity.sh

index 2952f03..48e28a4 100644 (file)
@@ -514,6 +514,7 @@ static int ofd_set_info_async(const struct lu_env *env, struct obd_export *exp,
        } else if (KEY_IS(KEY_GRANT_SHRINK)) {
                struct ost_body *body = val;
 
+               ofd_info_init(env, exp);
                /** handle grant shrink, similar to a read request */
                ofd_grant_prepare_read(env, exp, &body->oa);
        } else {
index 357b893..8988ebd 100644 (file)
@@ -3163,27 +3163,28 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp,
            Even if something bad goes through, we'd get a -EINVAL from OST
            anyway. */
 
-        if (KEY_IS(KEY_GRANT_SHRINK))
-                req = ptlrpc_request_alloc(imp, &RQF_OST_SET_GRANT_INFO);
-        else
-                req = ptlrpc_request_alloc(imp, &RQF_OBD_SET_INFO);
-
-        if (req == NULL)
-                RETURN(-ENOMEM);
-
-        req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY,
-                             RCL_CLIENT, keylen);
-        req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_VAL,
-                             RCL_CLIENT, vallen);
-        rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SET_INFO);
-        if (rc) {
-                ptlrpc_request_free(req);
-                RETURN(rc);
-        }
+       req = ptlrpc_request_alloc(imp, KEY_IS(KEY_GRANT_SHRINK) ?
+                                               &RQF_OST_SET_GRANT_INFO :
+                                               &RQF_OBD_SET_INFO);
+       if (req == NULL)
+               RETURN(-ENOMEM);
+
+       req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY,
+                            RCL_CLIENT, keylen);
+       if (!KEY_IS(KEY_GRANT_SHRINK))
+               req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_VAL,
+                                    RCL_CLIENT, vallen);
+       rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SET_INFO);
+       if (rc) {
+               ptlrpc_request_free(req);
+               RETURN(rc);
+       }
 
-        tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_KEY);
-        memcpy(tmp, key, keylen);
-        tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_VAL);
+       tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_KEY);
+       memcpy(tmp, key, keylen);
+       tmp = req_capsule_client_get(&req->rq_pill, KEY_IS(KEY_GRANT_SHRINK) ?
+                                                       &RMF_OST_BODY :
+                                                       &RMF_SETINFO_VAL);
         memcpy(tmp, val, vallen);
 
        if (KEY_IS(KEY_GRANT_SHRINK)) {
index 5ccf2b1..6ff54ce 100644 (file)
@@ -4272,6 +4272,11 @@ test_64b () {
 }
 run_test 64b "check out-of-space detection on client ==========="
 
+test_64c() {
+       $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
+}
+run_test 64c "verify grant shrink ========================------"
+
 # bug 1414 - set/get directories' stripe info
 test_65a() {
        mkdir -p $DIR/d65