All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Marzinski <bmarzins@redhat.com>
To: Martin Wilck <martin.wilck@suse.com>
Cc: Brian Bunker <brian@purestorage.com>,
	dm-devel@lists.linux.dev,
	Christophe Varoqui <christophe.varoqui@opensvc.com>
Subject: Re: [PATCH v3 1/1] multipathd: don't leave maps read-only after write protect is cleared
Date: Tue, 27 Oct 2026 00:52:17 -0400	[thread overview]
Message-ID: <auAuAQ-JR4WveD2D@redhat.com> (raw)
In-Reply-To: <5bb12dded4b0686d4246274a467d6adf6044cb18.camel@suse.com>

On Mon, Oct 26, 2026 at 11:20:35PM +0100, Martin Wilck wrote:
> On Fri, 2026-10-23 at 19:40 -0400, Benjamin Marzinski wrote:
> > 
> > To solve this, whenever multipath detects that a device has switched
> > to
> > read-only, it forces a read-only table reload, so that all the path
> > devices get re-opened read-only (since their requested mode doesn't
> > match their current mode).
> 
> I am sorry, I guess I am just looking in the wrong place. But the way I
> read the code in dm_get_device() [1], the kernel will re-open a device
> only if the mode is upgraded, i.e. switched from ro to rw.
> 
> [1] https://elixir.bootlin.com/linux/v7.3/source/drivers/md/dm-table.c#L398
> 
> I don't see how a switch from rw to ro would cause a device to be
> reopened.

That only happens if find_device() already found that device in THIS
table (it's called with t->devices). For instance, the dm-delay table
can list the same device three times. Instead of opening the device 3
times, you just open it once.  Additionally, if you have already opened
the device in the current table in a mode that includes the capabilites
of the mode you need in a future call to dm_get_device() it will just
use the existing open. If you need more capabilites, you will upgrade
the open.

What matters in the multipath case is if the device isn't found in the
existing table. In that case you call dm_get_table_device(), which
calls find_table_device(). This looks for a device in the
md->table_devices list, which includes devices from all tables. But in
this case, the mode must match exactly
https://elixir.bootlin.com/linux/v7.3/source/drivers/md/dm.c#L807

Thinking about it now, I'm actually not sure if that upgrading from
dm_get_device() is a good thing. If a target asks to open multiple
copies of the same device with different modes, and dm gives it one open
that has a union of all the modes, it seems like we've dropped some
safety guardrails. I'm not sure off the top of my head if there actually
is a target that does this.

-Ben

> 
> Thanks
> Martin
> 
> -- 
> Dr. Martin Wilck <mwilck@suse.com>
> SUSE Software Solutions Germany GmbH, Frankenstr. 146, 90461 Nürnberg,
> Germany
> Geschäftsführer: Stefan Gaiser, Jochen Jaser, Abhinav Puri (HRB
> 36809,AG Nürnberg)


      reply	other threads:[~2026-10-27  4:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-21 18:27 [PATCH v2 0/1] multipathd: don't leave maps read-only after write protect is cleared Brian Bunker
2026-10-21 18:27 ` [PATCH v2 1/1] " Brian Bunker
2026-10-21 19:50   ` Benjamin Marzinski
2026-10-21 21:34   ` mwilck
2026-10-21 23:19     ` [PATCH v3 0/1] " Brian Bunker
2026-10-21 23:19       ` [PATCH v3 1/1] " Brian Bunker
2026-10-22 20:17         ` Martin Wilck
2026-10-23  0:24           ` Benjamin Marzinski
2026-10-23 20:50             ` Martin Wilck
2026-10-23 23:40               ` Benjamin Marzinski
2026-10-26  9:26                 ` Martin Wilck
2026-10-26 18:04                   ` Brian Bunker
2026-10-26 22:23                     ` Martin Wilck
2026-10-27  4:29                       ` Benjamin Marzinski
2026-10-26 22:20                 ` Martin Wilck
2026-10-27  4:52                   ` Benjamin Marzinski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=auAuAQ-JR4WveD2D@redhat.com \
    --to=bmarzins@redhat.com \
    --cc=brian@purestorage.com \
    --cc=christophe.varoqui@opensvc.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=martin.wilck@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.