]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.9-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 Jun 2022 14:34:32 +0000 (16:34 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 Jun 2022 14:34:32 +0000 (16:34 +0200)
added patches:
ata-libata-add-qc-flags-in-ata_qc_complete_template-tracepoint.patch
dm-era-commit-metadata-in-postsuspend-after-worker-stops.patch

queue-4.9/ata-libata-add-qc-flags-in-ata_qc_complete_template-tracepoint.patch [new file with mode: 0644]
queue-4.9/dm-era-commit-metadata-in-postsuspend-after-worker-stops.patch [new file with mode: 0644]
queue-4.9/series

diff --git a/queue-4.9/ata-libata-add-qc-flags-in-ata_qc_complete_template-tracepoint.patch b/queue-4.9/ata-libata-add-qc-flags-in-ata_qc_complete_template-tracepoint.patch
new file mode 100644 (file)
index 0000000..e6cf982
--- /dev/null
@@ -0,0 +1,30 @@
+From 540a92bfe6dab7310b9df2e488ba247d784d0163 Mon Sep 17 00:00:00 2001
+From: Edward Wu <edwardwu@realtek.com>
+Date: Fri, 17 Jun 2022 11:32:20 +0800
+Subject: ata: libata: add qc->flags in ata_qc_complete_template tracepoint
+
+From: Edward Wu <edwardwu@realtek.com>
+
+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 <edwardwu@realtek.com>
+Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ include/trace/events/libata.h |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/include/trace/events/libata.h
++++ b/include/trace/events/libata.h
+@@ -248,6 +248,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.9/dm-era-commit-metadata-in-postsuspend-after-worker-stops.patch b/queue-4.9/dm-era-commit-metadata-in-postsuspend-after-worker-stops.patch
new file mode 100644 (file)
index 0000000..3daf4fc
--- /dev/null
@@ -0,0 +1,91 @@
+From 9ae6e8b1c9bbf6874163d1243e393137313762b7 Mon Sep 17 00:00:00 2001
+From: Nikos Tsironis <ntsironis@arrikto.com>
+Date: Tue, 21 Jun 2022 15:24:03 +0300
+Subject: dm era: commit metadata in postsuspend after worker stops
+
+From: Nikos Tsironis <ntsironis@arrikto.com>
+
+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 <ntsironis@arrikto.com>
+Signed-off-by: Mike Snitzer <snitzer@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ 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
+@@ -1398,7 +1398,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);
+ }
+ /*----------------------------------------------------------------
+@@ -1583,6 +1583,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)
index 06f3721768956666255029cca52d15d38dfe3ad2..e349bfa39de6f8ef3e4a982eddf72bec554a622b 100644 (file)
@@ -1,2 +1,4 @@
 vt-drop-old-font-ioctls.patch
 random-schedule-mix_interrupt_randomness-less-often.patch
+ata-libata-add-qc-flags-in-ata_qc_complete_template-tracepoint.patch
+dm-era-commit-metadata-in-postsuspend-after-worker-stops.patch