History log of /external/e2fsprogs/misc/e4defrag.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
7719e69a5c3308f383babb9abde7cf60ebec0027 06-Sep-2015 Theodore Ts'o <tytso@mit.edu> e4defrag: fix build failure if libc doesn't have sync_file_range()

The posix_fadvise() to hint to the system that the file can be removed
from memory will probably not work well without the sync_file_range(2)
call, but e4defrag should still fundamentally work, and this will
allow e4defrag to compile if the C library doesn't happen this system
call exposed.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
63cd76d6ac3bb7f90c583f240fc75e657610f2ea 17-May-2015 Darrick J. Wong <darrick.wong@oracle.com> misc: fix Coverity bugs

Fix Coverity bugs 1297093, 1297096, 1297489, 1297491, 1297493,
1297506, 1297507, 1297514, 1297516, and 1297517.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
c7c539e8fd86de691475eea00409c6c030f312cd 22-Jul-2014 Darrick J. Wong <darrick.wong@oracle.com> e4defrag: backwards-allocated files should be defragmented too

Currently, e4defrag avoids increasing file fragmentation by comparing
the number of runs of physical extents of both the original and the
donor files. Unfortunately, there is a bug in the routine that counts
physical extents, since it doesn't look at the logical block offsets
of the extents. Therefore, a file whose blocks were allocated in
reverse order will be seen as only having one big physical extent, and
therefore will not be defragmented.

Fix the counting routine to consider logical extent offset so that we
defragment backwards-allocated files. This could be problematic if we
ever gain the ability to lay out logically sparse extents in a
physically contiguous manner, but presumably one wouldn't call defrag
on such a file.

Reported-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
47fee2ef6a23ae06f680336ffde57caa64604a4c 06-Jul-2014 Lukas Czerner <lczerner@redhat.com> 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>
/external/e2fsprogs/misc/e4defrag.c
aa73432f71bdab01ef9519f929dad0e4e13c7622 11-Apr-2014 Theodore Ts'o <tytso@mit.edu> e4defrag: fix error reporting when ext2fs_open fails

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
4a77520a9816f0548e9e7f3b2992446a68f4f6fd 11-Apr-2014 Jon Ernst <jonernst07@gmail.com> e4defrag: open fs with EXT2_FLAG_64BITS flag

This allows e4defrag to work with 64-bit and bigalloc file systems.

Signed-off-by: Jon Ernst <jonernst07@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
58229aaf85d435469e901c974f31ead6d9124166 19-Feb-2014 Baruch Siach <baruch@tkos.co.il> e4defrag: remove local sync_file_range and fallocate

The locally defined versions of both sync_file_range and fallocate are broken
on 32bit systems. On these systems two 32bit registers are needed for each
64bit parameter. Also, sync_file_range on MIPS32 needs a dummy parameters
after the fd parameter. Just leave all these subtleties to the C library.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
9a3938918545b831b215b2befc2454f7b1a2dd84 02-Jan-2014 Baruch Siach <baruch@tkos.co.il> e4defrag: choose the best available posix_fadvise variant

Use posix_fadvise64() when available. This allows 64bit offsets on
32bit systems.

