On Wed, Oct 21, 2026 at 11:27:59AM -0700, Brian Bunker wrote: > ev_add_path() sets mpp->force_readonly when a newly added path is > read-only, but never clears it. If a map is created or reloaded while > its storage is write protected, the flag stays set. When write protect > is cleared, the reload that uev_update_path() does for the DISK_RO=0 > uevent uses the stale flag and loads the map read-only, even though all > of its paths are read-write. uev_update_path() clears the flag after > that reload, so the map only recovers if another DISK_RO=0 uevent > reloads it again. If none comes, the map stays read-only, and since > mpp->dmi.read_only is then 1, needs_ro_update() also ignores later > DISK_RO=1 uevents for it. > > Fix this by setting force_readonly before each load and clearing it > when a load succeeds: > > - needs_ro_update() now sets force_readonly whenever it returns true: > to 1 for a DISK_RO=1 uevent, to 0 when all of the map's paths are > writable, and from the paths' state when the map has no dm info. > uev_update_path() no longer sets or clears it itself. > > - ev_add_path() sets it from all of the map's paths rather than only > the path being added, and only when it is about to load the map > (need_do_map). mpp->paths is up to date there after adopt_paths(), > while mpp->pg doesn't contain the new paths yet.
Oops. Good catch. > > - update_map(), which does reloads that were delayed while the map was > waiting for udev (UDEV_WAIT_RELOAD), recomputes it from the map's > paths before setting up the map. > > - dm_addmap() clears it after a successful load, as it does for > need_reload, so it can't outlive the load it was set for. > > Signed-off-by: Brian Bunker <[email protected]> Reviewed-by: Benjamin Marzinski <[email protected]>
