From: Namjae Jeon <linkinjeon@gmail.com>
To: david@fromorbit.com, tytso@mit.edu
Cc: Namjae Jeon <linkinjeon@gmail.com>,
Namjae Jeon <namjae.jeon@samsung.com>,
bfoster@redhat.com, linux-kernel@vger.kernel.org,
xfs@oss.sgi.com, a.sangwan@samsung.com,
linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org
Subject: [PATCH v8 4/11] xfsprogs: xfs_io: add finsert command for insert range
Date: Wed, 14 Jan 2015 01:05:19 +0900 [thread overview]
Message-ID: <1421165126-3585-5-git-send-email-linkinjeon@gmail.com> (raw)
In-Reply-To: <1421165126-3585-1-git-send-email-linkinjeon@gmail.com>
From: Namjae Jeon <namjae.jeon@samsung.com>
Add finsert command for fallocate FALLOC_FL_INSERT_RANGE flag.
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Ashish Sangwan <a.sangwan@samsung.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
---
io/prealloc.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/io/prealloc.c b/io/prealloc.c
index aba6b44..4ab3d8c 100644
--- a/io/prealloc.c
+++ b/io/prealloc.c
@@ -37,6 +37,10 @@
#define FALLOC_FL_ZERO_RANGE 0x10
#endif
+#ifndef FALLOC_FL_INSERT_RANGE
+#define FALLOC_FL_INSERT_RANGE 0x20
+#endif
+
static cmdinfo_t allocsp_cmd;
static cmdinfo_t freesp_cmd;
static cmdinfo_t resvsp_cmd;
@@ -46,6 +50,7 @@ static cmdinfo_t zero_cmd;
static cmdinfo_t falloc_cmd;
static cmdinfo_t fpunch_cmd;
static cmdinfo_t fcollapse_cmd;
+static cmdinfo_t finsert_cmd;
static cmdinfo_t fzero_cmd;
#endif
@@ -169,11 +174,14 @@ fallocate_f(
int mode = 0;
int c;
- while ((c = getopt(argc, argv, "ckp")) != EOF) {
+ while ((c = getopt(argc, argv, "cikp")) != EOF) {
switch (c) {
case 'c':
mode = FALLOC_FL_COLLAPSE_RANGE;
break;
+ case 'i':
+ mode = FALLOC_FL_INSERT_RANGE;
+ break;
case 'k':
mode = FALLOC_FL_KEEP_SIZE;
break;
@@ -237,6 +245,25 @@ fcollapse_f(
}
static int
+finsert_f(
+ int argc,
+ char **argv)
+{
+ xfs_flock64_t segment;
+ int mode = FALLOC_FL_INSERT_RANGE;
+
+ if (!offset_length(argv[1], argv[2], &segment))
+ return 0;
+
+ if (fallocate(file->fd, mode,
+ segment.l_start, segment.l_len)) {
+ perror("fallocate");
+ return 0;
+ }
+ return 0;
+}
+
+static int
fzero_f(
int argc,
char **argv)
@@ -345,6 +372,16 @@ prealloc_init(void)
_("de-allocates space and eliminates the hole by shifting extents");
add_command(&fcollapse_cmd);
+ finsert_cmd.name = "finsert";
+ finsert_cmd.cfunc = finsert_f;
+ finsert_cmd.argmin = 2;
+ finsert_cmd.argmax = 2;
+ finsert_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK;
+ finsert_cmd.args = _("off len");
+ finsert_cmd.oneline =
+ _("creates new space for writing within file by shifting extents");
+ add_command(&finsert_cmd);
+
fzero_cmd.name = "fzero";
fzero_cmd.cfunc = fzero_f;
fzero_cmd.argmin = 2;
--
1.7.9.5
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2015-01-13 16:05 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-13 16:05 [PATCH v8 0/11] fs: Introduce FALLOC_FL_INSERT_RANGE for fallocate Namjae Jeon
2015-01-13 16:05 ` [PATCH v8 1/11] fs: Add support " Namjae Jeon
2015-01-13 16:05 ` [PATCH v8 2/11] xfs: " Namjae Jeon
2015-01-15 12:29 ` Brian Foster
2015-01-16 7:26 ` Namjae Jeon
2015-01-13 16:05 ` [PATCH v8 3/11] ext4: " Namjae Jeon
2015-01-13 16:05 ` Namjae Jeon [this message]
2015-01-13 16:05 ` [PATCH v8 5/11] xfstests: generic/039: Standard insert range tests Namjae Jeon
2015-01-13 16:05 ` [PATCH v8 6/11] xfstests: generic/040: Delayed allocation insert range Namjae Jeon
2015-01-13 16:05 ` [PATCH v8 7/11] xfstests: generic/041: Multi insert range tests Namjae Jeon
2015-01-13 16:05 ` [PATCH v8 8/11] xfstests: generic/042: Delayed allocation multi insert Namjae Jeon
2015-01-13 16:05 ` [PATCH v8 9/11] xfstests: generic/043: Test multiple fallocate insert/collapse range calls Namjae Jeon
2015-01-14 20:17 ` Brian Foster
2015-01-15 10:14 ` Namjae Jeon
2015-01-15 12:28 ` Brian Foster
2015-01-16 7:30 ` Namjae Jeon
2015-01-13 16:05 ` [PATCH v8 10/11] xfstests: fsstress: Add fallocate insert range operation Namjae Jeon
2015-01-13 16:05 ` [PATCH v8 11/11] xfstests: fsx: " Namjae Jeon
2015-01-14 20:16 ` Brian Foster
2015-01-15 10:14 ` Namjae Jeon
2015-01-15 12:28 ` Brian Foster
2015-01-16 7:27 ` Namjae Jeon
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=1421165126-3585-5-git-send-email-linkinjeon@gmail.com \
--to=linkinjeon@gmail.com \
--cc=a.sangwan@samsung.com \
--cc=bfoster@redhat.com \
--cc=david@fromorbit.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=namjae.jeon@samsung.com \
--cc=tytso@mit.edu \
--cc=xfs@oss.sgi.com \
/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;
as well as URLs for NNTP newsgroup(s).