Commit Graph

37 Commits (d5c1d82ed8812a036846267a1720faec223c0ba0)

Author SHA1 Message Date
Theodore Ts'o b18c5fd51e Merge branch 'maint' into next 2011-05-07 23:24:55 -04:00
Eric Sandeen a8d8432b58 filefrag: count 0 extents properly when verbose
/boot/a: 0 extents found

works properly, but

Filesystem type is: ef53
Filesystem cylinder groups is approximately 61
File size of a is 0 (0 blocks, blocksize 1024)
 ext logical physical expected length flags
a: 1 extent found

yields 1 extent when it should be 0.

Fix this up by special-casing no extents returned in verbose
mode; skip printing the header for the columns too, since there
are no columns to print.

Also, in nonverbose mode we can set fm_extent_count to 0
so that FIEMAP will just query the extent count without gathering
details; clarify this with a comment.

Addresses-RedHat-Bugzilla: 653234
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-05-07 18:34:40 -04:00
Theodore Ts'o 616f68bf77 Merge branch 'maint' into next 2011-02-10 19:04:46 -05:00
Jim Meyering b637f8e7ed filefrag: remove useless assignment
The very next one memset's all bytes of fiemap to 0.

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-02-06 19:01:25 -05:00
Theodore Ts'o 2d07b3ad98 Merge branch 'maint' into next
Conflicts:
	configure
	lib/ext2fs/alloc_tables.c
	misc/mke2fs.c
2010-01-31 18:49:08 -05:00
Theodore Ts'o ca92d98f0a filefrag: Fix a core dump on sparc32 platforms with 8k file systems
On 32-bit platforms where the file system block size is 8k or greater,
the calculation bpib*bpib*bpib* will overflow a 32-bit calculation,
leading to a divide by zero error.  Fix this.

Thanks to Mikulas Patocka for pointing this out.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-11-29 01:03:04 -05:00
Eric Sandeen 334cfccbca filefrag: don't print extent header on bmap fallback
The extent list header gets printed before we fall back to bmap:

# filefrag -v /mnt/test/bar
Filesystem type is: 58465342
File size of /mnt/test/bar is 12288 (3 blocks, blocksize 4096)
 ext logical physical expected length flags <---- HERE
Discontinuity: Block 2 is at 17 (was 16)
/mnt/test/bar: 2 extents found

so delay printing it until we know fiemap is working.

(though ideally it'd be nice to have the same verbose output
regardless of the interface we used, I think).

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-08-15 23:52:27 -04:00
Eric Sandeen 1f3d16deaa filefrag: fix frag count in bmap case
The fragmentation count in the bmap case seems to be
off by one:

/mnt/test/bar: 0 extents found

Addresses-Debian-Bug: #540376

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-08-15 23:52:00 -04:00
Theodore Ts'o 5d5e01d7e0 filefrag: Add option to force use of the FIBMAP ioctl
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-15 23:15:44 -04:00
Theodore Ts'o 1d72214658 Merge branch 'maint' into next 2009-08-22 13:18:29 -04:00
Theodore Ts'o 88fca201ac Move declaration of FS_IOC_FIEMAP ioctl to fiemap.h
This helps e4defrag compile on systems where the system header files
don't yet define FS_IOC_FIEMAP.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-22 13:16:14 -04:00
Eric Sandeen bbbb81c1d9 filefrag: fix it so it works in the bmap fallback case.
It looks like some debugging crept in?

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-07-18 09:56:10 -04:00
Theodore Ts'o 9d4bade4ac filefrag: Restore "perfect" number of extents calculation for ext2/ext3
The FIEMAP support added in e2fsprogs 1.41.6 broke the "perfection
would be XXX expects" calculation restore it.

Also fix some gcc -Wall warnings as well.  (Cleaning up gcc -Wall is
what caused me to notice this regression).

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-11 23:44:56 -04:00
Peng Tao f97ea10fde filefrag: fix fm_start in filefrag_fiemap loop
When used with -v and the targeted file has more than 144
extents(double of the length of fm_extents array provided by buf),
filefrag_fiemap loops and calls fiemap ioctl() multiple times to
calculate the actual number of extents in a file. Each call to fiemap
ioctl() uses fm_start as the starting logical offset. The patch fixes
fm_start in each loop( except for the first one) and makes the extent
calculation correct for files with more that 144 extents.

To produce the problem, first run filefrag -v on a highly fragmented
file.  Then change the buf size in filefrag_fiemap to make it large
enough to have all the extent mapped in a single loop and run filefrag
-v after recompiling.  The former will produce a much smaller extent
count because of the false fm_start used in the loop. And the two will
produce different extent output since the 145th extent.

