From bdc7dbd3ee45731b321f3b0708e14a05df6b58cd Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Thu, 20 Feb 2014 09:58:51 -0600 Subject: [PATCH] LU-4320 mdt: fixup MDS_SWAP_LAYOUTS ELC handling In mdc_ioc_swap_layouts() cancel *any* unused locks with LAYOUT or XATTR IBITS set on the two files. (This matches the locks acquired in mdt_swap_layouts(). Previously only locks that conflicted with a CR LAYOUT lock were cancelled.) Add HABEO_CLAVIS to the target handler flags for MDS_SWAP_LAYOUTS and call ldlm_request_cancel() from mdt_swap_layouts() to do the intended early lock cancellation before the handler acquires its own locks. Signed-off-by: John L. Hammond Change-Id: I9d7ba9ac660b136dafa7e307177b92204a1257c3 Reviewed-on: http://review.whamcloud.com/9329 Reviewed-by: Andreas Dilger Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Faccini Bruno Reviewed-by: Oleg Drokin --- lustre/mdc/mdc_request.c | 6 ++++-- lustre/mdt/mdt_handler.c | 9 +++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 85fd541..4e540d6 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -2416,9 +2416,11 @@ static int mdc_ioc_swap_layouts(struct obd_export *exp, * with the request RPC to avoid extra RPC round trips */ count = mdc_resource_get_unused(exp, &op_data->op_fid1, &cancels, - LCK_CR, MDS_INODELOCK_LAYOUT); + LCK_EX, MDS_INODELOCK_LAYOUT | + MDS_INODELOCK_XATTR); count += mdc_resource_get_unused(exp, &op_data->op_fid2, &cancels, - LCK_CR, MDS_INODELOCK_LAYOUT); + LCK_EX, MDS_INODELOCK_LAYOUT | + MDS_INODELOCK_XATTR); req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_SWAP_LAYOUTS); diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 0fa9e83..efe4614 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -1147,6 +1147,10 @@ int mdt_swap_layouts(struct tgt_session_info *tsi) RETURN(-EOPNOTSUPP); info = tsi2mdt_info(tsi); + + if (info->mti_dlm_req != NULL) + ldlm_request_cancel(req, info->mti_dlm_req, 0); + if (req_capsule_get_size(info->mti_pill, &RMF_CAPA1, RCL_CLIENT)) mdt_set_capainfo(info, 0, &info->mti_body->fid1, req_capsule_client_get(info->mti_pill, @@ -4220,8 +4224,9 @@ TGT_MDT_HDL(HABEO_CORPUS| HABEO_REFERO | MUTABOR, MDS_HSM_STATE_SET, TGT_MDT_HDL(HABEO_CORPUS| HABEO_REFERO, MDS_HSM_ACTION, mdt_hsm_action), TGT_MDT_HDL(HABEO_CORPUS| HABEO_REFERO, MDS_HSM_REQUEST, mdt_hsm_request), -TGT_MDT_HDL(HABEO_CORPUS|HABEO_REFERO | MUTABOR, MDS_SWAP_LAYOUTS, - mdt_swap_layouts) +TGT_MDT_HDL(HABEO_CLAVIS | HABEO_CORPUS | HABEO_REFERO | MUTABOR, + MDS_SWAP_LAYOUTS, + mdt_swap_layouts), }; static struct tgt_handler mdt_sec_ctx_ops[] = { -- 1.8.3.1