summaryrefslogtreecommitdiff
path: root/lib/ext2fs
AgeCommit message (Collapse)AuthorFilesLines
2011-09-16debugfs: add 64-bit support to the set_field commandsTheodore Ts'o2-2/+2
The set_fields commands (set_super_value, set_inode_field, set_block_group) now handle fields which store in split fields on ext4's on-disk format. For example, the superblock fields s_blocks_count and s_blocks_count_hi. The user can either set the low or high part of the field via "blocks_count_lo" or "blocks_count_hi", or both parts can be set via "blocks_count". Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-16libext2fs: add metadata checksum and snapshot feature flagsTheodore Ts'o4-12/+39
Reserve EXT4_FEATURE_RO_COMPAT_METADATA_CSUM and EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP. Also reserve fields in the superblock and the inode for the checksums. In the block group descriptor, reserve the exclude bitmap field for the snapshot feature, and checksums for the inode and block allocation bitmaps. With this commit, the metadata checksum and exclude bitmap features should have reserved all of the fields they need in ext4's on-disk format. This commit also fixes an a missing byte swap for s_overhead_blocks. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Cc: Darrick J. Wong <djwong@us.ibm.com> Cc: Amir Goldstein <amir73il@gmail.com>
2011-09-16libext2fs: remove redundant last-group check in ext2fs_check_desc()Eric Sandeen1-2/+0
ext2fs_group_last_block2() already properly calculates the last block in the last group, so there is no need to special-case this after the call. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16e2fsprogs: add ext2fs_group_blocks_count helperEric Sandeen4-17/+22
Code to count the number of blocks in the last partial group is cut and pasted around the e2fsprogs codebase a few times. Making this a helper function should improve matters. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16libext2fs: fix size check in tst_inode_sizeTheodore Ts'o2-1/+2
Also add run tst_inode_size automaically from "make check" Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-16Merge branch 'maint' into nextTheodore Ts'o4-4/+17
2011-09-15e2fsprogs: Use punch hole as "discard" on regular filesLukas Czerner2-8/+46
If e2fsprogs tools (mke2fs, e2fsck) is run on regular file instead of on block device, we can use punch hole instead of regular discard command which would not work on regular file anyway. This gives us several advantages. First of all when e2fsck is run with '-E discard' parameter it will punch out all ununsed space from the image, hence trimming down the file system image. And secondly, when creating an file system on regular file (with '-E discard' which is default), we can use punch hole to clear the file content, hence we can skip inode table initialization, because reads from sparse area returns zeros. This will result in faster file system creation (without the need to specify lazy_itable_init) and smaller images. This commit also fixes some tests that would fail due to mke2fs showing discard progress, hence the output would differ. Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-15e2fsprogs: create open() and stat() helpersLukas Czerner4-22/+44
In many places we are using #ifdef HAVE_OPEN64 to determine if we can use open64() but that's ugly. This commit creates two new helpers ext2fs_open_file() for open() and ext2fs_stat() for stat(). Also we need new typedef ext2fs_struct_stat for struct stat. Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-15libext2fs: Add crc32c implementation for metadata checksummingDarrick J. Wong5-2/+1345
Add a slicing-by-8 CRC32c implementation for metadata checksumming. Adapted from Bob Pearson's kernel patch. Also added a self-test mechanism so we can verify that the crc32c implementation is working correctly. Signed-off-by: Darrick J. Wong <djwong@us.ibm.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-15libext2fs: fix the range validation in bitmap_range2 funcsAmir Goldstein1-5/+5
The condition ((start+num) & ~0xffffffffULL) in bitmap_range2 and generic_bmap_range funcs in get_bitmap64.c was wrong and inconsistent with the condition (start+num-1 > bmap->real_end) in generic_bitmap_range funcs in get_bitmap.c. I got the following error from tune2fs on a 16TB fs: Illegal block number passed to ext2fs_unmark_block_bitmap #4294967295 for block bitmap for 16TB.img tune2fs: Invalid argument while reading bitmaps Fix to condition to ((start+num-1) & ~0xffffffffULL), because the bit (start+num) is not going to be changed by the funcs. Signed-off-by: Amir Goldstein <amir73il@users.sf.net> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-15libext2fs: fix binary and source compatibility with the dump programTheodore Ts'o4-4/+17
The dump program relies on fs->frag_size and the EXT2_FRAGS_PER_BLOCK() macro. Kind of silly for it to do so, but it's part of the kludgy way the dump program (which was originally written for the BSD FFS was ported over to support ext2/3.) Given how it makes assumptions about the ext2/3/4 file system being similar to the BSD FFS, it's a bit of a miracle it works for ext4 --- or at least appears to work... Addresses-Debian-Bug: #636418 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-14libext2fs: add new test: tst_inode_sizeTheodore Ts'o2-1/+87
This test makes sure the size of the ext2_inode is what we expect Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-14resize2fs: add support for new in-kernel online resize ioctlYongqiang Yang1-0/+1
This is needed to support online resizing for > 32-bit file systems Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-08-31e2fsck: add support for checking the built-in quota filesAditya Kali1-1/+2
This patch adds support for doing quota accounting during full e2fsck scan if the 'quota' feature was set on the superblock. If user-visible quota inodes are in use, they will be hidden and converted to the reserved quota inodes. Signed-off-by: Aditya Kali <adityakali@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-08-31libext2fs: fix binary search for the icount and badblocks storesTheodore Ts'o2-26/+2
Remove the interpolation because there is a bug in icount which can cause a core dump if calculated range gets turned into a NaN and then do an out-of-bounds array access. We could fix this with some more tests, but the complexity is such that nuking all of the interpolation code will be faster than fixing the interpolation. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-08-10libext2fs: copy cluster_bits in ext2fs_copy_generic_bmapEric Sandeen1-0/+1
The f_lotsbad regression test was failing on some systems with: Restarting e2fsck from the beginning... Pass 1: Checking inodes, blocks, and sizes +Illegal block number passed to ext2fs_test_block_bitmap #0 for in-use block map Pass 2: Checking directory structure Entry 'termcap' in / (2) has deleted/unused inode 12. Clear? yes Running with valgrind (./test_script --valgrind f_lotsbad) we see: +==31409== Conditional jump or move depends on uninitialised value(s) +==31409== at 0x42927A: ext2fs_test_generic_bmap (gen_bitmap64.c:378) among others. Looking at gen_bitmap64.c: 376: arg >>= bitmap->cluster_bits; 377: 378: if ((arg < bitmap->start) || (arg > bitmap->end)) { A little more debugging showed that it was actually bitmap->cluster_bits which was uninitialized, because it never gets copied over in ext2fs_copy_generic_bmap() Patch below resolves the issue. Reported-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-07-09libext2fs: fix block iterator when the callback function modifies an extentTheodore Ts'o1-0/+11
If the callback interator modifies a block in the middle of an extent during a call to the block iterator, causing the extent to be split, ext2_block_iterate3() will end up calling the callback function twice for some number of blocks. Fix this. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-07-08misc: use EXT2_I_SIZE() consistently to get sizeAndreas Dilger2-5/+3
Use the EXT2_I_SIZE() macro consistently to access the inode size. The i_size/i_size_high combination is open coded in several places. Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-07-07libext2fs: don't hang in ext2fs_new_block2() on a full bigalloc file systemTheodore Ts'o1-0/+2
Prevent ext2fs_new_block2() from looping forever when a bigalloc file system is full. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-07-07libext2fs: teach ext2fs_bmap2() about bigallocTheodore Ts'o1-2/+44
This allows debugfs's write command to work correctly on bigalloc file systems. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-07-07libext2fs: move ext2fs_bmap2()'s the extent handling to a separate functionTheodore Ts'o1-54/+68
Separate the extent handling to a separate function to make BMAP_ALLOC processing more efficient. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-07-07libext2fs: teach ext2fs_block_alloc_stats2() about bigallocTheodore Ts'o1-1/+2
Change ext2fs_block_alloc_stats2() so that when a cluster is allocated, the free blocks counter in the superblock is appropriately decremented by the cluster size. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-07-07libext2fs: replace missing flexbg initialization in flexbg_offsetTheodore Ts'o1-0/+2
Commit 25567a7b0fa9 accidentally removed the initialization for flexbg and flexbg_size, which affected ext2fs_allocate_group_table() and ext2fs_allocate_tables(). Replace them. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-07-07libext2fs: Fix gcc -Wall warningsTheodore Ts'o9-20/+29
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-07-05libext2fs: fix 64-bit support in ext2fs_bmap2()Theodore Ts'o1-3/+9
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-07-05libext2fs: fix 64-bit support in ext2fs_{read,write}_inode_full()Theodore Ts'o1-2/+4
This fixes a problem where reading or writing inodes located after the 4GB boundary would fail. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-07-05e2fsck, libext2fs: support for bigalloc file systems with a blocksize of 1024Theodore Ts'o5-38/+56
Filesystems with a blocksize of 1024 have the superblock starting at block #1. However, the first data block in the superblock is 0 to simplify the cluster calculations. So we must compensate for this in a number of places, mostly in the ext2fs library, but also in e2fsck. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-19libext2fs: fix makefile dependency problemTheodore Ts'o1-2/+14
lib/ext2fs/Makefile.in had a buggy entry for blkmap64_ba.c in $(SRCS), which caused this source file to not have a valid Makefile dependency entry, so blkmap64_ba.o would not get rebuilt when it needed to be. Also updated the Makefile dependency for the misc directory while we're at it. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-16mke2fs, e2fsck: fix i_blocks handling for bigalloc file systemsTheodore Ts'o3-2/+5
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-16Fix superblock field s_blocks_count for bigalloc file systemsTheodore Ts'o1-4/+5
Treat the s_blocks_count field in the superblock as a free block count (instead of the number of free clusters) for bigalloc file systems. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-15misc: quiet "unused variable" compiler warningsAndreas Dilger1-1/+1
Some of the newly-merged patches added "unused variable" compiler warnings. Delete unused variables. Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-15libext2fs: fix regression in ext2fs_new_block2() for uninit_bg file systemsTheodore Ts'o1-0/+2
Commit b0ecb787ef introduced a bug in check_block_uninit(), which is used by ext2fs_new_block2(). This bug resulted in the block bitmap for the block group in question not having space reserved for the file system metadata blocks. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-11Merge branch 'maint' into nextTheodore Ts'o1-1/+1
2011-06-11ext2fs: fix error handling in ext2fs_add_dir_blockAndreas Dilger1-1/+1
In ext2fs_add_dir_block() the dblist allocation size was changed to grow as the number of items in the dblist increases. However, the error handling in case of allocation failure wasn't changed to match. Fix the error case to revert to the old allocation size on failure. Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-11mke2fs: skip zeroing journal blocksAndreas Dilger2-6/+19
Add the ability to skip zeroing journal blocks on disk. This can significantly speed up mke2fs with large journals. At worst the uninitialized journal is only a very short-term risk (if at all), because the journal will be overwritten on any new filesystem as soon as any significant amount of data is written to disk, and the new journal TID would need to match the offset/TID of an old commit block still left on disk. Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-11ext2fs: Handle internal journal over 2^32 bytesAndreas Dilger3-33/+42
The write_journal_inode() code is only setting the low 32-bit i_size for the journal size, even though it is possible to specify a journal up to 10M blocks in size. Trying to create a journal larger than 2GB will succeed, but an immediate e2fsck would fail. Store i_size_high for the journal inode when creating it, and load it upon access. Use s_jnl_blocks[15] to store the journal i_size_high backup. This field is currently unused, as EXT2_N_BLOCKS is 15, so it is using s_jnl_blocks[0..14], and i_size is in s_jnl_blocks[16]. Rename the "size" argument "num_blocks" for the journal creation functions to clarify this parameter is in units of filesystem blocks and not bytes. Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-11ext2fs: don't use O_DIRECT if not availableAndreas Dilger1-0/+2
O_DIRECT is not defined on OSX. Since direct IO is only a new optimization and not needed for correct functionality, disable it if O_DIRECT is unavailable. Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-11misc: fix compile warnings on OSXAndreas Dilger2-9/+5
The BLKFLSBUF and FDFLUSH ioctls are Linux specific, and do not really have anything to do with __GNUC__ (which is also used on OS/X and Solaris). Only print these warnings on Linux systems. statfs64() is deprecated on OSX and generates a deliberate warning. Fix some other warnings that show up on OSX builds. Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-11ext2fs: fix ext2fs_warn_bitmap32() return warningAndreas Dilger2-2/+2
This was reported as "control reaches end of non-void function", but comparing to other similar functions it should be a void function. Since it is only declared in the "private" ext2fsP.h header, it should be OK to change the function prototype. Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-11ext2fs: fix undeclared posix_memalign() warningAndreas Dilger1-1/+12
Older distros do not define posix_memalign() by default in the headers. If ext2fs.h is included early in the headers, it is possible to "#define _XOPEN_SOURCE 600" so that the stdlib.h header will define it, but if ext2fs.h is included after stdlib.h there is no posix_memalign() declaration. Add a posix_memalign() declaration if stdlib.h didn't do it. This is a bit of a hack for GNU headers, but it works on Linux and OS/X without problems. Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-11misc: clean up compiler warningsAndreas Dilger6-6/+6
Fix several types of compiler warnings (unused variables/labels), uninitialized variables, etc that are hit with gcc -Wall. Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-10e2fsck: add basic bigalloc support to check (but not yet repair) file systemsTheodore Ts'o2-2/+3
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-10mke2fs: support creating bigalloc file systemsTheodore Ts'o1-11/+47
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-10libext2fs: allocate clusters to files in expand_dir.c and mkjournal.cTheodore Ts'o2-10/+26
Teach ext2fs_expand_dir() and ext2fs_add_journal_inode() about allocating blocks when clustered allocation is enabled. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-10libext2fs: teach block allocation functions about bigalloc/clustersTheodore Ts'o1-5/+12
Optimize ext2fs_new_block2() and ext2fs_get_free_blocks2() when bigalloc is enabled. Also fix the uninitialized block bitmap code so that it correctly deals clustered allocation. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-10libext2fs: teach bitmap functions about bigalloc/clusterTheodore Ts'o4-2/+111
This patch makes the following changes: * ext2fs_allocate_block_bitmap() now allocates a bitmap with cluster granularity for bigalloc file systems. For mke2fs and e2fsck, a newly added function, ext2fs_allocate_subcluster_bitmap() allocates a bitmap with block granularity (even for bigalloc file systems). The newly added function ext2fs_get_bitmap_granularity() will return the number of bits (log2) of the granularity used by the bitmap. * The ext2fs_{mark,unmark,test}_block_bitmap2() functions will shift their passed-in argument by log2(cluster_ganularity) bits right. This means that the arguments for the single-argument bitmap functions will be interpreted with block granluarity, since this minimizes code changes in the rest of the code base. * The ext2fs_{get,set}_block_bitmap_range() functions will interpret their arguments in cluster granularity. This is a bit inconsistent, but the caller of those functions will need to be taught about the subtleties of clusters for bigalloc file systems. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-10libext2fs: create extent-based directories if the extents feature is enabledTheodore Ts'o1-2/+15
This allows mke2fs to create the root and lost+found directories using extents. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-04Merge branch 'maint' into nextTheodore Ts'o6-12/+41
Conflicts: lib/ext2fs/bitmaps.c lib/ext2fs/rw_bitmaps.c misc/dumpe2fs.c
2011-06-04libext2fs: Teach block bitmap read, write, and allocation funcs about clustersTheodore Ts'o2-9/+10
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-04libext2fs: change fs->clustersize to fs->cluster_ratio_bitsTheodore Ts'o3-3/+21
The log2 of the ratio of cluster size to block size is far more useful than just storing the cluster size. So make this change, and then define basic utility macros: EXT2FS_CLUSTER_RATIO(), EXT2FS_CLUSTER_MASK(), EXT2FS_B2C(), EXT2FS_C2B(), and EXT2FS_NUM_B2C(). Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>