summaryrefslogtreecommitdiff
path: root/resize
AgeCommit message (Collapse)AuthorFilesLines
2010-12-22resize2fs: do not clear resize inode for 0 resvd blocksEric Sandeen1-15/+0
I ran into odd behavior where mkfs.ext4 of a 16T filesystem would create a resize inode with 0 reserved blocks, and mark the resize_inode feature. A subsequent slight downward resize of the filesystem would remove the resize inode, making any further offline resizing impossible. This is especially odd in light of the fact that a large downward resize (say, to 8T) will actually add blocks to the resize inode - so a small resize removes it, a large resize expands it ... commit 8ade268cf2fde8629b51bfd1c044a83db88234cd had added this: If the filesystem is grown to the point where the resize_inode is no longer needed, clean it up properly so e2fsck doesn't have to. but, it seems e2fsck does not care about this situation, either. So, simply leave the resize_inode intact in this case, and everything seems to be happy. Note, this is for the 1.41.xx branch. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-16resize2fs: handle exactly-16T filesystems in resize2fsEric Sandeen1-3/+11
Before we go whole-hog on 64-bit e2fsprogs, I wonder if this is worth considering as a last-minute addition to the 1.41 stream. Currently, mke2fs will shave a block off an exactly-16T device to fit*, but resize2fs does not do the same, leading to some asymmetry. This patch fixes that up, and allows 16T devices to be handled more gracefully in offline resize. (in fact resize2fs will not even open a 16T device, today). *commit 37d17a65ecb4615546b417038190a41bafca7c51 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-11-26resize2fs: Clarify error explaining on-line shrinking is not supported at allTheodore Ts'o1-2/+1
Addresses-Debian-Bug: #599786 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-11-26resize2fs.8.in: Document that resize2fs -p only works on offline resizesTheodore Ts'o1-2/+2
Addresses-Launchpad-Bug: #505719 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-09-25resize2fs.8: Make it clear that power-of-2 units are meant by kilobytesTheodore Ts'o1-0/+8
It's sad that this needs to be made clear.... Addresses-Debian-Bug: #594004 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-07-19resize2fs.8: Update man page to indicate ext4 supports on-line resizeTheodore Ts'o1-1/+1
Addresses-Debian-Bug: #589345 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-07-17resize2fs: relax requirements for -P output a bitEric Sandeen1-2/+1
Requiring an immediate pre-fsck before printing a minimum resize size seems a bit draconian; if the fs isn't clean or marked with error, then certainly, but for an informational minimum size, I don't think we need to require a fsck since last mount. I had simply copied the checks from the actual resize path, previously. Installers use this option (-P) to gather minimum resize info, and requiring an actual fsck before use just seems to go too far. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-07-05e2fsck, resize2fs: fix a fp precision error that can lead to a seg faultTheodore Ts'o1-1/+6
Commit 641b66b fixed a floating point precision error which can result in a search algorithm looping forever. It can also result in an array index being out of bounds and causing a segfault. Here are two more cases in e2fsck and resize2fs that need to be fixed. I've just used the same fix from the that commit. Signed-off-by: Lachlan McIlroy <lmcilroy@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-05-12resize2fs: don't print minimum size if fs is not cleanEric Sandeen1-0/+8
Right now, resize2fs -P on a dirty filesystem will give you a number; however, it's probably wrong if the fs is not clean: # resize2fs -P myimage.img resize2fs 1.41.9 (22-Aug-2009) Estimated minimum size of the filesystem: 75623 # e2fsck -fy myimage.img e2fsck 1.41.9 (22-Aug-2009) myimage.img: recovering journal Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information myimage.img: ***** FILE SYSTEM WAS MODIFIED ***** myimage.img: 9530/53760 files (0.1% non-contiguous), 24737/98304 blocks # resize2fs -P myimage.img resize2fs 1.41.9 (22-Aug-2009) Estimated minimum size of the filesystem: 32165 We should issue the same "Please run e2fsck ..." message for -P as we do for an actual resize request. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-02-05resize2fs: Fix fix uninit group test accessing invalid memoryTheodore Ts'o1-0/+4
Commit 74128f8 added tests for uninit groups, but it could access past the end of the group_desc[] array after processing the last group: ==19668== Invalid read of size 2 ==19668== at 0x40518C: resize_fs (resize2fs.c:1824) ==19668== by 0x405A46: main (main.c:451) ==19668== Address 0x5a0d002 is not stack'd, malloc'd or (recently) free'd ==19668== ==19668== Invalid read of size 2 ==19668== at 0x405391: resize_fs (resize2fs.c:1864) ==19668== by 0x405A46: main (main.c:451) ==19668== Address 0x5a0d002 is not stack'd, malloc'd or (recently) free'd ==19668== It was found by Eric Sandeen running the regression suite through valgrind. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-11-12resize2fs: exit fix_sb_journal_backup early for external journalEric Sandeen1-0/+4
Resizing a filesystem with an external journal fails when it tries to read inode 0: # touch testfs # truncate testfs 1342177280 # touch testjournal # truncate testjournal 134217728 # mke2fs -O journal_dev testjournal # losetup /dev/loop0 testjournal # mkfs.ext4 -J device=/dev/loop0 testfs 127680 # resize2fs testfs resize2fs 1.41.9 (22-Aug-2009) Resizing the filesystem on testfs to 327680 (4k) blocks. resize2fs: Illegal inode number while trying to resize testfs Please run 'e2fsck -fy testfs' to fix the filesystem after the aborted resize operation. I think the right, simple thing to do is just bail out early for an external journal here, as there are no backup blocks to update. Reported-by: mjevans1983@gmail.com Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-10-04Don't use in-tree header files if using system uuid or blkid librariesTheodore Ts'o1-10/+19
This commit forces the use of the system-provided blkid or uuid header files if we are using the system-provided blkid or uuid libraries. This avoids using the in-tree header files with the system libraries. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07resize2fs: fix minimum resize size calculation with flex_bgPeng Tao1-3/+17
When flex_bg is on, calculate_minimum_resize_size() should add more meta blocks for newly added flex_bg. Addresses-RedHat-Bugzilla: #519131 Signed-off-by: Peng Tao <bergwolf@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-09-07resize2fs: calculate minimal fs size only oncePeng Tao1-1/+1
When running resize2fs -M, no need to recalculate the minimal fs size. Signed-off-by: "Peng Tao" <bergwolf@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-07-11resize2fs: If resize2fs fails, tell the user to run e2fsckTheodore Ts'o2-2/+12
If the resize operation fails in the middle of the operation, mark the filesystem as needing to be checked, and tell the user that they should run e2fsck -fy on the device. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-02resize2fs: Fix error message so the mountpoint is printed correctlyTheodore Ts'o1-3/+2
The resize2fs program was freeing the mountpoint information too early, so garbage was getting printed instead of the correct information in an error message. Addresses-Debian-Bug: #535452 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-02Add support for configure --enable-verbose-makecmdsTheodore Ts'o1-16/+16
Some people don't want to see the concise "kernel-style" make output. This configure option allows build engines that want to see the full set of commands executed by the makefile to get what they want. Most people will find this more distracting than useful, unless they need to debug the Makefiles. (It is not necessary to rerun configure to enable this verbose make output temprarily; if a developer wants to do a quick debug of a directory's makefile, he or she can simply edit the definition of the $(E) and $(Q) variables in the Makefile; instructions can be found in the MCONFIG file which is included in at the beginning of every Makefile.) Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-01Fix Makefile dependencies for libcom_errTheodore Ts'o1-3/+3
The e2fsprogs makefiles were using the same Makefile variable LIBCOM_ERR for the link-line arguments as well as the dependencies. Since LIBCOM_ERR can now include non-file arguments such as "-lpthread", we need to use a separate DEPLIBCOM_ERR variable that only has build file dependencies. Do the same thing for STATIC_LIBCOM_ERR and PROFILED_LIBCOM_ERR. Addresses-Sourceforge-Patches: #2813809 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-18resize2fs: update sb journal backup if journal was movedEric Sandeen1-0/+27
This was reported in Fedora, since the livecd creator does a lot of resizing. If we've moved the journal blocks during resize (more likely now, due to the journal being in the middle) the backup blocks in the superblock don't get updated, and a subsequent e2fsck will find issues: e2fsck 1.41.6 (30-May-2009) Backing up journal inode block information. Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /mnt/test/img: ***** FILE SYSTEM WAS MODIFIED ***** /mnt/test/img: 11/16000 files (0.0% non-contiguous), 17789/38400 blocks This can be shown in a simple test: # dd if=/dev/zero of=img bs=1 count=0 seek=3000M # mke2fs -t ext4 -F img # resize2fs img 150M # e2fsck -f img (thanks to the Fedora reporter Mads Kiilerich for the testcase! https://bugzilla.redhat.com/show_bug.cgi?id=506105#c2) So, update the backup journal in the superblock before resize2fs exits. Addresses-RedHat-Bugzilla: #505339 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-15resize2fs: fix miscellaneous memory leaksTheodore Ts'o2-1/+7
Fix various memory leaks which were discovered using valgrind. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-30Update man pages to include ext4 in the synposis, instead of just "ext2/ext3"Theodore Ts'o1-3/+3
The e2fsprogs programs have historically just said that they operate on ext2 and ext3 file system in their man pages. Update them to say that they also operate on ext4 file systems. Addresses-Launchpad-bug: #381854 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-25resize2fs: don't try to resize below calculated minimumEric Sandeen1-1/+9
Without a force flag, don't allow resize2fs to even start resizing below what it thinks the minimum safe value is. This may stop resizes which could otherwise proceed with a bit of space still left, but seems like a reasonably safe thing to do. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-05-25resize2fs: fix minimum size calculationsEric Sandeen1-0/+6
The extra padding added to the minimum size calculations: /* * We need to reserve a few extra blocks if extents are * enabled, in case we need to grow the extent tree. The more * we shrink the file system, the more space we need. */ if (fs->super->s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS) blks_needed += (fs->super->s_blocks_count - blks_needed)/500; can go quite wrong if we've already added up more "blks_needed" than our current size, and the above subtraction wraps. This can easily happen for a filesystem which is almost completely full. In this case, just return the current fs size as the minimum and be done with it. With this fix we could probably call calculate_minimum_resize_size() for each resize2fs invocation and refuse to resize smaller than that? Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-04-22resize2fs: Print a warning message if the ftruncate system call failsTheodore Ts'o1-2/+7
Resize2fs will attempt to truncate an image file of a filesystem down to size for the convenience of the system administrator. If the truncate operation fails, print a warning message. This also avoids a gcc warning message. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-18resize2fs: Fix corruption bug impacting ext4 filesystems with uninit_bgTheodore Ts'o1-1/+1
Due to a fencepost bug, when skipping a block group whose block bitmap was uninitialized (and hence could not contain any blocks eligible for relaocation), the block immediately following the block group wasn't checked as well. If it was in use and required relocation, it wouldn't get properly relocated, with the result that an inode using such a block would end up, post resize, with a pointer to a block now outside the bounds of the filesystem. This commit fixes this fencepost error. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-18resize2fs: Fix data corruption bug when shrinking the inode table for ext4Theodore Ts'o3-15/+44
If we need to shrink the inode table, we need to make sure the inodes contained in the part of the inode table we are vacating don't get reused as part of the filesystem shrink operation. This wasn't a problem with ext3 filesystems, since the inode table was located in the block group that was going away, so that location was not eligible for reallocation. However with ext4 filesystems with flex_bg enabled, it's possible for a portion of the inode table in the last flex_bg group to be deallocated, but in a part of the filesystem which could be used as data blocks. So we must mark those blocks as reserved to prevent their reuse, and adjust the minimum filesystem size calculation to assure that we don't shrink a filesystem too small for the resize operation to succeed. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-18resize2fs: Fix data corruption bug when growing an ext4 filesystem off-lineTheodore Ts'o1-0/+21
When allocating a new set of block group metadata as part of growing the filesystem, the resize2fs code assumes that the bitmap and inode table blocks are in their own block group; an assumption which is changed by the flex_bg feature. This commit works around the problem by temporarily turning off flex_bg while allocating the new block group metadata, to avoid potentially overwriting previously allocated data blocks. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-03-08remove useless if-before-free testsJim Meyering1-2/+1
In case you're wondering about whether this change is safe from a portability standpoint, fear not. This has been beaten to death in other forums. Here are a few threads: http://thread.gmane.org/gmane.comp.version-control.git/74187 http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/12712 http://thread.gmane.org/gmane.emacs.devel/98144 http://thread.gmane.org/gmane.comp.lib.glibc.alpha/13092 There has been debate about whether it's a good idea from a performance standpoint, too, but imho you'll have a hard time finding an instance where this sort of change induces a measurable performance penalty. If you do, please let me know. Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-01-20resize2fs: Reserve some extra space for -P/-M for ext4 filesystemsTheodore Ts'o1-0/+8
Some extra blocks may be needed to expand some extent allocation trees while we are shrinking the filesystem. We don't know exactly how much, so we use a hueristic. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-19resize2fs: Release bitmap and itable blocks in flex_bg filesystemsTheodore Ts'o1-0/+37
Previously resize2fs assumed that bitmap and inode table blocks were always located in their respective block group. However, this is no longer true with flex_bg. So it is necessary to check all of the block groups which will be truncated to see if they have metadata blocks that need to be marked as no longer being in use in the new, shrunk filesystem. This bug fixes resize2fs -M, which would otherwise fail because without the released blocks, there would not be enough space in the filesystem. This bug also avoids (mostly harmless) filesystem corruptions reported by e2fsck regarding blocks marked in use but not actually used (these being the bitmap and inode table blocks associated with the truncated block groups). Note: in theory it is possible to have block group N utilize bitmap and inode table blocks in block group N+X with flex_bg. At the moment neither mke2fs nor e2fsck will create filesystems like this, which is good, because resize2fs doesn't handle this case correctly. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-19resize2fs: Move all required blocks for ext4 filesystemsTheodore Ts'o1-1/+1
In the function blocks_to_move(), when checking to see if a block group's block bitmap is initialized, we need to check the old_fs's block group descriptors, not the new file system's (already truncated) group descriptor data structures. Otherwise we will end up derferencing past the end of the array boundary, and the resulting garbage value may indicate that the bitmap is uninitialized, and so all of the blocks in that block group will be skipped, resulting in some blocks not getting marked as needing relocation. This showed up in the following test case: mke2fs -t ext4 -b 1024 test.img 1048576 resize2fs test.img 80000 The journal inode after the resize operation looked like this: debugfs: stat <8> Inode: 8 Type: regular Mode: 0600 Flags: 0x80000 ... BLOCKS: (IND):35385, (0-5836):2356-8192, (5837-21959):8454-24576, (21960-32506):24838-35 384, (32507-32767):434177-434437 TOTAL: 32769 The blocks 434177-434437 were not moved because block group 53 was wrongly thought to have an unitialized block group. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-11-16Fix various signed/unsigned gcc warningsTheodore Ts'o1-4/+3
Some of these could affect filesystems between 2^31 and 2^32-1 blocks. Thanks to Valerie Aurora Henson for pointing out the problems in lib/ext2fs/alloc_tables.c, which led me to do a "make gcc-wall" scan over the source tree. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-10-12resize2fs: check for bogus new_sizeEric Sandeen1-0/+5
If we don't check for new_size == 0, bogus values send resize2fs into a tailspin: resize2fs 1.41.0 (10-Jul-2008) Illegal block number passed to ext2fs_test_block_bitmap #1 for block bitmap for /tmp/tmp.lntZtMFvz8/fake-disk ...the same message repeated zillion times... Probably should see where that loop is, but at any rate we should error-check parse_num_blocks. Thanks to Petr Muller for reporting this. Addresses-Red-Hat-Bugzilla: #465984 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-10-01resize2fs: Fix potential memory corruption in ext2fs_progress_init()Manish Katiyar1-1/+1
Check the return value of ext2fs_get_mem, since prog isn't initialized so checking may miss a failed memory allocation. Signed-off-by: Manish Katiyar <mkatiyar@gmail.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-01Fix debug flag definitions for the resize2fs man pageTheodore Ts'o1-4/+2
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-01Only use the test_io manager if the right environment variables are setTheodore Ts'o1-1/+6
In order to make it possible for the test_io manager to be compiled in by default, make all of the programs that might try to use it to only do so if the environment variables TEST_IO_FLAGS and TEST_IO_DEBUG are set. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-28resize2fs: Allow (non-optimal) on-line resizing for flex_bg filesystemsTheodore Ts'o1-1/+12
The current method of adding one block group at a time to a mounted filesystem means it is impossible to accomodate the flex_bg allocation method of placing the metadata together in a single block group. For now we "fix" this issue by using the traditional layout for new block groups, where each block group is self-contained and contains its own bitmap blocks and inode tables. This means we don't get the layout advantages of flex_bg in the new block groups, but at least it allows on-line resizing to function. Long term, we will need to create a new ioctl which does much more of the resizing work in the kernel. We also fix a bug in the ext3/ext4 ioctl fallback code so we stop trying the ext3 ioctl for every single block group when resizing an ext4 filesystem. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-27Remove trailing whitespace for the entire source treeTheodore Ts'o7-138/+138
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-22resize2fs: Make sure we close out the progress bar in pass #4Theodore Ts'o1-0/+4
This fixes a cosemtic issue where we don't complete the progress bar and issue a newline before printing the final resize successful message. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-22resize2fs: supply block allocator for extents functionTheodore Ts'o1-0/+25
In the rare case where new blocks are needed while mutating an extent tree, supply a specialized block allocator so that extent_node_split() allocates valid blocks for the interior nodes of the extent tree. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-22resize2fs: Fix support for filesystems with the uninit_bg featureTheodore Ts'o1-13/+84
If the filesystem has the uninit_bg feature, then parts of the block and inode bitmap may not be initialized. Teach resize2fs how to deal with these case appropriately. (Most of these fixes were fortunately not necessary for the common case where the resize_inode is present to reserve space, and where the filesystem is being expanded instead of being shrunk.) Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-17resize2fs: Fix double bumping of directory in-use countsTheodore Ts'o1-7/+0
When moving directories into new block groups (which would only happen when shrinking a filesystem), resize2fs would increase the directory in-use count by 2 times the necessary value, due to a change in ext2fs_inode_alloc_stats() made in e2fsprogs 1.26. This is largely harmless, but it does result in a filesystem corruption for e2fsck to fix. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-07-17Fix missing space typo's in partinfo and resize2fsTheodore Ts'o1-1/+1
These were caused by multi-line strings missing a space at the line break. Thanks to translator Phillipp Thomas for noticing these typo's. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-07-10resize2fs: Clean up the resize inode properly if necessaryTheodore Ts'o1-3/+15
If the filesystem is grown to the point where the resize_inode is no longer needed, clean it up properly so e2fsck doesn't have to. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-17Merge branch 'maint'Theodore Ts'o2-7/+9
Conflicts: README resize/online.c version.h
2008-06-17mke2fs, tune2fs, resize2fs: Use floating point to calculate percentagesTheodore Ts'o2-7/+9
When calculating the number reserved blocks, use floating point for better accuracy, since for big filesystems it really makes a difference. In addition, mke2fs and tune2fs accepts a floating point number from the user, so they should provide that level of accuracy. Addresses-Debian-Bug: #452639 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-17resize2fs: Prohibit the combination of flex_bg and !resize_inodeTheodore Ts'o1-1/+20
This is a potentially a difficult case for resize2fs to handle, so prohibit it for now. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-17resize2fs: Fix support for the uninit_bg featureTheodore Ts'o2-24/+65
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-07resize2fs: Add support to use the ext4 online resize ioctl'sTheodore Ts'o1-1/+17
First try the ext3 ioctl, but if we get an error, try using the ext4 ioctl. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-07Fix gcc -Wall warnings in resize2fsTheodore Ts'o3-4/+10
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>