aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-core.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2012-07-31 03:08:14 -0400
committerJens Axboe <axboe@kernel.dk>2012-07-31 03:08:14 -0400
commit9cbb17508808f8a6bdd83354b61e126ac4fa6fed (patch)
treebc797d1b5cd829751a333115e6e6d52799fb6df2 /block/blk-core.c
parent0021b7bc045e4b0b85d8c53614342aaf84ca96a5 (diff)
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/blk-core.c')
-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)
2927 } 2927 }
2928} 2928}
2929 2929
2930struct blk_plug_cb *blk_check_plugged(blk_plug_cb_fn unplug, void *data,
2931 int size)
2932{
2933 struct blk_plug *plug = current->plug;
2934 struct blk_plug_cb *cb;
2935
2936 if (!plug)
2937 return NULL;
2938
2939 list_for_each_entry(cb, &plug->cb_list, list)
2940 if (cb->callback == unplug && cb->data == data)
2941 return cb;
2942
2943 /* Not currently on the callback list */
2944 BUG_ON(size < sizeof(*cb));
2945 cb = kzalloc(size, GFP_ATOMIC);
2946 if (cb) {
2947 cb->data = data;
2948 cb->callback = unplug;
2949 list_add(&cb->list, &plug->cb_list);
2950 }
2951 return cb;
2952}
2953EXPORT_SYMBOL(blk_check_plugged);
2954
2930void blk_flush_plug_list(struct blk_plug *plug, bool from_schedule) 2955void blk_flush_plug_list(struct blk_plug *plug, bool from_schedule)
2931{ 2956{
2932 struct request_queue *q; 2957 struct request_queue *q;