summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
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 Dilger6-24/+23
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 Dilger8-11/+12
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'o7-13/+43
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>
2011-06-04libext2fs: change EXT2_MAX_BLOCKS_PER_GROUP() to be cluster size awareTheodore Ts'o1-1/+5
Change the EXT2_MAX_BLOCKS_PER_GROUP so that it takes the cluster size into account. This way we can open bigalloc file systems without ext2fs_open() thinking that they are corrupt. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-04libext2fs: require cluster size == block_size when opening a !bigalloc fsTheodore Ts'o1-0/+6
In ext2fs_open() check to make sure the cluster size superblock field is the same as the block size field when the bigalloc feature is not set. This is necessary since we will start introducing calculations based on the cluster size field. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-04libcom_err: Fix install rule if installing with hard linksTheodore Ts'o1-1/+2
If $(LINK_INSTALL_FLAGS) is -f instead of -sf, the Makefile's install rule would not work correctly while installing com_err.h Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-05-18e2image: Add support for qcow2 formatLukas Czerner5-14/+377
This commit adds support for exporting filesystem into QCOW2 image format. Like sparse format this saves space, by writing only necessary (metadata blocks) into image. Unlike sparse image, QCOW2 image is NOT sparse, hence does not change its size by copying with not-sparse-aware tools. New options '-Q' has been added to tell the e2image to use QCOW2 as an output image format. QCOW2 supports encryption and compression, however e2image so far does no support such features, however you can still scramble filenames with '-s' option. Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-05-18e2fsprogs: Add memory allocation and zero-out helpersLukas Czerner1-1/+27
Add functions ext2fs_get_memzero() which will malloc() the memory using ext2fs_get_mem(), but it will zero the allocated memory afterwards with memset(). Add function ext2fs_get_arrayzero() which will use calloc() for allocating and zero-out the array. Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-05-14mke2fs: make s_inodes_per_group >= 8 in ext2fs_initializeTao Ma1-0/+2
current mkfs.ext4 fails if we tried with the following parameters: mkfs.ext4 -m 0 -N 16 -O ^has_journal,^resize_inode,^uninit_bg,extent,meta_bg -b 1024 /dev/sdb3 It will cause segfault, but it is caused by another issue. See my patch "mke2fs: Avoid segmentation fault in ext2fs_alloc_generic_bmap". And with that patch, the mkfs.ext4 will fail with the error: /dev/sdb3: Memory allocation failed while setting up superblock The reason is that in ext2fs_initialize, we align s_inodes_per_group to 8, but fails to consider the case that s_inodes_per_group < 8. So make at least 8 inodes for s_inodes_per_group. Signed-off-by: Tao Ma <boyu.mt@taobao.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-05-08e2fsprogs: fix memory leak in ext2fs_free_generic_bmap()Lukas Czerner1-0/+1
In ext2fs_free_generic_bmap() when we are freeing 64-bit bitmap, we do call free_bmap() to free backend specific bitmap structures, however we should also free ext2fs_generic_bitmap structure as well. Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-05-08e2fsprogs: fix freeing bitmap in allocation error pathLukas Czerner1-1/+1
In ext2fs_alloc_generic_bmap() error path, when new bitmap allocation fails ext2fs_generic_bitmap should be freed, however in current state it first frees ext2fs_generic_bitmap and then ext2fs_generic_bitmap->description which is wrong. This commit fix the free ordering. Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-03-18Merge branch 'maint' into nextTheodore Ts'o3-2/+7
Conflicts: lib/e2p/ls.c
2011-03-18add new superblock field: s_overhead_blocksTheodore Ts'o3-2/+7
It turns out that it's very hard to calculate overheads in the face of clustered allocation (bigalloc). This is because multiple metadata blocks from different block groups can end up in the same allocation cluster. Calculating the exact overhead requires O(all block bitmaps) in memory, or O(number of block groups**2) in time. So we will calculate this at mkfs time and stash it in the superblock. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-02-27mke2fs: If the device supports discard, don't print an error messageTheodore Ts'o1-0/+3
Check to see if the device supports discard before starting the progress bar, and then printing an error about inappropriate ioctl for device (when creating a file system image to a file, for example). Also, add a function signature in the ext2_io.h header file for io_channel_discard() and fix an extra, uneeded argument in mke2fs's call to that function. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-02-27Merge branch 'maint' into nextTheodore Ts'o9-33/+55
Conflicts: lib/ext2fs/initialize.c
2011-02-25Add basic BIGALLOC support for cluster-based allocationTheodore Ts'o8-30/+36
This adds the superblock fields needed so that dumpe2fs works and the code points and renames the superblock fields from describing fragments to clusters. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-02-25e2fsprogs: reserving code points for new ext4 quota featureAditya Kali6-3/+19
This patch adds support for detecting the new 'quota' feature in ext4. The patch reserves code points for usr and group quota inodes and also for the feature flag EXT4_FEATURE_RO_COMPAT_QUOTA. Signed-off-by: Aditya Kali <adityakali@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-02-20Merge branch 'maint' into nextTheodore Ts'o2-15/+4
Conflicts: misc/mke2fs.conf.5.in
2011-02-20e2fsprogs: enable user namespace xattrs by defaultEric Sandeen1-0/+1
User namespace xattrs are generally useful, and I think extN is the only filesystem requiring a special mount option to enable them, when xattrs are otherwise available. So this change sets that mount option into the defaults, via a mke2fs.conf option. Note that if xattrs are config'd off, this will lead to a mostly-harmless: EXT4-fs (sdc1): (no)user_xattr options not supported message at mount time... Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-02-20e2fsprogs: turn off enforced fsck intervals by defaultEric Sandeen1-15/+2
The forced fsck often comes at unexpected and inopportune moments, and even enterprise customers are often caught by surprise when this happens. Because a filesystem with an error condition will be marked as requiring fsck anyway, I submit that the time-based and mount-based checks are not particularly useful, and that administrators can schedule fscks on their own time, or tune2fs the enforced intervals if they so choose. This patch disables the intervals by default, and I've added a new mkfs.conf option to turn on the old behavior of random, unexpected, time-consuming fscks at boot time. ;) Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-02-20e2fsprogs: create com_err.h link in includedirEric Sandeen1-0/+1
After debian bug #192277, debian/rules started making a symlink to com_err.h in /usr/include. Now I have Fedora bug #550889 for the same issue, and perhaps it's time to make this link by default, rather than fixing it up in packaging steps? [ Changed by tytso to remove the explicit -s option; this will default to creating a hard link by default, which slightly faster. If people want to use symlinks for all links during the install process, they can use configure option --enable-symlink-install. The reason for this change is that some file systems, like AFS, don't support symlinks, and AFS users complain when they can't build or install into AFS. So I don't want to use symlinks unconditionally without a way of switching things back and forth, and it's easier if we just make all links made during the install process to be hard links or sym links. ] Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-22Merge branch 'maint' into nextTheodore Ts'o1-1/+3
Conflicts: resize/resize2fs.c
2010-12-22libext2fs: Don't use the extended rec_len encoding for standard file systemsTheodore Ts'o1-1/+3
If the file system has a blocksize less than 64k, then don't use the extended rec_len encoding, to be consistent with what the kernel will do. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-22libext2fs: fix possible memory leak in write_journal_inode()Namhyung Kim1-0/+1
ext2fs_zero_block2() allocates static buffer if needed so it should be freed at last (call it again with 0 args). Signed-off-by: Namhyung Kim <namhyung@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-21ext2fs: fix memory leak in an error case in inode_open()Theodore Ts'o1-2/+3
Reported-by: Namhyung Kim <namhyung@gmail.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-20libext2fs: fix potential free() of garbage in ext2fs_update_bb_inode()Theodore Ts'o1-2/+1
There was a potential of freeing an uninitialized pointer in rec.block_buf, which was pointed out by Namhyung Kim <namhyung@gmail.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-20libext2fs: fix dubious code in ext2fs_unmark_generic_bitmap()Namhyung Kim1-1/+1
Looks like a copy & paste problem to me. Signed-off-by: Namhyung Kim <namhyung@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-20libext2fs: remove unnecessary casts to ext2fs_generic_bitmapNamhyung Kim1-49/+30
Signed-off-by: Namhyung Kim <namhyung@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-20libext2fs: fix dubious code in ext2fs_numeric_progress_init()Namhyung Kim1-1/+1
Looks like a copy & paste problem to me. Signed-off-by: Namhyung Kim <namhyung@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-20libext2fs: fix potential build failure with OMIT_COM_ERRNamhyung Kim1-6/+6
This fixes following build failure when OMIT_COM_ERR is defined: lib/ext2fs/gen_bitmap.c: In function ‘ext2fs_clear_generic_bitmap’: lib/ext2fs/gen_bitmap.c:437: error: invalid storage class for function ‘ext2fs_test_clear_generic_bitmap_range’ lib/ext2fs/gen_bitmap.c:559: error: expected declaration or statement at end of input lib/ext2fs/gen_bitmap.c: In function ‘ext2fs_get_generic_bitmap_end’: lib/ext2fs/gen_bitmap.c:559: error: expected declaration or statement at end of input lib/ext2fs/gen_bitmap.c: In function ‘ext2fs_get_generic_bitmap_start’: lib/ext2fs/gen_bitmap.c:559: error: expected declaration or statement at end of input lib/ext2fs/gen_bitmap.c: In function ‘ext2fs_unmark_generic_bitmap’: lib/ext2fs/gen_bitmap.c:559: error: expected declaration or statement at end of input lib/ext2fs/gen_bitmap.c: In function ‘ext2fs_mark_generic_bitmap’: lib/ext2fs/gen_bitmap.c:559: error: expected declaration or statement at end of input lib/ext2fs/gen_bitmap.c: In function ‘ext2fs_test_generic_bitmap’: lib/ext2fs/gen_bitmap.c:559: error: expected declaration or statement at end of input make[2]: *** [gen_bitmap.o] Error 1 make[2]: Leaving directory e2fsprogs/lib/ext2fs' make[1]: *** [all-libs-recursive] Error 1 make[1]: Leaving directory e2fsprogs' make: *** [all] Error 2 Signed-off-by: Namhyung Kim <namhyung@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-20Merge branch 'maint' into nextTheodore Ts'o3-6/+10
Conflicts: lib/ext2fs/block.c lib/ext2fs/csum.c resize/main.c
2010-12-16libext2fs: Fix compile bug on big-endian architecturesTheodore Ts'o1-1/+1
Addresses-Sourceforge-Bug: #3138115 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>