aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCesar Eduardo Barros <[email protected]>2011-03-22 16:33:28 -0700
committerLinus Torvalds <[email protected]>2011-03-22 17:44:07 -0700
commit5de771e41f0fc2243c39585357b73f0ff757b280 (patch)
treea807bb46f4334b6697c0dba7dc80075e8dccae5f
parent87ade72a799a9a895b4a60918c32b43d3dfc3324 (diff)
sys_swapon: move setting of swapfilepages near use
There is no reason I can see to read inode->i_size long before it is needed. Move its read to just before it is needed, to reduce the variable lifetime. Signed-off-by: Cesar Eduardo Barros <[email protected]> Tested-by: Eric B Munson <[email protected]> Acked-by: Eric B Munson <[email protected]> Reviewed-by: Jesper Juhl <[email protected]> Reviewed-by: Pekka Enberg <[email protected]> Reviewed-by: KAMEZAWA Hiroyuki <[email protected]> Cc: Hugh Dickins <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r--mm/swapfile.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 61a604c12a96..4dade515b086 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1975,8 +1975,6 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
if (unlikely(error))
goto bad_swap;
- swapfilepages = i_size_read(inode) >> PAGE_SHIFT;
-
/*
* Read the swap header.
*/
@@ -2045,6 +2043,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
error = -EINVAL;
if (!maxpages)
goto bad_swap;
+ swapfilepages = i_size_read(inode) >> PAGE_SHIFT;
if (swapfilepages && maxpages > swapfilepages) {
printk(KERN_WARNING
"Swap area shorter than signature indicates\n");