From 24b28252fd5eb9628581ca7829a37ef407b07849 Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Fri, 29 Nov 2024 17:27:04 -0500 Subject: [PATCH] LU-18500 mdc: rename mdc_get_unused It doesn't 'get' unused - it cancels them. Actually, it cancels unused conflicting locks, but that made the name too long and hopefully it's clear from the signature. Test-Parameters: trivial Signed-off-by: Patrick Farrell Change-Id: I3f01f79a63069dfb019667ff4ca0d427e1699511 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57200 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Timothy Day Reviewed-by: Andreas Dilger Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin --- lustre/mdc/mdc_dev.c | 6 ++-- lustre/mdc/mdc_internal.h | 14 ++++---- lustre/mdc/mdc_locks.c | 24 ++++++------- lustre/mdc/mdc_reint.c | 89 ++++++++++++++++++++++++----------------------- lustre/mdc/mdc_request.c | 22 ++++++------ 5 files changed, 78 insertions(+), 77 deletions(-) diff --git a/lustre/mdc/mdc_dev.c b/lustre/mdc/mdc_dev.c index 92f58d1..894f259 100644 --- a/lustre/mdc/mdc_dev.c +++ b/lustre/mdc/mdc_dev.c @@ -759,9 +759,9 @@ static int mdc_enqueue_send(const struct lu_env *env, struct obd_export *exp, /* For WRITE lock cancel other locks on resource early if any */ if (einfo->ei_mode & LCK_PW) - count = mdc_resource_get_unused_res(exp, res_id, &cancels, - einfo->ei_mode, - MDS_INODELOCK_DOM); + count = mdc_resource_cancel_unused_res(exp, res_id, &cancels, + einfo->ei_mode, + MDS_INODELOCK_DOM); else count = 0; diff --git a/lustre/mdc/mdc_internal.h b/lustre/mdc/mdc_internal.h index d07e7e8..6ccb55f 100644 --- a/lustre/mdc/mdc_internal.h +++ b/lustre/mdc/mdc_internal.h @@ -77,13 +77,13 @@ int mdc_enqueue_async(struct obd_export *exp, struct ldlm_enqueue_info *einfo, obd_enqueue_update_f upcall, struct md_op_data *op_data, const union ldlm_policy_data *policy, __u64 lock_flags); -int mdc_resource_get_unused_res(struct obd_export *exp, - struct ldlm_res_id *res_id, - struct list_head *cancels, - enum ldlm_mode mode, __u64 bits); -int mdc_resource_get_unused(struct obd_export *exp, const struct lu_fid *fid, - struct list_head *cancels, enum ldlm_mode mode, - __u64 bits); +int mdc_resource_cancel_unused_res(struct obd_export *exp, + struct ldlm_res_id *res_id, + struct list_head *cancels, + enum ldlm_mode mode, __u64 bits); +int mdc_resource_cancel_unused(struct obd_export *exp, const struct lu_fid *fid, + struct list_head *cancels, enum ldlm_mode mode, + __u64 bits); /* mdc/mdc_request.c */ int mdc_fid_alloc(const struct lu_env *env, struct obd_export *exp, struct lu_fid *fid, struct md_op_data *op_data); diff --git a/lustre/mdc/mdc_locks.c b/lustre/mdc/mdc_locks.c index fbfc1f4..8500ae1 100644 --- a/lustre/mdc/mdc_locks.c +++ b/lustre/mdc/mdc_locks.c @@ -276,9 +276,9 @@ mdc_intent_open_pack(struct obd_export *exp, struct lookup_intent *it, else mode = LCK_CR; } - count = mdc_resource_get_unused(exp, &op_data->op_fid2, - &cancels, mode, - MDS_INODELOCK_OPEN); + count = mdc_resource_cancel_unused(exp, &op_data->op_fid2, + &cancels, mode, + MDS_INODELOCK_OPEN); } /* If CREATE, cancel parent's UPDATE lock. */ @@ -286,9 +286,9 @@ mdc_intent_open_pack(struct obd_export *exp, struct lookup_intent *it, mode = LCK_EX; else mode = LCK_CR; - count += mdc_resource_get_unused(exp, &op_data->op_fid1, - &cancels, mode, - MDS_INODELOCK_UPDATE); + count += mdc_resource_cancel_unused(exp, &op_data->op_fid1, + &cancels, mode, + MDS_INODELOCK_UPDATE); req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_INTENT_OPEN); @@ -447,9 +447,9 @@ mdc_intent_create_pack(struct obd_export *exp, struct lookup_intent *it, if (fid_is_sane(&op_data->op_fid1)) /* cancel parent's UPDATE lock. */ - count = mdc_resource_get_unused(exp, &op_data->op_fid1, - &cancels, LCK_EX, - MDS_INODELOCK_UPDATE); + count = mdc_resource_cancel_unused(exp, &op_data->op_fid1, + &cancels, LCK_EX, + MDS_INODELOCK_UPDATE); req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_INTENT_CREATE); @@ -708,9 +708,9 @@ static struct ptlrpc_request *mdc_intent_layout_pack(struct obd_export *exp, if (fid_is_sane(&op_data->op_fid2) && (it->it_op & IT_LAYOUT) && (it->it_open_flags & FMODE_WRITE)) { - count = mdc_resource_get_unused(exp, &op_data->op_fid2, - &cancels, LCK_EX, - MDS_INODELOCK_LAYOUT); + count = mdc_resource_cancel_unused(exp, &op_data->op_fid2, + &cancels, LCK_EX, + MDS_INODELOCK_LAYOUT); } req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_CLIENT, 0); diff --git a/lustre/mdc/mdc_reint.c b/lustre/mdc/mdc_reint.c index d9aa4dc..6faa624 100644 --- a/lustre/mdc/mdc_reint.c +++ b/lustre/mdc/mdc_reint.c @@ -40,11 +40,12 @@ static int mdc_reint(struct ptlrpc_request *request, int level) /* Find and cancel locally locks matched by inode @bits & @mode in the resource * found by @fid. Found locks are added into @cancel list. Returns the amount of - * locks added to @cancels list. */ -int mdc_resource_get_unused_res(struct obd_export *exp, - struct ldlm_res_id *res_id, - struct list_head *cancels, - enum ldlm_mode mode, __u64 bits) + * locks added to @cancels list. + */ +int mdc_resource_cancel_unused_res(struct obd_export *exp, + struct ldlm_res_id *res_id, + struct list_head *cancels, + enum ldlm_mode mode, __u64 bits) { struct ldlm_namespace *ns = exp->exp_obd->obd_namespace; union ldlm_policy_data policy = { { 0 } }; @@ -73,14 +74,14 @@ int mdc_resource_get_unused_res(struct obd_export *exp, RETURN(count); } -int mdc_resource_get_unused(struct obd_export *exp, const struct lu_fid *fid, - struct list_head *cancels, enum ldlm_mode mode, - __u64 bits) +int mdc_resource_cancel_unused(struct obd_export *exp, const struct lu_fid *fid, + struct list_head *cancels, enum ldlm_mode mode, + __u64 bits) { struct ldlm_res_id res_id; fid_build_reg_res_name(fid, &res_id); - return mdc_resource_get_unused_res(exp, &res_id, cancels, mode, bits); + return mdc_resource_cancel_unused_res(exp, &res_id, cancels, mode, bits); } int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data, @@ -99,8 +100,8 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data, bits |= MDS_INODELOCK_LOOKUP; if ((op_data->op_flags & MF_MDC_CANCEL_FID1) && (fid_is_sane(&op_data->op_fid1))) - count = mdc_resource_get_unused(exp, &op_data->op_fid1, - &cancels, LCK_EX, bits); + count = mdc_resource_cancel_unused(exp, &op_data->op_fid1, + &cancels, LCK_EX, bits); req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_REINT_SETATTR); if (req == NULL) { @@ -168,9 +169,9 @@ rebuild: count = 0; if ((op_data->op_flags & MF_MDC_CANCEL_FID1) && (fid_is_sane(&op_data->op_fid1))) - count = mdc_resource_get_unused(exp, &op_data->op_fid1, - &cancels, LCK_EX, - MDS_INODELOCK_UPDATE); + count = mdc_resource_cancel_unused(exp, &op_data->op_fid1, + &cancels, LCK_EX, + MDS_INODELOCK_UPDATE); req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_REINT_CREATE_ACL); @@ -316,18 +317,18 @@ int mdc_unlink(struct obd_export *exp, struct md_op_data *op_data, if ((op_data->op_flags & MF_MDC_CANCEL_FID1) && (fid_is_sane(&op_data->op_fid1))) - count = mdc_resource_get_unused(exp, &op_data->op_fid1, - &cancels, LCK_EX, - MDS_INODELOCK_UPDATE); + count = mdc_resource_cancel_unused(exp, &op_data->op_fid1, + &cancels, LCK_EX, + MDS_INODELOCK_UPDATE); if ((op_data->op_flags & MF_MDC_CANCEL_FID3) && (fid_is_sane(&op_data->op_fid3))) /* cancel DOM lock only if it has no data to flush */ - count += mdc_resource_get_unused(exp, &op_data->op_fid3, - &cancels, LCK_EX, - op_data->op_cli_flags & - CLI_DIRTY_DATA ? - MDS_INODELOCK_ELC : - MDS_INODELOCK_FULL); + count += mdc_resource_cancel_unused(exp, &op_data->op_fid3, + &cancels, LCK_EX, + op_data->op_cli_flags & + CLI_DIRTY_DATA ? + MDS_INODELOCK_ELC : + MDS_INODELOCK_FULL); req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_REINT_UNLINK); if (req == NULL) { @@ -384,14 +385,14 @@ int mdc_link(struct obd_export *exp, struct md_op_data *op_data, if ((op_data->op_flags & MF_MDC_CANCEL_FID2) && (fid_is_sane(&op_data->op_fid2))) - count = mdc_resource_get_unused(exp, &op_data->op_fid2, - &cancels, LCK_EX, - MDS_INODELOCK_UPDATE); + count = mdc_resource_cancel_unused(exp, &op_data->op_fid2, + &cancels, LCK_EX, + MDS_INODELOCK_UPDATE); if ((op_data->op_flags & MF_MDC_CANCEL_FID1) && (fid_is_sane(&op_data->op_fid1))) - count += mdc_resource_get_unused(exp, &op_data->op_fid1, - &cancels, LCK_EX, - MDS_INODELOCK_UPDATE); + count += mdc_resource_cancel_unused(exp, &op_data->op_fid1, + &cancels, LCK_EX, + MDS_INODELOCK_UPDATE); req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_REINT_LINK); if (req == NULL) { @@ -448,24 +449,24 @@ int mdc_rename(struct obd_export *exp, struct md_op_data *op_data, if ((op_data->op_flags & MF_MDC_CANCEL_FID1) && (fid_is_sane(&op_data->op_fid1))) - count = mdc_resource_get_unused(exp, &op_data->op_fid1, - &cancels, LCK_EX, - MDS_INODELOCK_UPDATE); + count = mdc_resource_cancel_unused(exp, &op_data->op_fid1, + &cancels, LCK_EX, + MDS_INODELOCK_UPDATE); if ((op_data->op_flags & MF_MDC_CANCEL_FID2) && (fid_is_sane(&op_data->op_fid2))) - count += mdc_resource_get_unused(exp, &op_data->op_fid2, - &cancels, LCK_EX, - MDS_INODELOCK_UPDATE); + count += mdc_resource_cancel_unused(exp, &op_data->op_fid2, + &cancels, LCK_EX, + MDS_INODELOCK_UPDATE); if ((op_data->op_flags & MF_MDC_CANCEL_FID3) && (fid_is_sane(&op_data->op_fid3))) - count += mdc_resource_get_unused(exp, &op_data->op_fid3, - &cancels, LCK_EX, - MDS_INODELOCK_LOOKUP); + count += mdc_resource_cancel_unused(exp, &op_data->op_fid3, + &cancels, LCK_EX, + MDS_INODELOCK_LOOKUP); if ((op_data->op_flags & MF_MDC_CANCEL_FID4) && (fid_is_sane(&op_data->op_fid4))) - count += mdc_resource_get_unused(exp, &op_data->op_fid4, - &cancels, LCK_EX, - MDS_INODELOCK_ELC); + count += mdc_resource_cancel_unused(exp, &op_data->op_fid4, + &cancels, LCK_EX, + MDS_INODELOCK_ELC); req = ptlrpc_request_alloc(class_exp2cliimp(exp), op_data->op_cli_flags & CLI_MIGRATE ? @@ -542,9 +543,9 @@ int mdc_file_resync(struct obd_export *exp, struct md_op_data *op_data) if (op_data->op_flags & MF_MDC_CANCEL_FID1 && fid_is_sane(&op_data->op_fid1)) - count = mdc_resource_get_unused(exp, &op_data->op_fid1, - &cancels, LCK_EX, - MDS_INODELOCK_LAYOUT); + count = mdc_resource_cancel_unused(exp, &op_data->op_fid1, + &cancels, LCK_EX, + MDS_INODELOCK_LAYOUT); req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_REINT_RESYNC); diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 1df4e7b..9db02c3 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -376,9 +376,9 @@ static int mdc_xattr_common(struct obd_export *exp,const struct req_format *fmt, req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_CLIENT, 0); - count = mdc_resource_get_unused(exp, fid, - &cancels, LCK_EX, - MDS_INODELOCK_XATTR); + count = mdc_resource_cancel_unused(exp, fid, + &cancels, LCK_EX, + MDS_INODELOCK_XATTR); rc = mdc_prep_elc_req(exp, req, MDS_REINT, &cancels, count); if (rc) @@ -1976,8 +1976,8 @@ static inline int mdc_hsm_request_lock_to_cancel(struct obd_export *exp, for (i = 0; i < req_hr->hr_itemcount; i++, hui++) { if (!fid_is_sane(&hui->hui_fid)) continue; - count += mdc_resource_get_unused(exp, &hui->hui_fid, cancels, - LCK_EX, MDS_INODELOCK_LAYOUT); + count += mdc_resource_cancel_unused(exp, &hui->hui_fid, cancels, + LCK_EX, MDS_INODELOCK_LAYOUT); } return count; @@ -2202,12 +2202,12 @@ static int mdc_ioc_swap_layouts(struct obd_export *exp, * So the client must cancel its layout locks on the 2 fids * with the request RPC to avoid extra RPC round trips. */ - count = mdc_resource_get_unused(exp, &op_data->op_fid1, &cancels, - LCK_EX, MDS_INODELOCK_LAYOUT | - MDS_INODELOCK_XATTR); - count += mdc_resource_get_unused(exp, &op_data->op_fid2, &cancels, - LCK_EX, MDS_INODELOCK_LAYOUT | - MDS_INODELOCK_XATTR); + count = mdc_resource_cancel_unused(exp, &op_data->op_fid1, &cancels, + LCK_EX, MDS_INODELOCK_LAYOUT | + MDS_INODELOCK_XATTR); + count += mdc_resource_cancel_unused(exp, &op_data->op_fid2, &cancels, + LCK_EX, MDS_INODELOCK_LAYOUT | + MDS_INODELOCK_XATTR); req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_SWAP_LAYOUTS); -- 1.8.3.1