[PATCH] reiserfs lfs fix for 2.4.4-pre5 and above

Chris Mason (mason@suse.com)
Wed, 25 Apr 2001 19:12:12 -0400


Hello everyone,

2.4.4-pre5 started honoring the s_maxbytes field, so reiserfs needs a
patch to allow files > 4GB on 3.6.x format filesystems.

If you work with large files on reiserfs and are willing to try
the prerelease kernels (non-production), please give this a try,
it works for me but I'd like a few confirmations before I send to Linus.

This also prevents someone from using truncate to expand an old
format file past the 2GB mark.

-chris

diff -Nru a/fs/reiserfs/file.c b/fs/reiserfs/file.c
--- a/fs/reiserfs/file.c Tue Apr 24 13:37:21 2001
+++ b/fs/reiserfs/file.c Tue Apr 24 13:37:21 2001
@@ -106,6 +106,24 @@
return ( n_err < 0 ) ? -EIO : 0;
}

+static int reiserfs_setattr(struct dentry *dentry, struct iattr *attr) {
+ struct inode *inode = dentry->d_inode ;
+ int error ;
+ if (attr->ia_valid & ATTR_SIZE) {
+ /* version 2 items will be caught by the s_maxbytes check
+ ** done for us in vmtruncate
+ */
+ if (inode_items_version(inode) == ITEM_VERSION_1 &&
+ attr->ia_size > MAX_NON_LFS)
+ return -EFBIG ;
+ }
+
+ error = inode_change_ok(inode, attr) ;
+ if (!error)
+ inode_setattr(inode, attr) ;
+
+ return error ;
+}

struct file_operations reiserfs_file_operations = {
read: generic_file_read,
@@ -119,6 +137,7 @@

struct inode_operations reiserfs_file_inode_operations = {
truncate: reiserfs_vfs_truncate_file,
+ setattr: reiserfs_setattr,
};


diff -Nru a/fs/reiserfs/super.c b/fs/reiserfs/super.c
--- a/fs/reiserfs/super.c Tue Apr 24 13:37:21 2001
+++ b/fs/reiserfs/super.c Tue Apr 24 13:37:21 2001
@@ -492,7 +492,11 @@
SB_BUFFER_WITH_SB (s) = bh;
SB_DISK_SUPER_BLOCK (s) = rs;
s->s_op = &reiserfs_sops;
- s->s_maxbytes = 0xFFFFFFFF; /* 4Gig */
+
+ /* new format is limited by the 32 bit wide i_blocks field, want to
+ ** be one full block below that.
+ */
+ s->s_maxbytes = (512LL << 32) - s->s_blocksize ;
return 0;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/