Commit Graph

191 Commits (6e4fa6e28151a3bffea2d73c22ea3b7f2338f0fd)

Author SHA1 Message Date
Valerie Aurora Henson d7cca6b06f Convert to use block group accessor functions
Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25 21:43:47 -04:00
Theodore Ts'o cd65a24e75 libext2fs: Convert ext2fs_bg_flag_test() to ext2fs_bg_flags_test()
After cleaning up ext2fs_bg_flag_set() and ext2fs_bg_flag_clear(),
we're left with ext2fs_bg_flag_test().  Convert it to
ext2fs_bg_flags_test().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25 21:42:12 -04:00
Eric Sandeen e633b58ac7 libext2fs: clean up ext2fs_bg_flags_ interfaces
The ext2fs_bg_flag* functions were confusing.

Currently we have this:

void ext2fs_bg_flags_set(ext2_filsys fs, dgrp_t group, __u16 bg_flags);
void ext2fs_bg_flags_clear(ext2_filsys fs, dgrp_t group,__u16 bg_flags);

(_set (unused) sets exactly bg_flags; _clear clears all and ignores bg_flags)

and these, which can twiddle individual bits in bg_flags:

void ext2fs_bg_flag_set(ext2_filsys fs, dgrp_t group, __u16 bg_flag);
void ext2fs_bg_flag_clear(ext2_filsys fs, dgrp_t group, __u16 bg_flag);

A better interface, after the patch below, is just:

ext2fs_bg_flags_zap(fs, group) /* zeros bg_flags */
ext2fs_bg_flags_set(fs, group, flags) /* adds flags to bg_flags */
ext2fs_bg_flags_clear(fs, group, flags) /* clears flags in bg_flags */

and remove the original ext2fs_bg_flags_set / ext2fs_bg_flags_clear.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25 21:41:32 -04:00
Valerie Aurora Henson 4efbac6fed Convert uses of super->s_*_blocks_count to ext2fs_*_blocks_count()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07 20:46:34 -04:00
Valerie Aurora Henson a63745e81c Use ext2fs_file_acl_block() instead of using .i_file_acl directly
This provides support for 48-bit file acl blocks.

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07 22:29:45 -04:00
Peng Tao 2884d208a3 resize2fs: fix minimum resize size calculation with flex_bg
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-07 16:21:19 -04:00
Theodore Ts'o 732c8cd58f Use accessor functions fields for bg_flags in the block group descriptors
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07 21:15:12 -04:00
Valerie Aurora Henson 24a117abd0 Convert to use io_channel_read_blk64() and io_channel_write_blk64()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07 21:14:24 -04:00
Theodore Ts'o dc615a21c3 Merge branch 'maint' into next 2009-09-07 17:02:35 -04:00
Valerie Aurora Henson 3346084bea resize2fs: Move everything to new bitmap interface
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-22 21:13:37 -04:00
Theodore Ts'o 96cdb37e27 resize2fs: If resize2fs fails, tell the user to run e2fsck
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-11 14:16:39 -04:00
Eric Sandeen 8a6ede8b7a resize2fs: update sb journal backup if journal was moved
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-18 07:47:54 -04:00
Theodore Ts'o e2ca097fc6 resize2fs: fix miscellaneous memory leaks
Fix various memory leaks which were discovered using valgrind.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-15 03:54:31 -04:00
Eric Sandeen 69f7c80eaf resize2fs: fix minimum size calculations
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-05-25 22:40:35 -04:00
Theodore Ts'o 2d7361ebfa resize2fs: Fix corruption bug impacting ext4 filesystems with uninit_bg
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-18 22:42:13 -04:00
Theodore Ts'o c09043f1ab resize2fs: Fix data corruption bug when shrinking the inode table for ext4
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-18 22:32:03 -04:00
Theodore Ts'o 1ac84a948d resize2fs: Fix data corruption bug when growing an ext4 filesystem off-line
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-04-18 13:31:54 -04:00
Jim Meyering 45e338f533 remove useless if-before-free tests
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-03-08 20:37:12 -04:00
Theodore Ts'o 793a04a071 resize2fs: Reserve some extra space for -P/-M for ext4 filesystems
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-20 00:46:06 -05:00
Theodore Ts'o 9227c5bbbd resize2fs: Release bitmap and itable blocks in flex_bg filesystems
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-19 09:02:55 -05:00
Theodore Ts'o c58a08e673 resize2fs: Move all required blocks for ext4 filesystems
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>
2009-01-19 08:43:36 -05:00
Theodore Ts'o 03fa6f8ae2 Fix various signed/unsigned gcc warnings
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-11-16 10:06:59 -05:00
Theodore Ts'o efc6f628e1 Remove trailing whitespace for the entire source tree
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-27 23:07:54 -04:00
Theodore Ts'o 88dbf8287f resize2fs: Make sure we close out the progress bar in pass #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-22 09:57:44 -04:00
Theodore Ts'o 7f9c96ee74 resize2fs: supply block allocator for extents function
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-22 03:07:53 -04:00
Theodore Ts'o 86acdebd53 resize2fs: Fix support for filesystems with the uninit_bg feature
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-22 03:03:42 -04:00
Theodore Ts'o c89f1b4ca5 resize2fs: Fix double bumping of directory in-use counts
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-08-17 23:20:16 -04:00
Theodore Ts'o 8ade268cf2 resize2fs: Clean up the resize inode properly if necessary
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-07-10 14:18:41 -04:00
Theodore Ts'o 71ff129e9f Merge branch 'maint'
Conflicts:

	README
	resize/online.c
	version.h
