[v4,04/15] mm,madvise: Refactor madvise_inject_error
diff mbox series

Message ID 20200716123810.25292-5-osalvador@suse.de
State New
Headers show
Series
  • Hwpoison soft-offline rework
Related show

Commit Message

Oscar Salvador July 16, 2020, 12:37 p.m. UTC
Make a proper if-else condition for {hard,soft}-offline.

Signed-off-by: Oscar Salvador <osalvador@suse.com>
Acked-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
---
 mm/madvise.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

Patch
diff mbox series

diff --git a/mm/madvise.c b/mm/madvise.c
index 1fe89a5b8d33..dd2173d8f4e5 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -886,7 +886,6 @@  static long madvise_remove(struct vm_area_struct *vma,
 static int madvise_inject_error(int behavior,
 		unsigned long start, unsigned long end)
 {
-	struct page *page;
 	struct zone *zone;
 	unsigned long size;
 
@@ -896,6 +895,7 @@  static int madvise_inject_error(int behavior,
 
 	for (; start < end; start += size) {
 		unsigned long pfn;
+		struct page *page;
 		int ret;
 
 		ret = get_user_pages_fast(start, 1, 0, &page);
@@ -925,17 +925,15 @@  static int madvise_inject_error(int behavior,
 
 		if (behavior == MADV_SOFT_OFFLINE) {
 			pr_info("Soft offlining pfn %#lx at process virtual address %#lx\n",
-					pfn, start);
+				 pfn, start);
 
 			ret = soft_offline_page(pfn, 0);
-			if (ret)
-				return ret;
-			continue;
+		} else {
+			pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n",
+				 pfn, start);
+			ret = memory_failure(pfn, 0);
 		}
 
-		pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n",
-				pfn, start);
-		ret = memory_failure(pfn, 0);
 		if (ret)
 			return ret;
 	}