rpms/e2fsprogs/devel e2fsprogs-1.41.9-defrag.patch,NONE,1.1
Eric Sandeen
sandeen at fedoraproject.org
Mon Aug 24 05:00:12 UTC 2009
- Previous message (by thread): rpms/hyphen-as/devel .cvsignore, NONE, 1.1 Makefile, NONE, 1.1 sources, NONE, 1.1
- Next message (by thread): rpms/hyphen-as/devel hyph_as_IN.dic, NONE, 1.1 hyphen-as.spec, NONE, 1.1 import.log, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: sandeen
Update of /cvs/pkgs/rpms/e2fsprogs/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv30263
Added Files:
e2fsprogs-1.41.9-defrag.patch
Log Message:
And the missing patch...
e2fsprogs-1.41.9-defrag.patch:
Makefile.in | 3
configure | 2
configure.in | 2
misc/Makefile.in | 26
misc/e4defrag.8.in | 76 +
misc/e4defrag.c | 2153 +++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 2256 insertions(+), 6 deletions(-)
--- NEW FILE e2fsprogs-1.41.9-defrag.patch ---
Index: e2fsprogs-1.41.9/misc/e4defrag.8.in
===================================================================
--- /dev/null
+++ e2fsprogs-1.41.9/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.9/misc/e4defrag.c
===================================================================
--- /dev/null
+++ e2fsprogs-1.41.9/misc/e4defrag.c
@@ -0,0 +1,2153 @@
+/*
+ * 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
+ */
[...1963 lines suppressed...]
+ argv[i]);
+ /* Defrag single file process */
+ file_defrag(argv[i], &buf, FTW_F, NULL);
+ if (succeed_cnt != 0)
+ printf(" Success:\t\t\t[1/1]\n");
+ else
+ printf(" Success:\t\t\t[0/1]\n");
+
+ break;
+ }
+
+ if (succeed_cnt != 0)
+ success_flag = 1;
+ if (mode_flag & STATISTIC) {
+ if (current_uid != ROOT_UID) {
+ printf(" Done.\n");
+ continue;
+ }
+
+ if (!succeed_cnt) {
+ if (mode_flag & DETAIL)
+ printf("\n");
+
+ if (arg_type == DEVNAME)
+ printf(" In this device(%s), "
+ "none can be defragmented.\n", argv[i]);
+ else if (arg_type == DIRNAME)
+ printf(" In this directory(%s), "
+ "none can be defragmented.\n", argv[i]);
+ else
+ printf(" This file(%s) "
+ "can't be defragmented.\n", argv[i]);
+ } else {
+ float files_ratio = 0.0;
+ float score = 0.0;
+ files_ratio = (float)(extents_before_defrag -
+ extents_after_defrag) *
+ 100 / files_block_count;
+ score = CALC_SCORE(files_ratio);
+ printf("\n Total/best extents\t\t\t\t%d/%d\n"
+ " Fragmentation ratio\t\t\t\t%.2f%%\n"
+ " Fragmentation score\t\t\t\t%.2f\n",
+ extents_before_defrag,
+ extents_after_defrag,
+ files_ratio, score);
+ printf(" [0-30 no problem:"
+ " 31-55 a little bit fragmented:"
+ " 55- needs defrag]\n");
+
+ if (arg_type == DEVNAME)
+ printf(" This device(%s) ", argv[i]);
+ else if (arg_type == DIRNAME)
+ printf(" This directory(%s) ", argv[i]);
+ else
+ printf(" This file(%s) ", argv[i]);
+
+ if (score > BOUND_SCORE)
+ printf("needs defragmentation.\n");
+ else
+ printf("does not need "
+ "defragmentation.\n");
+ }
+ printf(" Done.\n");
+ }
+
+ }
+
+ if (success_flag)
+ return 0;
+
+ exit(1);
+
+out:
+ printf(MSG_USAGE);
+ exit(1);
+}
+
Index: e2fsprogs-1.41.9/misc/Makefile.in
===================================================================
--- e2fsprogs-1.41.9.orig/misc/Makefile.in
+++ e2fsprogs-1.41.9/misc/Makefile.in
@@ -51,6 +51,7 @@ BLKID_OBJS= blkid.o
FILEFRAG_OBJS= filefrag.o
E2UNDO_OBJS= e2undo.o
E2FREEFRAG_OBJS= e2freefrag.o
+E4DEFRAG_OBJS= e4defrag.o
PROFILED_TUNE2FS_OBJS= profiled/tune2fs.o profiled/util.o
PROFILED_MKLPF_OBJS= profiled/mklost+found.o
@@ -68,7 +69,7 @@ PROFILED_FSCK_OBJS= profiled/fsck.o prof
PROFILED_BLKID_OBJS= profiled/blkid.o
PROFILED_FILEFRAG_OBJS= profiled/filefrag.o
PROFILED_E2UNDO_OBJS= profiled/e2undo.o
-
+PROFILED_E4DEFRAG_OBJS= profiled/e4defrag.o
XTRA_CFLAGS= -I$(srcdir)/../e2fsck -I.
@@ -99,12 +100,12 @@ COMPILE_ET=$(top_builddir)/lib/et/compil
@PROFILE_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -g -pg -o profiled/$*.o -c $<
all:: profiled $(SPROGS) $(UPROGS) $(USPROGS) $(SMANPAGES) $(UMANPAGES) \
- $(FMANPAGES) $(LPROGS)
+ $(FMANPAGES) $(LPROGS) e4defrag
@PROFILE_CMT at all:: tune2fs.profiled blkid.profiled e2image.profiled \
e2undo.profiled mke2fs.profiled dumpe2fs.profiled fsck.profiled \
logsave.profiled filefrag.profiled uuidgen.profiled uuidd.profiled \
- e2image.profiled
+ e2image.profiled e4defrag.profiled
profiled:
@PROFILE_CMT@ $(E) " MKDIR $@"
@@ -191,6 +192,15 @@ e2undo.profiled: $(PROFILED_E2UNDO_OBJS)
$(Q) $(CC) $(ALL_LDFLAGS) -g -pg -o e2undo.profiled \
$(PROFILED_E2UNDO_OBJS) $(PROFILED_LIBS) $(LIBINTL)
+e4defrag: $(E4DEFRAG_OBJS)
+ $(E) " LD $@"
+ $(Q) $(CC) $(ALL_LDFLAGS) -o e4defrag $(E4DEFRAG_OBJS)
+
+e4defrag.profiled: $(PROFILED_E4DEFRAG_OBJS)
+ $(E) " LD $@"
+ $(Q) $(CC) $(ALL_LDFLAGS) -g -pg -o e4defrag.profiled \
+ $(PROFILED_E4DEFRAG_OBJS)
+
base_device: base_device.c
$(E) " LD $@"
$(Q) $(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(srcdir)/base_device.c \
@@ -338,6 +348,10 @@ e2image.8: $(DEP_SUBSTITUTE) $(srcdir)/e
$(E) " SUBST $@"
$(Q) $(SUBSTITUTE_UPTIME) $(srcdir)/e2image.8.in e2image.8
+e4defrag.8: $(DEP_SUBSTITUTE) $(srcdir)/e4defrag.8.in
+ $(E) " SUBST $@"
+ $(Q) $(SUBSTITUTE_UPTIME) $(srcdir)/e4defrag.8.in e4defrag.8
+
dumpe2fs.8: $(DEP_SUBSTITUTE) $(srcdir)/dumpe2fs.8.in
$(E) " SUBST $@"
$(Q) $(SUBSTITUTE_UPTIME) $(srcdir)/dumpe2fs.8.in dumpe2fs.8
@@ -394,6 +408,10 @@ installdirs:
$(DESTDIR)$(man1dir) $(DESTDIR)$(man5dir) \
$(DESTDIR)$(libdir) $(DESTDIR)/$(root_sysconfdir)
+install-e4defrag: e4defrag e4defrag.8 installdirs
+ $(INSTALL_PROGRAM) e4defrag $(DESTDIR)$(bindir)/e4defrag
+ $(INSTALL_DATA) e4defrag.8 $(DESTDIR)$(man8dir)/e4defrag.8
+
install: all $(SMANPAGES) $(UMANPAGES) installdirs
$(Q) for i in $(SPROGS); do \
echo " INSTALL $(root_sbindir)/$$i"; \
@@ -551,7 +569,7 @@ clean:
blkid.profiled tune2fs.profiled e2image.profiled \
e2undo.profiled mke2fs.profiled dumpe2fs.profiled \
logsave.profiled filefrag.profiled uuidgen.profiled \
- uuidd.profiled e2image.profiled \
+ uuidd.profiled e2image.profiled e4defrag \
profiled/*.o \#* *.s *.o *.a *~ core gmon.out
mostlyclean: clean
Index: e2fsprogs-1.41.9/configure
===================================================================
--- e2fsprogs-1.41.9.orig/configure
+++ e2fsprogs-1.41.9/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.9/configure.in
===================================================================
--- e2fsprogs-1.41.9.orig/configure.in
+++ e2fsprogs-1.41.9/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.9/Makefile.in
===================================================================
--- e2fsprogs-1.41.9.orig/Makefile.in
+++ e2fsprogs-1.41.9/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
- Previous message (by thread): rpms/hyphen-as/devel .cvsignore, NONE, 1.1 Makefile, NONE, 1.1 sources, NONE, 1.1
- Next message (by thread): rpms/hyphen-as/devel hyph_as_IN.dic, NONE, 1.1 hyphen-as.spec, NONE, 1.1 import.log, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the fedora-extras-commits
mailing list