diff mbox

[v9,4/11] xfsprogs: xfs_io: add finsert command for insert range

Message ID 1421853126-4505-5-git-send-email-linkinjeon@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Namjae Jeon Jan. 21, 2015, 3:11 p.m. UTC
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(-)

Comments

Dave Chinner Feb. 5, 2015, 11:40 p.m. UTC | #1
On Thu, Jan 22, 2015 at 12:11:59AM +0900, Namjae Jeon wrote:
> 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>

I've just pulled this patch into xfsprogs in preparation for getting
this functionality fully reviewed and merged in the 3.21 kernel
cycle.

Cheers,

Dave.
Dave Chinner Feb. 6, 2015, 3:11 a.m. UTC | #2
Hi Namjae,

On Fri, Feb 06, 2015 at 10:40:33AM +1100, Dave Chinner wrote:
> On Thu, Jan 22, 2015 at 12:11:59AM +0900, Namjae Jeon wrote:
> > 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>
> 
> I've just pulled this patch into xfsprogs in preparation for getting
> this functionality fully reviewed and merged in the 3.21 kernel
> cycle.

xfs/293 3s ... - output mismatch (see /home/dave/src/xfstests-dev/results//xfs/293.out.bad)
    --- tests/xfs/293.out       2014-01-20 16:57:34.000000000 +1100
    +++ /home/dave/src/xfstests-dev/results//xfs/293.out.bad    2015-02-06 12:21:47.000000000 +1100
    @@ -1,2 +1,3 @@
     QA output created by 293
     Silence is golden
    +finsert not documented in the xfs_io manpage
    .....

Can you send a patch that updates the xfs_io man page, please?

Cheers,

Dave.
Namjae Jeon Feb. 6, 2015, 4:27 a.m. UTC | #3
> Hi Namjae,
Hi Dave,
> 
> On Fri, Feb 06, 2015 at 10:40:33AM +1100, Dave Chinner wrote:
> > On Thu, Jan 22, 2015 at 12:11:59AM +0900, Namjae Jeon wrote:
> > > 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>
> >
> > I've just pulled this patch into xfsprogs in preparation for getting
> > this functionality fully reviewed and merged in the 3.21 kernel
> > cycle.
> 
> xfs/293 3s ... - output mismatch (see /home/dave/src/xfstests-dev/results//xfs/293.out.bad)
>     --- tests/xfs/293.out       2014-01-20 16:57:34.000000000 +1100
>     +++ /home/dave/src/xfstests-dev/results//xfs/293.out.bad    2015-02-06 12:21:47.000000000 +1100
>     @@ -1,2 +1,3 @@
>      QA output created by 293
>      Silence is golden
>     +finsert not documented in the xfs_io manpage
>     .....
> 
> Can you send a patch that updates the xfs_io man page, please?
Okay, I will send it soon.
Thanks a lot!
> 
> Cheers,
> 
> Dave.
> --
> Dave Chinner
> david@fromorbit.com

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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;