Commit 609e9513 authored by Weston Andros Adamson's avatar Weston Andros Adamson Committed by Greg Kroah-Hartman

nfs: check wait_on_bit_lock err in page_group_lock

commit e7029206 upstream.

Return errors from wait_on_bit_lock from nfs_page_group_lock.

Add a bool argument @wait to nfs_page_group_lock. If true, loop over
wait_on_bit_lock until it returns cleanly. If false, return the error
from wait_on_bit_lock.
Signed-off-by: default avatarWeston Andros Adamson <dros@primarydata.com>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent de4308d1
...@@ -147,17 +147,25 @@ static int nfs_wait_bit_uninterruptible(void *word) ...@@ -147,17 +147,25 @@ static int nfs_wait_bit_uninterruptible(void *word)
* @req - request in group that is to be locked * @req - request in group that is to be locked
* *
* this lock must be held if modifying the page group list * this lock must be held if modifying the page group list
*
* returns result from wait_on_bit_lock: 0 on success, < 0 on error
*/ */
void int
nfs_page_group_lock(struct nfs_page *req) nfs_page_group_lock(struct nfs_page *req, bool wait)
{ {
struct nfs_page *head = req->wb_head; struct nfs_page *head = req->wb_head;
int ret;
WARN_ON_ONCE(head != head->wb_head); WARN_ON_ONCE(head != head->wb_head);
wait_on_bit_lock(&head->wb_flags, PG_HEADLOCK, do {
ret = wait_on_bit_lock(&head->wb_flags, PG_HEADLOCK,
nfs_wait_bit_uninterruptible, nfs_wait_bit_uninterruptible,
TASK_UNINTERRUPTIBLE); TASK_UNINTERRUPTIBLE);
} while (wait && ret != 0);
WARN_ON_ONCE(ret > 0);
return ret;
} }
/* /*
...@@ -218,7 +226,7 @@ bool nfs_page_group_sync_on_bit(struct nfs_page *req, unsigned int bit) ...@@ -218,7 +226,7 @@ bool nfs_page_group_sync_on_bit(struct nfs_page *req, unsigned int bit)
{ {
bool ret; bool ret;
nfs_page_group_lock(req); nfs_page_group_lock(req, true);
ret = nfs_page_group_sync_on_bit_locked(req, bit); ret = nfs_page_group_sync_on_bit_locked(req, bit);
nfs_page_group_unlock(req); nfs_page_group_unlock(req);
...@@ -859,8 +867,13 @@ static int __nfs_pageio_add_request(struct nfs_pageio_descriptor *desc, ...@@ -859,8 +867,13 @@ static int __nfs_pageio_add_request(struct nfs_pageio_descriptor *desc,
struct nfs_page *subreq; struct nfs_page *subreq;
unsigned int bytes_left = 0; unsigned int bytes_left = 0;
unsigned int offset, pgbase; unsigned int offset, pgbase;
int ret;
nfs_page_group_lock(req); ret = nfs_page_group_lock(req, false);
if (ret < 0) {
desc->pg_error = ret;
return 0;
}
subreq = req; subreq = req;
bytes_left = subreq->wb_bytes; bytes_left = subreq->wb_bytes;
...@@ -882,7 +895,11 @@ static int __nfs_pageio_add_request(struct nfs_pageio_descriptor *desc, ...@@ -882,7 +895,11 @@ static int __nfs_pageio_add_request(struct nfs_pageio_descriptor *desc,
if (desc->pg_recoalesce) if (desc->pg_recoalesce)
return 0; return 0;
/* retry add_request for this subreq */ /* retry add_request for this subreq */
nfs_page_group_lock(req); ret = nfs_page_group_lock(req, false);
if (ret < 0) {
desc->pg_error = ret;
return 0;
}
continue; continue;
} }
......
...@@ -216,7 +216,7 @@ static bool nfs_page_group_covers_page(struct nfs_page *req) ...@@ -216,7 +216,7 @@ static bool nfs_page_group_covers_page(struct nfs_page *req)
unsigned int pos = 0; unsigned int pos = 0;
unsigned int len = nfs_page_length(req->wb_page); unsigned int len = nfs_page_length(req->wb_page);
nfs_page_group_lock(req); nfs_page_group_lock(req, true);
do { do {
tmp = nfs_page_group_search_locked(req->wb_head, pos); tmp = nfs_page_group_search_locked(req->wb_head, pos);
...@@ -456,7 +456,9 @@ nfs_lock_and_join_requests(struct page *page, bool nonblock) ...@@ -456,7 +456,9 @@ nfs_lock_and_join_requests(struct page *page, bool nonblock)
} }
/* lock each request in the page group */ /* lock each request in the page group */
nfs_page_group_lock(head); ret = nfs_page_group_lock(head, false);
if (ret < 0)
return ERR_PTR(ret);
subreq = head; subreq = head;
do { do {
/* /*
......
...@@ -120,7 +120,7 @@ extern size_t nfs_generic_pg_test(struct nfs_pageio_descriptor *desc, ...@@ -120,7 +120,7 @@ extern size_t nfs_generic_pg_test(struct nfs_pageio_descriptor *desc,
extern int nfs_wait_on_request(struct nfs_page *); extern int nfs_wait_on_request(struct nfs_page *);
extern void nfs_unlock_request(struct nfs_page *req); extern void nfs_unlock_request(struct nfs_page *req);
extern void nfs_unlock_and_release_request(struct nfs_page *); extern void nfs_unlock_and_release_request(struct nfs_page *);
extern void nfs_page_group_lock(struct nfs_page *); extern int nfs_page_group_lock(struct nfs_page *, bool);
extern void nfs_page_group_unlock(struct nfs_page *); extern void nfs_page_group_unlock(struct nfs_page *);
extern bool nfs_page_group_sync_on_bit(struct nfs_page *, unsigned int); extern bool nfs_page_group_sync_on_bit(struct nfs_page *, unsigned int);
......
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