From: Greg Kroah-Hartman Date: Sat, 25 Jun 2022 14:34:51 +0000 (+0200) Subject: 4.19-stable patches X-Git-Tag: v5.10.126~28 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5c54f91758ca1eb807825490e557b12b6b5876f8;p=thirdparty%2Fkernel%2Fstable-queue.git 4.19-stable patches added patches: ata-libata-add-qc-flags-in-ata_qc_complete_template-tracepoint.patch dm-era-commit-metadata-in-postsuspend-after-worker-stops.patch --- diff --git a/queue-4.19/ata-libata-add-qc-flags-in-ata_qc_complete_template-tracepoint.patch b/queue-4.19/ata-libata-add-qc-flags-in-ata_qc_complete_template-tracepoint.patch new file mode 100644 index 00000000000..f54460831af --- /dev/null +++ b/queue-4.19/ata-libata-add-qc-flags-in-ata_qc_complete_template-tracepoint.patch @@ -0,0 +1,30 @@ +From 540a92bfe6dab7310b9df2e488ba247d784d0163 Mon Sep 17 00:00:00 2001 +From: Edward Wu +Date: Fri, 17 Jun 2022 11:32:20 +0800 +Subject: ata: libata: add qc->flags in ata_qc_complete_template tracepoint + +From: Edward Wu + +commit 540a92bfe6dab7310b9df2e488ba247d784d0163 upstream. + +Add flags value to check the result of ata completion + +Fixes: 255c03d15a29 ("libata: Add tracepoints") +Cc: stable@vger.kernel.org +Signed-off-by: Edward Wu +Signed-off-by: Damien Le Moal +Signed-off-by: Greg Kroah-Hartman +--- + include/trace/events/libata.h | 1 + + 1 file changed, 1 insertion(+) + +--- a/include/trace/events/libata.h ++++ b/include/trace/events/libata.h +@@ -249,6 +249,7 @@ DECLARE_EVENT_CLASS(ata_qc_complete_temp + __entry->hob_feature = qc->result_tf.hob_feature; + __entry->nsect = qc->result_tf.nsect; + __entry->hob_nsect = qc->result_tf.hob_nsect; ++ __entry->flags = qc->flags; + ), + + TP_printk("ata_port=%u ata_dev=%u tag=%d flags=%s status=%s " \ diff --git a/queue-4.19/dm-era-commit-metadata-in-postsuspend-after-worker-stops.patch b/queue-4.19/dm-era-commit-metadata-in-postsuspend-after-worker-stops.patch new file mode 100644 index 00000000000..cd92c7d4ae9 --- /dev/null +++ b/queue-4.19/dm-era-commit-metadata-in-postsuspend-after-worker-stops.patch @@ -0,0 +1,91 @@ +From 9ae6e8b1c9bbf6874163d1243e393137313762b7 Mon Sep 17 00:00:00 2001 +From: Nikos Tsironis +Date: Tue, 21 Jun 2022 15:24:03 +0300 +Subject: dm era: commit metadata in postsuspend after worker stops + +From: Nikos Tsironis + +commit 9ae6e8b1c9bbf6874163d1243e393137313762b7 upstream. + +During postsuspend dm-era does the following: + +1. Archives the current era +2. Commits the metadata, as part of the RPC call for archiving the + current era +3. Stops the worker + +Until the worker stops, it might write to the metadata again. Moreover, +these writes are not flushed to disk immediately, but are cached by the +dm-bufio client, which writes them back asynchronously. + +As a result, the committed metadata of a suspended dm-era device might +not be consistent with the in-core metadata. + +In some cases, this can result in the corruption of the on-disk +metadata. Suppose the following sequence of events: + +1. Load a new table, e.g. a snapshot-origin table, to a device with a + dm-era table +2. Suspend the device +3. dm-era commits its metadata, but the worker does a few more metadata + writes until it stops, as part of digesting an archived writeset +4. These writes are cached by the dm-bufio client +5. Load the dm-era table to another device. +6. The new instance of the dm-era target loads the committed, on-disk + metadata, which don't include the extra writes done by the worker + after the metadata commit. +7. Resume the new device +8. The new dm-era target instance starts using the metadata +9. Resume the original device +10. The destructor of the old dm-era target instance is called and + destroys the dm-bufio client, which results in flushing the cached + writes to disk +11. These writes might overwrite the writes done by the new dm-era + instance, hence corrupting its metadata. + +Fix this by committing the metadata after the worker stops running. + +stop_worker uses flush_workqueue to flush the current work. However, the +work item may re-queue itself and flush_workqueue doesn't wait for +re-queued works to finish. + +This could result in the worker changing the metadata after they have +been committed, or writing to the metadata concurrently with the commit +in the postsuspend thread. + +Use drain_workqueue instead, which waits until the work and all +re-queued works finish. + +Fixes: eec40579d8487 ("dm: add era target") +Cc: stable@vger.kernel.org # v3.15+ +Signed-off-by: Nikos Tsironis +Signed-off-by: Mike Snitzer +Signed-off-by: Greg Kroah-Hartman +--- + drivers/md/dm-era-target.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +--- a/drivers/md/dm-era-target.c ++++ b/drivers/md/dm-era-target.c +@@ -1396,7 +1396,7 @@ static void start_worker(struct era *era + static void stop_worker(struct era *era) + { + atomic_set(&era->suspended, 1); +- flush_workqueue(era->wq); ++ drain_workqueue(era->wq); + } + + /*---------------------------------------------------------------- +@@ -1580,6 +1580,12 @@ static void era_postsuspend(struct dm_ta + } + + stop_worker(era); ++ ++ r = metadata_commit(era->md); ++ if (r) { ++ DMERR("%s: metadata_commit failed", __func__); ++ /* FIXME: fail mode */ ++ } + } + + static int era_preresume(struct dm_target *ti) diff --git a/queue-4.19/series b/queue-4.19/series index 1b56df21f7e..6448dc78a2f 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -3,3 +3,5 @@ random-schedule-mix_interrupt_randomness-less-often.patch alsa-hda-via-fix-missing-beep-setup.patch alsa-hda-conexant-fix-missing-beep-setup.patch alsa-hda-realtek-add-quirk-for-clevo-pd70pnt.patch +ata-libata-add-qc-flags-in-ata_qc_complete_template-tracepoint.patch +dm-era-commit-metadata-in-postsuspend-after-worker-stops.patch