Home Home > GIT Browse > SLE15
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2019-01-03 13:27:42 +0100
committerJan Kara <jack@suse.cz>2019-01-21 09:16:10 +0100
commita63c5478fdcb370f075bec425067246f9bce8469 (patch)
tree5ed2dd4480a93962f059a2db8550ce08b33c3a35
parent2baf0a570c6f99983a42f1b89edb2b7f25a04a22 (diff)
mm: migrate: lock buffers before migrate_page_move_mapping()
(bsc#1084216).
-rw-r--r--patches.fixes/mm-migrate-lock-buffers-before-migrate_page_move_map.patch79
-rw-r--r--series.conf1
2 files changed, 80 insertions, 0 deletions
diff --git a/patches.fixes/mm-migrate-lock-buffers-before-migrate_page_move_map.patch b/patches.fixes/mm-migrate-lock-buffers-before-migrate_page_move_map.patch
new file mode 100644
index 0000000000..12ad04167e
--- /dev/null
+++ b/patches.fixes/mm-migrate-lock-buffers-before-migrate_page_move_map.patch
@@ -0,0 +1,79 @@
+From cc4f11e69fd00c61c38619759b07d00631bda5ca Mon Sep 17 00:00:00 2001
+From: Jan Kara <jack@suse.cz>
+Date: Fri, 28 Dec 2018 00:39:05 -0800
+Subject: [PATCH] mm: migrate: lock buffers before migrate_page_move_mapping()
+Git-commit: cc4f11e69fd00c61c38619759b07d00631bda5ca
+Patch-mainline: v4.21-rc1
+References: bsc#1084216
+
+Lock buffers before calling into migrate_page_move_mapping() so that that
+function doesn't have to know about buffers (which is somewhat unexpected
+anyway) and all the buffer head logic is in buffer_migrate_page().
+
+Link: http://lkml.kernel.org/r/20181211172143.7358-3-jack@suse.cz
+Signed-off-by: Jan Kara <jack@suse.cz>
+Acked-by: Mel Gorman <mgorman@suse.de>
+Cc: Michal Hocko <mhocko@suse.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Acked-by: Jan Kara <jack@suse.cz>
+
+---
+ mm/migrate.c | 25 +++++++++++++------------
+ 1 file changed, 13 insertions(+), 12 deletions(-)
+
+--- a/mm/migrate.c
++++ b/mm/migrate.c
+@@ -743,24 +743,23 @@ int buffer_migrate_page(struct address_s
+ {
+ struct buffer_head *bh, *head;
+ int rc;
++ int expected_count;
+
+ if (!page_has_buffers(page))
+ return migrate_page(mapping, newpage, page, mode);
+
+- head = page_buffers(page);
++ /* Check whether page does not have extra refs before we do more work */
++ expected_count = expected_page_refs(page);
++ if (page_count(page) != expected_count)
++ return -EAGAIN;
+
+- rc = migrate_page_move_mapping(mapping, newpage, page, head, mode, 0);
++ head = page_buffers(page);
++ if (!buffer_migrate_lock_buffers(head, mode))
++ return -EAGAIN;
+
++ rc = migrate_page_move_mapping(mapping, newpage, page, NULL, mode, 0);
+ if (rc != MIGRATEPAGE_SUCCESS)
+- return rc;
+-
+- /*
+- * In the async case, migrate_page_move_mapping locked the buffers
+- * with an IRQ-safe spinlock held. In the sync case, the buffers
+- * need to be locked now
+- */
+- if (mode != MIGRATE_ASYNC)
+- BUG_ON(!buffer_migrate_lock_buffers(head, mode));
++ goto unlock_buffers;
+
+ ClearPagePrivate(page);
+ set_page_private(newpage, page_private(page));
+@@ -782,6 +781,8 @@ int buffer_migrate_page(struct address_s
+ else
+ migrate_page_states(newpage, page);
+
++ rc = MIGRATEPAGE_SUCCESS;
++unlock_buffers:
+ bh = head;
+ do {
+ unlock_buffer(bh);
+@@ -790,7 +791,7 @@ int buffer_migrate_page(struct address_s
+
+ } while (bh != head);
+
+- return MIGRATEPAGE_SUCCESS;
++ return rc;
+ }
+ EXPORT_SYMBOL(buffer_migrate_page);
+ #endif
diff --git a/series.conf b/series.conf
index 01edaaba3e..6ba46b0d61 100644
--- a/series.conf
+++ b/series.conf
@@ -19698,6 +19698,7 @@
patches.fixes/mm-put_and_wait_on_page_locked-while-page-is-migrated.patch
patches.fixes/0001-hwpoison-memory_hotplug-allow-hwpoisoned-pages-to-be.patch
patches.fixes/mm-migration-factor-out-code-to-compute-expected-num.patch
+ patches.fixes/mm-migrate-lock-buffers-before-migrate_page_move_map.patch
patches.drivers/gpiolib-Fix-return-value-of-gpio_to_desc-stub-if-GPI.patch
patches.drivers/power-supply-olpc_battery-correct-the-temperature-un.patch
patches.drivers/usb-dwc2-host-use-hrtimer-for-nak-retries.patch