xfsprogs: introduce defrag command to spaceman
PATCH 1/2 xfsprogs: introduce defrag command to spaceman
Non-exclusive defragment
Here we are introducing the non-exclusive manner to defragment a file, especially for huge files, without blocking IO to it long. Non-exclusive defragmentation divides the whole file into small segments. For each segment, we lock the file, defragment the segment and unlock the file. Defragmenting the small segment doesn’t take long. File IO requests can get served between defragmenting segments before blocked long. Also we put (user adjustable) idle time between defragmenting two consecutive segments to balance the defragmentation and file IOs.
Signed-off-by Wengang Wang <[email protected]>
--- spaceman/Makefile | 2 +- spaceman/defrag.c | 394 ++++++++++++++++++++++++++++++++++++++++++++++ spaceman/init.c | 1 + spaceman/space.h | 1 + 4 files changed, 397 insertions(+), 1 deletion(-) create mode 100644 spaceman/defrag.c
spaceman/Makefile +1 -1
@@ -7,7 +7,7 @@ include $(TOPDIR)/include/builddefs LTCOMMAND = xfs_spaceman HFILES = init.h space.h -CFILES = info.c init.c file.c health.c prealloc.c trim.c +CFILES = info.c init.c file.c health.c prealloc.c trim.c defrag.c LSRCFILES = xfs_info.sh LLDLIBS = $(LIBXCMD) $(LIBFROG)
spaceman/defrag.c new file +394 -0
394 lines not on this page · raw message
spaceman/init.c +1 -0
@@ -35,6 +35,7 @@ init_commands(void)trim_init ();freesp_init ();health_init (); +defrag_init (); } static int
spaceman/space.h +1 -0
@@ -26,6 +26,7 @@ extern void help_init(void);extern void prealloc_init (void );extern void quit_init (void );extern void trim_init (void ); +extern void defrag_init (void );#ifdef HAVE_GETFSMAP extern void freesp_init (void );#else
Signature · 1 line
2.39.3 (Apple Git-145)