Signed-off-by: Peng Tao <bergwolf@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-02 00:24:15 -04:00
Theodore Ts'o e78968f7a4 filefrag: Fix error checking for the fiemap ioctl
Thanks to Peng Tao for reporting this problem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-02 08:45:22 -04:00
Kalpak Shah e62847c5db filefrag: Add support to use the FIEMAP ioctl
The FIEMAP ioctl is more efficient and doesn't require root
privileges.  So if it is available, use it in preference to repeated
FIBMAP calls.

Signed-off-by: Kalpak Shah <kalpak.shah@sun.com>
Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-02 21:02:29 -04:00
Theodore Ts'o a8fbdc0950 filefrag: Fix calculation of ideal number of extents
Fix calculation of the ideal number of extents needed for a file to
take into account sparse files.

In addition, suppress the "this file is extent-based" message unless
verbose mode is enabled.

Addresses-Debian-Bug: #458306

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-01 15:58:37 -04: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
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
Theodore Ts'o 642935c082 Fix misc. gcc -Wall complaints in the misc and e2fsck directories
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-14 23:38:17 -05: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
Andreas Dilger 8fe81a3d53 Rename EXT3_EXTENTS_FL to EXT4_EXTENTS_FL and make it visible to the user
lsattr will display the EXT4_EXTENTS_FL flag

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-08-05 18:50:22 -04:00
Theodore Ts'o 9c07dc00b8 Add missing backwards compatibility for ancient Linux systems
This fixes some (but not all) of the compatibility bugs which prevented
e2fsprogs from being compiled on a Linux 2.0.35 system.  There are still
some unprotected use of long long's, and apparently some type problems
with the uuid library, but these can be fixed up later.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-05-29 11:06:16 -04:00
Theodore Ts'o 40198dd0bb Fix filefrag to be 32-bit clean
Currently filefrag uses signed int for block numbers, thus it reporting
corrupted block number for a file on a more than 8TB ext3. The following
trivial patch replace the signed int type block number with "unsigned
long type.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-04-22 04:49:09 -04:00
Theodore Ts'o 9b9a780f5a Fix various gcc -Wall complaints.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-12-10 21:50:30 -05:00
Theodore Ts'o 8198e79126 filefrag.c (frag_report, get_bmap): The FIBMAP and FIGETBSZ ioctls return
an integer, not an unsigned long.  Fix this to avoid problems on 64-bit 
platforms where the size of an integer != the size of a long.  
(Addresses Debian Bug #309655)
2005-05-20 23:10:35 -04:00
Theodore Ts'o bfd9762de6 Fix a bug in filefrag so that it doesn't when the first block found is an
indirect block, it doesn't falsely count an extra discontunity.  (Addresses
Debian Bug #307607).
2005-05-05 22:55:20 -04:00
Theodore Ts'o a4897d41c2 Don't abort filefrag if EXT3_IOC_GETFLAGS ioctl is not supported,
so that filefrag can work on non-ext2/3 filesystems, as advertised.
(Addresses Debian Bug: #303509)
2005-04-09 01:24:04 -04:00
Theodore Ts'o 3d16b3f4bb filefrag.c (frag_report): Automatically detect files that are
stored using the new experimental file fragments format,
	and use the non-ext2 algorithm for determing the number of
	extents.  Avoid reporting a false discontinuity if there
	is a non-allocated block (or extent) at the beginning of
	the file.
2005-03-18 20:37:45 -05:00
Theodore Ts'o 7f1faaa482 filefrag.c (frag_report): In verbose mode, print the first and
last block numbers; may be useful for some folks.
2005-02-04 09:50:41 -05:00
Theodore Ts'o 0aa0e0c7d6 filefrag.c (frag_report): Fix filefrag so that it works
correctly with sparse files; unallocated blocks should not
be treated as a discontinuity.
2005-01-20 17:37:01 -05:00
Theodore Ts'o 9290404ea7 Applied patch from Francois Petillon (fantec at proxad.net) to
avoid a file descriptor leak in the filefrag program.
2005-01-17 14:32:20 -05:00
Theodore Ts'o 6b394c1cd3 filefrag.c: Fix gcc -Wall nits. 2004-02-26 21:08:06 -05:00
Theodore Ts'o d605ba11ab filefrag.c: Use #ifdef __linux__ instead of __LINUX__ so that it
actually compiles on Linux.  (Addresses Debian bug
	#230992)
2004-02-03 19:18:03 -05:00
Matthias Andree b34cbddbd6 Re-add FreeBSD support.
Tested on FreeBSD 5.2-CURRENT as of 2003-12-28.
Tested on FreeBSD 4.9-STABLE  as of 2003-12-27.
2003-12-28 18:21:26 +01:00
Matthias Andree aa3a2fe49a Trivial warning fixes. 2003-12-21 00:52:48 +01:00
Theodore Ts'o 9642413014 Initial checkin of the filefrag program, which reports on how
badly fragmented a file might be.
2003-12-17 10:13:41 -05:00