Skip to content

Commit 4d7bca1

Browse files
author
Mike Snitzer
committed
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: Mike Snitzer <snitzer@kernel.org>
1 parent bd4a6dd commit 4d7bca1

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

drivers/md/dm-core.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,11 @@ struct dm_io {
250250
struct mapped_device *md;
251251
struct bio *orig_bio;
252252
blk_status_t status;
253+
spinlock_t lock;
253254
unsigned long start_time;
254255
void *data;
255256
struct hlist_node node;
256257
struct task_struct *map_task;
257-
spinlock_t startio_lock;
258-
spinlock_t endio_lock;
259258
struct dm_stats_aux stats_aux;
260259
/* last member of dm_target_io is 'struct bio' */
261260
struct dm_target_io tio;

drivers/md/dm.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,9 @@ static void dm_start_io_acct(struct dm_io *io, struct bio *clone)
550550
if (dm_io_flagged(io, DM_IO_ACCOUNTED))
551551
return;
552552
/* Can afford locking given DM_TIO_IS_DUPLICATE_BIO */
553-
spin_lock_irqsave(&io->startio_lock, flags);
553+
spin_lock_irqsave(&io->lock, flags);
554554
dm_io_set_flag(io, DM_IO_ACCOUNTED);
555-
spin_unlock_irqrestore(&io->startio_lock, flags);
555+
spin_unlock_irqrestore(&io->lock, flags);
556556
}
557557

558558
__dm_start_io_acct(io, bio);
@@ -584,8 +584,7 @@ static struct dm_io *alloc_io(struct mapped_device *md, struct bio *bio)
584584
io->orig_bio = NULL;
585585
io->md = md;
586586
io->map_task = current;
587-
spin_lock_init(&io->startio_lock);
588-
spin_lock_init(&io->endio_lock);
587+
spin_lock_init(&io->lock);
589588
io->start_time = jiffies;
590589
io->flags = 0;
591590

@@ -933,11 +932,11 @@ void dm_io_dec_pending(struct dm_io *io, blk_status_t error)
933932
/* Push-back supersedes any I/O errors */
934933
if (unlikely(error)) {
935934
unsigned long flags;
936-
spin_lock_irqsave(&io->endio_lock, flags);
935+
spin_lock_irqsave(&io->lock, flags);
937936
if (!(io->status == BLK_STS_DM_REQUEUE &&
938937
__noflush_suspending(io->md)))
939938
io->status = error;
940-
spin_unlock_irqrestore(&io->endio_lock, flags);
939+
spin_unlock_irqrestore(&io->lock, flags);
941940
}
942941

943942
if (atomic_dec_and_test(&io->io_count))

0 commit comments

Comments
 (0)