Re: [PATCH 2/2] dm-raid1: don't fail the mirror for invalid I/O errors

"Dr. David Alan Gilbert" <[email protected]>
Newsgroups dev.linux.lists.dm-devel,org.kernel.vger.linux-block
Message-ID <ajGtbuJ2kXo1GZ1d@gallifrey>
* Keith Busch ([email protected]) wrote:
> On Tue, Jun 16, 2026 at 05:54:28PM +0000, Dr. David Alan Gilbert wrote:
> > OK, for this pair I think would be fair for a Tested-by me as well;
> > they certainly resolve the hang and the WARN/BUGs.
> > I still see the errors as EIO on my tests, and on the older mirror type
> 
> Could you share your reproducer? I'm just using the original recipe you
> sent here:
> 
> https://lore.kernel.org/linux-block/ai7rnH20IYeSmY8s@gallifrey/
> 
> And I'm seeing EINVAL instead EIO.

Interesting; I've got your:
  dm-raid1: don't fail the mirror for invalid I/O errors
  For DM_IO_BIO requests, do_region() built each destination bio by walking..
ontop of e21ee273e6fa3879aec9a27251cfce98156e07c4 which is just before 7.1
  I've not your https://lore.kernel.org/linux-block/[email protected]/

root@dalek:/home/dg# lvcreate  --mirrors 1 -L 1G main /dev/sda2 /dev/sdb2
root@dalek:/home/dg# mkfs.ext4 /dev/mapper/main-lvol0
root@dalek:/home/dg# mount /dev/mapper/main-lvol0 /mnt/tmp/
root@dalek:/home/dg# chmod a+rwx /mnt/tmp

dg@dalek:~$ dd if=/dev/zero of=/mnt/tmp/testfile bs=1024k count=1

my two tests are separate tests:
{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}
dg@dalek:~$ cat dbf.c
#include <errno.h>
#include <fcntl.h>             
#include <asm-generic/fcntl.h>
#include <stdio.h> 
#include <unistd.h>


const char* path="/mnt/tmp/testfile";
static char buf[8192];

int main()                                       
{
  int fd=open(path, O_RDWR|O_DIRECT|O_CLOEXEC);
    
  errno=0;
  int res3=pread(fd, buf, 4096, 0);
  printf("pread of 4096 said: %d (%m)\n", res3);

}
{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}
dg@dalek:~$ cat dbf-write.c
#include <errno.h>
#include <fcntl.h>             
#include <asm-generic/fcntl.h>
#include <stdio.h> 
#include <unistd.h>


const char* path="/mnt/tmp/testfile";
static char buf[8192];

int main()                                       
{
  int fd=open(path, O_RDWR|O_DIRECT|O_CLOEXEC);
    
  errno=0;
  int res3=pwrite(fd, buf, 4096, 0);
  printf("pwrite of 4096 said: %d (%m)\n", res3);

}
{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}{--}


> > get the stuck resync on write, and on the newer mirror I see the write
> > apparently succeed (did it really?)
> 
> There was a time when ext4 used to fallback to buffered io for writes
> but not for reads, but looks like that was fixed since 6.18, so should
> be returning error.
> 
> I tried testing it with a modification to your original read test, and
> it is still failing with EINVAL for me:
> 
>   pread of 4096 said: -1 (Invalid argument)
>   pwrite of 4096 said: -1 (Invalid argument)

Your double test gives me:
dg@dalek:~$ ./dbf-joint 
pread of 4096 said: -1 (Input/output error)
pwrite of 4096 said: 4096 (Input/output error)

> ---
> #define _GNU_SOURCE
> #include <errno.h>
> #include <fcntl.h>
> #include <stdio.h>
> #include <unistd.h>
> 
> const char* path="/mnt/tmp/testfile";
> static char buf[8192];
> 
> int main()
> {
>   int fd=open(path, O_RDWR|O_DIRECT|O_CLOEXEC);
> 
>   errno=0;
>   int res3=pread(fd, buf, 4096, 0);
>   printf("pread of 4096 said: %d (%m)\n", res3);

errno=0;

>   res3=pwrite(fd, buf, 4096, 0);
>   printf("pwrite of 4096 said: %d (%m)\n", res3);
> }

Dave

> --
-- 
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
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.