Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 Oct 2005 19:53:40 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Brian Bergstrand <freebsd@classicalguitar.net>
Cc:        freebsd-fs@freebsd.org, Ivan Voras <ivoras@fer.hr>
Subject:   Re: ext2 large_file
Message-ID:  <20051031191139.J38757@delplex.bde.org>
In-Reply-To: <46D894BD-16E0-4CBA-B40A-EEBAAC2547D2@classicalguitar.net>
References:  <20051030183340.B19470@geri.cc.fer.hr> <46D894BD-16E0-4CBA-B40A-EEBAAC2547D2@classicalguitar.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 30 Oct 2005, Brian Bergstrand wrote:

> I ported the FreeBSD driver to Mac OS X / Darwin a few years ago and added 
> large file support in the process. Here's the patch, as you can see it's a 
> rather simple patch (as long as the in core i_size member is 64bit which I 
> think is true for FreeBSD):

tjr implemented it in FreeBSD almost 2 years ago:

% RCS file: /home/ncvs/src/sys/gnu/ext2fs/ext2_fs.h,v
% Working file: ext2_fs.h
% head: 1.13
% ...
% ----------------------------
% revision 1.13
% date: 2004/02/18 14:08:25;  author: tjr;  state: Exp;  lines: +2 -1
% Add partial support for large (>4GB) files on ext2 filesystems. This
% support is partial in that it will refuse to create large files on
% filesystems that haven't been upgraded to EXT2_DYN_REV or that don't
% have the EXT2_FEATURE_RO_COMPAT_LARGE_FILE flag set in the superblock.
% 
% MFC after:	2 weeks
% ----------------------------

I don't don't know if block allocation actually works for large files.

> I doubt this patch will apply cleanly as my tree has diverged from FreeBSD in 
> a non-compatible way quite a while ago -- but it should give you a start:

I prefer tjr's version.

> Index: ext2_inode_cnv.c
> ===================================================================
> RCS file: /cvsroot/ext2fsx/src/gnu/ext2fs/ext2_inode_cnv.c,v
> retrieving revision 1.6
> retrieving revision 1.7
> diff -u -b -r1.6 -r1.7
> - --- ext2_inode_cnv.c    3 May 2003 23:54:39 -0000       1.6
> +++ ext2_inode_cnv.c    9 Jul 2003 23:09:24 -0000       1.7
> ...
> @@ -182,6 +214,31 @@
>                raw_inode->i_uid_high = 0;
>                raw_inode->i_gid_high = 0;
>        }*/
> +   if (S_ISREG(ip->i_mode)) {
> +      ei->i_size_high = cpu_to_le32(ip->i_size >> 32);
> +      if (ip->i_size > 0x7fffffffULL) {
> +         struct ext2_sb_info *sb = ip->i_e2fs;
> +         if (!EXT2_HAS_RO_COMPAT_FEATURE(sb,
> +            EXT2_FEATURE_RO_COMPAT_LARGE_FILE) ||
> +            EXT2_SB(sb)->s_es->s_rev_level == cpu_to_le32 
> (EXT2_GOOD_OLD_REV)) {
> +            /* First large file, add the flag to the superblock. */

Compatibility flags shouldn't be forced on IMO.  Linux does it for this
flag, but this is a bug IMO.  It breaks subsequent remounting r/w on
old or other kernels that don't support large files.

Changes are also needed to at least ext2_fs.h (to indicate that the kernel
supports large files), ext2_vfsops.c (to set fs_maxfilesize according to
the compatibility flag), and ext2_readwrite.c (to actually use the ifdefed
out code that checks fs_maxfilesize, and fix minor bitrot in that code).

> On Oct 30, 2005, at 11:37 AM, Ivan Voras wrote:
>
>> I recently tried to use ext2 on FreeBSD but have decided not to when I saw 
>> that the support for large files is missing (and went with msdosfs 
>> instead).

msdosfs is physically incapable of supporting large files.  Its maximum
file size is the constant 0xffffffff.

>> Now I accidentaly noticed that large_file support is present in latest 
>> NetBSD (and maybe OpenBSD). Is anyone interested in porting the support to 
>> FreeBSD? :)

I prefer FreeBSD's version.

NetBSD got it 9 months ago, only a year after FreeBSD.  It refuses to
create files larger than 2G-1 if the ext2fs rev number is old, and says
in a comment that Linux silently upgrades the rev number.  It silently
clobbers the compat flag like Linux.  Someone has an off-by-power-of-2
error -- the corresponding limit in FreeBSD is 4G-1.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20051031191139.J38757>