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 10:06 PM, John Garry wrote:
> On 16/07/2026 16:16, Nilay Shroff wrote:
>>> +    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?
> 
> ehh, if the errno is not ENODEV or ENOENT, then how to handle? Would it to fail the test due to unexpected errno?

I think yes, something like below:

for (;;) {
         fd1 = open(argv[1], O_RDONLY);
         if (fd1 < 0) {
                 if (errno == EINTR)
                         continue;

                 if (errno == ENOENT || errno == ENODEV)
                         break;

                 perror("open");
                 return EINVAL;
         }

         close(fd1);
         usleep(500000);

         if (++count > 10) {
                 fprintf(stderr, "%s still present\n", argv[0]);
                 return EINVAL;
         }
}

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.