Skip to content

Commit fb6b53b

Browse files
author
Trond Myklebust
committed
NFS/pNFS: Add a helper pnfs_generic_search_commit_reqs()
Lift filelayout_search_commit_reqs() into the generic pnfs/nfs code, and add support for commit arrays. Signed-off-by: Trond Myklebust <[email protected]>
1 parent ba827c9 commit fb6b53b

File tree

3 files changed

+54
-31
lines changed

3 files changed

+54
-31
lines changed

fs/nfs/filelayout/filelayout.c

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,36 +1083,6 @@ static int filelayout_initiate_commit(struct nfs_commit_data *data, int how)
10831083
return -EAGAIN;
10841084
}
10851085

1086-
/* filelayout_search_commit_reqs - Search lists in @cinfo for the head reqest
1087-
* for @page
1088-
* @cinfo - commit info for current inode
1089-
* @page - page to search for matching head request
1090-
*
1091-
* Returns a the head request if one is found, otherwise returns NULL.
1092-
*/
1093-
static struct nfs_page *
1094-
filelayout_search_commit_reqs(struct nfs_commit_info *cinfo, struct page *page)
1095-
{
1096-
struct nfs_page *freq, *t;
1097-
struct pnfs_commit_bucket *b;
1098-
int i;
1099-
1100-
/* Linearly search the commit lists for each bucket until a matching
1101-
* request is found */
1102-
for (i = 0, b = cinfo->ds->buckets; i < cinfo->ds->nbuckets; i++, b++) {
1103-
list_for_each_entry_safe(freq, t, &b->written, wb_list) {
1104-
if (freq->wb_page == page)
1105-
return freq->wb_head;
1106-
}
1107-
list_for_each_entry_safe(freq, t, &b->committing, wb_list) {
1108-
if (freq->wb_page == page)
1109-
return freq->wb_head;
1110-
}
1111-
}
1112-
1113-
return NULL;
1114-
}
1115-
11161086
static int
11171087
filelayout_commit_pagelist(struct inode *inode, struct list_head *mds_pages,
11181088
int how, struct nfs_commit_info *cinfo)
@@ -1217,7 +1187,7 @@ static struct pnfs_layoutdriver_type filelayout_type = {
12171187
.clear_request_commit = pnfs_generic_clear_request_commit,
12181188
.scan_commit_lists = pnfs_generic_scan_commit_lists,
12191189
.recover_commit_reqs = pnfs_generic_recover_commit_reqs,
1220-
.search_commit_reqs = filelayout_search_commit_reqs,
1190+
.search_commit_reqs = pnfs_generic_search_commit_reqs,
12211191
.commit_pagelist = filelayout_commit_pagelist,
12221192
.read_pagelist = filelayout_read_pagelist,
12231193
.write_pagelist = filelayout_write_pagelist,

fs/nfs/pnfs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ void pnfs_generic_prepare_to_resend_writes(struct nfs_commit_data *data);
388388
void pnfs_generic_rw_release(void *data);
389389
void pnfs_generic_recover_commit_reqs(struct list_head *dst,
390390
struct nfs_commit_info *cinfo);
391+
struct nfs_page *pnfs_generic_search_commit_reqs(struct nfs_commit_info *cinfo,
392+
struct page *page);
391393
int pnfs_generic_commit_pagelist(struct inode *inode,
392394
struct list_head *mds_pages,
393395
int how,

fs/nfs/pnfs_nfs.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,57 @@ void pnfs_generic_recover_commit_reqs(struct list_head *dst,
375375
}
376376
EXPORT_SYMBOL_GPL(pnfs_generic_recover_commit_reqs);
377377

378+
static struct nfs_page *
379+
pnfs_bucket_search_commit_reqs(struct pnfs_commit_bucket *buckets,
380+
unsigned int nbuckets, struct page *page)
381+
{
382+
struct nfs_page *req;
383+
struct pnfs_commit_bucket *b;
384+
unsigned int i;
385+
386+
/* Linearly search the commit lists for each bucket until a matching
387+
* request is found */
388+
for (i = 0, b = buckets; i < nbuckets; i++, b++) {
389+
list_for_each_entry(req, &b->written, wb_list) {
390+
if (req->wb_page == page)
391+
return req->wb_head;
392+
}
393+
list_for_each_entry(req, &b->committing, wb_list) {
394+
if (req->wb_page == page)
395+
return req->wb_head;
396+
}
397+
}
398+
return NULL;
399+
}
400+
401+
/* pnfs_generic_search_commit_reqs - Search lists in @cinfo for the head reqest
402+
* for @page
403+
* @cinfo - commit info for current inode
404+
* @page - page to search for matching head request
405+
*
406+
* Returns a the head request if one is found, otherwise returns NULL.
407+
*/
408+
struct nfs_page *
409+
pnfs_generic_search_commit_reqs(struct nfs_commit_info *cinfo, struct page *page)
410+
{
411+
struct pnfs_ds_commit_info *fl_cinfo = cinfo->ds;
412+
struct pnfs_commit_array *array;
413+
struct nfs_page *req;
414+
415+
req = pnfs_bucket_search_commit_reqs(fl_cinfo->buckets,
416+
fl_cinfo->nbuckets, page);
417+
if (req)
418+
return req;
419+
list_for_each_entry(array, &fl_cinfo->commits, cinfo_list) {
420+
req = pnfs_bucket_search_commit_reqs(array->buckets,
421+
array->nbuckets, page);
422+
if (req)
423+
return req;
424+
}
425+
return NULL;
426+
}
427+
EXPORT_SYMBOL_GPL(pnfs_generic_search_commit_reqs);
428+
378429
static struct pnfs_layout_segment *
379430
pnfs_bucket_get_committing(struct list_head *head,
380431
struct pnfs_commit_bucket *bucket,

0 commit comments

Comments
 (0)