OSDN Git Service

NFS/pNFS: Add a helper pnfs_generic_search_commit_reqs()
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Fri, 20 Mar 2020 23:24:19 +0000 (19:24 -0400)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Fri, 27 Mar 2020 20:34:35 +0000 (16:34 -0400)
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
fs/nfs/pnfs.h
fs/nfs/pnfs_nfs.c

index e3cf42c..7955080 100644 (file)
@@ -1083,36 +1083,6 @@ out_err:
        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,
index 9647045..faed9be 100644 (file)
@@ -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,
index 5b426a0..9b55919 100644 (file)
@@ -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,