aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/pagelist.c
diff options
context:
space:
mode:
authorWeston Andros Adamson <dros@primarydata.com>2014-08-08 11:00:54 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2014-08-22 18:04:42 -0400
commitbc8a309e88a86205fc3e17f06e42a2e56fc6f807 (patch)
tree3a3df69f6e7a6e16fc6a816e2e4ee1d0544ec8cb /fs/nfs/pagelist.c
parentfd2f3a06d30c85a17cf035ebc60c88c2a13a8ece (diff)
nfs: fix nonblocking calls to nfs_page_group_lock
nfs_page_group_lock was calling wait_on_bit_lock even when told not to block. Fix by first trying test_and_set_bit, followed by wait_on_bit_lock if and only if blocking is allowed. Return -EAGAIN if nonblocking and the test_and_set of the bit was already locked. Signed-off-by: Weston Andros Adamson <dros@primarydata.com> Reviewed-by: Peng Tao <tao.peng@primarydata.com> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs/pagelist.c')
-rw-r--r--fs/nfs/pagelist.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index 7efa61586bc4..89d5d433e351 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -143,23 +143,28 @@ nfs_iocounter_wait(struct nfs_io_counter *c)
143 * 143 *
144 * this lock must be held if modifying the page group list 144 * this lock must be held if modifying the page group list
145 * 145 *
146 * returns result from wait_on_bit_lock: 0 on success, < 0 on error 146 * return 0 on success, < 0 on error: -EDELAY if nonblocking or the
147 * result from wait_on_bit_lock
148 *
149 * NOTE: calling with nonblock=false should always have set the
150 * lock bit (see fs/buffer.c and other uses of wait_on_bit_lock
151 * with TASK_UNINTERRUPTIBLE), so there is no need to check the result.
147 */ 152 */
148int 153int
149nfs_page_group_lock(struct nfs_page *req, bool nonblock) 154nfs_page_group_lock(struct nfs_page *req, bool nonblock)
150{ 155{
151 struct nfs_page *head = req->wb_head; 156 struct nfs_page *head = req->wb_head;
152 int ret;
153 157
154 WARN_ON_ONCE(head != head->wb_head); 158 WARN_ON_ONCE(head != head->wb_head);
155 159
156 do { 160 if (!test_and_set_bit(PG_HEADLOCK, &head->wb_flags))
157 ret = wait_on_bit_lock(&head->wb_flags, PG_HEADLOCK, 161 return 0;
158 TASK_UNINTERRUPTIBLE);
159 } while (!nonblock && ret != 0);
160 162
161 WARN_ON_ONCE(ret > 0); 163 if (!nonblock)
162 return ret; 164 return wait_on_bit_lock(&head->wb_flags, PG_HEADLOCK,
165 TASK_UNINTERRUPTIBLE);
166
167 return -EAGAIN;
163} 168}
164 169
165/* 170/*