Commit 4d7bca13 authored by Mike Snitzer's avatar Mike Snitzer

dm: consolidate spinlocks in dm_io struct

No reason to have separate startio_lock and endio_lock given endio_lock
could be used during submission anyway.

This change leaves the dm_io struct weighing in at 256 bytes (down
from 272 bytes, so saves a cacheline).
Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
parent bd4a6dd2
...@@ -250,12 +250,11 @@ struct dm_io { ...@@ -250,12 +250,11 @@ struct dm_io {
struct mapped_device *md; struct mapped_device *md;
struct bio *orig_bio; struct bio *orig_bio;
blk_status_t status; blk_status_t status;
spinlock_t lock;
unsigned long start_time; unsigned long start_time;
void *data; void *data;
struct hlist_node node; struct hlist_node node;
struct task_struct *map_task; struct task_struct *map_task;
spinlock_t startio_lock;
spinlock_t endio_lock;
struct dm_stats_aux stats_aux; struct dm_stats_aux stats_aux;
/* last member of dm_target_io is 'struct bio' */ /* last member of dm_target_io is 'struct bio' */
struct dm_target_io tio; struct dm_target_io tio;
......
...@@ -550,9 +550,9 @@ static void dm_start_io_acct(struct dm_io *io, struct bio *clone) ...@@ -550,9 +550,9 @@ static void dm_start_io_acct(struct dm_io *io, struct bio *clone)
if (dm_io_flagged(io, DM_IO_ACCOUNTED)) if (dm_io_flagged(io, DM_IO_ACCOUNTED))
return; return;
/* Can afford locking given DM_TIO_IS_DUPLICATE_BIO */ /* Can afford locking given DM_TIO_IS_DUPLICATE_BIO */
spin_lock_irqsave(&io->startio_lock, flags); spin_lock_irqsave(&io->lock, flags);
dm_io_set_flag(io, DM_IO_ACCOUNTED); dm_io_set_flag(io, DM_IO_ACCOUNTED);
spin_unlock_irqrestore(&io->startio_lock, flags); spin_unlock_irqrestore(&io->lock, flags);
} }
__dm_start_io_acct(io, bio); __dm_start_io_acct(io, bio);
...@@ -584,8 +584,7 @@ static struct dm_io *alloc_io(struct mapped_device *md, struct bio *bio) ...@@ -584,8 +584,7 @@ static struct dm_io *alloc_io(struct mapped_device *md, struct bio *bio)
io->orig_bio = NULL; io->orig_bio = NULL;
io->md = md; io->md = md;
io->map_task = current; io->map_task = current;
spin_lock_init(&io->startio_lock); spin_lock_init(&io->lock);
spin_lock_init(&io->endio_lock);
io->start_time = jiffies; io->start_time = jiffies;
io->flags = 0; io->flags = 0;
...@@ -933,11 +932,11 @@ void dm_io_dec_pending(struct dm_io *io, blk_status_t error) ...@@ -933,11 +932,11 @@ void dm_io_dec_pending(struct dm_io *io, blk_status_t error)
/* Push-back supersedes any I/O errors */ /* Push-back supersedes any I/O errors */
if (unlikely(error)) { if (unlikely(error)) {
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&io->endio_lock, flags); spin_lock_irqsave(&io->lock, flags);
if (!(io->status == BLK_STS_DM_REQUEUE && if (!(io->status == BLK_STS_DM_REQUEUE &&
__noflush_suspending(io->md))) __noflush_suspending(io->md)))
io->status = error; io->status = error;
spin_unlock_irqrestore(&io->endio_lock, flags); spin_unlock_irqrestore(&io->lock, flags);
} }
if (atomic_dec_and_test(&io->io_count)) if (atomic_dec_and_test(&io->io_count))
......
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