[ Modified by tytso to try to use fadvise64() as well, and to remove
the attempt to call the syscall directly, since because and
complexities caused by required dummy arguments on some
architectures, it's not worth the hair. ]

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
f404167dda29a59d2be2882328aeb074b9899669 17-Dec-2013 Theodore Ts'o <tytso@mit.edu> Clean up sparse warnings

Mostly by adding static and removing excess extern qualifiers. Also
convert a few remaining non-ANSI function declarations to ANSI.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
b1667425f8cd8b3c3d6b205ac9f3dee2e085058c 12-Dec-2013 Darrick J. Wong <darrick.wong@oracle.com> e4defrag: defensively check results of sysconf(_SC_PAGESIZE)

sysconf(_SC_PAGESIZE) will probably never return an error, but just in
case it does, we shouldn't pass what looks like a huge number to
sync_file_range() and posix_fadvise().

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
e661d2815194d6db3f3e38223277569ad55bb420 12-Dec-2013 Darrick J. Wong <darrick.wong@oracle.com> e4defrag: don't crash if umounts the filesystem races with us

If someone umounts the filesystem between statfs64() and the getmntent()
iteration, we can exit the loop having never set mnt_type, and strcmp
can crash. Fix the potential NULL dereference.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
032eafee3007001d07ee1798db6166a0031a3601 28-Jul-2012 Eric Sandeen <sandeen@redhat.com> e4defrag: handle device symlinks

Device nodes are commonly accessed via symlinks, i.e.

lrwxrwxrwx. 1 root root 7 Jul 19 13:01 /dev/mapper/testvg-testlv -> ../dm-0

Today, e4defrag on such a device will fail:

File is not regular file
"/dev/mapper/testvg-testlv"

due to it being a link, and e4defrag on the link target does as well:

Filesystem is not mounted

due to the target not being found in /etc/mtab.

Fix this by checking whether the symlink target is a block device
and if so, using that device in main(), and also changing get_mount_point()
to search for a matching device number, not device name.

Addresses-Red-Hat-Bugzilla: #707209

Reported-by: Peter Hjalmarsson <xake@rymdraket.net>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
d1154eb460efe588eaed3d439c1caaca149fa362 18-Sep-2011 Theodore Ts'o <tytso@mit.edu> 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>
/external/e2fsprogs/misc/e4defrag.c
25726554ca557e22b96684d8a7ecf36ec80572a5 16-Sep-2011 Eric Sandeen <sandeen@redhat.com> e4defrag: Check error return of sysconf()

In theory sysconf() can fail, so check for an error return.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
9ac557a1df6905b9861f90d2738e61b25580b002 19-Dec-2010 Kazuya Mio <k-mio@sx.jp.nec.com> e4defrag: Use libext2fs to get the correct superblock information

Currently, e4defrag always does byte-swapping when it gets superblock
information, so the calculation of the best extents count is not
correct on little endian machine. This doesn't cause data corruption,
but it may confuse users by showing the wrong extent count. To solve
this problem, we use ext2fs_open() instead of get_superblock_info()
that is the original function.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
b07f014face2e2aa0abf8a3266fd716152cd0cd4 18-Nov-2010 Kazuya Mio <k-mio@sx.jp.nec.com> e4defrag: fix segfault when e4defrag races with unlink/truncate

If a file gets deleted or truncated while e4defrag is trying to
operate on it, it's possible for it seg fault.

Addresses-Red-Hat-Bugzilla: #641926

Reported-by: Michal Piotrowski <mkkp4x4@gmail.com>
Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
30c0529d27edca148a6e5e52bcdd7b38d6cb28b2 17-Dec-2010 Theodore Ts'o <tytso@mit.edu> e4defrag: Fix the overflow in e4defrag with > 2GB files

The fallocate() interface on 32-bit machines is defined to use off_t,
not loff_t (even though the system call interface is 64-bit clean).
This causes e4defrag to fail on files greater than 2GB. Fix this by
trying to use fallocate64(), and using the hard-coded syscall if it
does not exist.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
4baacad7035820f6449473b62510d4202e69578a 13-Dec-2010 Kazuya Mio <k-mio@sx.jp.nec.com> e4defrag: avoid unsuccessful return for an non-privileged user

If non-privileged user runs e4defrag, e4defrag returns an exit status
of 1 despite its success. This patch fixes this problem.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
02808f7d9aabc7df6121d767fcebfb6e8aa32b56 13-Dec-2010 Kazuya Mio <k-mio@sx.jp.nec.com> e4defrag: fix file blocks calculation

e4defrag uses st_blocks (struct stat) to calculate file blocks. However,
st_blocks also has meta data blocks in addition to file blocks. So, we
calculate file blocks by sum of the extent length.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
94d26c267d30a8548e2a46e6fe9eaacdb6998596 13-Dec-2010 Kazuya Mio <k-mio@sx.jp.nec.com> e4defrag: output size per extent by -c option

e4defrag with -c option outputs "ratio" that means the levels of
fragmentation. However, it's difficult for users to understand, so we will
use size per extent instead of ratio.

Before:
# e4defrag -c /mnt/mp1/file
<File> now/best ratio
/mnt/mp1/file 6/1 0.00%

Total/best extents 6/1
Fragmentation ratio 0.00%
Fragmentation score 0.04
[0-30 no problem: 31-55 a little bit fragmented: 55- needs defrag]
This file(/mnt/mp1/file) does not need defragmentation.
Done.

After:
# e4defrag -c /mnt/mp1/file
<File> now/best size/ext
/mnt/mp1/file 6/1 16666 KB

Total/best extents 6/1
Average size per extent 16666 KB
Fragmentation score 0
[0-30 no problem: 31-55 a little bit fragmented: 56- needs defrag]
This file (/mnt/mp1/file) does not need defragmentation.
Done.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
ae09b934a7e8035edb9f91dd8d39726daa9048f0 13-Dec-2010 Peng Tao <bergwolf@gmail.com> e4defrag: return more specific error message on ioctl failure

Currently e4defrag relies on the EXT4_IOC_MOVE_EXT ioctl to perform online
defragmentation. However, this iotcl kernel patch is not available before
2.6.30-rc1. e4defrag shall fail without obvious reasons on systems running
older kernels. The patch adds more detailed error message addressing this
issue and prompts users with the minimal kernel version that is needed to
run e4defrag.

Signed-off-by: Peng Tao <bergwolf@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
43eb2ad47766c18faf39bb15a198a08144a0a707 08-Sep-2009 Eric Sandeen <sandeen@redhat.com> e4defrag: skip "rootfs" entry when checking for ext4 filesystem

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
90b9dce3e566613d509554e278c01126c83f8612 13-Dec-2010 Darrick J. Wong <djwong@us.ibm.com> e4defrag: open the file to be defragged in read/write mode

Akira Fujita merged a patch into 2.6.33 that adds a requirement that a
file being defragged must be opened with read and write access, so
e2fsprogs needs to satisfy that.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
a9e55a1191cf08fd219466009613ed1a04bbaac0 24-Aug-2009 Kyle McMartin <kyle@mcmartin.ca> e4defrag: fix ppc build

ppc glibc seems to be missing sync_file_range, so we fell back
to the local define, and there ppc differs as well, so the
build was failing.

Thanks to Kyle for the patch w/ the tidy solution.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
88fca201aca752cbb7a981e1fe1b2a875cc29833 22-Aug-2009 Theodore Ts'o <tytso@mit.edu> 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>
/external/e2fsprogs/misc/e4defrag.c
4f1d0e8608ddf488316dffbe4cd9993bf3b22084 27-Jul-2009 Eric Sandeen <sandeen@redhat.com> e4defrag: remove a lot of cruft

e4defrag.c had a lot of stuff copied into it from other
places, redefinitions of existing interfaces, etc.

We should be able to remove most of this, as the tool only
works on recent kernels anyway, we should just pick up
definitions from recent kernel headers whenever possible.

I've left the local definitions of fallocate, fadvise
(changed to posix_fadvise) and sync_file_range, and
wrapped them in #ifdef configure-time tests - though
really it seems like only fallocate should be necessary
by now, and perhaps the others can be dropped.

We still need some Makefile work so that it won't try to
build e4defrag if the right pieces aren't there (and
if the local definitions won't work...)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
ae5074600414f0c0111f2a4090edef0f106daab9 10-Jul-2009 Kazuya Mio <k-mio@sx.jp.nec.com> e4defrag: Fix compile warnings

When compile e2fsprogs git tree with gcc-wall option, we get some warnings about
e4defrag. This patch fixes them.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
1d21f4bd8ddf26281eaad3028feedb08c8401408 09-Jul-2009 Theodore Ts'o <tytso@mit.edu> e4defrag: Fix a core dump when trying to defrag a file with no blocks

Signed-off-by Akira Fujita <a-fujita@rs.jp.nec.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c
4836459a3fe8ff208a7bf21e28e4648bddc76440 09-Jul-2009 Theodore Ts'o <tytso@mit.edu> Add e4defrag to the misc directory

To make it easier to maintain changes and fixes to the e4defrag
program, check it into the e2fsprogs source tree.

Signed-off-by: Akira Fujita <a-fujita@rs.jp.nec.com>
Signed-off-by: Takashi Sato <t-sato@yk.jp.nec.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/misc/e4defrag.c