public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: green@linuxhacker.ru
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	devel@driverdev.osuosl.org,
	Andreas Dilger <andreas.dilger@intel.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Lustre Development List <lustre-devel@lists.lustre.org>,
	Jinshan Xiong <jinshan.xiong@intel.com>,
	Oleg Drokin <green@linuxhacker.ru>
Subject: [PATCH 41/43] staging/lustre/ldlm: ELC picks locks in a safer policy
Date: Wed, 30 Mar 2016 12:48:13 -0400	[thread overview]
Message-ID: <1459356495-2794775-42-git-send-email-green@linuxhacker.ru> (raw)
In-Reply-To: <1459356495-2794775-1-git-send-email-green@linuxhacker.ru>

From: Jinshan Xiong <jinshan.xiong@intel.com>

Change the policy of ELC to pick locks that have no dirty pages,
no page in writeback state, and no locked pages.

Signed-off-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-on: http://review.whamcloud.com/9175
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4300
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Bobi Jam <bobijam@gmail.com>
Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
---
 drivers/staging/lustre/lustre/include/lustre_dlm.h | 13 ++++++----
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  | 28 +++++++++++++++-------
 drivers/staging/lustre/lustre/mdc/mdc_request.c    |  4 ++--
 drivers/staging/lustre/lustre/osc/osc_lock.c       |  4 +++-
 drivers/staging/lustre/lustre/osc/osc_request.c    | 19 ++++++---------
 5 files changed, 39 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
index b1abdc2..9cade14 100644
--- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
+++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
@@ -270,7 +270,7 @@ struct ldlm_pool {
 	struct completion	 pl_kobj_unregister;
 };
 
-typedef int (*ldlm_cancel_for_recovery)(struct ldlm_lock *lock);
+typedef int (*ldlm_cancel_cbt)(struct ldlm_lock *lock);
 
 /**
  * LVB operations.
@@ -447,8 +447,11 @@ struct ldlm_namespace {
 	/** Limit of parallel AST RPC count. */
 	unsigned		ns_max_parallel_ast;
 
-	/** Callback to cancel locks before replaying it during recovery. */
-	ldlm_cancel_for_recovery ns_cancel_for_recovery;
+	/**
+	 * Callback to check if a lock is good to be canceled by ELC or
+	 * during recovery.
+	 */
+	ldlm_cancel_cbt		ns_cancel;
 
 	/** LDLM lock stats */
 	struct lprocfs_stats	*ns_stats;
@@ -480,9 +483,9 @@ static inline int ns_connect_lru_resize(struct ldlm_namespace *ns)
 }
 
 static inline void ns_register_cancel(struct ldlm_namespace *ns,
-				      ldlm_cancel_for_recovery arg)
+				      ldlm_cancel_cbt arg)
 {
-	ns->ns_cancel_for_recovery = arg;
+	ns->ns_cancel = arg;
 }
 
 struct ldlm_lock;
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index 42925ac..2f12194 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -1137,7 +1137,6 @@ static ldlm_policy_res_t ldlm_cancel_no_wait_policy(struct ldlm_namespace *ns,
 						    int count)
 {
 	ldlm_policy_res_t result = LDLM_POLICY_CANCEL_LOCK;
-	ldlm_cancel_for_recovery cb = ns->ns_cancel_for_recovery;
 
 	/* don't check added & count since we want to process all locks
 	 * from unused list.
@@ -1147,7 +1146,7 @@ static ldlm_policy_res_t ldlm_cancel_no_wait_policy(struct ldlm_namespace *ns,
 	switch (lock->l_resource->lr_type) {
 	case LDLM_EXTENT:
 	case LDLM_IBITS:
-		if (cb && cb(lock))
+			if (ns->ns_cancel && ns->ns_cancel(lock) != 0)
 			break;
 	default:
 		result = LDLM_POLICY_SKIP_LOCK;
@@ -1197,8 +1196,13 @@ static ldlm_policy_res_t ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
 	/* Stop when SLV is not yet come from server or lv is smaller than
 	 * it is.
 	 */
-	return (slv == 0 || lv < slv) ?
-		LDLM_POLICY_KEEP_LOCK : LDLM_POLICY_CANCEL_LOCK;
+	if (slv == 0 || lv < slv)
+		return LDLM_POLICY_KEEP_LOCK;
+
+	if (ns->ns_cancel && ns->ns_cancel(lock) == 0)
+		return LDLM_POLICY_KEEP_LOCK;
+
+	return LDLM_POLICY_CANCEL_LOCK;
 }
 
 /**
@@ -1236,11 +1240,17 @@ static ldlm_policy_res_t ldlm_cancel_aged_policy(struct ldlm_namespace *ns,
 						 int unused, int added,
 						 int count)
 {
-	/* Stop LRU processing if young lock is found and we reach past count */
-	return ((added >= count) &&
-		time_before(cfs_time_current(),
-			    cfs_time_add(lock->l_last_used, ns->ns_max_age))) ?
-		LDLM_POLICY_KEEP_LOCK : LDLM_POLICY_CANCEL_LOCK;
+	if (added >= count)
+		return LDLM_POLICY_KEEP_LOCK;
+
+	if (time_before(cfs_time_current(),
+			cfs_time_add(lock->l_last_used, ns->ns_max_age)))
+		return LDLM_POLICY_KEEP_LOCK;
+
+	if (ns->ns_cancel && ns->ns_cancel(lock) == 0)
+		return LDLM_POLICY_KEEP_LOCK;
+
+	return LDLM_POLICY_CANCEL_LOCK;
 }
 
 /**
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index 55dd8ef..98b27f1 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -2249,7 +2249,7 @@ static struct obd_uuid *mdc_get_uuid(struct obd_export *exp)
  * recovery, non zero value will be return if the lock can be canceled,
  * or zero returned for not
  */
