From: trondmy@kernel.org
To: linux-nfs@vger.kernel.org
Subject: [PATCH 14/22] NFS/pNFS: Add a helper pnfs_generic_search_commit_reqs()
Date: Tue, 24 Mar 2020 19:47:20 -0400 [thread overview]
Message-ID: <20200324234728.8997-15-trondmy@kernel.org> (raw)
In-Reply-To: <20200324234728.8997-14-trondmy@kernel.org>
From: Trond Myklebust <trond.myklebust@hammerspace.com>
Lift filelayout_search_commit_reqs() into the generic pnfs/nfs code,
and add support for commit arrays.
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
fs/nfs/filelayout/filelayout.c | 32 +--------------------
fs/nfs/pnfs.h | 2 ++
fs/nfs/pnfs_nfs.c | 51 ++++++++++++++++++++++++++++++++++
3 files changed, 54 insertions(+), 31 deletions(-)
diff --git a/fs/nfs/filelayout/filelayout.c b/fs/nfs/filelayout/filelayout.c
index 90c660aad337..05c97b6ba15d 100644
--- a/fs/nfs/filelayout/filelayout.c
+++ b/fs/nfs/filelayout/filelayout.c
@@ -1083,36 +1083,6 @@ static int filelayout_initiate_commit(struct nfs_commit_data *data, int how)
return -EAGAIN;
}
-/* filelayout_search_commit_reqs - Search lists in @cinfo for the head reqest
- * for @page
- * @cinfo - commit info for current inode
- * @page - page to search for matching head request
- *
- * Returns a the head request if one is found, otherwise returns NULL.
- */
-static struct nfs_page *
-filelayout_search_commit_reqs(struct nfs_commit_info *cinfo, struct page *page)
-{
- struct nfs_page *freq, *t;
- struct pnfs_commit_bucket *b;
- int i;
-
- /* Linearly search the commit lists for each bucket until a matching
- * request is found */
- for (i = 0, b = cinfo->ds->buckets; i < cinfo->ds->nbuckets; i++, b++) {
- list_for_each_entry_safe(freq, t, &b->written, wb_list) {
- if (freq->wb_page == page)
- return freq->wb_head;
- }
- list_for_each_entry_safe(freq, t, &b->committing, wb_list) {
- if (freq->wb_page == page)
- return freq->wb_head;
- }
- }
-
- return NULL;
-}
-
static int
filelayout_commit_pagelist(struct inode *inode, struct list_head *mds_pages,
int how, struct nfs_commit_info *cinfo)
@@ -1217,7 +1187,7 @@ static struct pnfs_layoutdriver_type filelayout_type = {
.clear_request_commit = pnfs_generic_clear_request_commit,
.scan_commit_lists = pnfs_generic_scan_commit_lists,
.recover_commit_reqs = pnfs_generic_recover_commit_reqs,
- .search_commit_reqs = filelayout_search_commit_reqs,
+ .search_commit_reqs = pnfs_generic_search_commit_reqs,
.commit_pagelist = filelayout_commit_pagelist,
.read_pagelist = filelayout_read_pagelist,
.write_pagelist = filelayout_write_pagelist,
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index 434503875f7f..20acd5108ddf 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -388,6 +388,8 @@ void pnfs_generic_prepare_to_resend_writes(struct nfs_commit_data *data);
void pnfs_generic_rw_release(void *data);
void pnfs_generic_recover_commit_reqs(struct list_head *dst,
struct nfs_commit_info *cinfo);
+struct nfs_page *pnfs_generic_search_commit_reqs(struct nfs_commit_info *cinfo,
+ struct page *page);
int pnfs_generic_commit_pagelist(struct inode *inode,
struct list_head *mds_pages,
int how,
diff --git a/fs/nfs/pnfs_nfs.c b/fs/nfs/pnfs_nfs.c
index 5b426a090ee3..9b55919e64ac 100644
--- a/fs/nfs/pnfs_nfs.c
+++ b/fs/nfs/pnfs_nfs.c
@@ -375,6 +375,57 @@ void pnfs_generic_recover_commit_reqs(struct list_head *dst,
}
EXPORT_SYMBOL_GPL(pnfs_generic_recover_commit_reqs);
+static struct nfs_page *
+pnfs_bucket_search_commit_reqs(struct pnfs_commit_bucket *buckets,
+ unsigned int nbuckets, struct page *page)
+{
+ struct nfs_page *req;
+ struct pnfs_commit_bucket *b;
+ unsigned int i;
+
+ /* Linearly search the commit lists for each bucket until a matching
+ * request is found */
+ for (i = 0, b = buckets; i < nbuckets; i++, b++) {
+ list_for_each_entry(req, &b->written, wb_list) {
+ if (req->wb_page == page)
+ return req->wb_head;
+ }
+ list_for_each_entry(req, &b->committing, wb_list) {
+ if (req->wb_page == page)
+ return req->wb_head;
+ }
+ }
+ return NULL;
+}
+
+/* pnfs_generic_search_commit_reqs - Search lists in @cinfo for the head reqest
+ * for @page
+ * @cinfo - commit info for current inode
+ * @page - page to search for matching head request
+ *
+ * Returns a the head request if one is found, otherwise returns NULL.
+ */
+struct nfs_page *
+pnfs_generic_search_commit_reqs(struct nfs_commit_info *cinfo, struct page *page)
+{
+ struct pnfs_ds_commit_info *fl_cinfo = cinfo->ds;
+ struct pnfs_commit_array *array;
+ struct nfs_page *req;
+
+ req = pnfs_bucket_search_commit_reqs(fl_cinfo->buckets,
+ fl_cinfo->nbuckets, page);
+ if (req)
+ return req;
+ list_for_each_entry(array, &fl_cinfo->commits, cinfo_list) {
+ req = pnfs_bucket_search_commit_reqs(array->buckets,
+ array->nbuckets, page);
+ if (req)
+ return req;
+ }
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(pnfs_generic_search_commit_reqs);
+
static struct pnfs_layout_segment *
pnfs_bucket_get_committing(struct list_head *head,
struct pnfs_commit_bucket *bucket,
--
2.25.1
next prev parent reply other threads:[~2020-03-24 23:49 UTC|newest]
Thread overview: 23+ 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 ` trondmy [this message]
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 ` [PATCH 17/22] NFS/pNFS: Simplify bucket layout segment reference counting trondmy
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
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-15-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox