From 954c0ff7522b666b328c4a02caa8248a9116f0c9 Mon Sep 17 00:00:00 2001 From: Lai Siyao Date: Mon, 15 Oct 2012 00:02:19 -0700 Subject: [PATCH] LU-1887 ptlrpc: grant shrink rpc format is special 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 Reviewed-on: http://review.whamcloud.com/4277 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Jinshan Xiong Reviewed-by: Bobi Jam Reviewed-by: Oleg Drokin --- lustre/ofd/ofd_obd.c | 1 + lustre/osc/osc_request.c | 41 +++++++++++++++++++++-------------------- lustre/tests/sanity.sh | 5 +++++ 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/lustre/ofd/ofd_obd.c b/lustre/ofd/ofd_obd.c index 2952f03..48e28a4 100644 --- a/lustre/ofd/ofd_obd.c +++ b/lustre/ofd/ofd_obd.c @@ -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 { diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 357b893..8988ebd 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -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)) { diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 5ccf2b1..6ff54ce 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -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 -- 1.8.3.1