Skip to content

Commit

Permalink
dm: add memory barrier before waitqueue_active
Browse files Browse the repository at this point in the history
Block core changes to switch bio-based IO accounting to be percpu had a
side-effect of altering DM core to now rely on calling waitqueue_active
(in both bio-based and request-based) to check if another task is in
dm_wait_for_completion().

A memory barrier is needed before calling waitqueue_active().  DM core
doesn't piggyback on a preceding memory barrier so it must explicitly
use its own.

For more details on why using waitqueue_active() without a preceding
barrier is unsafe, please see the comment before the waitqueue_active()
definition in include/linux/wait.h.

Add the missing memory barrier by switching to using wq_has_sleeper().

Fixes: 6f75723 ("dm: remove the pending IO accounting")
Fixes: c4576ae ("dm: fix request-based dm's use of dm_wait_for_completion")
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
  • Loading branch information
Mikulas Patocka authored and Mike Snitzer committed Feb 6, 2019
1 parent 8834f56 commit 645efa8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/md/dm-rq.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ static void rq_end_stats(struct mapped_device *md, struct request *orig)
static void rq_completed(struct mapped_device *md)
{
/* nudge anyone waiting on suspend queue */
if (unlikely(waitqueue_active(&md->wait)))
if (unlikely(wq_has_sleeper(&md->wait)))
wake_up(&md->wait);

/*
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ static void end_io_acct(struct dm_io *io)
true, duration, &io->stats_aux);

/* nudge anyone waiting on suspend queue */
if (unlikely(waitqueue_active(&md->wait)))
if (unlikely(wq_has_sleeper(&md->wait)))
wake_up(&md->wait);
}

Expand Down

0 comments on commit 645efa8

Please sign in to comment.