rpms/e2fsprogs/devel e2fsprogs-1.41.8-filefrag-fix.patch, NONE, 1.1 e2fsprogs-1.41.8-freefrag-defrag.patch, NONE, 1.1 e2fsprogs.spec, 1.147, 1.148
Eric Sandeen
sandeen at fedoraproject.org
Thu Aug 6 02:15:35 UTC 2009
Author: sandeen
Update of /cvs/pkgs/rpms/e2fsprogs/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv3653
Modified Files:
e2fsprogs.spec
Added Files:
e2fsprogs-1.41.8-filefrag-fix.patch
e2fsprogs-1.41.8-freefrag-defrag.patch
Log Message:
* Fri Aug 05 2009 Eric Sandeen <sandeen at redhat.com> 1.41.8-6
- Fix filefrag in fallback case
- Add e2freefrag & e4defrag (experimental)
e2fsprogs-1.41.8-filefrag-fix.patch:
filefrag.c | 2 --
1 file changed, 2 deletions(-)
--- NEW FILE e2fsprogs-1.41.8-filefrag-fix.patch ---
It looks like some debugging crept in?
Signed-off-by: Eric Sandeen <sandeen at redhat.com>
---
Index: e2fsprogs-1.41.8/misc/filefrag.c
===================================================================
--- e2fsprogs-1.41.8.orig/misc/filefrag.c
+++ e2fsprogs-1.41.8/misc/filefrag.c
@@ -95,8 +95,6 @@ static int get_bmap(int fd, unsigned lon
int ret;
unsigned int b;
- printf("Calling get_bmap for block %lu\n", block);
- abort();
b = block;
ret = ioctl(fd, FIBMAP, &b); /* FIBMAP takes pointer to integer */
if (ret < 0) {
e2fsprogs-1.41.8-freefrag-defrag.patch:
Makefile.in | 3
configure | 2
configure.in | 2
misc/Makefile.in | 46 -
misc/e2freefrag.8.in | 99 ++
misc/e2freefrag.c | 284 ++++++
misc/e2freefrag.h | 20
misc/e4defrag.8.in | 76 +
misc/e4defrag.c | 2147 +++++++++++++++++++++++++++++++++++++++++++++++++++
9 files changed, 2669 insertions(+), 10 deletions(-)
--- NEW FILE e2fsprogs-1.41.8-freefrag-defrag.patch ---
Index: e2fsprogs-1.41.8/misc/e4defrag.8.in
===================================================================
--- /dev/null
+++ e2fsprogs-1.41.8/misc/e4defrag.8.in
@@ -0,0 +1,76 @@
+.TH E4DEFRAG 8 "May 2009" "e4defrag version 2.0"
+.SH NAME
+e4defrag \- online defragmenter for ext4 filesystem
+.SH SYNOPSIS
+.B e4defrag
+[
+.B \-c
+]
+[
+.B \-v
+]
+.I target
+\&...
+.SH DESCRIPTION
+.B e4defrag
+reduces fragmentation of extent based file. The file targeted by
+.B e4defrag
+is created on ext4 filesystem made with "-O extent" option (see
+.BR mke2fs (8)).
+The targeted file gets more contiguous blocks and improves the file access
+speed.
+.PP
+.I target
+is a regular file, a directory, or a device that is mounted as ext4 filesystem.
+If
+.I target
+is a directory,
+.B e4defrag
+reduces fragmentation of all files in it. If
+.I target
+is a device,
+.B e4defrag
+gets the mount point of it and reduces fragmentation of all files in this mount
+point.
+.SH OPTIONS
+.TP
+.B \-c
+Get the fragmentation count and calculate fragmentation score based on it
+before and after defrag. By seeing this score, we can determine whether we
+should execute
+.B e4defrag
+to
+.IR target .
+When used with
+.B \-v
+option, the fragmentation count before and after defrag is printed for each
+file.
+.IP
+If this option is specified,
+.I target
+is never defragmented.
+.TP
+.B \-v
+Print error messages and the fragmentation count before and after defrag for
+each file.
+.SH NOTES
+.B e4defrag
+does not support swap file, files in lost+found directory, and files allocated
+in indirect blocks. When
+.I target
+is a device or a mount point,
+.B e4defrag
+doesn't defragment files in mount point of other device.
+.PP
+Non-privileged users can execute
+.B e4defrag
+to their own file, but the score is not printed if
+.B \-c
+option is specified. Therefore, it is desirable to be executed by root user.
+.SH AUTHOR
+Written by Akira Fujita <a-fujita at rs.jp.nec.com> and Takashi Sato
+<t-sato at yk.jp.nec.com>.
+.SH SEE ALSO
+.BR mke2fs (8),
+.BR mount (8).
+
Index: e2fsprogs-1.41.8/misc/e4defrag.c
===================================================================
--- /dev/null
+++ e2fsprogs-1.41.8/misc/e4defrag.c
@@ -0,0 +1,2147 @@
+/*
+ * e4defrag.c - ext4 filesystem defragmenter
+ *
+ * Copyright (C) 2009 NEC Software Tohoku, Ltd.
+ *
+ * Author: Akira Fujita <a-fujita at rs.jp.nec.com>
+ * Takashi Sato <t-sato at yk.jp.nec.com>
+ */
+
+#ifndef _LARGEFILE_SOURCE
+#define _LARGEFILE_SOURCE
+#endif
+
+#ifndef _LARGEFILE64_SOURCE
+#define _LARGEFILE64_SOURCE
+#endif
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#include <ctype.h>
+#include <dirent.h>
+#include <endian.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <ftw.h>
+#include <limits.h>
+#include <mntent.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <ext2fs/ext2_types.h>
+#include <ext2fs/ext2fs.h>
+#include <linux/fs.h>
+#include <ext2fs/fiemap.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/statfs.h>
+#include <sys/syscall.h>
+#include <sys/vfs.h>
+
+/* A relatively new ioctl interface ... */
+#ifndef EXT4_IOC_MOVE_EXT
+#define EXT4_IOC_MOVE_EXT _IOWR('f', 15, struct move_extent)
+#endif
+
+/* Macro functions */
+#define PRINT_ERR_MSG(msg) fprintf(stderr, "%s\n", (msg))
+#define IN_FTW_PRINT_ERR_MSG(msg) \
+ fprintf(stderr, "\t%s\t\t[ NG ]\n", (msg))
+#define PRINT_FILE_NAME(file) fprintf(stderr, " \"%s\"\n", (file))
+#define PRINT_ERR_MSG_WITH_ERRNO(msg) \
+ fprintf(stderr, "\t%s:%s\t[ NG ]\n", (msg), strerror(errno))
+#define STATISTIC_ERR_MSG(msg) \
+ fprintf(stderr, "\t%s\n", (msg))
+#define STATISTIC_ERR_MSG_WITH_ERRNO(msg) \
+ fprintf(stderr, "\t%s:%s\n", (msg), strerror(errno))
+#define min(x, y) (((x) > (y)) ? (y) : (x))
+#define SECTOR_TO_BLOCK(sectors, blocksize) \
+ ((sectors) / ((blocksize) >> 9))
+#define CALC_SCORE(ratio) \
+ ((ratio) > 10 ? (80 + 20 * (ratio) / 100) : (8 * (ratio)))
+/* Wrap up the free function */
+#define FREE(tmp) \
+ do { \
+ if ((tmp) != NULL) \
+ free(tmp); \
+ } while (0) \
+/* Insert list2 after list1 */
+#define insert(list1, list2) \
+ do { \
+ list2->next = list1->next; \
+ list1->next->prev = list2; \
+ list2->prev = list1; \
+ list1->next = list2; \
+ } while (0)
+
+/* To delete unused warning */
+#ifdef __GNUC__
+#define EXT2FS_ATTR(x) __attribute__(x)
+#else
+#define EXT2FS_ATTR(x)
+#endif
+
+/* The mode of defrag */
+#define DETAIL 0x01
+#define STATISTIC 0x02
+
+#define DEVNAME 0
+#define DIRNAME 1
+#define FILENAME 2
+
+#define FTW_OPEN_FD 2000
+
+#define FS_EXT4 "ext4"
+#define ROOT_UID 0
+
+#define BOUND_SCORE 55
+#define SHOW_FRAG_FILES 5
+
+/* Magic number for ext4 */
+#define EXT4_SUPER_MAGIC 0xEF53
+
+/* Definition of flex_bg */
+#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
+
+/* The following macro is used for ioctl FS_IOC_FIEMAP
+ * EXTENT_MAX_COUNT: the maximum number of extents for exchanging between
+ * kernel-space and user-space per ioctl
+ */
[...2437 lines suppressed...]
+ if (info->real_free_chunks) {
+ info->min = (info->min * fs->blocksize) >> 10;
+ info->max = (info->max * fs->blocksize) >> 10;
+ info->avg = (info->avg / info->real_free_chunks *
+ fs->blocksize) >> 10;
+ } else {
+ info->min = 0;
+ }
+
+ printf("\nMin free chunk: %lu KB \nMax free chunk: %lu KB\n"
+ "Avg free chunk: %lu KB\n", info->min, info->max, info->avg);
+
+ printf("\nHISTOGRAM OF FREE CHUNK SIZES:\n");
+ printf("%s : %12s %12s %7s\n", "Chunk Size Range", "Free chunks",
+ "Free Blocks", "Percent");
+ for (i = 0; i < MAX_HIST; i++) {
+ end = 1 << (i + info->blocksize_bits - units);
+ if (info->histogram.fc_chunks[i] != 0)
+ printf("%5lu%c...%5lu%c- : %12lu %12lu %6.2f%%\n",
+ start, *unitp, end, *unitp,
+ info->histogram.fc_chunks[i],
+ info->histogram.fc_blocks[i],
+ (double)info->histogram.fc_blocks[i] * 100 /
+ fs->super->s_free_blocks_count);
+ start = end;
+ if (start == 1<<10) {
+ start = 1;
+ units += 10;
+ unitp++;
+ }
+ }
+
+ return retval;
+}
+
+void close_device(char *device_name, ext2_filsys fs)
+{
+ int retval = ext2fs_close(fs);
+
+ if (retval)
+ com_err(device_name, retval, "while closing the filesystem.\n");
+}
+
+void collect_info(ext2_filsys fs, struct chunk_info *chunk_info)
+{
+ unsigned int retval = 0, i, free_blks;
+
+ printf("Device: %s\n", fs->device_name);
+ printf("Blocksize: %u bytes\n", fs->blocksize);
+
+ retval = ext2fs_read_block_bitmap(fs);
+ if (retval) {
+ com_err(fs->device_name, retval, "while reading block bitmap");
+ close_device(fs->device_name, fs);
+ exit(1);
+ }
+
+ init_chunk_info(fs, chunk_info);
+
+ retval = get_chunk_info(fs, chunk_info);
+ if (retval) {
+ com_err(fs->device_name, retval, "while collecting chunk info");
+ close_device(fs->device_name, fs);
+ exit(1);
+ }
+}
+
+void open_device(char *device_name, ext2_filsys *fs)
+{
+ int retval;
+ int flag = EXT2_FLAG_FORCE;
+
+ retval = ext2fs_open(device_name, flag, 0, 0, unix_io_manager, fs);
+ if (retval) {
+ com_err(device_name, retval, "while opening filesystem");
+ exit(1);
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ struct chunk_info chunk_info = { .chunkbytes = DEFAULT_CHUNKSIZE };
+ errcode_t retval = 0;
+ ext2_filsys fs = NULL;
+ char *device_name;
+ char *progname;
+ char c, *end;
+
+ progname = argv[0];
+
+ while ((c = getopt(argc, argv, "c:h")) != EOF) {
+ switch (c) {
+ case 'c':
+ chunk_info.chunkbytes = strtoull(optarg, &end, 0);
+ if (*end != '\0') {
+ fprintf(stderr, "%s: bad chunk size '%s'\n",
+ progname, optarg);
+ usage(progname);
+ }
+ if (chunk_info.chunkbytes &
+ (chunk_info.chunkbytes - 1)) {
+ fprintf(stderr, "%s: chunk size must be a "
+ "power of 2.", argv[0]);
+ usage(progname);
+ }
+ chunk_info.chunkbytes *= 1024;
+ break;
+ default:
+ fprintf(stderr, "%s: bad option '%c'\n",
+ progname, c);
+ case 'h':
+ usage(progname);
+ break;
+ }
+ }
+
+ if (optind == argc) {
+ fprintf(stderr, "%s: missing device name.\n", progname);
+ usage(progname);
+ }
+
+ device_name = argv[optind];
+
+ open_device(device_name, &fs);
+
+ if (chunk_info.chunkbytes < fs->blocksize) {
+ fprintf(stderr, "%s: chunksize must be greater than or equal "
+ "to filesystem blocksize.\n", progname);
+ exit(1);
+ }
+ collect_info(fs, &chunk_info);
+ close_device(device_name, fs);
+
+ return retval;
+}
Index: e2fsprogs-1.41.8/misc/e2freefrag.h
===================================================================
--- /dev/null
+++ e2fsprogs-1.41.8/misc/e2freefrag.h
@@ -0,0 +1,20 @@
+#include <sys/types.h>
+
+#define DEFAULT_CHUNKSIZE (1024*1024)
+
+#define MAX_HIST 32
+struct free_chunk_histogram {
+ unsigned long fc_chunks[MAX_HIST];
+ unsigned long fc_blocks[MAX_HIST];
+};
+
+struct chunk_info {
+ unsigned long chunkbytes; /* chunk size in bytes */
+ int chunkbits; /* chunk size in bits */
+ unsigned long free_chunks; /* total free chunks of given size */
+ unsigned long real_free_chunks; /* free chunks of any size */
+ int blocksize_bits; /* fs blocksize in bits */
+ int blks_in_chunk; /* number of blocks in a chunk */
+ unsigned long min, max, avg; /* chunk size stats */
+ struct free_chunk_histogram histogram; /* histogram of all chunk sizes*/
+};
Index: e2fsprogs-1.41.8/configure
===================================================================
--- e2fsprogs-1.41.8.orig/configure
+++ e2fsprogs-1.41.8/configure
@@ -15790,7 +15790,7 @@ fi
-for ac_func in chflags getrusage llseek lseek64 open64 fstat64 ftruncate64 getmntinfo strtoull strcasecmp srandom jrand48 fchown mallinfo fdatasync strnlen strptime strdup sysconf pathconf posix_memalign memalign valloc __secure_getenv prctl mmap utime setresuid setresgid usleep nanosleep getdtablesize getrlimit
+for ac_func in chflags getrusage llseek lseek64 open64 fstat64 ftruncate64 getmntinfo strtoull strcasecmp srandom jrand48 fchown mallinfo fdatasync strnlen strptime strdup sysconf pathconf posix_memalign memalign valloc __secure_getenv prctl mmap utime setresuid setresgid usleep nanosleep getdtablesize getrlimit sync_file_range posix_fadvise fallocate
do
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
Index: e2fsprogs-1.41.8/configure.in
===================================================================
--- e2fsprogs-1.41.8.orig/configure.in
+++ e2fsprogs-1.41.8/configure.in
@@ -828,7 +828,7 @@ AC_CHECK_MEMBER(struct sockaddr.sa_len,
[#include <sys/types.h>
#include <sys/socket.h>])
dnl
-AC_CHECK_FUNCS(chflags getrusage llseek lseek64 open64 fstat64 ftruncate64 getmntinfo strtoull strcasecmp srandom jrand48 fchown mallinfo fdatasync strnlen strptime strdup sysconf pathconf posix_memalign memalign valloc __secure_getenv prctl mmap utime setresuid setresgid usleep nanosleep getdtablesize getrlimit)
+AC_CHECK_FUNCS(chflags getrusage llseek lseek64 open64 fstat64 ftruncate64 getmntinfo strtoull strcasecmp srandom jrand48 fchown mallinfo fdatasync strnlen strptime strdup sysconf pathconf posix_memalign memalign valloc __secure_getenv prctl mmap utime setresuid setresgid usleep nanosleep getdtablesize getrlimit sync_file_range posix_fadvise fallocate)
dnl
dnl Check to see if -lsocket is required (solaris) to make something
dnl that uses socket() to compile; this is needed for the UUID library
Index: e2fsprogs-1.41.8/Makefile.in
===================================================================
--- e2fsprogs-1.41.8.orig/Makefile.in
+++ e2fsprogs-1.41.8/Makefile.in
@@ -57,6 +57,9 @@ clean-doc:
distclean-doc:
-test -d doc && cd doc && $(MAKE) distclean
+install-e4defrag: subs all-libs-recursive
+ $(MAKE) -C misc install-e4defrag
+
install: subs all-libs-recursive install-progs-recursive \
install-shlibs-libs-recursive install-doc-libs
if test ! -d e2fsck && test ! -d debugfs && test ! -d misc && test ! -d ext2ed ; then $(MAKE) install-libs ; fi
Index: e2fsprogs.spec
===================================================================
RCS file: /cvs/pkgs/rpms/e2fsprogs/devel/e2fsprogs.spec,v
retrieving revision 1.147
retrieving revision 1.148
diff -u -p -r1.147 -r1.148
--- e2fsprogs.spec 25 Jul 2009 23:54:38 -0000 1.147
+++ e2fsprogs.spec 6 Aug 2009 02:15:34 -0000 1.148
@@ -4,13 +4,17 @@
Summary: Utilities for managing ext2, ext3, and ext4 filesystems
Name: e2fsprogs
Version: 1.41.8
-Release: 5%{?dist}
+Release: 6%{?dist}
+
# License tags based on COPYING file distinctions for various components
License: GPLv2
Group: System Environment/Base
Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
Source1: ext2_types-wrapper.h
+
Patch2: e2fsprogs-1.40.4-sb_feature_check_ignore.patch
+Patch3: e2fsprogs-1.41.8-filefrag-fix.patch
+Patch4: e2fsprogs-1.41.8-freefrag-defrag.patch
Url: http://e2fsprogs.sourceforge.net/
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -136,6 +140,10 @@ It was originally inspired by the Multic
# mildly unsafe but 'til I get something better, avoid full fsck
# after an selinux install...
%patch2 -p1 -b .featurecheck
+# fix filefrag
+%patch3 -p1 -b .filefrag
+# frag tools
+%patch4 -p1 -b .frag
%build
%configure --enable-elf-shlibs --enable-nls --disable-uuidd --disable-fsck \
@@ -145,7 +153,7 @@ make %{?_smp_mflags} V=1
%install
rm -rf %{buildroot}
export PATH=/sbin:$PATH
-make install install-libs DESTDIR=%{buildroot} INSTALL="%{__install} -p" \
+make install install-libs install-e4defrag DESTDIR=%{buildroot} INSTALL="%{__install} -p" \
root_sbindir=%{_root_sbindir} root_libdir=%{_root_libdir}
# ugly hack to allow parallel install of 32-bit and 64-bit -devel packages:
@@ -208,8 +216,12 @@ exit 0
%{_root_sbindir}/resize2fs
%{_root_sbindir}/tune2fs
%{_sbindir}/filefrag
+%{_sbindir}/e2freefrag
%{_sbindir}/mklost+found
+%{_bindir}/e4defrag
+%{_mandir}/man8/e4defrag.8*
+
%{_bindir}/chattr
%{_bindir}/lsattr
%{_mandir}/man1/chattr.1*
@@ -223,6 +235,7 @@ exit 0
%{_mandir}/man8/dumpe2fs.8*
%{_mandir}/man8/e2fsck.8*
%{_mandir}/man8/filefrag.8*
+%{_mandir}/man8/e2freefrag.8*
%{_mandir}/man8/fsck.ext2.8*
%{_mandir}/man8/fsck.ext3.8*
%{_mandir}/man8/fsck.ext4.8*
@@ -291,6 +304,10 @@ exit 0
%{_libdir}/pkgconfig/ss.pc
%changelog
+* Fri Aug 05 2009 Eric Sandeen <sandeen at redhat.com> 1.41.8-6
+- Fix filefrag in fallback case
+- Add e2freefrag & e4defrag (experimental)
+
* Sun Jul 26 2009 Karel Zak <kzak at redhat.com> 1.41.8-5
- disable fsck (replaced by util-linux-ng)
More information about the scm-commits
mailing list