2008-06-17 23:54:51 -04:00
Theodore Ts'o 9ff8ece57d mke2fs, tune2fs, resize2fs: Use floating point to calculate percentages
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-17 21:08:49 -04:00
Theodore Ts'o 74128f8d7e resize2fs: Fix support for the uninit_bg feature
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-17 01:14:30 -04:00
Theodore Ts'o 2c25f7e75a Fix gcc -Wall warnings in resize2fs
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-07 11:52:33 -04:00
Theodore Ts'o 1ca1059fd0 Add support for the HUGE_FILE feature
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-17 16:38:13 -04:00
Jose R. Santos 236efede19 Make resize2fs uninit block group aware
Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-20 15:33:12 -04:00
Josef Bacik 199ddaaa44 resize2fs: Add options to print (and resizing to) the minimum filesystem size
Add the -P option to print the minimum filesystem size and exit.

Add the -M option to force resizing the filesystem to the minimum
filesystem size.

Signed-off-by: Josef Back <jbacik@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-15 01:30:43 -04:00
Theodore Ts'o a040a99b6c Merge branch 'maint'
Conflicts:

	lib/ext2fs/ext2_err.et.in
2008-03-13 10:53:26 -04:00
Theodore Ts'o edfd9b0a9f resize2fs: Fix resizing filesystems with large inodes
Use ext2fs_get_next_inode_full() in resize2fs and clean up large inode
handling; previous attempt was not properly handling all cases, and
was incorrectly setting i_extra_isize.  This caused some extended
attributes to get removed or randomly assigned to other inodes as a
result of the resize, which can be unfortunate on systems using
SELinux.

The previous commit didn't fix things completely on big-endian systems
like PowerPC.

Addresses-Red-Hat-Bugzilla: #434893

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-09 08:00:12 -04:00
Theodore Ts'o 399033a6ab Merge branch 'maint' 2008-02-29 00:43:29 -05:00
Eric Sandeen 4ef28824ca resize2fs: Fix movement of large (greater than 128 byte) inodes
inode_scan_and_fix() in resize2fs needs to do read/write of the full
inode to be sure it gets all data from larger (>128 byte) inodes.

Addresses-Red-Hat-Bugzilla: #434893

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-02-28 18:05:41 -05:00
Theodore Ts'o fef2b38d8e Merge branch 'maint' into next
Conflicts:

	configure
	debian/rules
	e2fsck/swapfs.c
	lib/ext2fs/ext2_fs.h
2008-01-01 12:41:35 -05:00
Theodore Ts'o e5aace908e Convert use of ext2fs_get_mem to ext2fs_get_array for overflow detection
Add some additional checks, primarily in resize2fs and in the rarely
used (and soon to-be-deprecated) e2fsck byte-swap filesystem function.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-27 10:08:13 -05:00
Valerie Clement f2de1d38d0 libext2fs: Add EXT2_DESC_SIZE and EXT2_DESC_PER_BLOCK macros
Add macros to support variable-length group descriptors for ext4.

