From patchwork Fri Apr 24 09:33:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingbo Xu X-Patchwork-Id: 1276305 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.alibaba.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 497psM0pNfz9sSM for ; Fri, 24 Apr 2020 19:34:14 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726798AbgDXJeO (ORCPT ); Fri, 24 Apr 2020 05:34:14 -0400 Received: from out30-131.freemail.mail.aliyun.com ([115.124.30.131]:33698 "EHLO out30-131.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726628AbgDXJeJ (ORCPT ); Fri, 24 Apr 2020 05:34:09 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07425;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0TwVx7HD_1587720845; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0TwVx7HD_1587720845) by smtp.aliyun-inc.com(127.0.0.1); Fri, 24 Apr 2020 17:34:05 +0800 From: Jeffle Xu To: fstests@vger.kernel.org Cc: linux-ext4@vger.kernel.org, joseph.qi@linux.alibaba.com, Jeffle Xu Subject: [PATCH RFC 1/2] xfstests: fsx: add support for cluster size Date: Fri, 24 Apr 2020 17:33:49 +0800 Message-Id: <1587720830-11955-2-git-send-email-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1587720830-11955-1-git-send-email-jefflexu@linux.alibaba.com> References: <1587720830-11955-1-git-send-email-jefflexu@linux.alibaba.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org The offset and size should be aligned with cluster size when inserting or collapsing range on ext4 with 'bigalloc' feature enabled. Currently I can find only ext4 with this limitation. Since fsx should have no assumption of the underlying filesystem, and thus add the '-u cluster_size' option. Tests can set this option when the underlying filesystem is ext4 with bigalloc enabled. Signed-off-by: Jeffle Xu --- ltp/fsx.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ltp/fsx.c b/ltp/fsx.c index 9d598a4..5fe5738 100644 --- a/ltp/fsx.c +++ b/ltp/fsx.c @@ -133,6 +133,7 @@ int dirpath = 0; /* -P flag */ int fd; /* fd for our test file */ blksize_t block_size = 0; +blksize_t cluster_size = 0; off_t file_size = 0; off_t biggest = 0; long long testcalls = 0; /* calls to function "test" */ @@ -2146,8 +2147,8 @@ have_op: break; case OP_COLLAPSE_RANGE: TRIM_OFF_LEN(offset, size, file_size - 1); - offset = offset & ~(block_size - 1); - size = size & ~(block_size - 1); + offset = offset & ~(cluster_size - 1); + size = size & ~(cluster_size - 1); if (size == 0) { log4(OP_COLLAPSE_RANGE, offset, size, FL_SKIPPED); goto out; @@ -2157,8 +2158,8 @@ have_op: 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); + offset = offset & ~(cluster_size - 1); + size = size & ~(cluster_size - 1); if (size == 0) { log4(OP_INSERT_RANGE, offset, size, FL_SKIPPED); goto out; @@ -2231,7 +2232,7 @@ void usage(void) { fprintf(stdout, "usage: %s", - "fsx [-dknqxABEFJLOWZ] [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\ + "fsx [-dknqxABEFJLOWZ] [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-u csize] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\ -b opnum: beginning operation number (default 1)\n\ -c P: 1 in P chance of file close+open at each op (default infinity)\n\ -d: debug output for all operations\n\ @@ -2249,6 +2250,7 @@ usage(void) -r readbdy: 4096 would make reads page aligned (default 1)\n\ -s style: 1 gives smaller truncates (default 0)\n\ -t truncbdy: 4096 would make truncates page aligned (default 1)\n\ + -u csize: filesystem specific cluster size that may be used for ops like insert/collapse range\n\ -w writebdy: 4096 would make writes page aligned (default 1)\n\ -x: preallocate file space before starting, XFS only (default 0)\n\ -y synchronize changes to a file\n" @@ -2485,7 +2487,7 @@ main(int argc, char **argv) setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */ while ((ch = getopt_long(argc, argv, - "b:c:dfg:i:j:kl:m:no:p:qr:s:t:w:xyABD:EFJKHzCILN:OP:RS:WXZ", + "b:c:dfg:i:j:kl:m:no:p:qr:s:t:u:w:xyABD:EFJKHzCILN:OP:RS:WXZ", longopts, NULL)) != EOF) switch (ch) { case 'b': @@ -2579,6 +2581,11 @@ main(int argc, char **argv) if (truncbdy <= 0) usage(); break; + case 'u': + cluster_size = getnum(optarg, &endp); + if (cluster_size <= 0) + usage(); + break; case 'w': writebdy = getnum(optarg, &endp); if (writebdy <= 0) @@ -2720,6 +2727,7 @@ main(int argc, char **argv) exit(91); } block_size = statbuf.st_blksize; + cluster_size = cluster_size ? : block_size; #ifdef XFS if (prealloc) { xfs_flock64_t resv = { 0 }; From patchwork Fri Apr 24 09:33:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingbo Xu X-Patchwork-Id: 1276304 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.alibaba.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 497psK5DjZz9sSM for ; Fri, 24 Apr 2020 19:34:13 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726857AbgDXJeN (ORCPT ); Fri, 24 Apr 2020 05:34:13 -0400 Received: from out30-45.freemail.mail.aliyun.com ([115.124.30.45]:58022 "EHLO out30-45.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726770AbgDXJeK (ORCPT ); Fri, 24 Apr 2020 05:34:10 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R361e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01355;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0TwVfl8I_1587720847; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0TwVfl8I_1587720847) by smtp.aliyun-inc.com(127.0.0.1); Fri, 24 Apr 2020 17:34:07 +0800 From: Jeffle Xu To: fstests@vger.kernel.org Cc: linux-ext4@vger.kernel.org, joseph.qi@linux.alibaba.com, Jeffle Xu Subject: [PATCH RFC 2/2] xfstests: common/rc: add cluster size support for ext4 Date: Fri, 24 Apr 2020 17:33:50 +0800 Message-Id: <1587720830-11955-3-git-send-email-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1587720830-11955-1-git-send-email-jefflexu@linux.alibaba.com> References: <1587720830-11955-1-git-send-email-jefflexu@linux.alibaba.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Inserting and collapsing range on ext4 with 'bigalloc' feature will fail due to the offset and size should be alligned with the cluster size. The previous patch has add support for cluster size in fsx. Detect and pass the cluster size parameter to fsx if the underlying filesystem is ext4 with bigalloc. Signed-off-by: Jeffle Xu --- common/rc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common/rc b/common/rc index 2000bd9..71dde5f 100644 --- a/common/rc +++ b/common/rc @@ -3908,6 +3908,15 @@ run_fsx() { echo fsx $@ local args=`echo $@ | sed -e "s/ BSIZE / $bsize /g" -e "s/ PSIZE / $psize /g"` + + if [ "$FSTYP" == "ext4" ]; then + local cluster_size=$(tune2fs -l $TEST_DEV | grep 'Cluster size' | awk '{print $3}') + if [ -n $cluster_size ]; then + echo "cluster size: $cluster_size" + args="$args -u $cluster_size" + fi + fi + set -- $here/ltp/fsx $args $FSX_AVOID $TEST_DIR/junk echo "$@" >>$seqres.full rm -f $TEST_DIR/junk