Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package blktests for openSUSE:Factory checked in at 2026-07-24 22:05:48 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/blktests (Old) and /work/SRC/openSUSE:Factory/.blktests.new.2004 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "blktests" Fri Jul 24 22:05:48 2026 rev:16 rq:1367577 version:0+20260723.8f6020e Changes: -------- --- /work/SRC/openSUSE:Factory/blktests/blktests.changes 2026-07-01 16:39:48.999699354 +0200 +++ /work/SRC/openSUSE:Factory/.blktests.new.2004/blktests.changes 2026-07-24 22:06:08.563385524 +0200 @@ -1,0 +2,22 @@ +Fri Jul 24 03:32:16 UTC 2026 - Sebastian Chlad <[email protected]> + +- Update to version 0+20260723.8f6020e: + * loop/006: settle udev before completing the test + * loop/009: only skip on a genuinely unrecognized --ping option + * new: guide long command options + * CONTRIBUTING: clarify that GPL-2.0 is not applicable + * nvme/rc: use _set_attr() in _create_nvmet_passthru() + * check: fix exit status code handling + * nvme/050: skip cleanly when debugfs is not mounted + * nvme/039: skip cleanly when debugfs is not mounted + * common/rc: add _have_debugfs() + * nvme/069: add a test for multipath cdev lifetime + * loop: test cleanup of manually added partitions + * docs: add fully annotated configuration example + * nvme/{033,036,037}: skip when the test target namespace has metadata + * nvme/039: drain udev events before passthru error injection + * block/044: basic block error injection sanity test + * common/rc: Fix _get_page_size() + * README.md, check: require getconf + +------------------------------------------------------------------- Old: ---- blktests-0+20260630.3494185.tar.xz New: ---- blktests-0+20260723.8f6020e.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ blktests.spec ++++++ --- /var/tmp/diff_new_pack.CEcGSa/_old 2026-07-24 22:06:09.091403964 +0200 +++ /var/tmp/diff_new_pack.CEcGSa/_new 2026-07-24 22:06:09.095404103 +0200 @@ -17,7 +17,7 @@ Name: blktests -Version: 0+20260630.3494185 +Version: 0+20260723.8f6020e Release: 0 Summary: Linux kernel block layer testing framework License: GPL-2.0-or-later ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.CEcGSa/_old 2026-07-24 22:06:09.155406198 +0200 +++ /var/tmp/diff_new_pack.CEcGSa/_new 2026-07-24 22:06:09.159406338 +0200 @@ -3,6 +3,6 @@ <param name="url">git://github.com/osandov/blktests</param> <param name="changesrevision">e10add032819db8f3abf0a9d53f160b7b10cfed8</param></service><service name="tar_scm"> <param name="url">https://github.com/osandov/blktests.git</param> - <param name="changesrevision">34941855abbfe363b7548559234046f26183f711</param></service></servicedata> + <param name="changesrevision">8f6020e8a252fef40a7de05f7e51c5eb69d29397</param></service></servicedata> (No newline at EOF) ++++++ blktests-0+20260630.3494185.tar.xz -> blktests-0+20260723.8f6020e.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blktests-0+20260630.3494185/CONTRIBUTING.md new/blktests-0+20260723.8f6020e/CONTRIBUTING.md --- old/blktests-0+20260630.3494185/CONTRIBUTING.md 2026-06-30 06:42:05.000000000 +0200 +++ new/blktests-0+20260723.8f6020e/CONTRIBUTING.md 2026-07-23 15:13:47.000000000 +0200 @@ -16,3 +16,7 @@ Please run `make check` before submitting a new test. This runs the [shellcheck](https://github.com/koalaman/shellcheck) static analysis tool and some other sanity checks. + +When you add new files, choose a license from GPL-3.0+ or GPL-2.0+. The main +license of blktests is GPL-3.0+. GPL-3.0+ is recommended. GPL-2.0+ is allowed +but GPL-2.0 cannot be applied. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blktests-0+20260630.3494185/README.md new/blktests-0+20260723.8f6020e/README.md --- old/blktests-0+20260630.3494185/README.md 2026-06-30 06:42:05.000000000 +0200 +++ new/blktests-0+20260723.8f6020e/README.md 2026-07-23 15:13:47.000000000 +0200 @@ -19,6 +19,7 @@ - fio - gcc - make +- getconf - systemd-udev (udevadm) Some tests require the following: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blktests-0+20260630.3494185/check new/blktests-0+20260723.8f6020e/check --- old/blktests-0+20260630.3494185/check 2026-06-30 06:42:05.000000000 +0200 +++ new/blktests-0+20260723.8f6020e/check 2026-07-23 15:13:47.000000000 +0200 @@ -701,7 +701,7 @@ } _check_and_call_test() { - local postfix + local postfix ret if declare -fF requires >/dev/null; then requires @@ -710,7 +710,9 @@ [[ -n $COND_DESC ]] && postfix=_${COND_DESC//[ =]/_} RESULTS_DIR="$OUTPUT/nodev${postfix}" _call_test test + ret=$? _unload_modules + return $ret } _check_and_call_test_device() { @@ -1118,6 +1120,7 @@ required_commands_and_packages[blockdev]="util-linux" required_commands_and_packages[fio]="fio" required_commands_and_packages[udevadm]="systemd-udev" + required_commands_and_packages[getconf]="glibc-common or libc-bin" for cmd in "${!required_commands_and_packages[@]}"; do command -v "$cmd" &> /dev/null && continue diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blktests-0+20260630.3494185/common/nvme new/blktests-0+20260723.8f6020e/common/nvme --- old/blktests-0+20260630.3494185/common/nvme 2026-06-30 06:42:05.000000000 +0200 +++ new/blktests-0+20260723.8f6020e/common/nvme 2026-07-23 15:13:47.000000000 +0200 @@ -300,6 +300,27 @@ done } +_nvme_find_subsys_nvme_generic() { + local subsyspath _subsysnqn subsyspathbase nvmegenericbase devicelink + local subsysnqn="$def_subsysnqn" + + for subsyspath in /sys/class/nvme-subsystem/*; do + _subsysnqn=$(cat "${subsyspath}/subsysnqn" 2> /dev/null) + if [ "$subsysnqn" == "$_subsysnqn" ]; then + subsyspathbase="$(basename "$subsyspath")" + for nvmegeneric in /sys/class/nvme-generic/*; do + nvmegenericbase="$(basename "$nvmegeneric")" + devicelink="$(readlink "$nvmegeneric/device")" + if [[ "$devicelink" =~ $subsyspathbase ]]; then + echo "$nvmegenericbase" + break + fi + done + break + fi + done +} + _nvme_connect_subsys() { local subsysnqn="$def_subsysnqn" local hostnqn="$def_hostnqn" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blktests-0+20260630.3494185/common/rc new/blktests-0+20260723.8f6020e/common/rc --- old/blktests-0+20260630.3494185/common/rc 2026-06-30 06:42:05.000000000 +0200 +++ new/blktests-0+20260723.8f6020e/common/rc 2026-07-23 15:13:47.000000000 +0200 @@ -223,6 +223,14 @@ return 0 } +_have_debugfs() { + if ! findmnt -t debugfs /sys/kernel/debug >/dev/null; then + SKIP_REASONS+=("debugfs is not mounted at /sys/kernel/debug") + return 1 + fi + return 0 +} + # Check if the specified kernel config files are available. _have_kernel_config_file() { if [[ ! -f /proc/config.gz && ! -f /boot/config-$(uname -r) ]]; then @@ -562,13 +570,8 @@ return 0 } -# Get system page size from kernel conguration _get_page_size() { - local page_shift - - page_shift=$(_get_kernel_option PAGE_SHIFT) - - echo $((1<< page_shift)) + getconf PAGE_SIZE } # Check if the system page size matches the required size (in bytes). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blktests-0+20260630.3494185/config.example new/blktests-0+20260723.8f6020e/config.example --- old/blktests-0+20260630.3494185/config.example 1970-01-01 01:00:00.000000000 +0100 +++ new/blktests-0+20260723.8f6020e/config.example 2026-07-23 15:13:47.000000000 +0200 @@ -0,0 +1,169 @@ +# blktests example configuration file +# +# Copy this file to "config" (or pass it with "./check -c config.example") +# and adjust the settings for your environment. +# +# The config file is sourced as a bash script, so shell syntax applies. +# Configuration file settings take precedence over environment variables. +# Command line options take precedence over both. + +# TEST_DEVS +# Array of block devices to use for tests that require a test device. +# WARNING: tests are destructive and will overwrite all data on these devices. +# If unset or empty, only tests that do not require a device will run. +# May also be set as a whitespace-separated string instead of an array. +# +# TEST_DEVS=(/dev/nvme0n1 /dev/sdb) + +# TEST_CASE_DEV_ARRAY +# Associative array that maps test case names (or glob patterns) to a +# space-separated list of block devices for tests that require multiple +# devices simultaneously (i.e., tests implementing test_device_array()). +# WARNING: tests are destructive and will overwrite all data on these devices. +# +# declare -A TEST_CASE_DEV_ARRAY +# TEST_CASE_DEV_ARRAY[md/003]="/dev/nvme0n1 /dev/nvme1n1 /dev/nvme2n1 /dev/nvme3n1" +# TEST_CASE_DEV_ARRAY[bcache/*]="/dev/nvme0n1 /dev/vdb /dev/vdc" +# TEST_CASE_DEV_ARRAY[meta/02*]="/dev/nvme0n1 /dev/nvme1n1" + +# DEVICE_ONLY +# When set to 1, only run tests that exercise a configured test device +# (i.e., tests implementing test_device() or test_device_array()). +# Equivalent to the -d / --device-only command line option. +# Requires TEST_DEVS or TEST_CASE_DEV_ARRAY to be set. +# +# DEVICE_ONLY=1 + +# EXCLUDE +# Array of test names or test group names to skip. +# Tests specified explicitly on the command line are always run even if +# listed here. May also be set as a whitespace-separated string instead +# of an array. Equivalent to the -x / --exclude command line option. +# +# EXCLUDE=(loop block/001) + +# QUICK_RUN +# When set to 1, only run tests that are marked as quick or that honour +# the TIMEOUT setting, and set a time limit for each such test. +# Equivalent to the -q / --quick command line option. +# +# QUICK_RUN=1 + +# TIMEOUT +# Maximum runtime in seconds for each test (only meaningful when +# QUICK_RUN is enabled). Defaults to 30 when -q is given without an +# explicit value. +# +# TIMEOUT=30 + +# OUTPUT +# Directory where test results are written. Defaults to "./results". +# Equivalent to the -o / --output command line option. +# +# OUTPUT=results + +# RUN_ZONED_TESTS +# When set to 1, test cases that can set up a virtual zoned block device +# (e.g., via null_blk) are executed twice: once in non-zoned mode and +# once in zoned mode. Requires CONFIG_BLK_DEV_ZONED in the kernel. +# +# RUN_ZONED_TESTS=1 + +# NORMAL_USER +# Name of an unprivileged user account used by test cases that must run +# with normal user privileges. Tests requiring this are skipped when the +# variable is unset or empty. +# +# NORMAL_USER=blktests_user + +# LOGGER_PROG +# Path to the logger(1) program used to annotate the system log with +# test progress. Defaults to the first "logger" found in PATH, or +# "true" (i.e., a no-op) if none is found. +# +# LOGGER_PROG=/usr/bin/logger + +# MODPROBE_PATIENT_RM_TIMEOUT_SECONDS +# Timeout in seconds for the patient module removal helper used by tests +# that load and unload kernel modules. Defaults to 50. +# +# MODPROBE_PATIENT_RM_TIMEOUT_SECONDS=50 + +# --------------------------------------------------------------------------- +# NVMe test parameters +# --------------------------------------------------------------------------- + +# NVMET_TRTYPES +# Space-separated list of NVMe transport types to exercise. +# Supported values: loop (default), tcp, rdma, fc. +# The tests are repeated once for each transport listed. +# The old name "nvme_trtype" is still accepted but deprecated. +# +# NVMET_TRTYPES="loop" + +# NVMET_BLKDEV_TYPES +# Space-separated list of NVMe target backend types to exercise. +# Supported values: device, file. Defaults to "device file". +# The tests are repeated once for each type listed. +# +# NVMET_BLKDEV_TYPES="device file" + +# NVME_IMG_SIZE +# Size of the image file used as the NVMe target backend when +# NVMET_BLKDEV_TYPES includes "file". Supports m/M/g/G suffixes. +# Defaults to 1G. The old name "nvme_img_size" is still accepted but +# deprecated. +# +# NVME_IMG_SIZE=1G + +# NVME_NUM_ITER +# Number of iterations performed by NVMe tests that loop internally. +# Defaults to 1000. The old name "nvme_num_iter" is still accepted but +# deprecated. +# +# NVME_NUM_ITER=1000 + +# NVME_TARGET_CONTROL +# Path to a script that handles NVMe target setup and teardown when +# testing against an externally configured real target instead of the +# loopback target prepared by blktests. When set, the generic target +# setup/cleanup code is skipped and this script is called instead. +# The script must implement the "config", "setup", and "cleanup" +# sub-commands described in Documentation/running-tests.md. +# +# NVME_TARGET_CONTROL=/path/to/nvme_target_control.sh + +# USE_RXE +# When set to 1, use the rdma_rxe (soft-RoCE) driver instead of the +# default siw (soft-iWARP) driver for RDMA-based NVMe and SRP tests. +# The old name "use_rxe" is still accepted but deprecated. +# +# USE_RXE=1 + +# --------------------------------------------------------------------------- +# NVMe-TCP zero-copy offload parameters +# --------------------------------------------------------------------------- + +# KERNELSRC +# Path to the running kernel's source tree. Required by the NVMe-TCP +# zero-copy offload tests to locate the ynl CLI and netlink spec files. +# +# KERNELSRC=/usr/src/linux + +# NVME_IFACE +# Name of the network interface used for the NVMe-TCP connection when +# testing zero-copy offload. Must be the same interface the NVMe +# connection is established on. +# +# NVME_IFACE=eth0 + +# --------------------------------------------------------------------------- +# Blk-throttle test parameters +# --------------------------------------------------------------------------- + +# THROTL_BLKDEV_TYPES +# Space-separated list of block device back-ends to use for blk-throttle +# tests. Supported values: nullb (null_blk), sdebug (scsi_debug). +# Defaults to "nullb sdebug". +# +# THROTL_BLKDEV_TYPES="nullb sdebug" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blktests-0+20260630.3494185/new new/blktests-0+20260723.8f6020e/new --- old/blktests-0+20260630.3494185/new 2026-06-30 06:42:05.000000000 +0200 +++ new/blktests-0+20260723.8f6020e/new 2026-07-23 15:13:47.000000000 +0200 @@ -279,6 +279,9 @@ # - Use the \$() form of command substitution instead of backticks. # - Use bash for loops instead of seq. E.g., for ((i = 0; i < 10; i++)), not # for i in \$(seq 0 9). +# - Use long command options instead of short options for readability and +# stability: e.g., 'nvme io-passthru --opcode X' is recommended over +# 'nvme io-passthru -o X'. # # Please run \`make check\` after your test is done to check for shell # scripting errors and other mistakes. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blktests-0+20260630.3494185/src/Makefile new/blktests-0+20260723.8f6020e/src/Makefile --- old/blktests-0+20260630.3494185/src/Makefile 2026-06-30 06:42:05.000000000 +0200 +++ new/blktests-0+20260723.8f6020e/src/Makefile 2026-07-23 15:13:47.000000000 +0200 @@ -18,6 +18,7 @@ loop_change_fd \ loop_get_status_null \ mount_clear_sock \ + nvme-delay-ioctl \ nvme-passthrough-meta \ ioctl-lbmd-query \ nbdsetsize \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blktests-0+20260630.3494185/src/nvme-delay-ioctl.c new/blktests-0+20260723.8f6020e/src/nvme-delay-ioctl.c --- old/blktests-0+20260630.3494185/src/nvme-delay-ioctl.c 1970-01-01 01:00:00.000000000 +0100 +++ new/blktests-0+20260723.8f6020e/src/nvme-delay-ioctl.c 2026-07-23 15:13:47.000000000 +0200 @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: GPL-3.0+ +// Copyright (C) 2026 John Garry + +/* + * Simple test to issue an ioctl some time after opening a cdev. + * This is to test lifetime of cdev, and whether we can handle + * removing the cdev while we have active fds. + */ +#define _GNU_SOURCE +#include <dirent.h> +#include <errno.h> +#include <fcntl.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <signal.h> + +#include <inttypes.h> +#include <sys/ioctl.h> +#include <linux/types.h> + +#ifndef _LINUX_NVME_IOCTL_H +#define _LINUX_NVME_IOCTL_H +#define NVME_IOCTL_ID _IO('N', 0x40) +#endif /* _UAPI_LINUX_NVME_IOCTL_H */ + +int main(int argc, char **argv) +{ + int fd, fd1; + int count; + + if (argc < 2) { + fprintf(stderr, "usage: %s /dev/ngXnX", argv[0]); + return EINVAL; + } + + fd = open(argv[1], O_RDONLY); + if (fd < 0) + return fd; + + /* + * Steps: + * a. Signal to parent that we have opened the file so that it may + * start the teardown. + * b. Try to open device until disallowed/gone. + * c. Sleep to allow nvme-subsystem be torn down. + * d. Issue the ioctl on original fd. + */ + kill(getppid(), SIGUSR2); + count = 0; + for (;;) { + fd1 = open(argv[1], O_RDONLY); + if (fd1 < 0) { + if (errno == EINTR) + continue; + + if (errno == ENOENT || errno == ENODEV) + break; + + perror("open"); + close(fd); + return EINVAL; + } + close(fd1); + count++; + if (count > 10) { + fprintf(stderr, "%s still present", argv[0]); + close(fd); + return EINVAL; + } + usleep(500000); + } + + ioctl(fd, NVME_IOCTL_ID); + close(fd); + + return 0; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blktests-0+20260630.3494185/tests/block/044 new/blktests-0+20260723.8f6020e/tests/block/044 --- old/blktests-0+20260630.3494185/tests/block/044 1970-01-01 01:00:00.000000000 +0100 +++ new/blktests-0+20260723.8f6020e/tests/block/044 2026-07-23 15:13:47.000000000 +0200 @@ -0,0 +1,62 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2026 Christoph Hellwig. +# +# Basic block error injection test. + +. tests/block/rc +. common/scsi_debug + +DESCRIPTION="basic block error injection test" +QUICK=1 + +requires() +{ + _have_kernel_option BLK_ERROR_INJECTION + _have_loadable_scsi_debug + _have_program xfs_io +} + +# load and remove scsi_debug once to test the static_key bug in the +# initial commit +_test_load_unload() +{ + if ! _init_scsi_debug dev_size_mb=500; then + return 1 + fi + echo "Testing unload without rules" + _exit_scsi_debug +} + +_test_rules() +{ + if ! _init_scsi_debug dev_size_mb=500; then + return 1 + fi + + local dev=${SCSI_DEBUG_DEVICES[0]} + local debugfs_file="/sys/kernel/debug/block/$dev/error_injection" + + echo "Testing valid rules" + echo "add,op=WRITE,status=RESOURCE,start=0,nr_sectors=8" > "$debugfs_file" + echo "add,op=READ,status=IOERR,start=16,nr_sectors=8" > "$debugfs_file" + xfs_io -d -c 'pwrite -q 0 4096' /dev/"$dev" + xfs_io -d -c 'pread -q 0 4096' /dev/"$dev" + xfs_io -d -c 'pwrite -q 4096 4096' /dev/"$dev" + xfs_io -d -c 'pread -q 8192 8192' /dev/"$dev" + + echo "Testing invalid rules" + echo "op=READ,status=IOERR" > "$debugfs_file" + echo "add,op=READ,status=EIO,start=32" > "$debugfs_file" + _exit_scsi_debug +} + +test() +{ + echo "Running ${TEST_NAME}" + + _test_load_unload + _test_rules + + echo "Test complete" +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blktests-0+20260630.3494185/tests/block/044.out new/blktests-0+20260723.8f6020e/tests/block/044.out --- old/blktests-0+20260630.3494185/tests/block/044.out 1970-01-01 01:00:00.000000000 +0100 +++ new/blktests-0+20260723.8f6020e/tests/block/044.out 2026-07-23 15:13:47.000000000 +0200 @@ -0,0 +1,9 @@ +Running block/044 +Testing unload without rules +Testing valid rules +pwrite: Cannot allocate memory +pread: Input/output error +Testing invalid rules +tests/block/044: line 56: echo: write error: Invalid argument +tests/block/044: line 57: echo: write error: Invalid argument +Test complete diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blktests-0+20260630.3494185/tests/loop/006 new/blktests-0+20260723.8f6020e/tests/loop/006 --- old/blktests-0+20260630.3494185/tests/loop/006 2026-06-30 06:42:05.000000000 +0200 +++ new/blktests-0+20260723.8f6020e/tests/loop/006 2026-07-23 15:13:47.000000000 +0200 @@ -69,5 +69,10 @@ fi losetup -d "$loop_dev" + # Let udev catch up on the attach/detach/change-fd before + # handing control back, so it doesn't leave a backlog for + # whatever test runs next. + udevadm settle + echo "Test complete" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blktests-0+20260630.3494185/tests/loop/009 new/blktests-0+20260723.8f6020e/tests/loop/009 --- old/blktests-0+20260630.3494185/tests/loop/009 2026-06-30 06:42:05.000000000 +0200 +++ new/blktests-0+20260723.8f6020e/tests/loop/009 2026-07-23 15:13:47.000000000 +0200 @@ -11,7 +11,7 @@ QUICK=1 requires() { - if ! udevadm control --ping >& /dev/null; then + if ! udevadm control --help 2>&1 | grep --quiet -- '--ping'; then SKIP_REASONS+=("udevadm control does not support --ping option") fi } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blktests-0+20260630.3494185/tests/loop/013 new/blktests-0+20260723.8f6020e/tests/loop/013 --- old/blktests-0+20260630.3494185/tests/loop/013 1970-01-01 01:00:00.000000000 +0100 +++ new/blktests-0+20260723.8f6020e/tests/loop/013 2026-07-23 15:13:47.000000000 +0200 @@ -0,0 +1,79 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2026 Daan De Meyer +# +# Verify that partitions added manually with BLKPG do not remain after a loop +# device without LO_FLAGS_PARTSCAN is detached and reopened. +# +# Regression test for commit c4f4c0fc551c ("loop: remove manually added +# partitions on detach"). + +. tests/loop/rc + +DESCRIPTION="remove manually added partitions before loop device reuse" +QUICK=1 + +loop_device= +udevd_stopped= + +requires() { + _have_program sfdisk + _have_program partx +} + +cleanup() { + if [[ -n "$loop_device" ]]; then + losetup --detach "$loop_device" &>/dev/null + fi + if [[ -n "$udevd_stopped" ]]; then + _systemd_start_udevd + fi +} + +test() { + echo "Running ${TEST_NAME}" + _register_test_cleanup cleanup + + truncate --size=3MiB "$TMPDIR/img" + sfdisk "$TMPDIR/img" >"$FULL" 2>&1 <<-EOF + label: gpt + size=1MiB + EOF + + # Keep userspace from removing the partition on our behalf. + if _systemctl_unit_is_active systemd-udevd; then + _systemd_stop_udevd + udevd_stopped=1 + fi + + if ! loop_device="$(losetup --find --show "$TMPDIR/img")"; then + echo "Failed to configure loop device" + echo "Test complete" + return + fi + local name="${loop_device##*/}" + local partition="/sys/block/$name/${name}p1" + + # Add a partition without setting LO_FLAGS_PARTSCAN on the loop device. + if ! partx --add "$loop_device" >>"$FULL" 2>&1; then + echo "Failed to add partition" + elif [[ ! -e "$partition" ]]; then + echo "Partition was not created" + fi + + if ! losetup --detach "$loop_device" >>"$FULL" 2>&1; then + echo "Failed to detach loop device" + echo "Test complete" + return + fi + loop_device= + + # Historically, opening the unbound device performed a lazy cleanup. + # The partition may also have been removed eagerly during detach. + : >"/dev/$name" + if [[ -e "$partition" ]]; then + echo "Partition still exists after loop device reuse" + fi + + echo "Test complete" +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blktests-0+20260630.3494185/tests/loop/013.out new/blktests-0+20260723.8f6020e/tests/loop/013.out --- old/blktests-0+20260630.3494185/tests/loop/013.out 1970-01-01 01:00:00.000000000 +0100 +++ new/blktests-0+20260723.8f6020e/tests/loop/013.out 2026-07-23 15:13:47.000000000 +0200 @@ -0,0 +1,2 @@ +Running loop/013 +Test complete diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blktests-0+20260630.3494185/tests/nvme/033 new/blktests-0+20260723.8f6020e/tests/nvme/033 --- old/blktests-0+20260630.3494185/tests/nvme/033 2026-06-30 06:42:05.000000000 +0200 +++ new/blktests-0+20260723.8f6020e/tests/nvme/033 2026-07-23 15:13:47.000000000 +0200 @@ -15,6 +15,7 @@ device_requires() { _require_test_dev_is_not_nvme_multipath + _test_dev_has_no_metadata } set_conditions() { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blktests-0+20260630.3494185/tests/nvme/036 new/blktests-0+20260723.8f6020e/tests/nvme/036 --- old/blktests-0+20260630.3494185/tests/nvme/036 2026-06-30 06:42:05.000000000 +0200 +++ new/blktests-0+20260723.8f6020e/tests/nvme/036 2026-07-23 15:13:47.000000000 +0200 @@ -15,6 +15,7 @@ device_requires() { _require_test_dev_is_not_nvme_multipath + _test_dev_has_no_metadata } set_conditions() { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blktests-0+20260630.3494185/tests/nvme/037 new/blktests-0+20260723.8f6020e/tests/nvme/037 --- old/blktests-0+20260630.3494185/tests/nvme/037 2026-06-30 06:42:05.000000000 +0200 +++ new/blktests-0+20260723.8f6020e/tests/nvme/037 2026-07-23 15:13:47.000000000 +0200 @@ -14,6 +14,7 @@ device_requires() { _require_test_dev_is_not_nvme_multipath + _test_dev_has_no_metadata } set_conditions() { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blktests-0+20260630.3494185/tests/nvme/039 new/blktests-0+20260723.8f6020e/tests/nvme/039 --- old/blktests-0+20260630.3494185/tests/nvme/039 2026-06-30 06:42:05.000000000 +0200 +++ new/blktests-0+20260723.8f6020e/tests/nvme/039 2026-07-23 15:13:47.000000000 +0200 @@ -15,6 +15,7 @@ requires() { _have_program nvme _have_kernel_options FAULT_INJECTION FAULT_INJECTION_DEBUG_FS + _have_debugfs } device_requires() { @@ -206,6 +207,8 @@ inject_invalid_status_on_read "${ns_dev}" inject_write_fault_on_write "${ns_dev}" + udevadm settle + if [ -e "$TEST_DEV_SYSFS/passthru_err_log_enabled" ]; then _nvme_passthru_logging_setup "${ns_dev}" "${ctrl_dev}" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blktests-0+20260630.3494185/tests/nvme/050 new/blktests-0+20260723.8f6020e/tests/nvme/050 --- old/blktests-0+20260630.3494185/tests/nvme/050 2026-06-30 06:42:05.000000000 +0200 +++ new/blktests-0+20260723.8f6020e/tests/nvme/050 2026-07-23 15:13:47.000000000 +0200 @@ -17,6 +17,7 @@ _have_fio _nvme_requires _have_kernel_options FAIL_IO_TIMEOUT FAULT_INJECTION_DEBUG_FS + _have_debugfs } test_device() { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blktests-0+20260630.3494185/tests/nvme/069 new/blktests-0+20260723.8f6020e/tests/nvme/069 --- old/blktests-0+20260630.3494185/tests/nvme/069 1970-01-01 01:00:00.000000000 +0100 +++ new/blktests-0+20260723.8f6020e/tests/nvme/069 2026-07-23 15:13:47.000000000 +0200 @@ -0,0 +1,61 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2026 John Garry +# +# Test NVMe multipath nvme-generic cdev lifetime behaves as expected. + +. tests/nvme/rc + +DESCRIPTION="NVMe multipath cdev lifetime test" +CHECK_DMESG=1 +QUICK=1 + +requires() { + _nvme_requires + _have_loop + _have_module_param_value nvme_core multipath Y + _require_nvme_trtype_is_fabrics + _have_kernel_options KASAN +} + +set_conditions() { + _set_nvme_trtype "$@" +} + +test() { + echo "Running ${TEST_NAME}" + + local nvmedev + local loops=0 + local quit=0 + local nvmegeneric + + _setup_nvmet + _nvmet_target_setup + _nvme_connect_subsys + + nvmedev=$(_find_nvme_dev "${def_subsysnqn}") + nvmegeneric=$(_nvme_find_subsys_nvme_generic) + + trap 'quit=1' USR2 + # nvme-delay-ioctl will open the nvme-generic cdev, wait for teardown, + # and then issue an ioctl. + # We tear down the nvme-subsystem in the foreground so we can catch + # if the ioctl triggers a use-after-free KASAN warn. + src/nvme-delay-ioctl "/dev/$nvmegeneric" & + + while [ "$quit" -ne 1 ]; do + sleep 0.1 + ((loops++)) + if [[ "$loops" == "100" ]]; then + echo "no signal" + break + fi + done + + _nvme_disconnect_ctrl "${nvmedev}" + _nvmet_target_cleanup + wait "$(jobs -p)" + + echo "Test complete" +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blktests-0+20260630.3494185/tests/nvme/069.out new/blktests-0+20260723.8f6020e/tests/nvme/069.out --- old/blktests-0+20260630.3494185/tests/nvme/069.out 1970-01-01 01:00:00.000000000 +0100 +++ new/blktests-0+20260723.8f6020e/tests/nvme/069.out 2026-07-23 15:13:47.000000000 +0200 @@ -0,0 +1,2 @@ +Running nvme/069 +Test complete diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blktests-0+20260630.3494185/tests/nvme/rc new/blktests-0+20260723.8f6020e/tests/nvme/rc --- old/blktests-0+20260630.3494185/tests/nvme/rc 2026-06-30 06:42:05.000000000 +0200 +++ new/blktests-0+20260723.8f6020e/tests/nvme/rc 2026-07-23 15:13:47.000000000 +0200 @@ -225,7 +225,7 @@ mkdir -p "${subsys_path}" _set_attr 0 "${subsys_path}/attr_allow_any_host" - _test_dev_nvme_ctrl > "${passthru_path}/device_path" + _set_attr "$(_test_dev_nvme_ctrl)" "${passthru_path}/device_path" _set_attr 1 "${passthru_path}/enable" if [[ -f "${passthru_path}/clear_ids" ]]; then _set_attr 1 "${passthru_path}/clear_ids"
