History

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.

Weston Andros Adamson committed 12 years ago

Commit bc8a3091 parent fd2f3a01 file · +13 −8Browse files

Unified · Split

fs/nfs/pagelist.c+13−8
@@ -143,23 +143,28 @@ nfs_iocounter_wait(struct nfs_io_counter *c) · 142 unmodified lines
143 *143 *
144 * this lock must be held if modifying the page group list144 * 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 error146 * 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 */
148int153int
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/*

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t