PATCH for reiserfs, max 2GB in version 3.5

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If we create a file greater than 2GB in a reiserfs v3.5,
the file size will not be checked and the file can be
created like this:

pc1:/mnt_hdg10 # dd if=/dev/zero of=zero_3GB.dd bs=1024 count=3000000
3000000+0 records in
3000000+0 records out
pc1:/mnt_hdg10 #

The command "ls -l" shows the file size as created above:

pc1:/mnt_hdg10 # ls -l zero_3GB.dd
-rw-r--r--  1 root root 3072000000 Oct  3 15:59 zero_3GB.dd
pc1:/mnt_hdg10 #

When we read this file, read will abort when the 2GB border is reached:

pc1:/mnt_hdg10 # dd if=zero_3GB.dd of=/dev/null bs=1024
dd: reading `zero_3GB.dd': Input/output error
2097152+0 records in
2097152+0 records out
pc1:/mnt_hdg10 #


A file system check does not help,
the command "reiserfsck --fix-fixable /dev/hdg10"
spit out this massage:

/zero_3GB.ddvpf-10670: The file [2 23061] has the wrong size in the StatData (3072000000) - corrected to (3072000000)

BTW this file can be delete with the command "rm zero_3GB.dd".


The same test in a reiserfs v3.5 with a file greater than 4GB will end in more trouble.
You can test this like:

pc1:/mnt_hdg10 # dd if=/dev/zero of=zero_5GB.dd bs=1024 count=5000000


---------------------------------------------------------------------------

A simple check will avoid to create files greater than 2GB in reiserfs v3.5,
see patch below:

---------------------------------------------------------------------------

--- linux-2.6.13/fs/reiserfs/file.c.ORIG 2005-08-29 01:41:01.000000000 +0200
+++ linux-2.6.13/fs/reiserfs/file.c     2005-10-11 11:41:23.000000000 +0200
@@ -1343,10 +1343,14 @@

        down(&inode->i_sem);    // locks the entire file for just us

        pos = *ppos;

+       // 2005-10-07 --ms, max 2GB on v3.5
+       if (get_inode_item_key_version(inode) == KEY_FORMAT_3_5)
+ file->f_flags &= ~O_LARGEFILE; // for LFS rule in generic_write_checks()
+
        /* Check if we can write to specified region of file, file
           is not overly big and this kind of stuff. Adjust pos and
           count, if needed */
        res = generic_write_checks(file, &pos, &count, 0);
        if (res)


Signed-off-by: Manfred Scherer <[email protected]>

-------------------------------------------------------------------------

BTW the 2.4 kernel will have the same problem.

fs/reiserfs/file.c:

static ssize_t
reiserfs_file_write(struct file *f, const char *b, size_t count, loff_t *ppos)
{
    ssize_t ret;
    struct inode *inode = f->f_dentry->d_inode;

+    // 2005-10-07 --ms, max 2GB on v 3.5
+    if (get_inode_item_key_version(inode) == KEY_FORMAT_3_5)
+ file->f_flags &= ~O_LARGEFILE; // for LFS rule in precheck_file_write()
+
    ret = generic_file_write(f, b, count, ppos);
    if (ret >= 0 && f->f_flags & O_SYNC) {
        lock_kernel();
        reiserfs_commit_for_inode(inode);
        unlock_kernel();
    }
    return ret;
}

-------------------------------------------------------------------------

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

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux