[lustre-devel] [PATCH 02/22] lustre: osc: Remove oap lock

James Simmons jsimmons at infradead.org
Sun Nov 20 06:16:48 PST 2022


From: Patrick Farrell <pfarrell at whamcloud.com>

The OAP lock is taken around setting the oap flags, but not
any of the other fields in oap.  As far as I can tell, this
is just some cargo cult belief about locking - there's no
reason for it.

Remove it entirely.  (From the code, a queued spin lock
appears to be 12 bytes on x86_64.)

WC-bug-id: https://jira.whamcloud.com/browse/LU-15619
Lustre-commit: b2274a716087fad24 ("LU-15619 osc: Remove oap lock")
Signed-off-by: Patrick Farrell <pfarrell at whamcloud.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/46719
Reviewed-by: James Simmons <jsimmons at infradead.org>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Reviewed-by: Zhenyu Xu <bobijam at hotmail.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
 fs/lustre/include/lustre_osc.h |  2 --
 fs/lustre/osc/osc_cache.c      | 11 -----------
 fs/lustre/osc/osc_io.c         |  8 ++------
 fs/lustre/osc/osc_page.c       |  5 -----
 4 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/fs/lustre/include/lustre_osc.h b/fs/lustre/include/lustre_osc.h
index 2e8c184..a0f1afc 100644
--- a/fs/lustre/include/lustre_osc.h
+++ b/fs/lustre/include/lustre_osc.h
@@ -88,8 +88,6 @@ struct osc_async_page {
 
 	struct ptlrpc_request	*oap_request;
 	struct osc_object	*oap_obj;
-
-	spinlock_t		oap_lock;
 };
 
 #define oap_page	oap_brw_page.pg
diff --git a/fs/lustre/osc/osc_cache.c b/fs/lustre/osc/osc_cache.c
index e563809..b5776a1 100644
--- a/fs/lustre/osc/osc_cache.c
+++ b/fs/lustre/osc/osc_cache.c
@@ -1140,9 +1140,7 @@ static int osc_extent_make_ready(const struct lu_env *env,
 		rc = osc_make_ready(env, oap, OBD_BRW_WRITE);
 		switch (rc) {
 		case 0:
-			spin_lock(&oap->oap_lock);
 			oap->oap_async_flags |= ASYNC_READY;
-			spin_unlock(&oap->oap_lock);
 			break;
 		case -EALREADY:
 			LASSERT((oap->oap_async_flags & ASYNC_READY) != 0);
@@ -1165,9 +1163,7 @@ static int osc_extent_make_ready(const struct lu_env *env,
 			 "last_oap_count %d\n", last_oap_count);
 		LASSERT(last->oap_page_off + last_oap_count <= PAGE_SIZE);
 		last->oap_count = last_oap_count;
-		spin_lock(&last->oap_lock);
 		last->oap_async_flags |= ASYNC_COUNT_STABLE;
-		spin_unlock(&last->oap_lock);
 	}
 
 	/* for the rest of pages, we don't need to call osf_refresh_count()
@@ -1176,9 +1172,7 @@ static int osc_extent_make_ready(const struct lu_env *env,
 	list_for_each_entry(oap, &ext->oe_pages, oap_pending_item) {
 		if (!(oap->oap_async_flags & ASYNC_COUNT_STABLE)) {
 			oap->oap_count = PAGE_SIZE - oap->oap_page_off;
-			spin_lock(&last->oap_lock);
 			oap->oap_async_flags |= ASYNC_COUNT_STABLE;
-			spin_unlock(&last->oap_lock);
 		}
 	}
 
@@ -1866,9 +1860,7 @@ static void osc_ap_completion(const struct lu_env *env, struct client_obd *cli,
 	}
 
 	/* As the transfer for this page is being done, clear the flags */
-	spin_lock(&oap->oap_lock);
 	oap->oap_async_flags = 0;
-	spin_unlock(&oap->oap_lock);
 
 	if (oap->oap_cmd & OBD_BRW_WRITE && xid > 0) {
 		spin_lock(&cli->cl_loi_list_lock);
@@ -2330,7 +2322,6 @@ int osc_prep_async_page(struct osc_object *osc, struct osc_page *ops,
 	INIT_LIST_HEAD(&oap->oap_pending_item);
 	INIT_LIST_HEAD(&oap->oap_rpc_item);
 
-	spin_lock_init(&oap->oap_lock);
 	CDEBUG(D_INFO, "oap %p vmpage %p obj off %llu\n",
 	       oap, vmpage, oap->oap_obj_off);
 	return 0;
@@ -2619,9 +2610,7 @@ int osc_flush_async_page(const struct lu_env *env, struct cl_io *io,
 	if (rc)
 		goto out;
 
-	spin_lock(&oap->oap_lock);
 	oap->oap_async_flags |= ASYNC_READY | ASYNC_URGENT;
-	spin_unlock(&oap->oap_lock);
 
 	if (current->flags & PF_MEMALLOC)
 		ext->oe_memalloc = 1;
diff --git a/fs/lustre/osc/osc_io.c b/fs/lustre/osc/osc_io.c
index aa8f61d..b9362d9 100644
--- a/fs/lustre/osc/osc_io.c
+++ b/fs/lustre/osc/osc_io.c
@@ -192,12 +192,8 @@ int osc_io_submit(const struct lu_env *env, const struct cl_io_slice *ios,
 			continue;
 		}
 
-		if (page->cp_type != CPT_TRANSIENT) {
-			spin_lock(&oap->oap_lock);
-			oap->oap_async_flags = ASYNC_URGENT | ASYNC_READY;
-			oap->oap_async_flags |= ASYNC_COUNT_STABLE;
-			spin_unlock(&oap->oap_lock);
-		}
+		if (page->cp_type != CPT_TRANSIENT)
+			oap->oap_async_flags = ASYNC_URGENT | ASYNC_READY | ASYNC_COUNT_STABLE;
 
 		osc_page_submit(env, opg, crt, brw_flags);
 		list_add_tail(&oap->oap_pending_item, &list);
diff --git a/fs/lustre/osc/osc_page.c b/fs/lustre/osc/osc_page.c
index ba10ba3..667825a 100644
--- a/fs/lustre/osc/osc_page.c
+++ b/fs/lustre/osc/osc_page.c
@@ -204,12 +204,7 @@ static void osc_page_clip(const struct lu_env *env,
 	opg->ops_from = from;
 	/* argument @to is exclusive, but @ops_to is inclusive */
 	opg->ops_to = to - 1;
-	/* This isn't really necessary for transient pages, but we also don't
-	 * call clip on transient pages often, so it's OK.
-	 */
-	spin_lock(&oap->oap_lock);
 	oap->oap_async_flags |= ASYNC_COUNT_STABLE;
-	spin_unlock(&oap->oap_lock);
 }
 
 static int osc_page_flush(const struct lu_env *env,
-- 
1.8.3.1



More information about the lustre-devel mailing list