The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Manfred Scherer <Manfred.Scherer.Mhm@t-online.de>
To: reiserfs-dev@namesys.com
Cc: linux-kernel@vger.kernel.org
Subject: PATCH for reiserfs, max 2GB in version 3.5
Date: Thu, 13 Oct 2005 14:38:25 +0200	[thread overview]
Message-ID: <434E5541.5030307@t-online.de> (raw)

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 <manfred.scherer.mhm@t-online.de>

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

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

             reply	other threads:[~2005-10-13 20:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-13 12:38 Manfred Scherer [this message]
2005-10-14 11:01 ` PATCH for reiserfs, max 2GB in version 3.5 David R
2005-10-14 11:13   ` David R

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=434E5541.5030307@t-online.de \
    --to=manfred.scherer.mhm@t-online.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=reiserfs-dev@namesys.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox