aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
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/nfs
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/nfs')
-rw-r--r--fs/nfs/file.c4
-rw-r--r--fs/nfs/filelayout/filelayoutdev.c4
-rw-r--r--fs/nfs/inode.c4
-rw-r--r--fs/nfs/nfs4state.c4
-rw-r--r--fs/nfs/pagelist.c12
-rw-r--r--fs/nfs/pnfs.c2
-rw-r--r--fs/nfs/write.c4
7 files changed, 13 insertions, 21 deletions
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 4042ff58fe3f..524dd80d1898 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -361,8 +361,8 @@ start:
361 * Prevent starvation issues if someone is doing a consistency 361 * Prevent starvation issues if someone is doing a consistency
362 * sync-to-disk 362 * sync-to-disk
363 */ 363 */
364 ret = wait_on_bit(&NFS_I(mapping->host)->flags, NFS_INO_FLUSHING, 364 ret = wait_on_bit_action(&NFS_I(mapping->host)->flags, NFS_INO_FLUSHING,
365 nfs_wait_bit_killable, TASK_KILLABLE); 365 nfs_wait_bit_killable, TASK_KILLABLE);
366 if (ret) 366 if (ret)
367 return ret; 367 return ret;
368 368
diff --git a/fs/nfs/filelayout/filelayoutdev.c b/fs/nfs/filelayout/filelayoutdev.c
index 44bf0140a4c7..e2a0361e24c6 100644
--- a/fs/nfs/filelayout/filelayoutdev.c
+++ b/fs/nfs/filelayout/filelayoutdev.c
@@ -783,8 +783,8 @@ nfs4_fl_select_ds_fh(struct pnfs_layout_segment *lseg, u32 j)
783static void nfs4_wait_ds_connect(struct nfs4_pnfs_ds *ds) 783static void nfs4_wait_ds_connect(struct nfs4_pnfs_ds *ds)
784{ 784{
785 might_sleep(); 785 might_sleep();
786 wait_on_bit(&ds->ds_state, NFS4DS_CONNECTING, 786 wait_on_bit_action(&ds->ds_state, NFS4DS_CONNECTING,
787 nfs_wait_bit_killable, TASK_KILLABLE); 787 nfs_wait_bit_killable, TASK_KILLABLE);
788} 788}
789 789
790static void nfs4_clear_ds_conn_bit(struct nfs4_pnfs_ds *ds) 790static void nfs4_clear_ds_conn_bit(struct nfs4_pnfs_ds *ds)
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 9927913c97c2..b7b710e7d08e 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1074,8 +1074,8 @@ int nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping)
1074 * the bit lock here if it looks like we're going to be doing that. 1074 * the bit lock here if it looks like we're going to be doing that.
1075 */ 1075 */
1076 for (;;) { 1076 for (;;) {
1077 ret = wait_on_bit(bitlock, NFS_INO_INVALIDATING, 1077 ret = wait_on_bit_action(bitlock, NFS_INO_INVALIDATING,
1078 nfs_wait_bit_killable, TASK_KILLABLE); 1078 nfs_wait_bit_killable, TASK_KILLABLE);
1079 if (ret) 1079 if (ret)
1080 goto out; 1080 goto out;
1081 spin_lock(&inode->i_lock); 1081 spin_lock(&inode->i_lock);
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 848f6853c59e..42f121182167 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -1251,8 +1251,8 @@ int nfs4_wait_clnt_recover(struct nfs_client *clp)
1251 might_sleep(); 1251 might_sleep();
1252 1252
1253 atomic_inc(&clp->cl_count); 1253 atomic_inc(&clp->cl_count);
1254 res = wait_on_bit(&clp->cl_state, NFS4CLNT_MANAGER_RUNNING, 1254 res = wait_on_bit_action(&clp->cl_state, NFS4CLNT_MANAGER_RUNNING,
1255 nfs_wait_bit_killable, TASK_KILLABLE); 1255 nfs_wait_bit_killable, TASK_KILLABLE);
1256 if (res) 1256 if (res)
1257 goto out; 1257 goto out;
1258 if (clp->cl_cons_state < 0) 1258 if (clp->cl_cons_state < 0)
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index b6ee3a6ee96d..6104d3500b49 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -138,12 +138,6 @@ nfs_iocounter_wait(struct nfs_io_counter *c)
138 return __nfs_iocounter_wait(c); 138 return __nfs_iocounter_wait(c);
139} 139}
140 140
141static int nfs_wait_bit_uninterruptible(void *word)
142{
143 io_schedule();
144 return 0;
145}
146
147/* 141/*
148 * nfs_page_group_lock - lock the head of the page group 142 * nfs_page_group_lock - lock the head of the page group
149 * @req - request in group that is to be locked 143 * @req - request in group that is to be locked
@@ -158,7 +152,6 @@ nfs_page_group_lock(struct nfs_page *req)
158 WARN_ON_ONCE(head != head->wb_head); 152 WARN_ON_ONCE(head != head->wb_head);
159 153
160 wait_on_bit_lock(&head->wb_flags, PG_HEADLOCK, 154 wait_on_bit_lock(&head->wb_flags, PG_HEADLOCK,
161 nfs_wait_bit_uninterruptible,
162 TASK_UNINTERRUPTIBLE); 155 TASK_UNINTERRUPTIBLE);
163} 156}
164 157
@@ -425,9 +418,8 @@ void nfs_release_request(struct nfs_page *req)
425int 418int
426nfs_wait_on_request(struct nfs_page *req) 419nfs_wait_on_request(struct nfs_page *req)
427{ 420{
428 return wait_on_bit(&req->wb_flags, PG_BUSY, 421 return wait_on_bit_io(&req->wb_flags, PG_BUSY,
429 nfs_wait_bit_uninterruptible, 422 TASK_UNINTERRUPTIBLE);
430 TASK_UNINTERRUPTIBLE);
431} 423}
432 424
433/* 425/*
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 6fdcd233d6f7..a8914b335617 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -1885,7 +1885,7 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync)
1885 if (test_and_set_bit(NFS_INO_LAYOUTCOMMITTING, &nfsi->flags)) { 1885 if (test_and_set_bit(NFS_INO_LAYOUTCOMMITTING, &nfsi->flags)) {
1886 if (!sync) 1886 if (!sync)
1887 goto out; 1887 goto out;
1888 status = wait_on_bit_lock(&nfsi->flags, 1888 status = wait_on_bit_lock_action(&nfsi->flags,
1889 NFS_INO_LAYOUTCOMMITTING, 1889 NFS_INO_LAYOUTCOMMITTING,
1890 nfs_wait_bit_killable, 1890 nfs_wait_bit_killable,
1891 TASK_KILLABLE); 1891 TASK_KILLABLE);
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 98ff061ccaf3..f05f321f9d3d 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -397,7 +397,7 @@ int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc)
397 int err; 397 int err;
398 398
399 /* Stop dirtying of new pages while we sync */ 399 /* Stop dirtying of new pages while we sync */
400 err = wait_on_bit_lock(bitlock, NFS_INO_FLUSHING, 400 err = wait_on_bit_lock_action(bitlock, NFS_INO_FLUSHING,
401 nfs_wait_bit_killable, TASK_KILLABLE); 401 nfs_wait_bit_killable, TASK_KILLABLE);
402 if (err) 402 if (err)
403 goto out_err; 403 goto out_err;
@@ -1475,7 +1475,7 @@ int nfs_commit_inode(struct inode *inode, int how)
1475 return error; 1475 return error;
1476 if (!may_wait) 1476 if (!may_wait)
1477 goto out_mark_dirty; 1477 goto out_mark_dirty;
1478 error = wait_on_bit(&NFS_I(inode)->flags, 1478 error = wait_on_bit_action(&NFS_I(inode)->flags,
1479 NFS_INO_COMMIT, 1479 NFS_INO_COMMIT,
1480 nfs_wait_bit_killable, 1480 nfs_wait_bit_killable,
1481 TASK_KILLABLE); 1481 TASK_KILLABLE);