Commit 078b5fd9 authored by Trond Myklebust's avatar Trond Myklebust

NFS: Clean up list moves of struct nfs_page

In several places we're just moving the struct nfs_page from one list to
another by first removing from the existing list, then adding to the new
one.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 8127d827
...@@ -664,8 +664,7 @@ static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq) ...@@ -664,8 +664,7 @@ static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq)
list_for_each_entry_safe(req, tmp, &reqs, wb_list) { list_for_each_entry_safe(req, tmp, &reqs, wb_list) {
if (!nfs_pageio_add_request(&desc, req)) { if (!nfs_pageio_add_request(&desc, req)) {
nfs_list_remove_request(req); nfs_list_move_request(req, &failed);
nfs_list_add_request(req, &failed);
spin_lock(&cinfo.inode->i_lock); spin_lock(&cinfo.inode->i_lock);
dreq->flags = 0; dreq->flags = 0;
if (desc.pg_error < 0) if (desc.pg_error < 0)
......
...@@ -768,8 +768,7 @@ int nfs_generic_pgio(struct nfs_pageio_descriptor *desc, ...@@ -768,8 +768,7 @@ int nfs_generic_pgio(struct nfs_pageio_descriptor *desc,
pageused = 0; pageused = 0;
while (!list_empty(head)) { while (!list_empty(head)) {
req = nfs_list_entry(head->next); req = nfs_list_entry(head->next);
nfs_list_remove_request(req); nfs_list_move_request(req, &hdr->pages);
nfs_list_add_request(req, &hdr->pages);
if (!last_page || last_page != req->wb_page) { if (!last_page || last_page != req->wb_page) {
pageused++; pageused++;
...@@ -961,8 +960,7 @@ static int nfs_pageio_do_add_request(struct nfs_pageio_descriptor *desc, ...@@ -961,8 +960,7 @@ static int nfs_pageio_do_add_request(struct nfs_pageio_descriptor *desc,
} }
if (!nfs_can_coalesce_requests(prev, req, desc)) if (!nfs_can_coalesce_requests(prev, req, desc))
return 0; return 0;
nfs_list_remove_request(req); nfs_list_move_request(req, &mirror->pg_list);
nfs_list_add_request(req, &mirror->pg_list);
mirror->pg_count += req->wb_bytes; mirror->pg_count += req->wb_bytes;
return 1; return 1;
} }
...@@ -994,8 +992,7 @@ nfs_pageio_cleanup_request(struct nfs_pageio_descriptor *desc, ...@@ -994,8 +992,7 @@ nfs_pageio_cleanup_request(struct nfs_pageio_descriptor *desc,
{ {
LIST_HEAD(head); LIST_HEAD(head);
nfs_list_remove_request(req); nfs_list_move_request(req, &head);
nfs_list_add_request(req, &head);
desc->pg_completion_ops->error_cleanup(&head); desc->pg_completion_ops->error_cleanup(&head);
} }
...@@ -1237,9 +1234,8 @@ int nfs_pageio_resend(struct nfs_pageio_descriptor *desc, ...@@ -1237,9 +1234,8 @@ int nfs_pageio_resend(struct nfs_pageio_descriptor *desc,
while (!list_empty(&hdr->pages)) { while (!list_empty(&hdr->pages)) {
struct nfs_page *req = nfs_list_entry(hdr->pages.next); struct nfs_page *req = nfs_list_entry(hdr->pages.next);
nfs_list_remove_request(req);
if (!nfs_pageio_add_request(desc, req)) if (!nfs_pageio_add_request(desc, req))
nfs_list_add_request(req, &failed); nfs_list_move_request(req, &failed);
} }
nfs_pageio_complete(desc); nfs_pageio_complete(desc);
if (!list_empty(&failed)) { if (!list_empty(&failed)) {
......
...@@ -164,6 +164,16 @@ nfs_list_add_request(struct nfs_page *req, struct list_head *head) ...@@ -164,6 +164,16 @@ nfs_list_add_request(struct nfs_page *req, struct list_head *head)
list_add_tail(&req->wb_list, head); list_add_tail(&req->wb_list, head);
} }
/**
* nfs_list_move_request - Move a request to a new list
* @req: request
* @head: head of list into which to insert the request.
*/
static inline void
nfs_list_move_request(struct nfs_page *req, struct list_head *head)
{
list_move_tail(&req->wb_list, head);
}
/** /**
* nfs_list_remove_request - Remove a request from its wb_list * nfs_list_remove_request - Remove a request from its wb_list
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment