[PATCH 16/18] lustre: mdc: Use early cancels for hsm requests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Etienne AUJAMES <eaujames@xxxxxxx>

HSM RELEASE and RESTORE requests take EX layout lock on the MDT side.
So the client can use early cancel for its local lock on the resource
to limit the contention (mdt side).

This patch does not pack ldlm request inside the hsm request because
the field (RMF_DLM_REQ) does not exist in the request. Adding this
field inside the request would break compatibility with _old_ servers.

WC-bug-id: https://jira.whamcloud.com/browse/LU-15132
Lustre-commit: 60d2a4b0efa4a944b ("LU-15132 mdc: Use early cancels for hsm requests")
Signed-off-by: Etienne AUJAMES <eaujames@xxxxxxx>
Reviewed-on: https://review.whamcloud.com/47181
Reviewed-by: Nikitas Angelinas <nikitas.angelinas@xxxxxxx>
Reviewed-by: Sergey Cheremencev <sergey.cheremencev@xxxxxxx>
Reviewed-by: Oleg Drokin <green@xxxxxxxxxxxxx>
Signed-off-by: James Simmons <jsimmons@xxxxxxxxxxxxx>
---
 fs/lustre/mdc/mdc_request.c | 37 +++++++++++++++++++++++++++++++++----
 1 file changed, 33 insertions(+), 4 deletions(-)

diff --git a/fs/lustre/mdc/mdc_request.c b/fs/lustre/mdc/mdc_request.c
index f553d44..bb51878 100644
--- a/fs/lustre/mdc/mdc_request.c
+++ b/fs/lustre/mdc/mdc_request.c
@@ -2000,6 +2000,32 @@ static int mdc_ioc_hsm_state_set(struct obd_export *exp,
 	return rc;
 }
 
+/* For RESTORE and RELEASE the mdt will take EX lock on the file layout.
+ * So we can use early cancel on client side locks for that resource.
+ */
+static inline int mdc_hsm_request_lock_to_cancel(struct obd_export *exp,
+						 struct hsm_user_request *hur,
+						 struct list_head *cancels)
+{
+	struct hsm_user_item *hui = &hur->hur_user_item[0];
+	struct hsm_request *req_hr = &hur->hur_request;
+	int count = 0;
+	int i;
+
+	if (req_hr->hr_action != HUA_RESTORE &&
+	    req_hr->hr_action != HUA_RELEASE)
+		return 0;
+
+	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);
+	}
+
+	return count;
+}
+
 static int mdc_ioc_hsm_request(struct obd_export *exp,
 			       struct hsm_user_request *hur)
 {
@@ -2008,13 +2034,13 @@ static int mdc_ioc_hsm_request(struct obd_export *exp,
 	struct hsm_request *req_hr;
 	struct hsm_user_item *req_hui;
 	char *req_opaque;
+	LIST_HEAD(cancels);
+	int count;
 	int rc;
 
 	req = ptlrpc_request_alloc(imp, &RQF_MDS_HSM_REQUEST);
-	if (!req) {
-		rc = -ENOMEM;
-		goto out;
-	}
+	if (!req)
+		return -ENOMEM;
 
 	req_capsule_set_size(&req->rq_pill, &RMF_MDS_HSM_USER_ITEM, RCL_CLIENT,
 			     hur->hur_request.hr_itemcount
@@ -2028,6 +2054,9 @@ static int mdc_ioc_hsm_request(struct obd_export *exp,
 		return rc;
 	}
 
+	/* Cancel existing locks */
+	count = mdc_hsm_request_lock_to_cancel(exp, hur, &cancels);
+	ldlm_cli_cancel_list(&cancels, count, NULL, 0);
 	mdc_pack_body(&req->rq_pill, NULL, 0, 0, -1, 0);
 
 	/* Copy hsm_request struct */
-- 
1.8.3.1




[Index of Archives]     [linux Cryptography]     [Asterisk App Development]     [PJ SIP]     [Gnu Gatekeeper]     [IETF Sipping]     [Info Cyrus]     [ALSA User]     [Fedora Linux Users]     [Linux SCTP]     [DCCP]     [Gimp]     [Yosemite News]     [Deep Creek Hot Springs]     [Yosemite Campsites]     [ISDN Cause Codes]

  Powered by Linux