Skip to contentSkip to conversation

fsfreeze: avoid to return zero in __get_user_pages

PATCH Superseded Marco Stornelli 2 participants 2 messages Apr 6, 2013

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 4/4 fsfreeze: avoid to return zero in __get_user_pages

In case of VM_FAULT_RETRY, __get_user_pages returns the number of pages alredy gotten, but there isn't a check if this number is zero. Instead, we have to return a proper error code so we can avoid a possible extra call of __get_user_pages. There are several places where get_user_pages is called inside a loop until all the pages requested are gotten or an error code is returned.

---
 mm/memory.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
mm/memory.c +1 -1
index 494526a..cca14ed 100644
@@ -1858,7 +1858,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
 				if (ret & VM_FAULT_RETRY) {
 					if (nonblocking)
 						*nonblocking = 0;
-					return i;
+					return i ? i : -ERESTARTSYS;
 				}
 
 				/*
Signature · 1 line
1.7.3.4
#1 lore raw
Quoted 17 lines · Marco Stornelli

In case of VM_FAULT_RETRY, __get_user_pages returns the number of pages alredy gotten, but there isn't a check if this number is zero. Instead, we have to return a proper error code so we can avoid a possible extra call of __get_user_pages. There are several places where get_user_pages is called inside a loop until all the pages requested are gotten or an error code is returned.

---
 mm/memory.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
mm/memory.c +0 -0
index 494526a..cca14ed 100644

mm/memory.c long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm, · line 1861

Quoted 5 lines
mm/memory.c +1 -1
@@ -1858,7 +1858,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
                                if (ret & VM_FAULT_RETRY) {
                                        if (nonblocking)
                                                *nonblocking = 0;
-                                       return i;
+                                       return i ? i : -ERESTARTSYS;

nonblock argument is only used from __mm_populate() and it expect __get_user_pages() return 0.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>