Commit Graph

22 Commits (188960ea4b830ec69607aab3068537ce55f44be4)

Author SHA1 Message Date
Artemiy Volkov bf140bf298 debugfs: fix argument parsing in do_freefrag()
When do_freefrag() is called from debugfs, the value of optind is
not reset. Rectify that by calling reset_getopt().

Signed-off-by: Artemiy Volkov <artemiyv@acm.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-02 19:53:04 -04:00
Lukas Czerner 47fee2ef6a e2fsprogs: introduce ext2fs_close_free() helper
Currently there are many uses of ext2fs_close() which might be wrong.
First of all ext2fs_close() does not set the ext2_filsys pointer to NULL
so the caller is responsible for clearing it, however there are some
cases there we do not do it.

Second of all very small number of users of ext2fs_close() actually
check the return value. If there is a problem in ext2fs_close() it will
not even free the ext2_filsys structure, but majority of users expect it
to do so.

To fix both problems this commit introduces a new helper
ext2fs_close_free() which will not only check for the return value and
free the ext2_filsys structure if the call to ext2fs_close2() failed,
but it will also set the ext2_filsys pointer to NULL.

Replace every use of ext2fs_close() in e2fsprogs tools with
ext2fs_close_free() - there is no real reason to keep using
ext2fs_close().

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
2014-07-05 21:06:48 -04:00
Theodore Ts'o d055089567 e2freefrag: avoid integer overflow when reporting free space statistics
An integer overflow could happen if the file system is large and has
very large contiguous chunks of free space.

Addresses-Debian-Bug: #718205

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-28 22:25:11 -05:00
Theodore Ts'o ea2d378862 e2freefrag: use 64-bit rbtree bitmaps
Enable the use of 64-bit bitmaps, so e2freefrag will work on file
systems with the 64-bit feature enabled.  In addition, enable the
rbtree-based bitmaps, which significantly saves the amount of memory
required (from 97 megs to 1.7 megs for an empty 3T file system) at the
cost of additional CPU overhead (but we will claw back some of the
additional CPU overhead in the next commit).

Addresses-Google-Bug: 7269948

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-10-04 23:30:23 -04:00
Theodore Ts'o 3cebf9c102 debugfs: fix gcc -Wall complaints
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-11-18 22:14:23 -05:00
Theodore Ts'o 5e96c5721d debugfs: add the freefrag command
The freefrag command provides the functionality of e2freefrag on the
currently open file system in debugfs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-11-18 22:12:12 -05:00
Robin Dong 554bc091b7 e2freefrag: fix "Illegal block number" errors with bigalloc file systems
After:
# mke2fs -O ^has_journal,^resize_inode,^uninit_bg,extent,meta_bg,flex_bg,bigalloc /dev/sda
# e2freefrag /dev/sda

It will report error message like:

 Illegal block number passed to ext2fs_test_block_bitmap #1732133 for block bitmap for /dev/sda
 Illegal block number passed to ext2fs_test_block_bitmap #1732134 for block bitmap for /dev/sda
 Illegal block number passed to ext2fs_test_block_bitmap #1732135 for block bitmap for /dev/sda

One bit in bitmap of bigalloc-ext4 means a cluster not a block,
therefore ext2fs_fast_test_block_bitmap2 should check cluster.

Signed-off-by: Robin Dong <sanbai@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-11-11 21:15:55 -05:00
Theodore Ts'o d1154eb460 Shorten compile commands run by the build system
The DEFS line in MCONFIG had gotten so long that it exceeded 4k, and
this was starting to cause some tools heartburn.  It also made "make
V=1" almost useless, since trying to following the individual commands
run by make was lost in the noise of all of the defines.

So fix this by putting the configure-generated defines in lib/config.h
and the directory pathnames to lib/dirpaths.h.

In addition, clean up some vestigal defines in configure.in and in the
Makefiles to further shorten the cc command lines.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-18 17:34:37 -04:00
Eric Sandeen 4ebbc0a310 freefrag: fix up getopt case statement
There is no need to print out a "bad option" message; getopt
does that for us, and in fact will change "c" to "?" so
it's not even useful.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16 18:43:05 -04:00
Andreas Dilger cf5301d7f2 misc: clean up compiler warnings
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-11 10:58:25 -04:00
Theodore Ts'o db0bdb49f4 Merge branch 'maint' into next
Conflicts:
	resize/extent.c
2010-07-19 02:37:41 -04:00
Mike Frysinger b887f08f95 e2freefrag: Fix getopt bug on machines with unsigned chars
The getopt() function returns an int, not a char.  On systems where the
default char is unsigned (like ppc), we get weird behavior where -1 is
truncated to 0xff but compared to (int)-1.

Also fix this same bug for two test programs, test_rel and iscan,
which aren't currently used at the moment.

Addresses-Gentoo-Bug: #299386

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-07-05 14:53:58 -04:00
Theodore Ts'o f96cb89e7a e2freefrag: Display the total number of free extents
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-07-05 14:51:47 -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 3c041a514c Convert tune2fs, dumpe2fs, and e2image to the 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:15:30 -04:00
Theodore Ts'o 1e48a456b6 e2freefrag: Take into account the last free extent in the file system
Fix a bug in e2freefrag where if the last free extent is at the very
end of the filesystem, it would be disregarded.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-09 23:22:24 -04:00
Theodore Ts'o 3e343b8d9a e2freefrag: Fix to work correctly for file systems with 1kb block sizes
If the file system has a non-zero s_first_data_block, as is the case
when the block size is 1kb, e2freefrag would incorrectly try to
reference invalid data blocks in the block allocation bitmap.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-09 23:21:23 -04:00
Theodore Ts'o cba91c4b52 e2freefrag: Do not print chunk-related information by default
Only print information related to chunk sizes if a chunksize is
printed.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-09 23:21:23 -04:00
Theodore Ts'o aff2cf8ed2 e2freefrag: Clarify e2freefrag's messages
"Free chunks" is confusing since it has nothing to do with the
chunksize; use "free extents" instead.

Also add a missing newline in an error message.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-09 23:21:17 -04:00
Theodore Ts'o 137a7dc05c e2freefrag: Initialize the ext2 error table
... so error messages are printed correctly

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-09 19:15:45 -04:00
Andreas Dilger ad751f11ec e2freefrag: Improve output to include be more like xfs_db's freesp -s
Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-24 18:33:46 -04:00
Theodore Ts'o 0b2681f45b e2freefrag: New program which displays how fragmented the free space is
Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-22 03:40:58 -04:00