All of lore.kernel.org
 help / color / mirror / Atom feed
From: trondmy@kernel.org
To: linux-nfs@vger.kernel.org
Subject: [PATCH 17/22] NFS/pNFS: Simplify bucket layout segment reference counting
Date: Tue, 24 Mar 2020 19:47:23 -0400	[thread overview]
Message-ID: <20200324234728.8997-18-trondmy@kernel.org> (raw)
In-Reply-To: <20200324234728.8997-17-trondmy@kernel.org>

From: Trond Myklebust <trond.myklebust@hammerspace.com>

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 fs/nfs/pnfs_nfs.c       | 39 ++++++++++++++++++++-------------------
 include/linux/nfs_xdr.h |  3 +--
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/fs/nfs/pnfs_nfs.c b/fs/nfs/pnfs_nfs.c
index 06df2e6663dc..abf16fc98346 100644
--- a/fs/nfs/pnfs_nfs.c
+++ b/fs/nfs/pnfs_nfs.c
@@ -59,6 +59,17 @@ void pnfs_generic_commit_release(void *calldata)
 }
 EXPORT_SYMBOL_GPL(pnfs_generic_commit_release);
 
+static struct pnfs_layout_segment *
+pnfs_free_bucket_lseg(struct pnfs_commit_bucket *bucket)
+{
+	if (list_empty(&bucket->committing) && list_empty(&bucket->written)) {
+		struct pnfs_layout_segment *freeme = bucket->lseg;
+		bucket->lseg = NULL;
+		return freeme;
+	}
+	return NULL;
+}
+
 /* The generic layer is about to remove the req from the commit list.
  * If this will make the bucket empty, it will need to put the lseg reference.
  * Note this must be called holding nfsi->commit_mutex
@@ -78,8 +89,7 @@ pnfs_generic_clear_request_commit(struct nfs_page *req,
 		bucket = list_first_entry(&req->wb_list,
 					  struct pnfs_commit_bucket,
 					  written);
-		freeme = bucket->wlseg;
-		bucket->wlseg = NULL;
+		freeme = pnfs_free_bucket_lseg(bucket);
 	}
 out:
 	nfs_request_remove_commit_list(req, cinfo);
@@ -103,8 +113,7 @@ pnfs_alloc_commit_array(size_t n, gfp_t gfp_flags)
 	for (b = &p->buckets[0]; n != 0; b++, n--) {
 		INIT_LIST_HEAD(&b->written);
 		INIT_LIST_HEAD(&b->committing);
-		b->wlseg = NULL;
-		b->clseg = NULL;
+		b->lseg = NULL;
 		b->direct_verf.committed = NFS_INVALID_STABLE_HOW;
 	}
 	return p;
@@ -246,12 +255,6 @@ pnfs_bucket_scan_ds_commit_list(struct pnfs_commit_bucket *bucket,
 	if (ret) {
 		cinfo->ds->nwritten -= ret;
 		cinfo->ds->ncommitting += ret;
-		if (bucket->clseg == NULL)
-			bucket->clseg = pnfs_get_lseg(bucket->wlseg);
-		if (list_empty(src)) {
-			pnfs_put_lseg(bucket->wlseg);
-			bucket->wlseg = NULL;
-		}
 	}
 	return ret;
 }
@@ -317,9 +320,8 @@ pnfs_bucket_recover_commit_reqs(struct list_head *dst,
 		if (!nwritten)
 			continue;
 		ret += nwritten;
-		if (list_empty(&b->written)) {
-			freeme = b->wlseg;
-			b->wlseg = NULL;
+		freeme = pnfs_free_bucket_lseg(b);
+		if (freeme) {
 			pnfs_put_lseg(freeme);
 			goto restart;
 		}
@@ -405,15 +407,12 @@ pnfs_bucket_get_committing(struct list_head *head,
 			   struct pnfs_commit_bucket *bucket,
 			   struct nfs_commit_info *cinfo)
 {
-	struct pnfs_layout_segment *freeme;
 	struct list_head *pos;
 
 	list_for_each(pos, &bucket->committing)
 		cinfo->ds->ncommitting--;
 	list_splice_init(&bucket->committing, head);
-	freeme = bucket->clseg;
-	bucket->clseg = NULL;
-	return freeme;
+	return pnfs_free_bucket_lseg(bucket);
 }
 
 static struct nfs_commit_data *
@@ -425,6 +424,8 @@ pnfs_bucket_fetch_commitdata(struct pnfs_commit_bucket *bucket,
 	if (!data)
 		return NULL;
 	data->lseg = pnfs_bucket_get_committing(&data->pages, bucket, cinfo);
+	if (!data->lseg)
+		data->lseg = pnfs_get_lseg(bucket->lseg);
 	return data;
 }
 
@@ -1182,8 +1183,8 @@ pnfs_layout_mark_request_commit(struct nfs_page *req,
 		 * off due to a rewrite, in which case it will be done in
 		 * pnfs_common_clear_request_commit
 		 */
