From patchwork Sat Feb 21 15:45:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namjae Jeon X-Patchwork-Id: 5859961 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5BD8B9F30C for ; Sat, 21 Feb 2015 15:51:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 759CD20465 for ; Sat, 21 Feb 2015 15:51:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9708A20456 for ; Sat, 21 Feb 2015 15:51:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752632AbbBUPvP (ORCPT ); Sat, 21 Feb 2015 10:51:15 -0500 Received: from mail-pd0-f181.google.com ([209.85.192.181]:41675 "EHLO mail-pd0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752409AbbBUPtm (ORCPT ); Sat, 21 Feb 2015 10:49:42 -0500 Received: by pdno5 with SMTP id o5so14644916pdn.8; Sat, 21 Feb 2015 07:49:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=F/Mz2ptynSNpSFgrVrtc0b6NP86IrGJoDQcmg+2xbEM=; b=a9ZbVBvP7joTi+y3z/YodVABgKgX66qApg13F8kEgnplrk3xRrtqnWSxG69aGikUEs Gsw/cd5JiTrb87KwfLemnMlQzL1rA+KS0WetrwdO2rbBmgiIxd1CkWzrHjsINqPq0Uzk D17Gdi5o6ILea2CXZFfUrgqmQqUp/+Fq1lXx5JdrpOtgabZtZnRfygCbBOtBjo+TXmyT kQXn5X7IaGnvu1bJ89NlzArTMW3hoENudUV7fDqLFg11m08Gt7K9y2DADdwMMkRACyAA pnTpb+AjVnN3XReSEG1AhQ8Qazh6nJTGgdf9jpoDTZ1z2NElQQS22CgBfFmoQCGIiRyM 3uaA== X-Received: by 10.66.163.168 with SMTP id yj8mr5174709pab.132.1424533781366; Sat, 21 Feb 2015 07:49:41 -0800 (PST) Received: from linkinjeon-Aspire-One-522.kornet ([125.129.25.112]) by mx.google.com with ESMTPSA id fc6sm187055pab.6.2015.02.21.07.49.37 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 21 Feb 2015 07:49:40 -0800 (PST) From: Namjae Jeon To: david@fromorbit.com, tytso@mit.edu Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, xfs@oss.sgi.com, a.sangwan@samsung.com, bfoster@redhat.com, mtk.manpages@gmail.com, linux-man@vger.kernel.org, linux-api@vger.kernel.org, Namjae Jeon , Namjae Jeon Subject: [PATCH v10 10/12] xfstests: fsstress: Add fallocate insert range operation Date: Sun, 22 Feb 2015 00:45:52 +0900 Message-Id: <1424533554-28024-11-git-send-email-linkinjeon@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1424533554-28024-1-git-send-email-linkinjeon@gmail.com> References: <1424533554-28024-1-git-send-email-linkinjeon@gmail.com> 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.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 From: Namjae Jeon This commit adds insert operation support for fsstress, which is meant to exercise fallocate FALLOC_FL_INSERT_RANGE support. Signed-off-by: Namjae Jeon Signed-off-by: Ashish Sangwan Reviewed-by: Brian Foster --- ltp/fsstress.c | 19 ++++++++++++++++--- src/global.h | 4 ++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/ltp/fsstress.c b/ltp/fsstress.c index b56fe5c..aa3e0c3 100644 --- a/ltp/fsstress.c +++ b/ltp/fsstress.c @@ -72,6 +72,7 @@ typedef enum { OP_PUNCH, OP_ZERO, OP_COLLAPSE, + OP_INSERT, OP_READ, OP_READLINK, OP_RENAME, @@ -170,6 +171,7 @@ void mknod_f(int, long); void punch_f(int, long); void zero_f(int, long); void collapse_f(int, long); +void insert_f(int, long); void read_f(int, long); void readlink_f(int, long); void rename_f(int, long); @@ -209,6 +211,7 @@ opdesc_t ops[] = { { OP_PUNCH, "punch", punch_f, 1, 1 }, { OP_ZERO, "zero", zero_f, 1, 1 }, { OP_COLLAPSE, "collapse", collapse_f, 1, 1 }, + { OP_INSERT, "insert", insert_f, 1, 1 }, { OP_READ, "read", read_f, 1, 0 }, { OP_READLINK, "readlink", readlink_f, 1, 0 }, { OP_RENAME, "rename", rename_f, 2, 1 }, @@ -2176,6 +2179,7 @@ struct print_flags falloc_flags [] = { { FALLOC_FL_NO_HIDE_STALE, "NO_HIDE_STALE"}, { FALLOC_FL_COLLAPSE_RANGE, "COLLAPSE_RANGE"}, { FALLOC_FL_ZERO_RANGE, "ZERO_RANGE"}, + { FALLOC_FL_INSERT_RANGE, "INSERT_RANGE"}, { -1, NULL} }; @@ -2227,10 +2231,11 @@ do_fallocate(int opno, long r, int mode) off %= maxfsize; len = (off64_t)(random() % (1024 * 1024)); /* - * Collapse range requires off and len to be block aligned, make it - * more likely to be the case. + * Collapse/insert range requires off and len to be block aligned, + * make it more likely to be the case. */ - if ((mode & FALLOC_FL_COLLAPSE_RANGE) && (opno % 2)) { + if ((mode & (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE)) && + (opno % 2)) { off = ((off + stb.st_blksize - 1) & ~(stb.st_blksize - 1)); len = ((len + stb.st_blksize - 1) & ~(stb.st_blksize - 1)); } @@ -2656,6 +2661,14 @@ collapse_f(int opno, long r) } void +insert_f(int opno, long r) +{ +#ifdef HAVE_LINUX_FALLOC_H + do_fallocate(opno, r, FALLOC_FL_INSERT_RANGE); +#endif +} + +void read_f(int opno, long r) { char *buf; diff --git a/src/global.h b/src/global.h index 8180f66..f63246b 100644 --- a/src/global.h +++ b/src/global.h @@ -172,6 +172,10 @@ #define FALLOC_FL_ZERO_RANGE 0x10 #endif +#ifndef FALLOC_FL_INSERT_RANGE +#define FALLOC_FL_INSERT_RANGE 0x20 +#endif + #endif /* HAVE_LINUX_FALLOC_H */ #endif /* GLOBAL_H */