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 05A857FA1 for ; Fri, 8 Aug 2014 00:06:31 -0500 (CDT) Received: from cuda.sgi.com (cuda1.sgi.com [192.48.157.11]) by relay3.corp.sgi.com (Postfix) with ESMTP id 96D9CAC003 for ; Thu, 7 Aug 2014 22:06:30 -0700 (PDT) Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by cuda.sgi.com with ESMTP id agvmHo2VvtzReCsn (version=TLSv1 cipher=RC4-MD5 bits=128 verify=NO) for ; Thu, 07 Aug 2014 22:06:29 -0700 (PDT) Received: from epcpsbgr5.samsung.com (u145.gpu120.samsung.co.kr [203.254.230.145]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N9Z000TB26QUKB0@mailout1.samsung.com> for xfs@oss.sgi.com; Fri, 08 Aug 2014 14:06:26 +0900 (KST) From: Namjae Jeon Subject: [PATCH v5 4/10] xfsprogs: xfs_io: add finsert command for insert range via fallocate Date: Fri, 08 Aug 2014 14:06:26 +0900 Message-id: <004501cfb2c6$81801f80$84805e80$@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: Brian Foster , linux-kernel@vger.kernel.org, xfs@oss.sgi.com, linux-fsdevel@vger.kernel.org, =?iso-8859-2?Q?Luk=E1=B9_Czerner?= , linux-ext4 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 = + _("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.11-rc0 _______________________________________________ xfs mailing list xfs@oss.sgi.com http://oss.sgi.com/mailman/listinfo/xfs