diff options
author | pfg <pfg@FreeBSD.org> | 2013-08-12 21:34:48 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2013-08-12 21:34:48 +0000 |
commit | 0b111bdfcbe8e9c5f1d30ef4226b1250231c8716 (patch) | |
tree | e860424fb0197712306853c548b2f4f68cda88d8 /sys/fs/ext2fs/ext2_vfsops.c | |
parent | 3eef1145fb2dc3eb7434ad247e8dd4f79a183cd0 (diff) | |
download | FreeBSD-src-0b111bdfcbe8e9c5f1d30ef4226b1250231c8716.zip FreeBSD-src-0b111bdfcbe8e9c5f1d30ef4226b1250231c8716.tar.gz |
Add read-only support for extents in ext2fs.
Basic support for extents was implemented by Zheng Liu as part
of his Google Summer of Code in 2010. This support is read-only
at this time.
In addition to extents we also support the huge_file extension
for read-only purposes. This works nicely with the additional
support for birthtime/nanosec timestamps and dir_index that
have been added lately.
The implementation may not work for all ext4 filesystems as
it doesn't support some features that are being enabled by
default on recent linux like flex_bg. Nevertheless, the feature
should be very useful for migration or simple access in
filesystems that have been converted from ext2/3 or don't use
incompatible features.
Special thanks to Zheng Liu for his dedication and continued
work to support ext2 in FreeBSD.
Submitted by: Zheng Liu (lz@)
Reviewed by: Mike Ma, Christoph Mallon (previous version)
Sponsored by: Google Inc.
MFC after: 3 weeks
Diffstat (limited to 'sys/fs/ext2fs/ext2_vfsops.c')
-rw-r--r-- | sys/fs/ext2fs/ext2_vfsops.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/sys/fs/ext2fs/ext2_vfsops.c b/sys/fs/ext2fs/ext2_vfsops.c index 1c8e1aa..b468356 100644 --- a/sys/fs/ext2fs/ext2_vfsops.c +++ b/sys/fs/ext2fs/ext2_vfsops.c @@ -397,9 +397,11 @@ compute_sb_data(struct vnode *devvp, struct ext2fs *es, if (es->e2fs_rev == E2FS_REV0 || !EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_LARGEFILE)) fs->e2fs_maxfilesize = 0x7fffffff; - else - fs->e2fs_maxfilesize = 0x7fffffffffffffff; - + else { + fs->e2fs_maxfilesize = 0xffffffffffff; + if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_HUGE_FILE)) + fs->e2fs_maxfilesize = 0x7fffffffffffffff; + } if (es->e4fs_flags & E2FS_UNSIGNED_HASH) { fs->e2fs_uhash = 3; } else if ((es->e4fs_flags & E2FS_SIGNED_HASH) == 0) { @@ -961,8 +963,12 @@ ext2_vget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp) * Now we want to make sure that block pointers for unused * blocks are zeroed out - ext2_balloc depends on this * although for regular files and directories only + * + * If EXT4_EXTENTS flag is enabled, unused blocks aren't + * zeroed out because we could corrupt the extent tree. */ - if(S_ISDIR(ip->i_mode) || S_ISREG(ip->i_mode)) { + if (!(ip->i_flags & EXT4_EXTENTS) && + (S_ISDIR(ip->i_mode) || S_ISREG(ip->i_mode))) { used_blocks = (ip->i_size+fs->e2fs_bsize-1) / fs->e2fs_bsize; for (i = used_blocks; i < EXT2_NDIR_BLOCKS; i++) ip->i_db[i] = 0; |