Skip to content

Commit

Permalink
blk: clean up plug
Browse files Browse the repository at this point in the history
Current code looks like inner plug gets flushed with a
blk_finish_plug(). Actually it's a nop. All requests/callbacks are added
to current->plug, while only outmost plug is assigned to current->plug.
So inner plug always has empty request/callback list, which makes
blk_flush_plug_list() a nop. This tries to make the code more clear.

Signed-off-by: Shaohua Li <shli@fb.com>
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
Shaohua Li authored and Jens Axboe committed May 8, 2015
1 parent 9dc6c80 commit dd6cf3e
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3032,21 +3032,20 @@ void blk_start_plug(struct blk_plug *plug)
{
struct task_struct *tsk = current;

/*
* If this is a nested plug, don't actually assign it.
*/
if (tsk->plug)
return;

INIT_LIST_HEAD(&plug->list);
INIT_LIST_HEAD(&plug->mq_list);
INIT_LIST_HEAD(&plug->cb_list);

/*
* If this is a nested plug, don't actually assign it. It will be
* flushed on its own.
* Store ordering should not be needed here, since a potential
* preempt will imply a full memory barrier
*/
if (!tsk->plug) {
/*
* Store ordering should not be needed here, since a potential
* preempt will imply a full memory barrier
*/
tsk->plug = plug;
}
tsk->plug = plug;
}
EXPORT_SYMBOL(blk_start_plug);

Expand Down Expand Up @@ -3193,10 +3192,11 @@ void blk_flush_plug_list(struct blk_plug *plug, bool from_schedule)

void blk_finish_plug(struct blk_plug *plug)
{
if (plug != current->plug)
return;
blk_flush_plug_list(plug, false);

if (plug == current->plug)
current->plug = NULL;
current->plug = NULL;
}
EXPORT_SYMBOL(blk_finish_plug);

Expand Down

0 comments on commit dd6cf3e

Please sign in to comment.