From patchwork Tue Mar 18 07:26:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 14020401 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C6601F0985 for ; Tue, 18 Mar 2025 07:34:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742283290; cv=none; b=b8nOD6eptntkJBco1Nk9ru04+K7cc8eA4qX6N5sQyjHwuExc0ARV9Umtrnd99je93yjYx1f7E+ZcdSPC9Wsgqu/D6MxKQpYXyTeDZRGPKNpptvOk9XLVGhuim/eQJYEd1m0arolxIGk3jfzR0JJxcmtkbpygtbVgxGylJDitwIo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742283290; c=relaxed/simple; bh=6g3bhbPGPsuTRVT8vq4jGUeLPW16Uvdsrbmr2YsZQSU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bbD+kSdAZ1WmghAuGT0I6KXmtjidzPAmZiLIn7MYDjPzMVWZpvwf2AxSkRqTODljDabPDrZcaMxVxMCw39bmu75CYKi3+oBnufwllOfmMglT6CAMZQRcmr24I7wWy0MNWgvYE2F0g73bwJ/GRlnTWy1Hyg3o2b/xVYRCilWSSpk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4ZH3WS6n2qz4f3jkr for ; Tue, 18 Mar 2025 15:34:28 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 37DC91A058E for ; Tue, 18 Mar 2025 15:34:46 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.112.188]) by APP4 (Coremail) with SMTP id gCh0CgCnCl8EItlnJDdYGw--.56140S8; Tue, 18 Mar 2025 15:34:46 +0800 (CST) From: Zhang Yi To: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@lists.linux.dev, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org Cc: linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, hch@lst.de, tytso@mit.edu, djwong@kernel.org, john.g.garry@oracle.com, bmarzins@redhat.com, chaitanyak@nvidia.com, shinichiro.kawasaki@wdc.com, yi.zhang@huawei.com, yi.zhang@huaweicloud.com, chengzhihao1@huawei.com, yukuai3@huawei.com, yangerkun@huawei.com Subject: [PATCH xfstests 4/5] fstress: add fallocate write zeroes support Date: Tue, 18 Mar 2025 15:26:14 +0800 Message-ID: <20250318072615.3505873-5-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20250318072615.3505873-1-yi.zhang@huaweicloud.com> References: <20250318072615.3505873-1-yi.zhang@huaweicloud.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgCnCl8EItlnJDdYGw--.56140S8 X-Coremail-Antispam: 1UD129KBjvJXoW7uFWDAr45Kw4UXFWDurWUXFb_yoW8uFy3pa yDtFW8Cay8Wa4ayr18urs5WFn0qrsYqr15C397Kr1IvayYyr9Igrn0g3s5Gw1DXFWDtay5 ZF90gFyq93WUA37anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmS14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCY1x0262kKe7AKxVW8ZVWrXwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkE bVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67 AF67kF1VAFwI0_GFv_WrylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI 42IY6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF 4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBI daVFxhVjvjDU0xZFpf9x0pRJ3kZUUUUU= X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ From: Zhang Yi Add fstress to suppoet fallocate FALLOC_FL_WRITE_ZEROES command by introducing OP_WZERO operation. Signed-off-by: Zhang Yi --- ltp/fsstress.c | 12 ++++++++++++ src/global.h | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/ltp/fsstress.c b/ltp/fsstress.c index 3d248ee2..ed2a54ab 100644 --- a/ltp/fsstress.c +++ b/ltp/fsstress.c @@ -114,6 +114,7 @@ typedef enum { OP_MWRITE, OP_PUNCH, OP_ZERO, + OP_WZERO, OP_COLLAPSE, OP_INSERT, OP_READ, @@ -245,6 +246,7 @@ void mread_f(opnum_t, long); void mwrite_f(opnum_t, long); void punch_f(opnum_t, long); void zero_f(opnum_t, long); +void wzero_f(opnum_t, long); void collapse_f(opnum_t, long); void insert_f(opnum_t, long); void unshare_f(opnum_t, long); @@ -312,6 +314,7 @@ struct opdesc ops[OP_LAST] = { [OP_MWRITE] = {"mwrite", mwrite_f, 2, 1 }, [OP_PUNCH] = {"punch", punch_f, 1, 1 }, [OP_ZERO] = {"zero", zero_f, 1, 1 }, + [OP_WZERO] = {"wzero", wzero_f, 1, 1 }, [OP_COLLAPSE] = {"collapse", collapse_f, 1, 1 }, [OP_INSERT] = {"insert", insert_f, 1, 1 }, [OP_READ] = {"read", read_f, 1, 0 }, @@ -3758,6 +3761,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_WRITE_ZEROES, "WRITE_ZEROES"}, { FALLOC_FL_INSERT_RANGE, "INSERT_RANGE"}, { FALLOC_FL_UNSHARE_RANGE, "UNSHARE_RANGE"}, { -1, NULL} @@ -4446,6 +4450,14 @@ zero_f(opnum_t opno, long r) #endif } +void +wzero_f(opnum_t opno, long r) +{ +#ifdef HAVE_LINUX_FALLOC_H + do_fallocate(opno, r, FALLOC_FL_WRITE_ZEROES); +#endif +} + void collapse_f(opnum_t opno, long r) { diff --git a/src/global.h b/src/global.h index fbc0a0b5..6b1e30c9 100644 --- a/src/global.h +++ b/src/global.h @@ -175,6 +175,10 @@ #define FALLOC_FL_ZERO_RANGE 0x10 #endif +#ifndef FALLOC_FL_WRITE_ZEROES +#define FALLOC_FL_WRITE_ZEROES 0x80 +#endif + #ifndef FALLOC_FL_INSERT_RANGE #define FALLOC_FL_INSERT_RANGE 0x20 #endif