From: "Darrick J. Wong" <djwong@kernel.org>
To: cem@kernel.org, djwong@kernel.org
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 02/10] xfs_io: support using XFS_IOC_MAP_FREESP to map free space
Date: Sun, 31 Dec 2023 16:40:30 +9900 [thread overview]
Message-ID: <170405020351.1820796.4340744744634500451.stgit@frogsfrogsfrogs> (raw)
In-Reply-To: <170405020316.1820796.451112156000559887.stgit@frogsfrogsfrogs>
From: Darrick J. Wong <djwong@kernel.org>
Add a command to call XFS_IOC_MAP_FREESP. This is experimental code to
see if we can build a free space defragmenter out of this.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
io/prealloc.c | 35 +++++++++++++++++++++++++++++++++++
man/man8/xfs_io.8 | 8 +++++++-
2 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/io/prealloc.c b/io/prealloc.c
index 5805897a4a0..0de3e142de1 100644
--- a/io/prealloc.c
+++ b/io/prealloc.c
@@ -45,6 +45,7 @@ static cmdinfo_t finsert_cmd;
static cmdinfo_t fzero_cmd;
static cmdinfo_t funshare_cmd;
#endif
+static cmdinfo_t fmapfree_cmd;
static int
offset_length(
@@ -383,6 +384,30 @@ funshare_f(
}
#endif /* HAVE_FALLOCATE */
+static int
+fmapfree_f(
+ int argc,
+ char **argv)
+{
+ struct xfs_flock64 segment;
+ struct xfs_map_freesp args = { };
+
+ if (!offset_length(argv[1], argv[2], &segment)) {
+ exitcode = 1;
+ return 0;
+ }
+
+ args.offset = segment.l_start;
+ args.len = segment.l_len;
+
+ if (ioctl(file->fd, XFS_IOC_MAP_FREESP, &args)) {
+ perror("XFS_IOC_MAP_FREESP");
+ exitcode = 1;
+ return 0;
+ }
+ return 0;
+}
+
void
prealloc_init(void)
{
@@ -497,4 +522,14 @@ prealloc_init(void)
_("unshares shared blocks within the range");
add_command(&funshare_cmd);
#endif /* HAVE_FALLOCATE */
+
+ fmapfree_cmd.name = "fmapfree";
+ fmapfree_cmd.cfunc = fmapfree_f;
+ fmapfree_cmd.argmin = 2;
+ fmapfree_cmd.argmax = 2;
+ fmapfree_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK;
+ fmapfree_cmd.args = _("off len");
+ fmapfree_cmd.oneline =
+ _("maps free space into a file");
+ add_command(&fmapfree_cmd);
}
diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8
index 411144151a1..e360d22dc38 100644
--- a/man/man8/xfs_io.8
+++ b/man/man8/xfs_io.8
@@ -513,8 +513,14 @@ Call fallocate with FALLOC_FL_INSERT_RANGE flag as described in the
.BR fallocate (2)
manual page to create the hole by shifting data blocks.
.TP
+.BI fmapfree " offset length"
+Maps free physical space into the file by calling XFS_IOC_MAP_FREESP as
+described in the
+.BR XFS_IOC_MAP_FREESP (2)
+manual page.
+.TP
.BI fpunch " offset length"
-Punches (de-allocates) blocks in the file by calling fallocate with
+Punches (de-allocates) blocks in the file by calling fallocate with
the FALLOC_FL_PUNCH_HOLE flag as described in the
.BR fallocate (2)
manual page.
next prev parent reply other threads:[~2024-01-01 0:40 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-31 18:25 [NYE PATCHRIVER 4/4] xfs: freespace defrag for online shrink Darrick J. Wong
2023-12-31 19:38 ` [PATCHSET 1/5] xfs: improve post-close eofblocks gc behavior Darrick J. Wong
2023-12-31 22:00 ` [PATCH 1/3] xfs: only free posteof blocks on first close Darrick J. Wong
2023-12-31 22:00 ` [PATCH 2/3] xfs: don't free EOF blocks on read close Darrick J. Wong
2023-12-31 22:00 ` [PATCH 3/3] xfs: Don't free EOF blocks on close when extent size hints are set Darrick J. Wong
2023-12-31 19:38 ` [PATCHSET RFC 2/5] xfs: noalloc allocation groups Darrick J. Wong
2023-12-31 22:00 ` [PATCH 1/5] xfs: track deferred ops statistics Darrick J. Wong
2023-12-31 22:01 ` [PATCH 2/5] xfs: whine to dmesg when we encounter errors Darrick J. Wong
2023-12-31 22:01 ` [PATCH 3/5] xfs: create a noalloc mode for allocation groups Darrick J. Wong
2023-12-31 22:01 ` [PATCH 4/5] xfs: enable userspace to hide an AG from allocation Darrick J. Wong
2023-12-31 22:02 ` [PATCH 5/5] xfs: apply noalloc mode to inode allocations too Darrick J. Wong
2023-12-31 19:39 ` [PATCHSET 3/5] xfs: report refcount information to userspace Darrick J. Wong
2023-12-31 22:02 ` [PATCH 1/1] xfs: export reference count " Darrick J. Wong
2023-12-31 19:39 ` [PATCHSET 4/5] xfs: defragment free space Darrick J. Wong
2023-12-31 22:02 ` [PATCH 1/2] xfs: capture the offset and length in fallocate tracepoints Darrick J. Wong
2023-12-31 22:02 ` [PATCH 2/2] xfs: add an ioctl to map free space into a file Darrick J. Wong
2023-12-31 19:39 ` [PATCHSET v2 5/5] xfs: aligned file data extent mappings Darrick J. Wong
2023-12-31 22:03 ` [PATCH 1/4] xfs: create a new inode flag to require extsize alignment of file data space Darrick J. Wong
2023-12-31 22:03 ` [PATCH 2/4] xfs: make file data allocations observe the 'forcealign' flag Darrick J. Wong
2024-01-16 9:26 ` John Garry
2023-12-31 22:03 ` [PATCH 3/4] xfs: support reflink with force align enabled Darrick J. Wong
2023-12-31 22:03 ` [PATCH 4/4] xfs: enable file data force-align feature Darrick J. Wong
2023-12-31 19:56 ` [PATCHSET RFC 1/3] xfsprogs: noalloc allocation groups Darrick J. Wong
2023-12-27 13:38 ` [PATCH 1/5] xfs: track deferred ops statistics Darrick J. Wong
2023-12-27 13:38 ` [PATCH 2/5] xfs: create a noalloc mode for allocation groups Darrick J. Wong
2023-12-27 13:38 ` [PATCH 3/5] xfs: enable userspace to hide an AG from allocation Darrick J. Wong
2023-12-27 13:39 ` [PATCH 4/5] xfs: apply noalloc mode to inode allocations too Darrick J. Wong
2023-12-27 13:39 ` [PATCH 5/5] xfs_io: enhance the aginfo command to control the noalloc flag Darrick J. Wong
2023-12-31 19:56 ` [PATCHSET 2/3] xfsprogs: report refcount information to userspace Darrick J. Wong
2023-12-27 13:39 ` [PATCH 1/2] xfs: export reference count " Darrick J. Wong
2023-12-27 13:39 ` [PATCH 2/2] xfs_io: dump reference count information Darrick J. Wong
2023-12-31 19:56 ` [PATCHSET 3/3] xfsprogs: defragment free space Darrick J. Wong
2023-12-27 13:40 ` [PATCH 01/10] xfs: add an ioctl to map free space into a file Darrick J. Wong
2023-12-27 13:40 ` Darrick J. Wong [this message]
2023-12-27 13:40 ` [PATCH 03/10] xfs_db: get and put blocks on the AGFL Darrick J. Wong
2023-12-27 13:41 ` [PATCH 04/10] xfs_spaceman: implement clearing free space Darrick J. Wong
2023-12-27 13:41 ` [PATCH 05/10] spaceman: physically move a regular inode Darrick J. Wong
2023-12-27 13:41 ` [PATCH 06/10] spaceman: find owners of space in an AG Darrick J. Wong
2023-12-27 13:41 ` [PATCH 07/10] xfs_spaceman: wrap radix tree accesses in find_owner.c Darrick J. Wong
2023-12-27 13:42 ` [PATCH 08/10] xfs_spaceman: port relocation structure to 32-bit systems Darrick J. Wong
2023-12-27 13:42 ` [PATCH 09/10] spaceman: relocate the contents of an AG Darrick J. Wong
2023-12-27 13:42 ` [PATCH 10/10] spaceman: move inodes with hardlinks Darrick J. Wong
2023-12-31 20:02 ` [PATCHSET 1/2] fstests: functional test for refcount reporting Darrick J. Wong
2023-12-27 14:06 ` [PATCH 1/2] xfs/122: update for the getfsrefs ioctl Darrick J. Wong
2023-12-27 14:06 ` [PATCH 2/2] xfs: test output of new FSREFCOUNTS ioctl Darrick J. Wong
2023-12-31 20:02 ` [PATCHSET 2/2] fstests: defragment free space Darrick J. Wong
2023-12-27 14:06 ` [PATCH 1/2] xfs/122: update for XFS_IOC_MAP_FREESP Darrick J. Wong
2023-12-27 14:07 ` [PATCH 2/2] xfs: test clearing of free space Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=170405020351.1820796.4340744744634500451.stgit@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=cem@kernel.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox