From 5de771e41f0fc2243c39585357b73f0ff757b280 Mon Sep 17 00:00:00 2001 From: Cesar Eduardo Barros Date: Tue, 22 Mar 2011 16:33:28 -0700 Subject: 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 Tested-by: Eric B Munson Acked-by: Eric B Munson Reviewed-by: Jesper Juhl Reviewed-by: Pekka Enberg Reviewed-by: KAMEZAWA Hiroyuki Cc: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/swapfile.c | 3 +-- 1 file changed, 1 insertion(+), 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"); -- cgit v1.2.3-59-g8ed1b