]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Fix page cache limit wrapping in filesystems
authorAndi Kleen <ak@muc.de>
Wed, 6 Feb 2002 14:13:48 +0000 (06:13 -0800)
committerLinus Torvalds <torvalds@athlon.transmeta.com>
Wed, 6 Feb 2002 14:13:48 +0000 (06:13 -0800)
Several file systems in tree that nominally support files >2GB set their
s_maxbytes value to ~0ULL. This has the nasty side effect on 32bit machines
that when a file write reaches the page cache limit (e.g. 2^43) it'll silently
wrap and destroy data at the beginning of the file.

This patch changes the file systems in question to fill in a proper limit.

I also have an alternate patch that adds a check for this generically
in super.c, but preliminary comments from Al suggested that he prefered
to do it in the file systems, so it is done this way way.

fs/nfs/inode.c
fs/ntfs/fs.c
fs/udf/super.c
include/linux/fs.h

index 261cadb586359fb32da143ddbbb4726e43e75324..b72b6e662e77361c7a61ebbe861123dcca5fd7a0 100644 (file)
@@ -455,6 +455,8 @@ nfs_read_super(struct super_block *sb, void *raw_data, int silent)
                 server->namelen = maxlen;
 
        sb->s_maxbytes = fsinfo.maxfilesize;
+       if (sb->s_maxbytes > MAX_LFS_FILESIZE) 
+               sb->s_maxbytes = MAX_LFS_FILESIZE; 
 
        /* Fire up the writeback cache */
        if (nfs_reqlist_alloc(server) < 0) {
index 4fa8e2f018e436de8cfd08d2c25a812a5d409f38..d28ea94084a95c2a4976dcf1891d401fb93d49d0 100644 (file)
@@ -1130,7 +1130,7 @@ struct super_block *ntfs_read_super(struct super_block *sb, void *options,
        /* Inform the kernel about which super operations are available. */
        sb->s_op = &ntfs_super_operations;
        sb->s_magic = NTFS_SUPER_MAGIC;
-       sb->s_maxbytes = ~0ULL >> 1;
+       sb->s_maxbytes = MAX_LFS_FILESIZE;
        ntfs_debug(DEBUG_OTHER, "Reading special files\n");
        if (ntfs_load_special_files(vol)) {
                ntfs_error("Error loading special files\n");
index a4984734a38426803c050b5d37ad88ed54f80c41..cf78cf53cc76785fafa7427affa5a9b480d94a01 100644 (file)
@@ -1544,7 +1544,7 @@ udf_read_super(struct super_block *sb, void *options, int silent)
                iput(inode);
                goto error_out;
        }
-       sb->s_maxbytes = ~0ULL;
+       sb->s_maxbytes = MAX_LFS_FILESIZE;
        return sb;
 
 error_out:
index 95b6286bbe58dd730284e96f954386c1301f8814..87b16073006057286c302987969fd9f17148b8cf 100644 (file)
@@ -520,6 +520,14 @@ extern int init_private_file(struct file *, struct dentry *, int);
 
 #define        MAX_NON_LFS     ((1UL<<31) - 1)
 
+/* Page cache limit. The filesystems should put that into their s_maxbytes 
+   limits, otherwise bad things can happen in VM. */ 
+#if BITS_PER_LONG==32
+#define MAX_LFS_FILESIZE       (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1) 
+#elif BITS_PER_LONG==64
+#define MAX_LFS_FILESIZE       0x7fffffffffffffff
+#endif
+
 #define FL_POSIX       1
 #define FL_FLOCK       2
 #define FL_BROKEN      4       /* broken flock() emulation */