]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
dm snapshot: flush merged data before committing metadata
authorAkilesh Kailash <akailash@google.com>
Mon, 28 Dec 2020 07:14:07 +0000 (07:14 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Jan 2021 14:48:41 +0000 (15:48 +0100)
commit82355e525619257be5714ca8e422a16591b3b2cd
treedecfd1824a569e6065cc8c4a40e2a5905d406a5c
parent399fecd2cfc6ca7af4e1781fc8f0e140872cac65
dm snapshot: flush merged data before committing metadata

commit fcc42338375a1e67b8568dbb558f8b784d0f3b01 upstream.

If the origin device has a volatile write-back cache and the following
events occur:

1: After finishing merge operation of one set of exceptions,
   merge_callback() is invoked.
2: Update the metadata in COW device tracking the merge completion.
   This update to COW device is flushed cleanly.
3: System crashes and the origin device's cache where the recent
   merge was completed has not been flushed.

During the next cycle when we read the metadata from the COW device,
we will skip reading those metadata whose merge was completed in
step (1). This will lead to data loss/corruption.

To address this, flush the origin device post merge IO before
updating the metadata.

Cc: stable@vger.kernel.org
Signed-off-by: Akilesh Kailash <akailash@google.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/dm-snap.c