]> www.infradead.org Git - users/sagi/blktests.git/commitdiff
block/025: test discard sector alignement and sector size overflow
authorMing Lei <ming.lei@redhat.com>
Thu, 15 Nov 2018 04:00:17 +0000 (12:00 +0800)
committerOmar Sandoval <osandov@fb.com>
Wed, 5 Dec 2018 23:36:00 +0000 (15:36 -0800)
This test covers the following two issues:

1) discard sector need to be aligned with logical block size

2) make sure 'sector_t' instead of 'unsigned int' is used when comparing
with discard sector size

Signed-off-by: Ming Lei <ming.lei@redhat.com>
[Omar: reword description]
Signed-off-by: Omar Sandoval <osandov@fb.com>
tests/block/025 [new file with mode: 0755]
tests/block/025.out [new file with mode: 0644]

diff --git a/tests/block/025 b/tests/block/025
new file mode 100755 (executable)
index 0000000..f746c1c
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2018 Ming Lei <ming.lei@redhat.com>
+#
+# Test two corner cases of BLKDISCARD. Regression test for commits 1adfc5e4136f
+# ("block: make sure discard bio is aligned with logical block size") and
+# 4800bf7bc8c72 ("block: fix 32 bit overflow in __blkdev_issue_discard()").
+
+. tests/block/rc
+. common/scsi_debug
+
+DESCRIPTION="do a huge discard with 4k sector size"
+
+requires() {
+       _have_scsi_debug
+}
+
+test() {
+       echo "Running ${TEST_NAME}"
+
+       rm -f "$FULL"
+
+       # Create a virtual device with unmap_zeroes_data support.
+       if ! _init_scsi_debug virtual_gb=2049 sector_size=4096 lbpws10=1 dev_size_mb=512; then
+               return 1
+       fi
+
+       local dev="/dev/${SCSI_DEBUG_DEVICES[0]}"
+       blkdiscard "$dev"
+
+       _exit_scsi_debug
+
+       echo "Test complete"
+}
diff --git a/tests/block/025.out b/tests/block/025.out
new file mode 100644 (file)
index 0000000..fd9a6d5
--- /dev/null
@@ -0,0 +1,2 @@
+Running block/025
+Test complete