xfs
[Top] [All Lists]

[PATCH 2/3] xfs_io: add -p for hole punching to falloc command

To: xfs@xxxxxxxxxxx
Subject: [PATCH 2/3] xfs_io: add -p for hole punching to falloc command
From: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Date: Fri, 04 Mar 2011 19:22:24 -0500
Cc: josef@xxxxxxxxxx
References: <20110305002222.395571492@xxxxxxxxxxxxxxxxxxxxxx>
User-agent: quilt/0.48-1
Signed-off-by: Josef Bacik <josef@xxxxxxxxxx>
Signed-off-by: Christoph Hellwig <hch@xxxxxx>

---
 io/prealloc.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

Index: xfsprogs-dev/io/prealloc.c
===================================================================
--- xfsprogs-dev.orig/io/prealloc.c     2010-09-11 19:49:44.000000000 +0000
+++ xfsprogs-dev/io/prealloc.c  2011-03-05 00:07:16.000000000 +0000
@@ -25,6 +25,10 @@
 #include "init.h"
 #include "io.h"
 
+#ifndef FALLOC_FL_PUNCH_HOLE
+#define FALLOC_FL_PUNCH_HOLE   0x02
+#endif
+
 static cmdinfo_t allocsp_cmd;
 static cmdinfo_t freesp_cmd;
 static cmdinfo_t resvsp_cmd;
@@ -154,11 +158,14 @@ fallocate_f(
        int             mode = 0;
        int             c;
 
-       while ((c = getopt(argc, argv, "k")) != EOF) {
+       while ((c = getopt(argc, argv, "kp")) != EOF) {
                switch (c) {
                case 'k':
                        mode = FALLOC_FL_KEEP_SIZE;
                        break;
+               case 'p':
+                       mode = FALLOC_FL_PUNCH_HOLE;
+                       break;
                default:
                        command_usage(&falloc_cmd);
                }
@@ -236,7 +243,7 @@ prealloc_init(void)
        falloc_cmd.argmin = 2;
        falloc_cmd.argmax = -1;
        falloc_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK;
-       falloc_cmd.args = _("[-k] off len");
+       falloc_cmd.args = _("[-k] [-p] off len");
        falloc_cmd.oneline =
                _("allocates space associated with part of a file via 
fallocate");
 

<Prev in Thread] Current Thread [Next in Thread>