]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
dm thin: fix bug where bio that overwrites thin block ignores FUA
authorNikos Tsironis <ntsironis@arrikto.com>
Thu, 14 Feb 2019 18:38:47 +0000 (20:38 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 2 May 2019 20:41:55 +0000 (21:41 +0100)
commitfee3db23d809345a96ede3ef617a8c4fba1157cd
tree639ee2816f1e0bf1f542e7f3ae6aab13e5070f1d
parent6fcac737c4a97588d3d15ab61096dffb9a6fe3f8
dm thin: fix bug where bio that overwrites thin block ignores FUA

commit 4ae280b4ee3463fa57bbe6eede26b97daff8a0f1 upstream.

When provisioning a new data block for a virtual block, either because
the block was previously unallocated or because we are breaking sharing,
if the whole block of data is being overwritten the bio that triggered
the provisioning is issued immediately, skipping copying or zeroing of
the data block.

When this bio completes the new mapping is inserted in to the pool's
metadata by process_prepared_mapping(), where the bio completion is
signaled to the upper layers.

This completion is signaled without first committing the metadata.  If
the bio in question has the REQ_FUA flag set and the system crashes
right after its completion and before the next metadata commit, then the
write is lost despite the REQ_FUA flag requiring that I/O completion for
this request must only be signaled after the data has been committed to
non-volatile storage.

Fix this by deferring the completion of overwrite bios, with the REQ_FUA
flag set, until after the metadata has been committed.

Signed-off-by: Nikos Tsironis <ntsironis@arrikto.com>
Acked-by: Joe Thornber <ejt@redhat.com>
Acked-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
[bwh: Backported to 3.16:
 - bio_endio() takes an error parameter
 - Adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/md/dm-thin.c