Signed-off-by: Valerie Clement <valerie.clement@bull.net>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-10-14 22:08:35 -04:00
Theodore Ts'o 058ad1c70c Don't write changes to the backup superblocks by default
This patch changes ext2fs_open() to set EXT2_FLAG_MASTER_SB_ONLY by
default.  This avoids some problems in e2fsck (reported by Jim Garlick)
where a corrupt journal can end up writing the bad superblock to the
backups.  In general, only e2fsck (after the filesystem is clean),
tune2fs, and resize2fs should change the backup superblocks by default.
Most callers of ext2fs_open() should not be touching anything where the
backups should be touched.  So let's change the defaults to avoid
potential problems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-06-18 18:26:50 -04:00
Andreas Dilger de8f3a7621 Fix gcc -Wall warnings, especially on 64-bit systems
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-05-25 11:18:11 -04:00
Brian Behlendorf d2b2a488f9 [COVERITY] Fix missing return code check for ext2fs_write_inode
Found 2 of the three places where a return code for ext2fs_write_inode() was
not being checked.

The second fix in e2fsck/emptydir.c is basically just to shut coverity up even
though it really is unnecessary.

Coverity ID: 1: Checked Return

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-03-18 11:16:33 -04:00
Eric Sandeen d1b4b85c3a Fix more rounding overflows for filesystems that have 2**32-1 blocks
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
2006-09-12 14:56:18 -04:00
Eric Sandeen f335864338 Add checks to make sure inode counts don't overflow a 32-bit value
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
2006-09-12 14:56:17 -04:00
Eric Sandeen 62c6d1403e Remove unused variables
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
2006-09-12 14:56:12 -04:00
Theodore Ts'o a8862d9e90 Fix potential 2**32-1 overflow by using e2p_percent()
Add a new functiom, e2p_percent(), which correct calculates the percentage
of a number based on a given percentage, without worrying about overflow
issues.  This is used where we calculate the number of reserved blocks using
a percentage of the total number of blocks in a filesystem.

Based on patches from Eric Sandeen, but generalized to use this new function.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
2006-08-30 03:08:13 -04:00
Eric Sandeen 5830d6be9c Detect overflows in loop counters
For loops such as:

for (i=1; i <= fs->super->s_blocks_count; i++) {
        <do_stuff>
}

if i is an int and s_blocks_count is (2^32-1), the condition is never false.
Change these loops to:

for (i=1; i <= fs->super->s_blocks_count && i > 0; i++) {
        <do_stuff>
}

to stop the loop when we overflow i

Signed-off-by: Eric Sandeen <esandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-08-30 02:16:55 -04:00
Theodore Ts'o 69022e029f Fix potential 2**32-1 overflow problems by ext2fs_div_ceil()
Add a new function, ext2fs_div_ceil(), which correctly calculates a division
of two unsigned integer where the result is always rounded up the next
largest integer.   This is used everywhere where we might have
previously caused an overflow when the number of blocks
or inodes is too close to 2**32-1.

Based on patches from Eric Sandeen, but generalized to use this new function

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
2006-08-30 01:57:00 -04:00
Takashi Sato 8deb80a5d1 Fix format statements to make e2fsprogs programs 32-bit clean
Change the format string(%d, %ld) for a block number and inode number
to %u or %lu.