-static int mdc_cancel_for_recovery(struct ldlm_lock *lock)
+static int mdc_cancel_weight(struct ldlm_lock *lock)
 {
 	if (lock->l_resource->lr_type != LDLM_IBITS)
 		return 0;
@@ -2331,7 +2331,7 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)
 	sptlrpc_lprocfs_cliobd_attach(obd);
 	ptlrpc_lprocfs_register_obd(obd);
 
-	ns_register_cancel(obd->obd_namespace, mdc_cancel_for_recovery);
+	ns_register_cancel(obd->obd_namespace, mdc_cancel_weight);
 
 	obd->obd_namespace->ns_lvbo = &inode_lvbo;
 
diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c
index 68c5013..49dfe9f 100644
--- a/drivers/staging/lustre/lustre/osc/osc_lock.c
+++ b/drivers/staging/lustre/lustre/osc/osc_lock.c
@@ -635,7 +635,9 @@ static int weigh_cb(const struct lu_env *env, struct cl_io *io,
 {
 	struct cl_page *page = ops->ops_cl.cpl_page;
 
-	if (cl_page_is_vmlocked(env, page)) {
+	if (cl_page_is_vmlocked(env, page) ||
+	    PageDirty(page->cp_vmpage) || PageWriteback(page->cp_vmpage)
+	   ) {
 		(*(unsigned long *)cbdata)++;
 		return CLP_GANG_ABORT;
 	}
diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
index 368b997..a6dc517 100644
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -2292,15 +2292,13 @@ no_match:
 	if (*flags & LDLM_FL_TEST_LOCK)
 		return -ENOLCK;
 	if (intent) {
-		LIST_HEAD(cancels);
-
 		req = ptlrpc_request_alloc(class_exp2cliimp(exp),
 					   &RQF_LDLM_ENQUEUE_LVB);
 		if (!req)
 			return -ENOMEM;
 
-		rc = ldlm_prep_enqueue_req(exp, req, &cancels, 0);
-		if (rc) {
+		rc = ptlrpc_request_pack(req, LUSTRE_DLM_VERSION, LDLM_ENQUEUE);
+		if (rc < 0) {
 			ptlrpc_request_free(req);
 			return rc;
 		}
@@ -3110,17 +3108,14 @@ static int osc_import_event(struct obd_device *obd,
  * \retval zero the lock can't be canceled
  * \retval other ok to cancel
  */
-static int osc_cancel_for_recovery(struct ldlm_lock *lock)
+static int osc_cancel_weight(struct ldlm_lock *lock)
 {
 	/*
-	 * Cancel all unused extent lock in granted mode LCK_PR or LCK_CR.
-	 *
-	 * XXX as a future improvement, we can also cancel unused write lock
-	 * if it doesn't have dirty data and active mmaps.
+	 * Cancel all unused and granted extent lock.
 	 */
 	if (lock->l_resource->lr_type == LDLM_EXTENT &&
-	    (lock->l_granted_mode == LCK_PR ||
-	     lock->l_granted_mode == LCK_CR) && osc_ldlm_weigh_ast(lock) == 0)
+	    lock->l_granted_mode == lock->l_req_mode &&
+	    osc_ldlm_weigh_ast(lock) == 0)
 		return 1;
 
 	return 0;
@@ -3197,7 +3192,7 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 	}
 
 	INIT_LIST_HEAD(&cli->cl_grant_shrink_list);
-	ns_register_cancel(obd->obd_namespace, osc_cancel_for_recovery);
+	ns_register_cancel(obd->obd_namespace, osc_cancel_weight);
 	return rc;
 
 out_ptlrpcd_work:
-- 
2.1.0

  parent reply	other threads:[~2016-03-30 16:53 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-30 16:47 [PATCH 00/43] Lustre IO stack simplifications and cleanups green
2016-03-30 16:47 ` [PATCH 01/43] staging/lustre/obdclass: limit lu_site hash table size green
2016-03-30 16:47 ` [PATCH 02/43] staging/lustre: Get rid of CFS_PAGE_MASK green
2016-03-30 16:47 ` [PATCH 03/43] staging/lustre: merge lclient/*.c into llite/ green
2016-03-30 16:47 ` [PATCH 04/43] staging/lustre: Reintroduce global env list green
2016-03-30 16:47 ` [PATCH 05/43] staging/lustre/osc: Adjustment on osc LRU for performance green
2016-03-30 16:47 ` [PATCH 06/43] staging/lustre/osc: to drop LRU pages with cl_lru_work green
2016-03-30 16:47 ` [PATCH 07/43] staging/lustre/clio: collapse layer of cl_page green
2016-03-30 16:47 ` [PATCH 08/43] staging/lustre/obdclass: Add a preallocated percpu cl_env green
2016-03-30 16:47 ` [PATCH 09/43] staging/lustre/clio: add pages into writeback cache in batches green
2016-03-30 16:47 ` [PATCH 10/43] staging/lustre/osc: add weight function for DLM lock green
2016-03-30 16:47 ` [PATCH 11/43] staging/lustre/clio: remove stackable cl_page completely green
2016-03-30 16:47 ` [PATCH 12/43] staging/lustre/clio: optimize read ahead code green
2016-03-30 16:47 ` [PATCH 13/43] staging/lustre/llite: remove lli_lvb green
2016-03-30 16:47 ` [PATCH 14/43] staging/lustre/lmv: remove lmv_init_{lock,unlock}() green
2016-03-30 16:47 ` [PATCH 15/43] staging/lustre/obd: remove struct client_obd_lock green
2016-03-30 16:47 ` [PATCH 16/43] staging/lustre/llite: remove some cl wrappers green
2016-03-30 16:47 ` [PATCH 17/43] staging/lustre: Remove struct ll_iattr green
2016-03-30 16:47 ` [PATCH 18/43] staging/lustre/clio: generalize cl_sync_io green
2016-03-30 16:47 ` [PATCH 19/43] staging/lustre/clio: cl_lock simplification green
2016-03-30 16:47 ` [PATCH 20/43] staging/lustre: update comments after " green
2016-03-30 16:47 ` [PATCH 21/43] staging/lustre/llite: clip page correctly for vvp_io_commit_sync green
2016-03-30 16:47 ` [PATCH 22/43] staging/lustre/llite: deadlock for page write green
2016-03-30 16:47 ` [PATCH 23/43] staging/lustre/llite: make sure we do cl_page_clip on the last page green
2016-03-30 16:47 ` [PATCH 24/43] staging/lustre/llite: merge lclient.h into llite/vvp_internal.h green
2016-03-30 16:47 ` [PATCH 25/43] staging/lustre/llite: rename ccc_device to vvp_device green
2016-03-30 16:47 ` [PATCH 26/43] staging/lustre/llite: rename ccc_object to vvp_object green
2016-03-30 16:47 ` [PATCH 27/43] staging/lustre/llite: rename ccc_page to vvp_page green
2016-03-30 16:48 ` [PATCH 28/43] staging/lustre/llite: rename ccc_lock to vvp_lock green
2016-03-30 16:48 ` [PATCH 29/43] staging/lustre:llite: remove struct ll_ra_read green
2016-03-30 16:48 ` [PATCH 30/43] staging/lustre/llite: merge ccc_io and vvp_io green
2016-03-30 16:48 ` [PATCH 31/43] staging/lustre/llite: use vui prefix for struct vvp_io members green
2016-03-30 16:48 ` [PATCH 32/43] staging/lustre/llite: move vvp_io functions to vvp_io.c green
2016-03-30 16:48 ` [PATCH 33/43] staging/lustre/llite: rename ccc_req to vvp_req green
2016-03-30 16:48 ` [PATCH 34/43] staging/lustre/llite: Rename struct ccc_grouplock to ll_grouplock green
2016-03-30 16:48 ` [PATCH 35/43] staging/lustre/llite: Rename struct vvp_thread_info to ll_thread_info green
2016-03-30 23:13   ` kbuild test robot
2016-03-30 23:39     ` [lustre-devel] " Oleg Drokin
2016-03-30 16:48 ` [PATCH 36/43] staging/lustre/llite: rename struct ccc_thread_info to vvp_thread_info green
2016-03-30 16:48 ` [PATCH 37/43] staging/lustre/llite: Remove ccc_global_{init,fini}() green
2016-03-30 16:48 ` [PATCH 38/43] staging/lustre/llite: Move ll_dirent_type_get and make it static green
2016-03-30 16:48 ` [PATCH 39/43] staging/lustre/llite: Move several declarations to llite_internal.h green
2016-03-30 16:48 ` [PATCH 40/43] staging/lustre/llite: Remove unused vui_local_lock field green
2016-03-30 16:48 ` green [this message]
2016-03-30 16:48 ` [PATCH 42/43] staging/lustre/ldlm: revert changes to ldlm_cancel_aged_policy() green
2016-03-30 16:48 ` [PATCH 43/43] staging/lustre/ldlm: restore the ELC for enqueue green

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1459356495-2794775-42-git-send-email-green@linuxhacker.ru \
    --to=green@linuxhacker.ru \
    --cc=andreas.dilger@intel.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jinshan.xiong@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lustre-devel@lists.lustre.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox