diff options
| author | Mikulas Patocka <mpatocka@redhat.com> | 2018-11-06 22:35:01 +0100 |
|---|---|---|
| committer | Mike Snitzer <snitzer@redhat.com> | 2018-11-12 11:53:05 -0500 |
| commit | 78f95b53c203c969bbe6b86e405f7a891a43b6be (patch) | |
| tree | db91af083b06be1e4b442f9868720d72658d2805 | |
| parent | b5616f7a11592cc74860f4ec3e3c4fba6688eefa (diff) | |
| download | linux-dm-78f95b53c203c969bbe6b86e405f7a891a43b6be.tar.gz | |
dm: remove the pending variable
Notice: this object is not reachable from any branch.
Remove the "pending" variable and use dm_disk(md)->part0.in_flight.
These variables hold identical values.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Notice: this object is not reachable from any branch.
| -rw-r--r-- | drivers/md/dm-core.h | 1 | ||||
| -rw-r--r-- | drivers/md/dm-rq.c | 10 | ||||
| -rw-r--r-- | drivers/md/dm.c | 34 |
3 files changed, 22 insertions, 23 deletions
diff --git a/drivers/md/dm-core.h b/drivers/md/dm-core.h index 224d44503a067..0a93f2c83d8a1 100644 --- a/drivers/md/dm-core.h +++ b/drivers/md/dm-core.h @@ -65,7 +65,6 @@ struct mapped_device { */ struct work_struct work; wait_queue_head_t wait; - atomic_t pending[2]; spinlock_t deferred_lock; struct bio_list deferred; diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c index 7cd36e4d13101..5b106ed13fc1b 100644 --- a/drivers/md/dm-rq.c +++ b/drivers/md/dm-rq.c @@ -130,11 +130,13 @@ static void rq_end_stats(struct mapped_device *md, struct request *orig) */ static void rq_completed(struct mapped_device *md, int rw, bool run_queue) { - atomic_dec(&md->pending[rw]); + atomic_dec(&dm_disk(md)->part0.in_flight[rw]); /* nudge anyone waiting on suspend queue */ - if (!md_in_flight(md)) - wake_up(&md->wait); + if (unlikely(waitqueue_active(&md->wait))) { + if (!md_in_flight(md)) + wake_up(&md->wait); + } /* * dm_put() must be at the end of this function. See the comment above @@ -436,7 +438,7 @@ ssize_t dm_attr_rq_based_seq_io_merge_deadline_store(struct mapped_device *md, static void dm_start_request(struct mapped_device *md, struct request *orig) { blk_mq_start_request(orig); - atomic_inc(&md->pending[rq_data_dir(orig)]); + atomic_inc(&dm_disk(md)->part0.in_flight[rq_data_dir(orig)]); if (unlikely(dm_stats_used(&md->stats))) { struct dm_rq_target_io *tio = tio_from_request(orig); diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 5f02ffa265f6d..a2acc145a0531 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -648,23 +648,20 @@ static void free_tio(struct dm_target_io *tio) int md_in_flight(struct mapped_device *md) { - return atomic_read(&md->pending[READ]) + - atomic_read(&md->pending[WRITE]); + return atomic_read(&dm_disk(md)->part0.in_flight[READ]) + + atomic_read(&dm_disk(md)->part0.in_flight[WRITE]); } static void start_io_acct(struct dm_io *io) { struct mapped_device *md = io->md; struct bio *bio = io->orig_bio; - int rw = bio_data_dir(bio); io->start_time = jiffies; generic_start_io_acct(md->queue, bio_op(bio), bio_sectors(bio), &dm_disk(md)->part0); - atomic_inc(&md->pending[rw]); - 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), @@ -676,27 +673,30 @@ static void end_io_acct(struct dm_io *io) struct mapped_device *md = io->md; struct bio *bio = io->orig_bio; unsigned long duration = jiffies - io->start_time; - int pending; - int rw = bio_data_dir(bio); + /* + * make sure that atomic_dec in generic_end_io_acct is not reordered + * with previous writes + */ + smp_mb__before_atomic(); generic_end_io_acct(md->queue, bio_op(bio), &dm_disk(md)->part0, io->start_time); + /* + * generic_end_io_acct does atomic_dec, this barrier makes sure that + * atomic_dec is not reordered with waitqueue_active + */ + smp_mb__after_atomic(); 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, &io->stats_aux); - /* - * After this is decremented the bio must not be touched if it is - * a flush. - */ - pending = atomic_dec_return(&md->pending[rw]); - pending += atomic_read(&md->pending[rw^0x1]); - /* nudge anyone waiting on suspend queue */ - if (!pending) - wake_up(&md->wait); + if (unlikely(waitqueue_active(&md->wait))) { + if (!md_in_flight(md)) + wake_up(&md->wait); + } } /* @@ -1892,8 +1892,6 @@ static struct mapped_device *alloc_dev(int minor) if (!md->disk) goto bad; - atomic_set(&md->pending[0], 0); - atomic_set(&md->pending[1], 0); init_waitqueue_head(&md->wait); INIT_WORK(&md->work, dm_wq_work); init_waitqueue_head(&md->eventq); |
