xfs_io: support a basic extent swap command
PATCH v2 1/1 xfs_io: support a basic extent swap command
Extent swap is a low level mechanism exported by XFS to facilitate filesystem defragmentation. It is typically invoked by xfs_fsr under conditions that will atomically adjust inode extent state without loss of file data.
While xfs_fsr provides some debug capability to tailor its behavior, it is not flexible enough to facilitate low level tests of the extent swap mechanism. For example, xfs_fsr may skip swaps between inodes that consist solely of preallocated extents because it considers such files already 100% defragmented. Further, xfs_fsr copies data between files where doing so may be unnecessary and thus inefficient for lower level tests.
Add a basic swapext command to xfs_io that allows userspace invocation of the command under more controlled conditions. This facilites targeted tests without interference from xfs_fsr policy, such as using files with only preallocated extents, known/expected failure cases, etc. This command makes no effort to retain data across the operation. As such, it is for testing purposes only.
---
v2:
- Update xfs_io man page.
- Fix up commit log description.
v1: https://marc.info/?l=linux-xfs&m=151792224511355&w=2
io/Makefile | 3 +- io/init.c | 1 + io/io.h | 1 + io/swapext.c | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ man/man8/xfs_io.8 | 5 +++ 5 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 io/swapext.c
io/Makefile +2 -1
@@ -11,7 +11,8 @@ HFILES = init.h io.h CFILES = init.c \ attr.c bmap.c cowextsize.c encrypt.c file.c freeze.c fsync.c \ getrusage.c imap.c link.c mmap.c open.c parent.c pread.c prealloc.c \ - pwrite.c reflink.c seek.c shutdown.c stat.c sync.c truncate.c utimes.c + pwrite.c reflink.c seek.c shutdown.c stat.c swapext.c sync.c \ + truncate.c utimes.c LLDLIBS = $(LIBXCMD) $(LIBHANDLE) $(LIBPTHREAD) LTDEPENDENCIES = $(LIBXCMD) $(LIBHANDLE)
io/init.c +1 -0
@@ -88,6 +88,7 @@ init_commands(void)sendfile_init ();shutdown_init ();stat_init (); +swapext_init ();sync_init ();sync_range_init ();truncate_init ();
io/io.h +1 -0
@@ -118,6 +118,7 @@ extern void quit_init(void);extern void seek_init (void );extern void shutdown_init (void );extern void stat_init (void ); +extern void swapext_init (void );extern void sync_init (void );extern void truncate_init (void );extern void utimes_init (void );
io/swapext.c new file +107 -0
107 lines not on this page · raw message
man/man8/xfs_io.8 +5 -0
@@ -761,6 +761,11 @@ sec uses UNIX timestamp notation and is the seconds elapsed since nsec is the nanoseconds since the sec. This value needs to be in the range 0-999999999 with UTIME_NOW and UTIME_OMIT being exceptions. Each (sec, nsec) pair constitutes a single timestamp value. +.TP +.BI swapext " donor_file " +Swaps extent forks between files. The current open file is the target. The donor +file is specified by path. Note that file data is not copied (file content moves +with the fork(s)). .SH MEMORY MAPPED I/O COMMANDS .TP
Signature · 1 line
2.13.6
Quoted 13 lines · Brian Foster
Extent swap is a low level mechanism exported by XFS to facilitate filesystem defragmentation. It is typically invoked by
xfs_fsrunder conditions that will atomically adjust inode extent state without loss of file data.While
xfs_fsrprovides some debug capability to tailor its behavior, it is not flexible enough to facilitate low level tests of the extent swap mechanism. For example,xfs_fsrmay skip swaps between inodes that consist solely of preallocated extents because it considers such files already 100% defragmented. Further,xfs_fsrcopies data between files where doing so may be unnecessary and thus inefficient for lower level tests.
Quoted 8 lines
Add a basic swapext command to
xfs_iothat allows userspace invocation of the command under more controlled conditions. This facilites targeted tests without interference fromxfs_fsrpolicy, such as using files with only preallocated extents, known/expected failure cases, etc. This command makes no effort to retain data across the operation. As such, it is for testing purposes only.Signed-off-by Brian Foster <[email protected]>
Looks ok,
--D
Quoted 20 lines · Brian Foster
Extent swap is a low level mechanism exported by XFS to facilitate filesystem defragmentation. It is typically invoked by
xfs_fsrunder conditions that will atomically adjust inode extent state without loss of file data.While
xfs_fsrprovides some debug capability to tailor its behavior, it is not flexible enough to facilitate low level tests of the extent swap mechanism. For example,xfs_fsrmay skip swaps between inodes that consist solely of preallocated extents because it considers such files already 100% defragmented. Further,xfs_fsrcopies data between files where doing so may be unnecessary and thus inefficient for lower level tests.Add a basic swapext command to
xfs_iothat allows userspace invocation of the command under more controlled conditions. This facilites targeted tests without interference fromxfs_fsrpolicy, such as using files with only preallocated extents, known/expected failure cases, etc. This command makes no effort to retain data across the operation. As such, it is for testing purposes only.
Quoted 7 lines
Signed-off-by Brian Foster <[email protected]>---
v2:
- Updatexfs_ioman page.
- Fix up commit log description.
v1: https://marc.info/?l=linux-xfs&m=151792224511355&w=2
Looks good. I'm no longer confused :)
Signature · 2 lines
Dave Chinner [email protected]