Skip to contentSkip to conversation

block/025: test discard sector alignement and sector size overflow

PATCH Applied Ming Lei 3 participants 5 messages Nov 15, 2018 – Dec 5, 2018 Block layer

lore
Share & tools
lore

Ming Lei

author
#0 lore raw

PATCH 1/1 block/025: test discard sector alignement and sector size overflow

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

---
 tests/block/025     | 37 +++++++++++++++++++++++++++++++++++++
 tests/block/025.out |  2 ++
 2 files changed, 39 insertions(+)
 create mode 100755 tests/block/025
 create mode 100644 tests/block/025.out
tests/block/025 new file +37 -0
new file mode 100755
index 000000000000..32b632431793
@@ -0,0 +1,37 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2018 Ming Lei <[email protected]>
+#
+# Check two corener cases of BLKDISCARD.
+#
+# 1) test if discard bio's sector is algined with logical size, fixed by
+#    1adfc5e4136f ("block: make sure discard bio is aligned with logical block size")
+# 2) test 32 bit overflow when comparing discard sector size. Fixed by
+#    4800bf7bc8c72 ("block: fix 32 bit overflow in __blkdev_issue_discard()")
+
+. tests/block/rc
+. common/scsi_debug
+
+DESCRIPTION="check sector alignment and sector size overflow of BLKDISCARD"
+
+requires() {
+	_have_scsi_debug
+}
+
+test() {
+	echo "Running ${TEST_NAME}"
+
+	rm -f "$FULL"
+
+	# Create 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"
+}
tests/block/025.out new file +2 -0
new file mode 100644
index 000000000000..fd9a6d5f70de
@@ -0,0 +1,2 @@
+Running block/025
+Test complete
Signature · 1 line
2.9.5
#1 lore raw
Quoted 68 lines · Ming Lei

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

---
 tests/block/025     | 37 +++++++++++++++++++++++++++++++++++++
 tests/block/025.out |  2 ++
 2 files changed, 39 insertions(+)
 create mode 100755 tests/block/025
 create mode 100644 tests/block/025.out
tests/block/025 new file +37 -0
new file mode 100755
index 000000000000..32b632431793
@@ -0,0 +1,37 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2018 Ming Lei <[email protected]>
+#
+# Check two corener cases of BLKDISCARD.
+#
+# 1) test if discard bio's sector is algined with logical size, fixed by
+#    1adfc5e4136f ("block: make sure discard bio is aligned with logical block size")
+# 2) test 32 bit overflow when comparing discard sector size. Fixed by
+#    4800bf7bc8c72 ("block: fix 32 bit overflow in __blkdev_issue_discard()")
+
+. tests/block/rc
+. common/scsi_debug
+
+DESCRIPTION="check sector alignment and sector size overflow of BLKDISCARD"
+
+requires() {
+       _have_scsi_debug
+}
+
+test() {
+       echo "Running ${TEST_NAME}"
+
+       rm -f "$FULL"
+
+       # Create 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"
+}
tests/block/025.out new file +2 -1
new file mode 100644
index 000000000000..fd9a6d5f70de
@@ -0,0 +1,2 @@
+Running block/025
+Test complete
--
Quoted 2 lines

2.9.5

Gentle ping...

thanks,
Ming Lei

#2 lore raw
In reply to Ming Lei
Quoted 21 lines · Ming Lei

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

---
 tests/block/025     | 37 +++++++++++++++++++++++++++++++++++++
 tests/block/025.out |  2 ++
 2 files changed, 39 insertions(+)
 create mode 100755 tests/block/025
 create mode 100644 tests/block/025.out
tests/block/025 new file +0 -0
new file mode 100755
index 000000000000..32b632431793

tests/block/025 line 8

Quoted 8 lines
tests/block/025 new file +8 -0
@@ -0,0 +1,37 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2018 Ming Lei <[email protected]>
+#
+# Check two corener cases of BLKDISCARD.
+#
+# 1) test if discard bio's sector is algined with logical size, fixed by
+#    1adfc5e4136f ("block: make sure discard bio is aligned with logical block size")

Hm, I'm not seeing how this test case tests this commit. Aren't 2049G and 512M both aligned to 4096 bytes?

Quoted 40 lines
tests/block/025 new file +29 -0
+# 2) test 32 bit overflow when comparing discard sector size. Fixed by
+#    4800bf7bc8c72 ("block: fix 32 bit overflow in __blkdev_issue_discard()")
+
+. tests/block/rc
+. common/scsi_debug
+
+DESCRIPTION="check sector alignment and sector size overflow of BLKDISCARD"
+
+requires() {
+	_have_scsi_debug
+}
+
+test() {
+	echo "Running ${TEST_NAME}"
+
+	rm -f "$FULL"
+
+	# Create 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"
+}
tests/block/025.out new file +2 -0
new file mode 100644
index 000000000000..fd9a6d5f70de
@@ -0,0 +1,2 @@
+Running block/025
+Test complete
Signature · 1 line
2.9.5
author
#3 lore raw
Quoted 25 lines · Omar Sandoval
Quoted 24 lines · Ming Lei

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

---
 tests/block/025     | 37 +++++++++++++++++++++++++++++++++++++
 tests/block/025.out |  2 ++
 2 files changed, 39 insertions(+)
 create mode 100755 tests/block/025
 create mode 100644 tests/block/025.out
tests/block/025 new file +3 -0
new file mode 100755
index 000000000000..32b632431793
@@ -0,0 +1,37 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2018 Ming Lei <[email protected]>
Quoted 8 lines

tests/block/025 line 8

Quoted 5 lines
tests/block/025 new file +5 -0
+#
+# Check two corener cases of BLKDISCARD.
+#
+# 1) test if discard bio's sector is algined with logical size, fixed by
+#    1adfc5e4136f ("block: make sure discard bio is aligned with logical block size")

Hm, I'm not seeing how this test case tests this commit. Aren't 2049G and 512M both aligned to 4096 bytes?

2049G caused 32bit 'nr_sects' in __blkdev_issue_discard() overflow,
please see commit 4800bf7bc8c725e955fcb ("block: fix 32 bit overflow in __blkdev_issue_discard()").

4096 logical block size may trigger 'req_sects' un-alignment issue because 'nr_sects' from fs is 512byte aligned, please see 1adfc5e4136f5967d59 ("block:
make sure discard bio is aligned with logical block size").

Thanks,
Ming

#4 lore raw
In reply to Ming Lei
Quoted 7 lines · Ming Lei

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

Quoted 7 lines
---
 tests/block/025     | 37 +++++++++++++++++++++++++++++++++++++
 tests/block/025.out |  2 ++
 2 files changed, 39 insertions(+)
 create mode 100755 tests/block/025
 create mode 100644 tests/block/025.out

Applied, thanks Ming.