From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from relay.sgi.com (relay3.corp.sgi.com [198.149.34.15]) by oss.sgi.com (Postfix) with ESMTP id 4F49C7F53 for ; Thu, 8 May 2014 05:30:55 -0500 (CDT) Received: from cuda.sgi.com (cuda3.sgi.com [192.48.176.15]) by relay3.corp.sgi.com (Postfix) with ESMTP id D688EAC006 for ; Thu, 8 May 2014 03:30:51 -0700 (PDT) Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by cuda.sgi.com with ESMTP id tPcSpPBxNqAPgGta (version=TLSv1 cipher=RC4-MD5 bits=128 verify=NO) for ; Thu, 08 May 2014 03:30:50 -0700 (PDT) Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N5900HY53VBBS70@mailout4.samsung.com> for xfs@oss.sgi.com; Thu, 08 May 2014 19:30:47 +0900 (KST) From: Namjae Jeon Subject: [PATCH v2 4/10] xfsprogs: xfs_io: add finsert command for insert range via fallocate Date: Thu, 08 May 2014 19:30:47 +0900 Message-id: <003a01cf6aa8$933f6890$b9be39b0$@samsung.com> MIME-version: 1.0 Content-language: ko List-Id: XFS Filesystem from SGI List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: xfs-bounces@oss.sgi.com Sender: xfs-bounces@oss.sgi.com To: 'Dave Chinner' , 'Theodore Ts'o' Cc: linux-fsdevel@vger.kernel.org, 'linux-ext4' , linux-kernel@vger.kernel.org, 'Ashish Sangwan' , xfs@oss.sgi.com Add finsert command for fallocate FALLOC_FL_INSERT_RANGE flag. Signed-off-by: Namjae Jeon Signed-off-by: Ashish Sangwan --- io/prealloc.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/io/prealloc.c b/io/prealloc.c index aba6b44..11b1e12 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 = + _("allocates zeroes space after creating the hole by shifting extents"); + add_command(&finsert_cmd); + fzero_cmd.name = "fzero"; fzero_cmd.cfunc = fzero_f; fzero_cmd.argmin = 2; -- 1.7.11-rc0 _______________________________________________ xfs mailing list xfs@oss.sgi.com http://oss.sgi.com/mailman/listinfo/xfs