Re: [PATCH RFC 0/5] device mapper atomic write support
From: Mikulas Patocka
Date: Thu Jan 16 2025 - 08:00:05 EST
On Thu, 16 Jan 2025, John Garry wrote:
> On 07/01/2025 17:13, Mikulas Patocka wrote:
> >
> >
> > On Mon, 6 Jan 2025, John Garry wrote:
> >
> > BTW. could it be possible to add dm-mirror support as well? dm-mirror is
> > used when the user moves the logical volume to another physical volume, so
> > it would be nice if this worked without resulting in not-supported errors.
> >
> > dm-mirror uses dm-io to perform the writes on multiple mirror legs (see
> > the function do_write() -> dm_io()), I looked at the code and it seems
> > that the support for atomic writes in dm-mirror and dm-io would be
> > straightforward.
>
> I tried this out, and it seems to work ok.
>
> However, I need to set DM_TARGET_ATOMIC_WRITES in the mirror_target.features
> member, like:
>
> diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
> index 9511dae5b556..913a92c55904 100644
> --- a/drivers/md/dm-raid1.c
> +++ b/drivers/md/dm-raid1.c
> @@ -1485,6 +1485,7 @@ static struct target_type mirror_target = {
> .name = "mirror",
> .version = {1, 14, 0},
> .module = THIS_MODULE,
> + .features = DM_TARGET_ATOMIC_WRITES,
> .ctr = mirror_ctr,
> .dtr = mirror_dtr,
> .map = mirror_map,
>
>
> Is this the right thing to do? I ask, as none of the other DM_TARGET* flags
> are set already, which makes me suspicious.
>
> Thanks,
> John
Yes - that's right. I suggest that you verify that the atomic flag is
really passed through the dm-raid1.c and dm-io.c stack. Add a printk that
tests if REQ_ATOMIC is set to the function do_region in dm-io.c just
before "submit_bio(bio)".
Alternatively, you can use blktrace to test if the REQ_ATOMIC is passed
through correctly.
Mikulas