Commit 5de771e4 authored by Cesar Eduardo Barros's avatar Cesar Eduardo Barros Committed by Linus Torvalds

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: default avatarCesar Eduardo Barros <cesarb@cesarb.net>
Tested-by: default avatarEric B Munson <emunson@mgebm.net>
Acked-by: default avatarEric B Munson <emunson@mgebm.net>
Reviewed-by: default avatarJesper Juhl <jj@chaosbits.net>
Reviewed-by: default avatarPekka Enberg <penberg@kernel.org>
Reviewed-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 87ade72a
......@@ -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");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment