diff options
author | Shaohua Li <shaohua.li@intel.com> | 2011-03-22 03:35:35 -0400 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2011-03-22 03:35:35 -0400 |
commit | 1e9bb8808ac11094d711d20d580e7b45a4992d0c (patch) | |
tree | d0e228b619664b7f507e37e5eba4a5ebeef103a0 /drivers | |
parent | 5e84ea3a9c662dc2d7a48703a4468fad954a3b7f (diff) |
block: fix non-atomic access to genhd inflight structures
After the stack plugging introduction, these are called lockless.
Ensure that the counters are updated atomically.
Signed-off-by: Shaohua Li<shaohua.li@intel.com>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/dm.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 88820704a191..0cf68b478878 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
@@ -477,7 +477,8 @@ static void start_io_acct(struct dm_io *io) | |||
477 | cpu = part_stat_lock(); | 477 | cpu = part_stat_lock(); |
478 | part_round_stats(cpu, &dm_disk(md)->part0); | 478 | part_round_stats(cpu, &dm_disk(md)->part0); |
479 | part_stat_unlock(); | 479 | part_stat_unlock(); |
480 | dm_disk(md)->part0.in_flight[rw] = atomic_inc_return(&md->pending[rw]); | 480 | atomic_set(&dm_disk(md)->part0.in_flight[rw], |
481 | atomic_inc_return(&md->pending[rw])); | ||
481 | } | 482 | } |
482 | 483 | ||
483 | static void end_io_acct(struct dm_io *io) | 484 | static void end_io_acct(struct dm_io *io) |
@@ -497,8 +498,8 @@ static void end_io_acct(struct dm_io *io) | |||
497 | * After this is decremented the bio must not be touched if it is | 498 | * After this is decremented the bio must not be touched if it is |
498 | * a flush. | 499 | * a flush. |
499 | */ | 500 | */ |
500 | dm_disk(md)->part0.in_flight[rw] = pending = | 501 | pending = atomic_dec_return(&md->pending[rw]); |
501 | atomic_dec_return(&md->pending[rw]); | 502 | atomic_set(&dm_disk(md)->part0.in_flight[rw], pending); |
502 | pending += atomic_read(&md->pending[rw^0x1]); | 503 | pending += atomic_read(&md->pending[rw^0x1]); |
503 | 504 | ||
504 | /* nudge anyone waiting on suspend queue */ | 505 | /* nudge anyone waiting on suspend queue */ |