aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2015-01-22 13:05:19 -0500
committerMister Oyster <oysterized@gmail.com>2017-05-27 19:39:50 +0200
commit6afe5ff62318fa752a965332d39e0033cd5b0d6e (patch)
tree32500605970cfba8189e26f737c2085a3dae4ac3
parent0a313f06382a89f03ebcbc7de2b1b6926bf0923d (diff)
sched: add bit_wait_io for 3.18 ext4 backport
Excerpted from commit 743162013: "sched: Remove proliferation of wait_on_bit() action functions" Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--include/linux/wait.h30
-rw-r--r--kernel/wait.c9
2 files changed, 38 insertions, 1 deletions
diff --git a/include/linux/wait.h b/include/linux/wait.h
index c8e576022..569d33b6b 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -959,5 +959,33 @@ static inline int wait_on_bit_lock(void *word, int bit,
return 0;
return out_of_line_wait_on_bit_lock(word, bit, action, mode);
}
-
+
+/* 3.18 backport */
+extern int bit_wait_io(void *);
+
+/**
+ * wait_on_bit_io - wait for a bit to be cleared
+ * @word: the word being waited on, a kernel virtual address
+ * @bit: the bit of the word being waited on
+ * @mode: the task state to sleep in
+ *
+ * Use the standard hashed waitqueue table to wait for a bit
+ * to be cleared. This is similar to wait_on_bit(), but calls
+ * io_schedule() instead of schedule() for the actual waiting.
+ *
+ * Returned value will be zero if the bit was cleared, or non-zero
+ * if the process received a signal and the mode permitted wakeup
+ * on that signal.
+ */
+static inline int
+wait_on_bit_io(void *word, int bit, unsigned mode)
+{
+ might_sleep();
+ if (!test_bit(bit, word))
+ return 0;
+ return out_of_line_wait_on_bit(word, bit,
+ bit_wait_io,
+ mode);
+}
+
#endif
diff --git a/kernel/wait.c b/kernel/wait.c
index 6698e0c04..bca170ef3 100644
--- a/kernel/wait.c
+++ b/kernel/wait.c
@@ -287,3 +287,12 @@ wait_queue_head_t *bit_waitqueue(void *word, int bit)
return &zone->wait_table[hash_long(val, zone->wait_table_bits)];
}
EXPORT_SYMBOL(bit_waitqueue);
+
+__sched int bit_wait_io(void *word)
+{
+ if (signal_pending_state(current->state, current))
+ return 1;
+ io_schedule();
+ return 0;
+}
+EXPORT_SYMBOL(bit_wait_io);