From patchwork Tue Feb 17 09:22:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namjae Jeon X-Patchwork-Id: 5838151 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B1D68BF440 for ; Tue, 17 Feb 2015 09:23:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ADDBB2011D for ; Tue, 17 Feb 2015 09:23:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8C94920114 for ; Tue, 17 Feb 2015 09:23:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933465AbbBQJWp (ORCPT ); Tue, 17 Feb 2015 04:22:45 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:20413 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756391AbbBQJWN (ORCPT ); Tue, 17 Feb 2015 04:22:13 -0500 Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NJW00KFDSOZU150@mailout1.samsung.com>; Tue, 17 Feb 2015 18:22:11 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.116]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id 6B.09.17016.34803E45; Tue, 17 Feb 2015 18:22:11 +0900 (KST) X-AuditID: cbfee68d-f79296d000004278-32-54e308433aab Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id B8.7E.20081.34803E45; Tue, 17 Feb 2015 18:22:11 +0900 (KST) Received: from DONAMJAEJEO06 ([10.88.104.63]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NJW002LWSOXL530@mmp1.samsung.com>; Tue, 17 Feb 2015 18:22:11 +0900 (KST) From: Namjae Jeon To: Dave Chinner Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, xfs@oss.sgi.com, Ashish Sangwan , Brian Foster Subject: [PATCH v10 11/12] xfstests: fsx: Add fallocate insert range operation Date: Tue, 17 Feb 2015 18:22:11 +0900 Message-id: <003a01d04a93$357f0870$a07d1950$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: AdBKkA0edhO+hCH6RuyZx82pRdf8cg== Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBIsWRmVeSWpSXmKPExsWyRsSkRNeZ43GIwfVDMhZLJ15itnj3ucpi y7F7jBZ79p5ksbi8aw6bxaK+W4wObB6nFkl4rL6wldHj/b6rbB59W1YxenzeJBfAGsVlk5Ka k1mWWqRvl8CVcW37SuaCrfoVu66cZm1g3KnSxcjJISFgIvFtYiszhC0mceHeerYuRi4OIYGl jBILr7xhhSm6vGcxE0RiEaPEsbmNjBDOX0aJKytOArVzcLAJaEv82SIK0iAioCYxadIOZpAa ZoH5jBITul+xgySEBfwkFmxvZgKxWQRUJSa/3MwIYvMKWEq8/f+EGcIWlPgx+R4LiM0soCWx fudxJghbXmLzmrdQpypI7Dj7mhFimZ5ET38HM0SNiMS+F+8YIWpOsUssuFkJsUtA4tvkQywg d0oIyEpsOgA1RlLi4IobLBMYxWYh2TwLyeZZSDbPQrJhASPLKkbR1ILkguKk9CJDveLE3OLS vHS95PzcTYzACDz971nvDsbbB6wPMQpwMCrx8E6Y9ChEiDWxrLgy9xCjKdBFE5mlRJPzgXGe VxJv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fp2PqVn302t8GywC8snunhPfa1ezNkVfI5Dh22Zuj1fnxHUb+VP0D6eJXcy0WR WnVSBjNTnP9ezgjLWKXEUpyRaKjFXFScCACuFLKeBgMAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This commit adds fallocate FALLOC_FL_INSERT_RANGE support for fsx. Signed-off-by: Namjae Jeon Signed-off-by: Ashish Sangwan Reviewed-by: Brian Foster --- ltp/fsx.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 114 insertions(+), 10 deletions(-) diff --git a/ltp/fsx.c b/ltp/fsx.c index 3709419..9fed5b2 100644 --- a/ltp/fsx.c +++ b/ltp/fsx.c @@ -95,7 +95,8 @@ int logcount = 0; /* total ops */ #define OP_PUNCH_HOLE 6 #define OP_ZERO_RANGE 7 #define OP_COLLAPSE_RANGE 8 -#define OP_MAX_FULL 9 +#define OP_INSERT_RANGE 9 +#define OP_MAX_FULL 10 /* operation modifiers */ #define OP_CLOSEOPEN 100 @@ -145,6 +146,7 @@ int fallocate_calls = 1; /* -F flag disables */ int punch_hole_calls = 1; /* -H flag disables */ int zero_range_calls = 1; /* -z flag disables */ int collapse_range_calls = 1; /* -C flag disables */ +int insert_range_calls = 1; /* -I flag disables */ int mapped_reads = 1; /* -R flag disables it */ int fsxgoodfd = 0; int o_direct; /* -Z */ @@ -339,6 +341,14 @@ logdump(void) lp->args[0] + lp->args[1]) prt("\t******CCCC"); break; + case OP_INSERT_RANGE: + prt("INSERT 0x%x thru 0x%x\t(0x%x bytes)", + lp->args[0], lp->args[0] + lp->args[1] - 1, + lp->args[1]); + if (badoff >= lp->args[0] && badoff < + lp->args[0] + lp->args[1]) + prt("\t******IIII"); + break; case OP_SKIPPED: prt("SKIPPED (no operation)"); break; @@ -1012,6 +1022,59 @@ do_collapse_range(unsigned offset, unsigned length) } #endif +#ifdef FALLOC_FL_INSERT_RANGE +void +do_insert_range(unsigned offset, unsigned length) +{ + unsigned end_offset; + int mode = FALLOC_FL_INSERT_RANGE; + + if (length == 0) { + if (!quiet && testcalls > simulatedopcount) + prt("skipping zero length insert range\n"); + log4(OP_SKIPPED, OP_INSERT_RANGE, offset, length); + return; + } + + if ((loff_t)offset >= file_size) { + if (!quiet && testcalls > simulatedopcount) + prt("skipping insert range behind EOF\n"); + log4(OP_SKIPPED, OP_INSERT_RANGE, offset, length); + return; + } + + log4(OP_INSERT_RANGE, offset, length, 0); + + if (testcalls <= simulatedopcount) + return; + + end_offset = offset + length; + if ((progressinterval && testcalls % progressinterval == 0) || + (debug && (monitorstart == -1 || monitorend == -1 || + end_offset <= monitorend))) { + prt("%lu insert\tfrom 0x%x to 0x%x, (0x%x bytes)\n", testcalls, + offset, offset+length, length); + } + if (fallocate(fd, mode, (loff_t)offset, (loff_t)length) == -1) { + prt("insert range: %x to %x\n", offset, length); + prterr("do_insert_range: fallocate"); + report_failure(161); + } + + memmove(good_buf + end_offset, good_buf + offset, + file_size - offset); + memset(good_buf + offset, '\0', length); + file_size += length; +} + +#else +void +do_insert_range(unsigned offset, unsigned length) +{ + return; +} +#endif + #ifdef HAVE_LINUX_FALLOC_H /* fallocate is basically a no-op unless extending, then a lot like a truncate */ void @@ -1117,14 +1180,25 @@ docloseopen(void) } } -#define TRIM_OFF_LEN(off, len, size) \ -do { \ - if (size) \ - (off) %= (size); \ - else \ - (off) = 0; \ - if ((off) + (len) > (size)) \ - (len) = (size) - (off); \ + +#define TRIM_OFF(off, size) \ +do { \ + if (size) \ + (off) %= (size); \ + else \ + (off) = 0; \ +} while (0) + +#define TRIM_LEN(off, len, size) \ +do { \ + if ((off) + (len) > (size)) \ + (len) = (size) - (off); \ +} while (0) + +#define TRIM_OFF_LEN(off, len, size) \ +do { \ + TRIM_OFF(off, size); \ + TRIM_LEN(off, len, size); \ } while (0) void @@ -1192,6 +1266,12 @@ test(void) goto out; } break; + case OP_INSERT_RANGE: + if (!insert_range_calls) { + log4(OP_SKIPPED, OP_INSERT_RANGE, offset, size); + goto out; + } + break; } switch (op) { @@ -1244,6 +1324,22 @@ test(void) } do_collapse_range(offset, size); break; + case OP_INSERT_RANGE: + TRIM_OFF(offset, file_size); + TRIM_LEN(file_size, size, maxfilelen); + offset = offset & ~(block_size - 1); + size = size & ~(block_size - 1); + if (size == 0) { + log4(OP_SKIPPED, OP_INSERT_RANGE, offset, size); + goto out; + } + if (file_size + size > maxfilelen) { + log4(OP_SKIPPED, OP_INSERT_RANGE, offset, size); + goto out; + } + + do_insert_range(offset, size); + break; default: prterr("test: unknown operation"); report_failure(42); @@ -1307,6 +1403,9 @@ usage(void) #ifdef FALLOC_FL_COLLAPSE_RANGE " -C: Do not use collapse range calls\n" #endif +#ifdef FALLOC_FL_INSERT_RANGE +" -I: Do not use insert range calls\n" +#endif " -L: fsxLite - no file creations & no file size changes\n\ -N numops: total # operations to do (default infinity)\n\ -O: use oplen (see -o flag) for every op (default random)\n\ @@ -1493,7 +1592,7 @@ main(int argc, char **argv) setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */ - while ((ch = getopt(argc, argv, "b:c:dfl:m:no:p:qr:s:t:w:xyAD:FHzCLN:OP:RS:WZ")) + while ((ch = getopt(argc, argv, "b:c:dfl:m:no:p:qr:s:t:w:xyAD:FHzCILN:OP:RS:WZ")) != EOF) switch (ch) { case 'b': @@ -1599,6 +1698,9 @@ main(int argc, char **argv) case 'C': collapse_range_calls = 0; break; + case 'I': + insert_range_calls = 0; + break; case 'L': lite = 1; break; @@ -1758,6 +1860,8 @@ main(int argc, char **argv) zero_range_calls = test_fallocate(FALLOC_FL_ZERO_RANGE); if (collapse_range_calls) collapse_range_calls = test_fallocate(FALLOC_FL_COLLAPSE_RANGE); + if (insert_range_calls) + insert_range_calls = test_fallocate(FALLOC_FL_INSERT_RANGE); while (numops == -1 || numops--) test();