Commit 0ab30b40 authored by Mike Snitzer's avatar Mike Snitzer

dm: eliminate copying of dm_io fields in dm_io_dec_pending

There is no need for dm_io_dec_pending() to copy dm_io fields
anymore now that DM provides its own pending_io counters again.

The race documented in commit d208b894 ("dm: fix mempool NULL
pointer race when completing IO") no longer exists now that block
core's in_flight counters aren't used to signal all dm_io is
complete.

Also, rename {start,end}_io_acct to dm_{start,end}_io_acct.
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent 0cdb90f0
...@@ -518,15 +518,14 @@ static void dm_io_acct(bool end, struct mapped_device *md, struct bio *bio, ...@@ -518,15 +518,14 @@ static void dm_io_acct(bool end, struct mapped_device *md, struct bio *bio,
bio->bi_iter.bi_size = bi_size; bio->bi_iter.bi_size = bi_size;
} }
static void start_io_acct(struct dm_io *io) static void dm_start_io_acct(struct dm_io *io)
{ {
dm_io_acct(false, io->md, io->orig_bio, io->start_time, &io->stats_aux); dm_io_acct(false, io->md, io->orig_bio, io->start_time, &io->stats_aux);
} }
static void end_io_acct(struct mapped_device *md, struct bio *bio, static void dm_end_io_acct(struct dm_io *io)
unsigned long start_time, struct dm_stats_aux *stats_aux)
{ {
dm_io_acct(true, md, bio, start_time, stats_aux); dm_io_acct(true, io->md, io->orig_bio, io->start_time, &io->stats_aux);
} }
static struct dm_io *alloc_io(struct mapped_device *md, struct bio *bio) static struct dm_io *alloc_io(struct mapped_device *md, struct bio *bio)
...@@ -808,8 +807,6 @@ void dm_io_dec_pending(struct dm_io *io, blk_status_t error) ...@@ -808,8 +807,6 @@ void dm_io_dec_pending(struct dm_io *io, blk_status_t error)
blk_status_t io_error; blk_status_t io_error;
struct bio *bio; struct bio *bio;
struct mapped_device *md = io->md; struct mapped_device *md = io->md;
unsigned long start_time = 0;
struct dm_stats_aux stats_aux;
/* Push-back supersedes any I/O errors */ /* Push-back supersedes any I/O errors */
if (unlikely(error)) { if (unlikely(error)) {
...@@ -841,10 +838,8 @@ void dm_io_dec_pending(struct dm_io *io, blk_status_t error) ...@@ -841,10 +838,8 @@ void dm_io_dec_pending(struct dm_io *io, blk_status_t error)
} }
io_error = io->status; io_error = io->status;
start_time = io->start_time; dm_end_io_acct(io);
stats_aux = io->stats_aux;
free_io(md, io); free_io(md, io);
end_io_acct(md, bio, start_time, &stats_aux);
smp_wmb(); smp_wmb();
this_cpu_dec(*md->pending_io); this_cpu_dec(*md->pending_io);
...@@ -1444,8 +1439,8 @@ static void __split_and_process_bio(struct mapped_device *md, ...@@ -1444,8 +1439,8 @@ static void __split_and_process_bio(struct mapped_device *md,
* so that it gets handled *after* bios already submitted * so that it gets handled *after* bios already submitted
* have been completely processed. * have been completely processed.
* We take a clone of the original to store in * We take a clone of the original to store in
* ci.io->orig_bio to be used by end_io_acct() and * ci.io->orig_bio to be used by dm_end_io_acct() and
* for dec_pending to use for completion handling. * for dm_io_dec_pending() to use for completion handling.
*/ */
struct bio *b = bio_split(bio, bio_sectors(bio) - ci.sector_count, struct bio *b = bio_split(bio, bio_sectors(bio) - ci.sector_count,
GFP_NOIO, &md->queue->bio_split); GFP_NOIO, &md->queue->bio_split);
...@@ -1456,7 +1451,7 @@ static void __split_and_process_bio(struct mapped_device *md, ...@@ -1456,7 +1451,7 @@ static void __split_and_process_bio(struct mapped_device *md,
submit_bio_noacct(bio); submit_bio_noacct(bio);
} }
} }
start_io_acct(ci.io); dm_start_io_acct(ci.io);
/* drop the extra reference count */ /* drop the extra reference count */
dm_io_dec_pending(ci.io, errno_to_blk_status(error)); dm_io_dec_pending(ci.io, errno_to_blk_status(error));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment