Commit c698b7f4 authored by Mikulas Patocka's avatar Mikulas Patocka
Browse files

dm-integrity: fix a typo in the code for write/discard race



If we send a write followed by a discard, it may be possible that the
discarded data end up being overwritten by the previous write from the
journal. The code tries to prevent that, but there was a typo in this
logic that made it not being activated as it should be.

Note that if we end up here the second time (when discard_retried is
true), it means that the write bio is actually racing with the discard
bio, and in this situation it is not specified which of them should win.

Cc: stable@vger.kernel.org
Fixes: 31843eda ("dm integrity: improve discard in journal mode")
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
parent e9f5a55b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2411,7 +2411,7 @@ static void dm_integrity_map_continue(struct dm_integrity_io *dio, bool from_map

		new_pos = find_journal_node(ic, dio->range.logical_sector, &next_sector);
		if (unlikely(new_pos != NOT_FOUND) ||
		    unlikely(next_sector < dio->range.logical_sector - dio->range.n_sectors)) {
		    unlikely(next_sector < dio->range.logical_sector + dio->range.n_sectors)) {
			remove_range_unlocked(ic, &dio->range);
			spin_unlock_irq(&ic->endio_wait.lock);
			queue_work(ic->commit_wq, &ic->commit_work);