force O_LARGEFILE in sys_swapon() and sys_swapoff()

William Lee Irwin III
2004-07-04T06:44:44Z

On Sat, Jul 03, 2004 at 11:41:22PM -0700, William Lee Irwin III wrote:
> Internal kernel open() of files barfs in important contexts, for
> instance, using strict non-overcommit with enough swap for large
> commitments. This is carried out through the entrypoint filp_open(),
> not sys_open(). sys_open() in turn calls filp_open(). So merely
> moving the forcing of the flag on 64-bit resolves this situation there,
> though not for 32-bit, whose solution is to appear in the sequel.

For 32-bit, one quickly discovers that swapon() is not given an fd
already opened with O_LARGEFILE to act upon and the forcing of
O_LARGEFILE for 64-bit is irrelevant, as the system call's argument is
a path. So this patch manually forces it for swapon() and swapoff().

-- wli

Index: mm5-2.6.7/mm/swapfile.c
===================================================================
--- mm5-2.6.7.orig/mm/swapfile.c 2004-07-02 20:43:30.000000000 -0700
+++ mm5-2.6.7/mm/swapfile.c 2004-07-03 23:12:35.000000000 -0700
@@ -1085,7 +1085,7 @@
if (IS_ERR(pathname))
goto out;

- victim = filp_open(pathname, O_RDWR, 0);
+ victim = filp_open(pathname, O_RDWR|O_LARGEFILE, 0);
putname(pathname);
err = PTR_ERR(victim);
if (IS_ERR(victim))
@@ -1354,7 +1354,7 @@
name = NULL;
goto bad_swap_2;
}
- swap_file = filp_open(name, O_RDWR, 0);
+ swap_file = filp_open(name, O_RDWR|O_LARGEFILE, 0);
error = PTR_ERR(swap_file);
if (IS_ERR(swap_file)) {
swap_file = NULL;