diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 6fd2899a362a..37b8bb4d80f0 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -681,14 +681,16 @@ static void end_io_acct(struct mapped_device *md, struct bio *bio, { unsigned long duration = jiffies - start_time; - generic_end_io_acct(md->queue, bio_op(bio), &dm_disk(md)->part0, - start_time); - if (unlikely(dm_stats_used(&md->stats))) dm_stats_account_io(&md->stats, bio_data_dir(bio), bio->bi_iter.bi_sector, bio_sectors(bio), true, duration, stats_aux); + smp_wmb(); + + generic_end_io_acct(md->queue, bio_op(bio), &dm_disk(md)->part0, + start_time); + /* nudge anyone waiting on suspend queue */ if (unlikely(wq_has_sleeper(&md->wait))) wake_up(&md->wait); @@ -2494,6 +2496,8 @@ static int dm_wait_for_completion(struct mapped_device *md, long task_state) } finish_wait(&md->wait, &wait); + smp_rmb(); + return r; }