Skip to content

Commit feb7695

Browse files
committed
dm io: fix duplicate bio completion due to missing ref count
If only a subset of the devices associated with multiple regions support a given special operation (eg. DISCARD) then the dec_count() that is used to set error for the region must increment the io->count. Otherwise, when the dec_count() is called it can cause the dm-io caller's bio to be completed multiple times. As was reported against the dm-mirror target that had mirror legs with a mix of discard capabilities. Bug: https://bugzilla.kernel.org/show_bug.cgi?id=196077 Reported-by: Zhang Yi <yizhan@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
1 parent 7def52b commit feb7695

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/md/dm-io.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ static void do_region(int op, int op_flags, unsigned region,
317317
else if (op == REQ_OP_WRITE_SAME)
318318
special_cmd_max_sectors = q->limits.max_write_same_sectors;
319319
if ((op == REQ_OP_DISCARD || op == REQ_OP_WRITE_ZEROES ||
320-
op == REQ_OP_WRITE_SAME) &&
321-
special_cmd_max_sectors == 0) {
320+
op == REQ_OP_WRITE_SAME) && special_cmd_max_sectors == 0) {
321+
atomic_inc(&io->count);
322322
dec_count(io, region, -EOPNOTSUPP);
323323
return;
324324
}

0 commit comments

Comments
 (0)