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 <cesarb@cesarb.net> Tested-by: Eric B Munson <emunson@mgebm.net> Acked-by: Eric B Munson <emunson@mgebm.net> Reviewed-by: Jesper Juhl <jj@chaosbits.net> Reviewed-by: Pekka Enberg <penberg@kernel.org> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Hugh Dickins <hughd@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
87ade72a79
commit
5de771e41f
@ -1975,8 +1975,6 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
|
|||||||
if (unlikely(error))
|
if (unlikely(error))
|
||||||
goto bad_swap;
|
goto bad_swap;
|
||||||
|
|
||||||
swapfilepages = i_size_read(inode) >> PAGE_SHIFT;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the swap header.
|
* Read the swap header.
|
||||||
*/
|
*/
|
||||||
@ -2045,6 +2043,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
|
|||||||
error = -EINVAL;
|
error = -EINVAL;
|
||||||
if (!maxpages)
|
if (!maxpages)
|
||||||
goto bad_swap;
|
goto bad_swap;
|
||||||
|
swapfilepages = i_size_read(inode) >> PAGE_SHIFT;
|
||||||
if (swapfilepages && maxpages > swapfilepages) {
|
if (swapfilepages && maxpages > swapfilepages) {
|
||||||
printk(KERN_WARNING
|
printk(KERN_WARNING
|
||||||
"Swap area shorter than signature indicates\n");
|
"Swap area shorter than signature indicates\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user