Received: by 2002:a9a:45c2:0:b029:115:3f2f:b9e1 with SMTP id r2csp836791lko; Mon, 5 Jul 2021 00:00:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvtvaBuYq3U7FFgugCabHZe23wZYZlXISclS0tFhjKz/OyRoPC74NUmdqFeAIvhRHHPioB X-Received: by 2002:a05:6402:290c:: with SMTP id ee12mr14400941edb.161.1625468427657; Mon, 05 Jul 2021 00:00:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625468427; cv=none; d=google.com; s=arc-20160816; b=af9q7irTVTxVQzq7QNrr9vLbc0gFfBADC+boHxkkajGu5sEfOVs7I1kZ7+mTWKkZAT 0GnxXgI5YIRSZhL4WxEPqW8KTus0+NTicc8Chwxpjrr6KiteKTY1qg4DFDBCJzFZ6Q2w 0VDzhJMNcg2LLXd465C4pBb+fBOV26pGOs1mBKdCLbjB3oGJoN0nQyNyKjfW0fhobIc1 Jsh8nR+D5vebNdFkmT++9JdrGDriSjeM/zb/E51pmhhtNY36FVRxbF0RGOLt6Nsph7I1 yIJAmXIqx68TUyLCRxSyavXFapj/pp5iFAV7o3VQtVMaElqd/AqusQAcw5/RBaCMjSEl +PTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:user-agent:date:message-id:subject:from:reply-to:cc:to; bh=ZY7AlrJ6ho2LkP4URVM+nNnKeCzaybI+FzFyWwPohKQ=; b=SZ6bew5ouT2kCRYrtK7x2qqgYJwXuQgFwkko0cY9lHnx8Dgf/jncsTMIff85+DSSkK bZarJcU9FdPQE+8XoHUjC9Ybp28ixLdvjdDnHPtlas6dc9irNlMvoMtknOTj3zJHJchr G7vG2wD6UzJcs2eydNMYik4BBYnoOMs7UMfRRXVQ78lRXljVkI5W4TbvUJ7W1IoBJCQF MLTp1h2ntv9PT77SBiONnjd2Nz4FMTFqP8nNHIMcKrkmagtymbNfPV88bEupPwjINy94 Mwn14b33vt4EHqzyURlpk0lt1Mt7425siwoKb1jHLc2vIyoCHVSur2nVBiQrORzX3c0Y +Tng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c2si10320738ejj.366.2021.07.04.23.59.57; Mon, 05 Jul 2021 00:00:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229884AbhGEHBb (ORCPT + 99 others); Mon, 5 Jul 2021 03:01:31 -0400 Received: from out30-44.freemail.mail.aliyun.com ([115.124.30.44]:46312 "EHLO out30-44.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229823AbhGEHBb (ORCPT ); Mon, 5 Jul 2021 03:01:31 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0Uejs0rR_1625468331; Received: from admindeMacBook-Pro-2.local(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0Uejs0rR_1625468331) by smtp.aliyun-inc.com(127.0.0.1); Mon, 05 Jul 2021 14:58:52 +0800 To: "Darrick J. Wong" Cc: fstests@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org Reply-To: 20200427173354.GM6740@magnolia From: JeffleXu Subject: Re: [RFC,2/2] xfstests: common/rc: add cluster size support for ext4 Message-ID: <0939cdf0-895c-7287-569a-2a9b4269b1ca@linux.alibaba.com> Date: Mon, 5 Jul 2021 14:58:51 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Sorry for digging this really old post [1]. The overall background is that, @offset and @len need to be aligned with cluster size when doing fallocate(), or several xfstests cases calling fsx will fail if the tested filesystem enabling 'bigalloc' feature. On April 27, 2020, 5:33 p.m. UTC Darrick J. Wong wrote: > On Fri, Apr 24, 2020 at 05:33:50PM +0800, Jeffle Xu wrote: >> 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 > > Computing the file allocation block size ought to be a separate helper. > > I wonder if there's a standard way to report cluster sizes, seeing as > fat, ext4, ocfs2, and xfs can all have minimum space allocation units > that are larger than the base fs block size. In fact only for insert_range and collapse range of ext4 and xfs (in realtime mode), @offset and @len need to be aligned with cluster size. Though fat and ocfs2 also support cluster size, ocfs2 only supports preallocate and punch_hole, and fat only supports preallocate, in which case @offset and @len needn't be aligned with cluster size. So we need to align @offset and @len with cluster size only for ext4 and xfs (in realtime mode) at a minimum cost, to fix this issue. But the question is, there's no standard programming interface exporting cluster size. For both ext4 and xfs, it's stored as a binary data in disk version superblock, e.g., tune2fs could detect the cluster size of ext4. Any idea on how to query the cluster size? [1] https://patchwork.kernel.org/project/fstests/cover/1587720830-11955-1-git-send-email-jefflexu@linux.alibaba.com/ -- Thanks, Jeffle