diff options
Diffstat (limited to 'fs/nfs/pagelist.c')
-rw-r--r-- | fs/nfs/pagelist.c | 92 |
1 files changed, 1 insertions, 91 deletions
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index 5668f7c54c4..d21fceaa9f6 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/file.h> | 13 | #include <linux/file.h> |
14 | #include <linux/sched.h> | 14 | #include <linux/sched.h> |
15 | #include <linux/sunrpc/clnt.h> | 15 | #include <linux/sunrpc/clnt.h> |
16 | #include <linux/nfs.h> | ||
16 | #include <linux/nfs3.h> | 17 | #include <linux/nfs3.h> |
17 | #include <linux/nfs4.h> | 18 | #include <linux/nfs4.h> |
18 | #include <linux/nfs_page.h> | 19 | #include <linux/nfs_page.h> |
@@ -106,36 +107,6 @@ void nfs_unlock_request(struct nfs_page *req) | |||
106 | nfs_release_request(req); | 107 | nfs_release_request(req); |
107 | } | 108 | } |
108 | 109 | ||
109 | /** | ||
110 | * nfs_set_page_tag_locked - Tag a request as locked | ||
111 | * @req: | ||
112 | */ | ||
113 | int nfs_set_page_tag_locked(struct nfs_page *req) | ||
114 | { | ||
115 | if (!nfs_lock_request_dontget(req)) | ||
116 | return 0; | ||
117 | if (test_bit(PG_MAPPED, &req->wb_flags)) | ||
118 | radix_tree_tag_set(&NFS_I(req->wb_context->dentry->d_inode)->nfs_page_tree, req->wb_index, NFS_PAGE_TAG_LOCKED); | ||
119 | return 1; | ||
120 | } | ||
121 | |||
122 | /** | ||
123 | * nfs_clear_page_tag_locked - Clear request tag and wake up sleepers | ||
124 | */ | ||
125 | void nfs_clear_page_tag_locked(struct nfs_page *req) | ||
126 | { | ||
127 | if (test_bit(PG_MAPPED, &req->wb_flags)) { | ||
128 | struct inode *inode = req->wb_context->dentry->d_inode; | ||
129 | struct nfs_inode *nfsi = NFS_I(inode); | ||
130 | |||
131 | spin_lock(&inode->i_lock); | ||
132 | radix_tree_tag_clear(&nfsi->nfs_page_tree, req->wb_index, NFS_PAGE_TAG_LOCKED); | ||
133 | nfs_unlock_request(req); | ||
134 | spin_unlock(&inode->i_lock); | ||
135 | } else | ||
136 | nfs_unlock_request(req); | ||
137 | } | ||
138 | |||
139 | /* | 110 | /* |
140 | * nfs_clear_request - Free up all resources allocated to the request | 111 | * nfs_clear_request - Free up all resources allocated to the request |
141 | * @req: | 112 | * @req: |
@@ -425,67 +396,6 @@ void nfs_pageio_cond_complete(struct nfs_pageio_descriptor *desc, pgoff_t index) | |||
425 | } | 396 | } |
426 | } | 397 | } |
427 | 398 | ||
428 | #define NFS_SCAN_MAXENTRIES 16 | ||
429 | /** | ||
430 | * nfs_scan_list - Scan a list for matching requests | ||
431 | * @nfsi: NFS inode | ||
432 | * @dst: Destination list | ||
433 | * @idx_start: lower bound of page->index to scan | ||
434 | * @npages: idx_start + npages sets the upper bound to scan. | ||
435 | * @tag: tag to scan for | ||
436 | * | ||
437 | * Moves elements from one of the inode request lists. | ||
438 | * If the number of requests is set to 0, the entire address_space | ||
439 | * starting at index idx_start, is scanned. | ||
440 | * The requests are *not* checked to ensure that they form a contiguous set. | ||
441 | * You must be holding the inode's i_lock when calling this function | ||
442 | */ | ||
443 | int nfs_scan_list(struct nfs_inode *nfsi, | ||
444 | struct list_head *dst, pgoff_t idx_start, | ||
445 | unsigned int npages, int tag) | ||
446 | { | ||
447 | struct nfs_page *pgvec[NFS_SCAN_MAXENTRIES]; | ||
448 | struct nfs_page *req; | ||
449 | pgoff_t idx_end; | ||
450 | int found, i; | ||
451 | int res; | ||
452 | struct list_head *list; | ||
453 | |||
454 | res = 0; | ||
455 | if (npages == 0) | ||
456 | idx_end = ~0; | ||
457 | else | ||
458 | idx_end = idx_start + npages - 1; | ||
459 | |||
460 | for (;;) { | ||
461 | found = radix_tree_gang_lookup_tag(&nfsi->nfs_page_tree, | ||
462 | (void **)&pgvec[0], idx_start, | ||
463 | NFS_SCAN_MAXENTRIES, tag); | ||
464 | if (found <= 0) | ||
465 | break; | ||
466 | for (i = 0; i < found; i++) { | ||
467 | req = pgvec[i]; | ||
468 | if (req->wb_index > idx_end) | ||
469 | goto out; | ||
470 | idx_start = req->wb_index + 1; | ||
471 | if (nfs_set_page_tag_locked(req)) { | ||
472 | kref_get(&req->wb_kref); | ||
473 | radix_tree_tag_clear(&nfsi->nfs_page_tree, | ||
474 | req->wb_index, tag); | ||
475 | list = pnfs_choose_commit_list(req, dst); | ||
476 | nfs_list_add_request(req, list); | ||
477 | res++; | ||
478 | if (res == INT_MAX) | ||
479 | goto out; | ||
480 | } | ||
481 | } | ||
482 | /* for latency reduction */ | ||
483 | cond_resched_lock(&nfsi->vfs_inode.i_lock); | ||
484 | } | ||
485 | out: | ||
486 | return res; | ||
487 | } | ||
488 | |||
489 | int __init nfs_init_nfspagecache(void) | 399 | int __init nfs_init_nfspagecache(void) |
490 | { | 400 | { |
491 | nfs_page_cachep = kmem_cache_create("nfs_page", | 401 | nfs_page_cachep = kmem_cache_create("nfs_page", |