mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 05:44:11 +00:00
dm: fix race in dm_start_io_acct
After commit82f6cdcc36
("dm: switch dm_io booleans over to proper flags") dm_start_io_acct stopped atomically checking and setting was_accounted, which turned into the DM_IO_ACCOUNTED flag. This opened the possibility for a race where IO accounting is started twice for duplicate bios. To remove the race, check the flag while holding the io->lock. Fixes:82f6cdcc36
("dm: switch dm_io booleans over to proper flags") Cc: stable@vger.kernel.org Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> Signed-off-by: Mike Snitzer <snitzer@kernel.org>
This commit is contained in:
parent
b13baccc38
commit
10eb3a0d51
1 changed files with 4 additions and 0 deletions
|
@ -555,6 +555,10 @@ static void dm_start_io_acct(struct dm_io *io, struct bio *clone)
|
|||
unsigned long flags;
|
||||
/* Can afford locking given DM_TIO_IS_DUPLICATE_BIO */
|
||||
spin_lock_irqsave(&io->lock, flags);
|
||||
if (dm_io_flagged(io, DM_IO_ACCOUNTED)) {
|
||||
spin_unlock_irqrestore(&io->lock, flags);
|
||||
return;
|
||||
}
|
||||
dm_io_set_flag(io, DM_IO_ACCOUNTED);
|
||||
spin_unlock_irqrestore(&io->lock, flags);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue