summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2012-07-31 09:08:14 +0200
committerJens Axboe <axboe@kernel.dk>2012-07-31 09:08:14 +0200
commit9cbb17508808f8a6bdd83354b61e126ac4fa6fed (patch)
treebc797d1b5cd829751a333115e6e6d52799fb6df2 /block
parent0021b7bc045e4b0b85d8c53614342aaf84ca96a5 (diff)
downloadlinux-stable-9cbb17508808f8a6bdd83354b61e126ac4fa6fed.tar.gz
linux-stable-9cbb17508808f8a6bdd83354b61e126ac4fa6fed.tar.bz2
linux-stable-9cbb17508808f8a6bdd83354b61e126ac4fa6fed.zip
blk: centralize non-request unplug handling.
Both md and umem has similar code for getting notified on an blk_finish_plug event. Centralize this code in block/ and allow each driver to provide its distinctive difference. Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r--block/blk-core.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index dd134d834d58..177ddcf356e6 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -2927,6 +2927,31 @@ static void flush_plug_callbacks(struct blk_plug *plug)
}
}
+struct blk_plug_cb *blk_check_plugged(blk_plug_cb_fn unplug, void *data,
+ int size)
+{
+ struct blk_plug *plug = current->plug;
+ struct blk_plug_cb *cb;
+
+ if (!plug)
+ return NULL;
+
+ list_for_each_entry(cb, &plug->cb_list, list)
+ if (cb->callback == unplug && cb->data == data)
+ return cb;
+
+ /* Not currently on the callback list */
+ BUG_ON(size < sizeof(*cb));
+ cb = kzalloc(size, GFP_ATOMIC);
+ if (cb) {
+ cb->data = data;
+ cb->callback = unplug;
+ list_add(&cb->list, &plug->cb_list);
+ }
+ return cb;
+}
+EXPORT_SYMBOL(blk_check_plugged);
+
void blk_flush_plug_list(struct blk_plug *plug, bool from_schedule)
{
struct request_queue *q;