-		WARN_ON_ONCE(buckets[ds_commit_idx].wlseg != NULL);
-		buckets[ds_commit_idx].wlseg = pnfs_get_lseg(lseg);
+		if (!buckets[ds_commit_idx].lseg)
+			buckets[ds_commit_idx].lseg = pnfs_get_lseg(lseg);
 	}
 	set_bit(PG_COMMIT_TO_DS, &req->wb_flags);
 	cinfo->ds->nwritten++;
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index adbbeae9ce5b..7bbb1f6fc1b1 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -1265,8 +1265,7 @@ struct nfstime4 {
 struct pnfs_commit_bucket {
 	struct list_head written;
 	struct list_head committing;
-	struct pnfs_layout_segment *wlseg;
-	struct pnfs_layout_segment *clseg;
+	struct pnfs_layout_segment *lseg;
 	struct nfs_writeverf direct_verf;
 };
 
-- 
2.25.1


  reply	other threads:[~2020-03-24 23:49 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-24 23:47 [PATCH 00/22] Fix NFS commit to DS trondmy
2020-03-24 23:47 ` [PATCH 01/22] pNFS/flexfiles: Simplify allocation of the mirror array trondmy
2020-03-24 23:47   ` [PATCH 02/22] NFS/pNFS: Refactor pnfs_generic_commit_pagelist() trondmy
2020-03-24 23:47     ` [PATCH 03/22] pNFS: Add a helper to allocate the array of buckets trondmy
2020-03-24 23:47       ` [PATCH 04/22] NFSv4/pnfs: Support a list of commit arrays in struct pnfs_ds_commit_info trondmy
2020-03-24 23:47         ` [PATCH 05/22] NFSv4/pNFS: Scan the full list of commit arrays when committing trondmy
2020-03-24 23:47           ` [PATCH 06/22] pNFS: Support per-layout segment commits in pnfs_generic_recover_commit_reqs() trondmy
2020-03-24 23:47             ` [PATCH 07/22] pNFS: Support per-layout segment commits in pnfs_generic_commit_pagelist() trondmy
2020-03-24 23:47               ` [PATCH 08/22] NFS/pNFS: Allow O_DIRECT to release the DS commitinfo trondmy
2020-03-24 23:47                 ` [PATCH 09/22] NFS: commit errors should be fatal trondmy
2020-03-24 23:47                   ` [PATCH 10/22] NFS: Fix O_DIRECT commit verifier handling trondmy
2020-03-24 23:47                     ` [PATCH 11/22] NFS/pNFS: Support commit arrays in nfs_clear_pnfs_ds_commit_verifiers() trondmy
2020-03-24 23:47                       ` [PATCH 12/22] pNFS: Add infrastructure for cleaning up per-layout commit structures trondmy
2020-03-24 23:47                         ` [PATCH 13/22] pNFS: Enable per-layout segment " trondmy
2020-03-24 23:47                           ` [PATCH 14/22] NFS/pNFS: Add a helper pnfs_generic_search_commit_reqs() trondmy
2020-03-24 23:47                             ` [PATCH 15/22] NFS: Remove bucket array from struct pnfs_ds_commit_info trondmy
2020-03-24 23:47                               ` [PATCH 16/22] NFS/pNFS: Clean up pNFS commit operations trondmy
2020-03-24 23:47                                 ` trondmy [this message]
2020-03-24 23:47                                   ` [PATCH 18/22] NFS/pNFS: Fix pnfs_layout_mark_request_commit() invalid layout segment handling trondmy
2020-03-24 23:47                                     ` [PATCH 19/22] pNFS/flexfile: Don't merge layout segments if the mirrors don't match trondmy
2020-03-24 23:47                                       ` [PATCH 20/22] pNFS/flexfiles: Check the layout segment range before doing I/O trondmy
2020-03-24 23:47                                         ` [PATCH 21/22] pNFS/flexfiles: remove requirement for whole file layouts trondmy
2020-03-24 23:47                                           ` [PATCH 22/22] pNFS/flexfiles: Specify the layout segment range in LAYOUTGET trondmy
2020-03-27  6:39                                 ` [PATCH 16/22] NFS/pNFS: Clean up pNFS commit operations kbuild test robot
2020-03-27  4:20         ` [PATCH 04/22] NFSv4/pnfs: Support a list of commit arrays in struct pnfs_ds_commit_info kbuild test robot

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=20200324234728.8997-18-trondmy@kernel.org \
    --to=trondmy@kernel.org \
    --cc=linux-nfs@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.