PATCH for reiserfs, max 2GB in version 3.5
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:
---------------------------------------------------------------------------
fs/reiserfs/file.c 2005-10-11 11:41:23.000000000 +0200 renamed from fs/reiserfs/file.c.ORIG 2005-08-29 01:41:01.000000000 +0200 +4 -0
@@ -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)
-------------------------------------------------------------------------
BTW the 2.4 kernel will have the same problem.
fs/reiserfs/file.c:
static ssize_treiserfs_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
Quoting Manfred Scherer <[email protected]>:
Quoted 4 lines
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:
I'm confused. I've got lots of video files > 2GB using Reiser 3
m@server:/mnt/raid/> dd if=051008-19.04.05.mpg of=/dev/null bs=1024 2573276+1 records in
2573276+1 records out
m@server:/mnt/raid/> ls -l 051008-19.04.05.mpg
-rw-r--r-- 1 m users 2635034636 2005-10-08 21:15 051008-19.04.05.mpg
that seem to work just fine?
David.
Quoting David R <[email protected]>:
Quoted 2 lines
I'm confused. I've got lots of video files > 2GB using Reiser 3
That would be a key format 3.6 volume. Sorry for the noise.
David