aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
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 /drivers/md
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 'drivers/md')
-rw-r--r--drivers/md/dm-bufio.c41
-rw-r--r--drivers/md/dm-snap.c10
2 files changed, 15 insertions, 36 deletions
diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
index 4e84095833db..96c92b75452f 100644
--- a/drivers/md/dm-bufio.c
+++ b/drivers/md/dm-bufio.c
@@ -615,16 +615,6 @@ static void write_endio(struct bio *bio, int error)
615} 615}
616 616
617/* 617/*
618 * This function is called when wait_on_bit is actually waiting.
619 */
620static int do_io_schedule(void *word)
621{
622 io_schedule();
623
624 return 0;
625}
626
627/*
628 * Initiate a write on a dirty buffer, but don't wait for it. 618 * Initiate a write on a dirty buffer, but don't wait for it.
629 * 619 *
630 * - If the buffer is not dirty, exit. 620 * - If the buffer is not dirty, exit.
@@ -640,8 +630,7 @@ static void __write_dirty_buffer(struct dm_buffer *b,
640 return; 630 return;
641 631
642 clear_bit(B_DIRTY, &b->state); 632 clear_bit(B_DIRTY, &b->state);
643 wait_on_bit_lock(&b->state, B_WRITING, 633 wait_on_bit_lock_io(&b->state, B_WRITING, TASK_UNINTERRUPTIBLE);
644 do_io_schedule, TASK_UNINTERRUPTIBLE);
645 634
646 if (!write_list) 635 if (!write_list)
647 submit_io(b, WRITE, b->block, write_endio); 636 submit_io(b, WRITE, b->block, write_endio);
@@ -675,9 +664,9 @@ static void __make_buffer_clean(struct dm_buffer *b)
675 if (!b->state) /* fast case */ 664 if (!b->state) /* fast case */
676 return; 665 return;
677 666
678 wait_on_bit(&b->state, B_READING, do_io_schedule, TASK_UNINTERRUPTIBLE); 667 wait_on_bit_io(&b->state, B_READING, TASK_UNINTERRUPTIBLE);
679 __write_dirty_buffer(b, NULL); 668 __write_dirty_buffer(b, NULL);
680 wait_on_bit(&b->state, B_WRITING, do_io_schedule, TASK_UNINTERRUPTIBLE); 669 wait_on_bit_io(&b->state, B_WRITING, TASK_UNINTERRUPTIBLE);
681} 670}
682 671
683/* 672/*
@@ -1030,7 +1019,7 @@ static void *new_read(struct dm_bufio_client *c, sector_t block,
1030 if (need_submit) 1019 if (need_submit)
1031 submit_io(b, READ, b->block, read_endio); 1020 submit_io(b, READ, b->block, read_endio);
1032 1021
1033 wait_on_bit(&b->state, B_READING, do_io_schedule, TASK_UNINTERRUPTIBLE); 1022 wait_on_bit_io(&b->state, B_READING, TASK_UNINTERRUPTIBLE);
1034 1023
1035 if (b->read_error) { 1024 if (b->read_error) {
1036 int error = b->read_error; 1025 int error = b->read_error;
@@ -1209,15 +1198,13 @@ again:
1209 dropped_lock = 1; 1198 dropped_lock = 1;
1210 b->hold_count++; 1199 b->hold_count++;
1211 dm_bufio_unlock(c); 1200 dm_bufio_unlock(c);
1212 wait_on_bit(&b->state, B_WRITING, 1201 wait_on_bit_io(&b->state, B_WRITING,
1213 do_io_schedule, 1202 TASK_UNINTERRUPTIBLE);
1214 TASK_UNINTERRUPTIBLE);
1215 dm_bufio_lock(c); 1203 dm_bufio_lock(c);
1216 b->hold_count--; 1204 b->hold_count--;
1217 } else 1205 } else
1218 wait_on_bit(&b->state, B_WRITING, 1206 wait_on_bit_io(&b->state, B_WRITING,
1219 do_io_schedule, 1207 TASK_UNINTERRUPTIBLE);
1220 TASK_UNINTERRUPTIBLE);
1221 } 1208 }
1222 1209
1223 if (!test_bit(B_DIRTY, &b->state) && 1210 if (!test_bit(B_DIRTY, &b->state) &&
@@ -1321,15 +1308,15 @@ retry:
1321 1308
1322 __write_dirty_buffer(b, NULL); 1309 __write_dirty_buffer(b, NULL);
1323 if (b->hold_count == 1) { 1310 if (b->hold_count == 1) {
1324 wait_on_bit(&b->state, B_WRITING, 1311 wait_on_bit_io(&b->state, B_WRITING,
1325 do_io_schedule, TASK_UNINTERRUPTIBLE); 1312 TASK_UNINTERRUPTIBLE);
1326 set_bit(B_DIRTY, &b->state); 1313 set_bit(B_DIRTY, &b->state);
1327 __unlink_buffer(b); 1314 __unlink_buffer(b);
1328 __link_buffer(b, new_block, LIST_DIRTY); 1315 __link_buffer(b, new_block, LIST_DIRTY);
1329 } else { 1316 } else {
1330 sector_t old_block; 1317 sector_t old_block;
1331 wait_on_bit_lock(&b->state, B_WRITING, 1318 wait_on_bit_lock_io(&b->state, B_WRITING,
1332 do_io_schedule, TASK_UNINTERRUPTIBLE); 1319 TASK_UNINTERRUPTIBLE);
1333 /* 1320 /*
1334 * Relink buffer to "new_block" so that write_callback 1321 * Relink buffer to "new_block" so that write_callback
1335 * sees "new_block" as a block number. 1322 * sees "new_block" as a block number.
@@ -1341,8 +1328,8 @@ retry:
1341 __unlink_buffer(b); 1328 __unlink_buffer(b);
1342 __link_buffer(b, new_block, b->list_mode); 1329 __link_buffer(b, new_block, b->list_mode);
1343 submit_io(b, WRITE, new_block, write_endio); 1330 submit_io(b, WRITE, new_block, write_endio);
1344 wait_on_bit(&b->state, B_WRITING, 1331 wait_on_bit_io(&b->state, B_WRITING,
1345 do_io_schedule, TASK_UNINTERRUPTIBLE); 1332 TASK_UNINTERRUPTIBLE);
1346 __unlink_buffer(b); 1333 __unlink_buffer(b);
1347 __link_buffer(b, old_block, b->list_mode); 1334 __link_buffer(b, old_block, b->list_mode);
1348 } 1335 }
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 5bd2290cfb1e..864b03f47727 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -1032,21 +1032,13 @@ static void start_merge(struct dm_snapshot *s)
1032 snapshot_merge_next_chunks(s); 1032 snapshot_merge_next_chunks(s);
1033} 1033}
1034 1034
1035static int wait_schedule(void *ptr)
1036{
1037 schedule();
1038
1039 return 0;
1040}
1041
1042/* 1035/*
1043 * Stop the merging process and wait until it finishes. 1036 * Stop the merging process and wait until it finishes.
1044 */ 1037 */
1045static void stop_merge(struct dm_snapshot *s) 1038static void stop_merge(struct dm_snapshot *s)
1046{ 1039{
1047 set_bit(SHUTDOWN_MERGE, &s->state_bits); 1040 set_bit(SHUTDOWN_MERGE, &s->state_bits);
1048 wait_on_bit(&s->state_bits, RUNNING_MERGE, wait_schedule, 1041 wait_on_bit(&s->state_bits, RUNNING_MERGE, TASK_UNINTERRUPTIBLE);
1049 TASK_UNINTERRUPTIBLE);
1050 clear_bit(SHUTDOWN_MERGE, &s->state_bits); 1042 clear_bit(SHUTDOWN_MERGE, &s->state_bits);
1051} 1043}
1052 1044