Signed-off-by: Takashi Sato <sho@tnes.nec.co.jp>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-03-18 21:43:46 -05:00
Theodore Ts'o bf69235ad0 Add support for on-line resizing to resize2fs
If the filesystem is mounted, attempt to use the on-line resizing
ioctls to resize the filesystem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-03-17 19:45:45 -05:00
Theodore Ts'o 68963d5a26 Clean up gcc -Wall complaints in resize2fs
Remove unused variables in mark_table_blocks()

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-12-29 15:44:45 -05:00
Theodore Ts'o 2787276ec5 Fix fencepost error in resize2fs caught by valgrind
There was a off-by-one fencepost error in the logic used to check if
we avoid copying zero-filled blocks when moving an inode table down by
a block or two.  Thanks to valgrind for catching it.  As far as I know
this fencepost error wasn't causing any actual problems, but it was
definitely a bug.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-08-08 18:57:04 -05:00
Theodore Ts'o f35fd3d5ee Fix some minor typo's and grammar's strings, and remove debugging strings
from needing to be translated.  Patch is from Benno Schulenberg.
2005-05-09 16:22:17 -04:00
Theodore Ts'o 64ad98acbe resize2fs.c: Fix bug where we don't release the blocks belonging
to the old inode table blocks when we move the inode
	table.  (Addresses Debian Bug: #290894)
2005-01-26 10:03:56 -05:00
Theodore Ts'o 9213a93b22 Fix resize2fs so that it properly handles filesystems with the resize_inode
feature enabled.
2004-12-24 01:34:29 -05:00
Theodore Ts'o 06191693d4 resize2fs.c (check_and_change_inodes): Fix debugging printf to
mask off the high 256 bits of dirent->name_len (which is
	where the file type information is stored).  (Addresses
	Debian Bug #271605)
2004-09-17 17:10:17 -04:00
Matthias Andree b969b1b8a5 Fix more compiler warnings. 2003-12-28 13:04:35 +01:00
Theodore Ts'o 544349270e Fix gcc -Wall nitpicks 2003-12-07 01:28:50 -05:00
Theodore Ts'o c4e3d3f374 ext2fs_getmem(), ext2fs_free_mem(), and ext2fs_resize_mem()
all now take a 'void *' instead of a 'void **' in order to 
avoid pointer aliasing problems with GCC 3.x.
2003-08-01 09:41:07 -04:00
Theodore Ts'o 7d7bdd578b Fix bug in resize2fs which caused it to fail on filesystems with a
non-empty bad block list.  Resize2fs now discards any blocks on the 
badblock list which are no longer part of the filesystem as the result
of a filesystem shrink.  (Note: this means that shrinking and then
enlarging a filesystem is no longer a reversible operation;
information about bad blocks in the part of the filesystem
which is to be chopped off will be lost.)
2003-06-24 17:34:02 -04:00
Theodore Ts'o 424cb7b62a Bug fix; we were incorrectly moving the block and inode bitmaps
for sparse superblock filesystems.  (Address Debian bug #174766)
2003-03-06 12:22:52 -05:00
Theodore Ts'o 085d2a8397 resize2fs.c (inode_scan_and_fix, check_and_change_inodes): When
moving an inode, set the ctime field so that people using
	dump/restore will backup the changed inode.  Also update
	the mtime and ctime of directories which get updated when
	we need to move an inode.
2002-10-31 19:56:56 -05:00
Theodore Ts'o 76dd5e5c28 Add support for the meta_bg feature flag to the resize2fs program.
Fix bug in meta_bg support in mke2fs, e2fsck, and dumpe2fs; we were 
incorrectly reserving the legacy block groups desriptor blocks.
2002-10-30 23:07:21 -05:00
Theodore Ts'o 0ccd488a76 Fix stupid typo in previous changeset. 2002-08-16 17:07:06 -04:00
Theodore Ts'o ed909bbe20 Fix up extended attribute handling in e2image, resize2fs, and in
debugfs's icheck command.
2002-08-16 17:03:59 -04:00
Theodore Ts'o cefbf4870c resize2fs.c (block_mover): If there are no blocks to move,
release the bmap table.  This significantly speeds up
	resize2fs when shrinking or expanding a filesystem by a
	very small number of blocks (which EVMS will do).
2002-07-26 01:56:22 -04:00
Theodore Ts'o 116db1b513 main.c (main): If we are resizing a plain file which is smaller
than the requested size, then we will attempt to
	transparently extend the filesize in a sparse fashion by
	writing a block at the end of the requested part of the
	filesystem.

main.c (main), resize2fs.c (resize_fs), resize2fs.h: Change the
	function prototype of resize_fs() so that it can modify
	the new_size parameter with the actual new size of the
	filesystem after the resize operation.  (This can
	sometimes be less than the requested new size if there
	isn't enough space to create the necessary block group
	metadata for that last bit of disk space.)  Resize2fs now
	prints the actual new size of the filesystem when it finishes.
2002-04-01 01:28:30 -05:00
Theodore Ts'o 546a1ff18c Fix various gcc -Wall complaints. 2002-03-07 23:52:56 -05:00
Theodore Ts'o dfcdc32f8d ChangeLog, libext2fs.texinfo:
libext2fs.texinfo: Change ino_t to ext2_ino_t
ChangeLog, extent.c, main.c, resize2fs.c:
  extent.c, main.c, resize2fs.c: Change ino_t to ext2_ino_t.
ChangeLog, mke2fs.c:
  mke2fs.c: Change ino_t to ext2_ino_t.
ChangeLog, test_icount.c, test_rel.c:
  test_icount.c, test_rel.c: Change ino_t to ext2_ino_t
2001-01-11 15:38:00 +00:00
Theodore Ts'o a13575f4d2 ChangeLog, extent.c, main.c, resize2fs.c, resize2fs.h:
main.c, resize2fs.c, resize2fs.h, extent.c: Add NLS support.
2000-06-12 22:06:16 +00:00
Theodore Ts'o 0cee8a5c42 Many files:
Update copyright of files in preparation for release of resize2fs.
  	Also removed the (obsolete) beta-test check that had been in the code,
  	as well as the old spec files used to package the separate
  	distribution of resize2fs.
  Makefile.in: No longer build resize2fs.static, since there's no real
  point in it any more.
  Modified Files:
  	ChangeLog Makefile.in extent.c main.c resize2fs.8.in
  	resize2fs.c resize2fs.h sim_progress.c test_extent.c
  Removed Files:
  	e2fsprogs-1.12.spec pq.gif resize2fs.spec version.h
2000-04-06 21:38:34 +00:00
Theodore Ts'o 1333fe9344 ChangeLog, resize2fs.c:
resize2fs.c: Rename max to max_groups and max_dirs to avoid possible
  	conflicts with a cpp macro named "max".
1998-09-03 00:26:49 +00:00
Theodore Ts'o 084307590c ChangeLog, resize2fs.c:
Change blkcnt_t to be e2_blkcnt_t to avoid collision with the LFS API.
1998-06-10 20:36:37 +00:00
Theodore Ts'o 76f875daa1 Many files:
ext2fs.h, bitops.h: Add support for the Watcom C compiler to do inline
  	functions.
  ext2fs.h, dosio.c: Use asm/types.h instead of linux/types.h to evade a
  	potential problem with glibc's header files trying to spike out
  	linux/types.h.
  ext2fs.h (ext2fs_resize_mem): Change the function prototype to include
  	the old size of the memory, which is needed for some braindamaged
  	memory allocation systems that don't support realloc().
  badblocks.c (ext2fs_badblocks_list_add):
  bb_inode.c (clear_bad_block_proc):
  dblist.c (ext2fs_add_dir_block):
  icount.c (insert_icount_el):
  irel_ma.c (ima_put):
  rs_bitmap.c (ext2fs_resize_generic_bitmap): Update functions to pass
  	the old size of the memory to be resized to ext2fs_resize_mem().
ChangeLog, dirinfo.c:
  dirinfo.c (e2fsck_add_dir_info): Update function to pass the old size
  	of the memory to be resized to ext2fs_resize_mem().
ChangeLog, extent.c, resize2fs.c:
  resize2fs.c (adjust_superblock):
  extent.c (ext2fs_add_extent_entry): Update functions to pass the old
  	size of the memory to be resized to ext2fs_resize_mem().
1998-04-27 01:41:13 +00:00
Theodore Ts'o 101c84f2e0 ChangeLog, main.c, resize2fs.c:
main.c (main): Check to make sure we can really resize this
  	filesystem.  If there are compatible feature sets that we don't
  	support, we need to abort.
  resize2fs.c: Change to use the new prototype required by
  	block_iterate2 (which uses blkcnt_t for the blockcount).
version.h, RELEASE-NOTES:
  Interim commit of changes to date.
1998-03-24 16:27:11 +00:00
Theodore Ts'o 2bc4d4f7e5 ChangeLog, resize2fs.c:
resize2fs.c (inode_scan_and_fix): If we are expanding the filesystem,
  	temporarily set rfs->old_fs->super->s_blocks_count to ultimate size of
  	the filesystem, to avoid catching an error on the block iterator.
1998-03-21 03:27:48 +00:00
Theodore Ts'o bce49798f7 ChangeLog, resize2fs.c:
resize2fs.c (blocks_to_move): Create the meta_bmap using the old
  	filesystem, not the new filesystem.
  (get_new_block): Don't try checking the old block bitmap if the block
  	we're testing is beyond the boundaries of the old filesystem.
1998-03-07 23:24:01 +00:00
Theodore Ts'o 3b627e8d67 ChangeLog, main.c, resize2fs.c, resize2fs.h:
Change the progress function to return an errcode_t; this allows the
  progress function to return a error indicating a user-requested
  cancel.
1998-02-24 20:24:49 +00:00
Theodore Ts'o f4b2a6db3f ChangeLog, main.c, resize2fs.8.in, resize2fs.c:
main.c (check_mount, main): Resize2fs now checks the size of the
  	partition, and uses this as a default new_size of the partition if one
  	is not specified.  Resize2fs will not let you resize a mounted
  	partition.
  resize2fs.c: Change how the progress function for the INODE_SCAN pass
  	is performed, so that the maximum size is never zero.
  resize2fs.8.in: Updated man page.
1998-02-21 04:20:44 +00:00
Theodore Ts'o a8519a2dbe Many files:
Major reoganization of how resizing works.  Functions in
  ext2_block_move.c, and ext2_inode_move.c moved into resize2fs.c.
  Multiple passes in those two files also combined into a single inode
  scanning pass.  Made the inode table moving function better handling
  the case where it needs to abort mid-operation.  When moving blocks
  around, made the block allocation function preferentially avoid the
  old group descriptor blocks, to make resize2fs more robust.
1998-02-16 22:16:20 +00:00
Theodore Ts'o 63b44fbe30 Many files:
resize2fs.c, resize2fs.h, ext2_block_move.c, ext2_inode_move.c,
  	main.c: Reorganize how the progress functions are called.
1998-02-13 22:58:18 +00:00
Theodore Ts'o ca8abba7e0 Many files:
resize2fs.h: If EXT2_FLAT_INCLUDES is defined, then assume all
  	of the ext2-specific header files are in a flat directory.
  ext2_block_move.c, ext2_inode_move.c, extent.c, resize2fs.c,
  	resize2fs.h: Rename variables named "new" to "new_block",
  	"new_inode", or "new_loc" to avoid C++ reserved word
  	clash.
  ext2_block_move.c, ext2_inode_move.c, extent.c, resize2fs.c,
  	sim_progress.c: Use ext2fs_get_memory(),
  	ext2fs_free_memory(), et. al., instead of malloc() and
  	free().
  ext2_block_move.c, ext2_inode_move.c, extent.c: Explicitly cast
  	all assignments from void * to be compatible with C++.
  banalysis.c, banalysis.h, ext2_inode_move.c, ext2_block_move.c:
  	Change private to priv_data to avoid C++ namespace clash.
ChangeLog, badblocks.8.in:
  badblocks.8.in: Add documentation for the -s option.
1998-01-19 14:55:24 +00:00
Theodore Ts'o 80c0fc3492 Many files:
resize2fs.c, ext2_block_move.c ext2_inode_move.c: Only include printf
  	statements if RESIZE2FS_DEBUG is defined.
  main.c: Don't read in the bitmaps since resize2fs.c does that.
e2label.c, mke2fs.c:
  Adjust header files.
1997-11-03 19:46:49 +00:00
Theodore Ts'o c762c8e632 Many files:
Checkin of work to date.  (Pretty much completely working now.)
1997-06-17 03:52:12 +00:00
Theodore Ts'o 05e112a11b ChangeLog, Makefile.in, version.h:
Allow people to set the version.h to something like 1.10-PLUS.
.del-inodemap.c~24510e64, main.c, resize2fs.c, resize2fs.h:
  More interim work.  All is functioning except progress meter.
1997-06-14 07:28:44 +00:00
Theodore Ts'o 052db4b76e Makefile.in, .del-inodemap.c~24510e64, main.c, resize2fs.c, resize2fs.h:
New snapshot (almost fully functional)
1997-06-12 07:14:32 +00:00
Theodore Ts'o 1e1da29fbd Many files:
bmove.c (ext2fs_move_blocks): New function which takes a bitmap of
  	blocks which need to be moved, and moves those blocks to another
  	location in the filesystem.
  rs_bitmap.c (ext2fs_resize_generic_bitmap): When expanding a bitmap,
  	make sure all of the new parts of the bitmap are zero.
  bitmaps.c (ext2fs_copy_bitmap): Fix bug; the destination bitmap wasn't
  	being returned to the caller.
  alloc_tables.c (ext2fs_allocate_group_table): Add new function
  	ext2fs_allocate_group_table() which sets the group tables for a
  	particular block group.  The relevant code was factored out of
  	ext2fs_allocate_tables().
  dblist.c (make_dblist): Adjust the initial size of the directory block
  	list to be a bit more realize (ten plus twice the number of
  	directories in the filesystem).
  Check in interim work.
1997-06-09 14:51:29 +00:00
Theodore Ts'o 24b2c7a7a1 ChangeLog, Makefile.in, configure.in:
configure.in (rmakefile): Added (optional) private directory for resize2fs.
  Makefile.in: Change recursive descent rules to check to see if a
  	directory exists before trying to make it.
Many files:
  Initial checkin of work done to date.
1997-06-07 20:42:58 +00:00