Re: [PATCH v4] nvme/069: add a test for multipath cdev lifetime

Nilay Shroff <[email protected]>
Newsgroups org.infradead.lists.linux-nvme,org.kernel.vger.linux-block
Message-ID <[email protected]>
On 7/16/26 1:59 PM, John Garry wrote:
> +#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);
> +		usleep(500000);
> +		if (fd1 < 0)
> +			break;

Does it make sense to check for errno set to ENODEV or ENOENT
before breaking out here?

Thanks,
--Nilay
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.