summaryrefslogtreecommitdiffstats
path: root/fs/fscache
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2014-07-07 01:16:04 -0400
committerIngo Molnar <mingo@kernel.org>2014-07-16 09:10:39 -0400
commit743162013d40ca612b4cb53d3a200dff2d9ab26e (patch)
treeb688e8afdbb96d18c7466b088b2dc21156a0bedd /fs/fscache
parentd26fad5b38e1c4667d4f2604936e59c837caa54d (diff)
sched: Remove proliferation of wait_on_bit() action functions
The current "wait_on_bit" interface requires an 'action' function to be provided which does the actual waiting. There are over 20 such functions, many of them identical. Most cases can be satisfied by one of just two functions, one which uses io_schedule() and one which just uses schedule(). So: Rename wait_on_bit and wait_on_bit_lock to wait_on_bit_action and wait_on_bit_lock_action to make it explicit that they need an action function. Introduce new wait_on_bit{,_lock} and wait_on_bit{,_lock}_io which are *not* given an action function but implicitly use a standard one. The decision to error-out if a signal is pending is now made based on the 'mode' argument rather than being encoded in the action function. All instances of the old wait_on_bit and wait_on_bit_lock which can use the new version have been changed accordingly and their action functions have been discarded. wait_on_bit{_lock} does not return any specific error code in the event of a signal so the caller must check for non-zero and interpolate their own error code as appropriate. The wait_on_bit() call in __fscache_wait_on_invalidate() was ambiguous as it specified TASK_UNINTERRUPTIBLE but used fscache_wait_bit_interruptible as an action function. David Howells confirms this should be uniformly "uninterruptible" The main remaining user of wait_on_bit{,_lock}_action is NFS which needs to use a freezer-aware schedule() call. A comment in fs/gfs2/glock.c notes that having multiple 'action' functions is useful as they display differently in the 'wchan' field of 'ps'. (and /proc/$PID/wchan). As the new bit_wait{,_io} functions are tagged "__sched", they will not show up at all, but something higher in the stack. So the distinction will still be visible, only with different function names (gds2_glock_wait versus gfs2_glock_dq_wait in the gfs2/glock.c case). Since first version of this patch (against 3.15) two new action functions appeared, on in NFS and one in CIFS. CIFS also now uses an action function that makes the same freezer aware schedule call as NFS. Signed-off-by: NeilBrown <neilb@suse.de> Acked-by: David Howells <dhowells@redhat.com> (fscache, keys) Acked-by: Steven Whitehouse <swhiteho@redhat.com> (gfs2) Acked-by: Peter Zijlstra <peterz@infradead.org> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Steve French <sfrench@samba.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: http://lkml.kernel.org/r/20140707051603.28027.72349.stgit@notabene.brown Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'fs/fscache')
-rw-r--r--fs/fscache/cookie.c7
-rw-r--r--fs/fscache/internal.h2
-rw-r--r--fs/fscache/main.c18
-rw-r--r--fs/fscache/page.c4
4 files changed, 4 insertions, 27 deletions
diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
index aec01be91b0a..89acec742e0b 100644
--- a/fs/fscache/cookie.c
+++ b/fs/fscache/cookie.c
@@ -160,7 +160,7 @@ void __fscache_enable_cookie(struct fscache_cookie *cookie,
160 _enter("%p", cookie); 160 _enter("%p", cookie);
161 161
162 wait_on_bit_lock(&cookie->flags, FSCACHE_COOKIE_ENABLEMENT_LOCK, 162 wait_on_bit_lock(&cookie->flags, FSCACHE_COOKIE_ENABLEMENT_LOCK,
163 fscache_wait_bit, TASK_UNINTERRUPTIBLE); 163 TASK_UNINTERRUPTIBLE);
164 164
165 if (test_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags)) 165 if (test_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags))
166 goto out_unlock; 166 goto out_unlock;
@@ -255,7 +255,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
255 if (!fscache_defer_lookup) { 255 if (!fscache_defer_lookup) {
256 _debug("non-deferred lookup %p", &cookie->flags); 256 _debug("non-deferred lookup %p", &cookie->flags);
257 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP, 257 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
258 fscache_wait_bit, TASK_UNINTERRUPTIBLE); 258 TASK_UNINTERRUPTIBLE);
259 _debug("complete"); 259 _debug("complete");
260 if (test_bit(FSCACHE_COOKIE_UNAVAILABLE, &cookie->flags)) 260 if (test_bit(FSCACHE_COOKIE_UNAVAILABLE, &cookie->flags))
261 goto unavailable; 261 goto unavailable;
@@ -463,7 +463,6 @@ void __fscache_wait_on_invalidate(struct fscache_cookie *cookie)
463 _enter("%p", cookie); 463 _enter("%p", cookie);
464 464
465 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_INVALIDATING, 465 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_INVALIDATING,
466 fscache_wait_bit_interruptible,
467 TASK_UNINTERRUPTIBLE); 466 TASK_UNINTERRUPTIBLE);
468 467
469 _leave(""); 468 _leave("");
@@ -525,7 +524,7 @@ void __fscache_disable_cookie(struct fscache_cookie *cookie, bool invalidate)
525 } 524 }
526 525
527 wait_on_bit_lock(&cookie->flags, FSCACHE_COOKIE_ENABLEMENT_LOCK, 526 wait_on_bit_lock(&cookie->flags, FSCACHE_COOKIE_ENABLEMENT_LOCK,
528 fscache_wait_bit, TASK_UNINTERRUPTIBLE); 527 TASK_UNINTERRUPTIBLE);
529 if (!test_and_clear_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags)) 528 if (!test_and_clear_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags))
530 goto out_unlock_enable; 529 goto out_unlock_enable;
531 530
diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
index bc6c08fcfddd..7872a62ef30c 100644
--- a/fs/fscache/internal.h
+++ b/fs/fscache/internal.h
@@ -97,8 +97,6 @@ static inline bool fscache_object_congested(void)
97 return workqueue_congested(WORK_CPU_UNBOUND, fscache_object_wq); 97 return workqueue_congested(WORK_CPU_UNBOUND, fscache_object_wq);
98} 98}
99 99
100extern int fscache_wait_bit(void *);
101extern int fscache_wait_bit_interruptible(void *);
102extern int fscache_wait_atomic_t(atomic_t *); 100extern int fscache_wait_atomic_t(atomic_t *);
103 101
104/* 102/*
diff --git a/fs/fscache/main.c b/fs/fscache/main.c
index 63f868e869b9..a31b83c5cbd9 100644
--- a/fs/fscache/main.c
+++ b/fs/fscache/main.c
@@ -197,24 +197,6 @@ static void __exit fscache_exit(void)
197module_exit(fscache_exit); 197module_exit(fscache_exit);
198 198
199/* 199/*
200 * wait_on_bit() sleep function for uninterruptible waiting
201 */
202int fscache_wait_bit(void *flags)
203{
204 schedule();
205 return 0;
206}
207
208/*
209 * wait_on_bit() sleep function for interruptible waiting
210 */
211int fscache_wait_bit_interruptible(void *flags)
212{
213 schedule();
214 return signal_pending(current);
215}
216
217/*
218 * wait_on_atomic_t() sleep function for uninterruptible waiting 200 * wait_on_atomic_t() sleep function for uninterruptible waiting
219 */ 201 */
220int fscache_wait_atomic_t(atomic_t *p) 202int fscache_wait_atomic_t(atomic_t *p)
diff --git a/fs/fscache/page.c b/fs/fscache/page.c
index ed70714503fa..85332b9d19d1 100644
--- a/fs/fscache/page.c
+++ b/fs/fscache/page.c
@@ -298,7 +298,6 @@ int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
298 298
299 jif = jiffies; 299 jif = jiffies;
300 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP, 300 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
301 fscache_wait_bit_interruptible,
302 TASK_INTERRUPTIBLE) != 0) { 301 TASK_INTERRUPTIBLE) != 0) {
303 fscache_stat(&fscache_n_retrievals_intr); 302 fscache_stat(&fscache_n_retrievals_intr);
304 _leave(" = -ERESTARTSYS"); 303 _leave(" = -ERESTARTSYS");
@@ -342,7 +341,6 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
342 if (stat_op_waits) 341 if (stat_op_waits)
343 fscache_stat(stat_op_waits); 342 fscache_stat(stat_op_waits);
344 if (wait_on_bit(&op->flags, FSCACHE_OP_WAITING, 343 if (wait_on_bit(&op->flags, FSCACHE_OP_WAITING,
345 fscache_wait_bit_interruptible,
346 TASK_INTERRUPTIBLE) != 0) { 344 TASK_INTERRUPTIBLE) != 0) {
347 ret = fscache_cancel_op(op, do_cancel); 345 ret = fscache_cancel_op(op, do_cancel);
348 if (ret == 0) 346 if (ret == 0)
@@ -351,7 +349,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
351 /* it's been removed from the pending queue by another party, 349 /* it's been removed from the pending queue by another party,
352 * so we should get to run shortly */ 350 * so we should get to run shortly */
353 wait_on_bit(&op->flags, FSCACHE_OP_WAITING, 351 wait_on_bit(&op->flags, FSCACHE_OP_WAITING,
354 fscache_wait_bit, TASK_UNINTERRUPTIBLE); 352 TASK_UNINTERRUPTIBLE);
355 } 353 }
356 _debug("<<< GO"); 354 _debug("<<< GO");
357 355