From cb61ed93f8563c26b6a6db396478fe54f8dc42cb Mon Sep 17 00:00:00 2001 From: Mikhail Pershin Date: Mon, 22 Apr 2019 15:20:45 +0300 Subject: [PATCH] LU-12212 mdt: fix SECCTX reply buffer handling LU-9193 changes for inline SECCTX in reply may cause often resends and reconnects in some loads, e.g. dbench runs. That is caused by missed buffer shrink when SECCTX is not used. Patch fo the following: - shrink SECCTX buffer if it is not used - in mdt_getattr_name_lock() fill SECCTX buffer a bit earlier for simpler handling DoM size attributes, also move LDLM_LOCK_PUT() at the end of block to don't use 'lock' after LDLM_LOCK_PUT() Fixes: fca35f74f9ec ("LU-9193 security: return security context for metadata ops") Test-Parameters: clientselinux testlist=sanity envdefinitions=EXCEPT=103a Test-Parameters: mdscount=2 mdtcount=4 clientselinux testlist=recovery-small,sanity-selinux Signed-off-by: Mikhail Pershin Change-Id: I9beffd06f76c3bd8e826ba4ab0ce70ac3f57951c Reviewed-on: https://review.whamcloud.com/34734 Tested-by: Jenkins Reviewed-by: Andreas Dilger Reviewed-by: Patrick Farrell Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/mdt/mdt_handler.c | 49 +++++++++++++++++++++++------------------------- lustre/mdt/mdt_lib.c | 6 ++++++ 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 2ce7a68..6055b0a 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -1626,7 +1626,6 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info, __u64 try_bits = 0; bool is_resent; int ma_need = 0; - bool deal_with_dom = false; int rc; ENTRY; @@ -1853,14 +1852,17 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info, GOTO(out_child, rc); } - lock = ldlm_handle2lock(&lhc->mlh_reg_lh); - /* finally, we can get attr for child. */ rc = mdt_getattr_internal(info, child, ma_need); if (unlikely(rc != 0)) { mdt_object_unlock(info, child, lhc, 1); - GOTO(out_lock, rc); - } else if (lock) { + GOTO(out_child, rc); + } + + mdt_pack_secctx_in_reply(info, child); + + lock = ldlm_handle2lock(&lhc->mlh_reg_lh); + if (lock) { /* Debugging code. */ LDLM_DEBUG(lock, "Returning lock to client"); LASSERTF(fid_res_name_eq(mdt_object_fid(child), @@ -1871,32 +1873,27 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info, if (S_ISREG(lu_object_attr(&child->mot_obj)) && mdt_object_exists(child) && !mdt_object_remote(child) && - child != parent) - deal_with_dom = true; - } - - mdt_pack_secctx_in_reply(info, child); - -out_lock: - if (lock) + child != parent) { + mdt_object_put(info->mti_env, child); + rc = mdt_pack_size2body(info, child_fid, + &lhc->mlh_reg_lh); + if (rc != 0 && child_bits & MDS_INODELOCK_DOM) { + /* DOM lock was taken in advance but this is + * not DoM file. Drop the lock. + */ + lock_res_and_lock(lock); + ldlm_inodebits_drop(lock, MDS_INODELOCK_DOM); + unlock_res_and_lock(lock); + } + LDLM_LOCK_PUT(lock); + GOTO(out_parent, rc = 0); + } LDLM_LOCK_PUT(lock); + } EXIT; out_child: mdt_object_put(info->mti_env, child); - if (deal_with_dom) { - rc = mdt_pack_size2body(info, child_fid, - &lhc->mlh_reg_lh); - if (rc != 0 && child_bits & MDS_INODELOCK_DOM) { - /* DOM lock was taken in advance but this is - * not DoM file. Drop the lock. - */ - lock_res_and_lock(lock); - ldlm_inodebits_drop(lock, MDS_INODELOCK_DOM); - unlock_res_and_lock(lock); - } - rc = 0; - } out_parent: if (lhp) mdt_object_unlock(info, parent, lhp, 1); diff --git a/lustre/mdt/mdt_lib.c b/lustre/mdt/mdt_lib.c index b6619fd..a7d5130 100644 --- a/lustre/mdt/mdt_lib.c +++ b/lustre/mdt/mdt_lib.c @@ -790,6 +790,12 @@ int mdt_fix_reply(struct mdt_thread_info *info) req_capsule_shrink(pill, &RMF_LOGCOOKIES, acl_size, RCL_SERVER); } + /* Shrink optional SECCTX buffer if it is not used */ + if (req_capsule_has_field(pill, &RMF_FILE_SECCTX, RCL_SERVER) && + req_capsule_get_size(pill, &RMF_FILE_SECCTX, RCL_SERVER) != 0 && + !(body->mbo_valid & OBD_MD_SECCTX)) + req_capsule_shrink(pill, &RMF_FILE_SECCTX, 0, RCL_SERVER); + /* * Some more field should be shrinked if needed. * This should be done by those who added fields to reply message. -- 1.8.3.1