Skip to content

Commit 3b03f7c

Browse files
author
Mike Snitzer
committed
dm: simplify dm_start_io_acct
Pull common DM_IO_ACCOUNTED check out to beginning of dm_start_io_acct. Also, use dm_tio_is_normal (and move it to dm-core.h). Signed-off-by: Mike Snitzer <[email protected]>
1 parent 4857abf commit 3b03f7c

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

drivers/md/dm-core.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,12 @@ static inline void dm_tio_set_flag(struct dm_target_io *tio, unsigned int bit)
237237
tio->flags |= (1U << bit);
238238
}
239239

240+
static inline bool dm_tio_is_normal(struct dm_target_io *tio)
241+
{
242+
return (dm_tio_flagged(tio, DM_TIO_INSIDE_DM_IO) &&
243+
!dm_tio_flagged(tio, DM_TIO_IS_DUPLICATE_BIO));
244+
}
245+
240246
/*
241247
* One of these is allocated per original bio.
242248
* It contains the first clone used for that original.

drivers/md/dm.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -538,17 +538,15 @@ static void dm_start_io_acct(struct dm_io *io, struct bio *clone)
538538

539539
/*
540540
* Ensure IO accounting is only ever started once.
541-
* Expect no possibility for race unless DM_TIO_IS_DUPLICATE_BIO.
542541
*/
543-
if (!clone ||
544-
likely(!dm_tio_flagged(clone_to_tio(clone), DM_TIO_IS_DUPLICATE_BIO))) {
545-
if (WARN_ON_ONCE(dm_io_flagged(io, DM_IO_ACCOUNTED)))
546-
return;
542+
if (dm_io_flagged(io, DM_IO_ACCOUNTED))
543+
return;
544+
545+
/* Expect no possibility for race unless DM_TIO_IS_DUPLICATE_BIO. */
546+
if (!clone || likely(dm_tio_is_normal(clone_to_tio(clone)))) {
547547
dm_io_set_flag(io, DM_IO_ACCOUNTED);
548548
} else {
549549
unsigned long flags;
550-
if (dm_io_flagged(io, DM_IO_ACCOUNTED))
551-
return;
552550
/* Can afford locking given DM_TIO_IS_DUPLICATE_BIO */
553551
spin_lock_irqsave(&io->lock, flags);
554552
dm_io_set_flag(io, DM_IO_ACCOUNTED);
@@ -923,12 +921,6 @@ static void dm_io_complete(struct dm_io *io)
923921
}
924922
}
925923

926-
static inline bool dm_tio_is_normal(struct dm_target_io *tio)
927-
{
928-
return (dm_tio_flagged(tio, DM_TIO_INSIDE_DM_IO) &&
929-
!dm_tio_flagged(tio, DM_TIO_IS_DUPLICATE_BIO));
930-
}
931-
932924
/*
933925
* Decrements the number of outstanding ios that a bio has been
934926
* cloned into, completing the original io if necc.

0 commit comments

Comments
 (0)