lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250318072615.3505873-4-yi.zhang@huaweicloud.com>
Date: Tue, 18 Mar 2025 15:26:13 +0800
From: Zhang Yi <yi.zhang@...weicloud.com>
To: linux-fsdevel@...r.kernel.org,
	linux-ext4@...r.kernel.org,
	linux-block@...r.kernel.org,
	dm-devel@...ts.linux.dev,
	linux-nvme@...ts.infradead.org,
	linux-scsi@...r.kernel.org
Cc: linux-xfs@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	hch@....de,
	tytso@....edu,
	djwong@...nel.org,
	john.g.garry@...cle.com,
	bmarzins@...hat.com,
	chaitanyak@...dia.com,
	shinichiro.kawasaki@....com,
	yi.zhang@...wei.com,
	yi.zhang@...weicloud.com,
	chengzhihao1@...wei.com,
	yukuai3@...wei.com,
	yangerkun@...wei.com
Subject: [PATCH xfstests 3/5] generic/766: test fallocate write zeroes on block device

From: Zhang Yi <yi.zhang@...wei.com>

Test the fallocate FALLOC_FL_WRITE_ZEROES command on a block device,
including unsupported flags.

Signed-off-by: Zhang Yi <yi.zhang@...wei.com>
---
 tests/generic/766     | 80 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/766.out | 23 +++++++++++++
 2 files changed, 103 insertions(+)
 create mode 100755 tests/generic/766
 create mode 100644 tests/generic/766.out

diff --git a/tests/generic/766 b/tests/generic/766
new file mode 100755
index 00000000..6f31c250
--- /dev/null
+++ b/tests/generic/766
@@ -0,0 +1,80 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2025 Huawei.  All Rights Reserved.
+#
+# FS QA Test No. 766
+#
+# Test fallocate(WRITE_ZEROES) on a block device, which should be able to
+# WRITE SAME (or equivalent) the range.
+#
+. ./common/preamble
+_begin_fstest blockdev rw zero
+
+_register_cleanup "_cleanup" BUS
+
+# Import common functions.
+. ./common/filter
+. ./common/scsi_debug
+
+# Modify as appropriate.
+_require_scsi_debug
+_require_xfs_io_command "fwzero"
+
+## 1. Test supported flags
+echo "Create with unmap writesame and format"
+dev=$(_get_scsi_debug_dev 512 512 0 4 "lbpws=1 lbpws10=1")
+_pwrite_byte 0x62 0 4m $dev >> $seqres.full
+$XFS_IO_PROG -c "fsync" $dev
+
+echo "Write zeroes"
+$XFS_IO_PROG -c "fwzero 512k 1m" $dev
+
+echo "Check contents"
+md5sum $dev | sed -e "s|$dev|SCSI_DEBUG_DEV|g"
+
+echo "Destroy device"
+_put_scsi_debug_dev
+
+echo "Create w/o unmap writesame and format"
+dev=$(_get_scsi_debug_dev 512 512 0 4 "lbpws=0 lbpws10=0 lbpu=0 write_same_length=0 unmap_max_blocks=0")
+_pwrite_byte 0x62 0 4m $dev >> $seqres.full
+$XFS_IO_PROG -c "fsync" $dev
+
+echo "Write zeroes, write fallback"
+$XFS_IO_PROG -c "fwzero 512k 1m" $dev
+
+echo "Check contents"
+md5sum $dev | sed -e "s|$dev|SCSI_DEBUG_DEV|g"
+
+echo "Destroy device"
+_put_scsi_debug_dev
+
+## 2. Test unsupported flags.
+echo "Create and format"
+dev=$(_get_scsi_debug_dev 4096 4096 0 4 "lbpws=1 lbpws10=1")
+_pwrite_byte 0x62 0 4m $dev >> $seqres.full
+$XFS_IO_PROG -c "fsync" $dev
+
+echo "Unaligned write zeroes"
+$XFS_IO_PROG -c "fwzero 512 512" $dev
+
+echo "Write zeroes past MAX_LFS_FILESIZE"
+# zod = MAX_LFS_FILESIZE
+zod=$(_get_max_lfs_filesize)
+$XFS_IO_PROG -c "fwzero 512k $zod" $dev
+
+echo "Write zeroes to MAX_LFS_FILESIZE"
+$XFS_IO_PROG -c "fwzero 0 $zod" $dev
+
+echo "Write zeroes starts past EOD"
+$XFS_IO_PROG -c "fwzero 900m 1m" $dev
+
+echo "Check contents"
+md5sum $dev | sed -e "s|$dev|SCSI_DEBUG_DEV|g"
+
+echo "Destroy device"
+_put_scsi_debug_dev
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/766.out b/tests/generic/766.out
new file mode 100644
index 00000000..7da0ceca
--- /dev/null
+++ b/tests/generic/766.out
@@ -0,0 +1,23 @@
+QA output created by 766
+Create with unmap writesame and format
+Write zeroes
+Check contents
+caa26edd6c70ce862eb7ec6f10b138a8  SCSI_DEBUG_DEV
+Destroy device
+Create w/o unmap writesame and format
+Write zeroes, write fallback
+Check contents
+caa26edd6c70ce862eb7ec6f10b138a8  SCSI_DEBUG_DEV
+Destroy device
+Create and format
+Unaligned write zeroes
+fallocate: Invalid argument
+Write zeroes past MAX_LFS_FILESIZE
+fallocate: File too large
+Write zeroes to MAX_LFS_FILESIZE
+fallocate: Invalid argument
+Write zeroes starts past EOD
+fallocate: Invalid argument
+Check contents
+b83f9394092e15bdcda585cd8e776dc6  SCSI_DEBUG_DEV
+Destroy device
-- 
2.46.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