On Tue, Nov 24, 2026 at 4:54 AM Mikulas Patocka <[email protected]> wrote:
>
> dm_cache_metadata_set_read_write can't change the state from read-only to
> read-write - the macro WRITE_LOCK_VOID returns if the device is
> read-only, thus dm_bm_set_read_write is not executed.
>
> Luckily, this doesn't cause any user-visible bug because the change from
> read-only to read-write is never requested. So, we can just delete the
> non-working code.
>
> Signed-off-by: Mikulas Patocka <[email protected]>
> Assisted-by: Claude:claude-opus-5
>
> ---
>  drivers/md/dm-cache-metadata.c |    7 -------
>  drivers/md/dm-cache-metadata.h |    1 -
>  drivers/md/dm-cache-target.c   |    1 -
>  3 files changed, 9 deletions(-)
>
> Index: linux-2.6/drivers/md/dm-cache-metadata.c
> ===================================================================
> --- linux-2.6.orig/drivers/md/dm-cache-metadata.c
> +++ linux-2.6/drivers/md/dm-cache-metadata.c
> @@ -1729,13 +1729,6 @@ void dm_cache_metadata_set_read_only(str
>         WRITE_UNLOCK(cmd);
>  }
>
> -void dm_cache_metadata_set_read_write(struct dm_cache_metadata *cmd)
> -{
> -       WRITE_LOCK_VOID(cmd);
> -       dm_bm_set_read_write(cmd->bm);
> -       WRITE_UNLOCK(cmd);
> -}
> -
>  int dm_cache_metadata_set_needs_check(struct dm_cache_metadata *cmd)
>  {
>         int r;
> Index: linux-2.6/drivers/md/dm-cache-metadata.h
> ===================================================================
> --- linux-2.6.orig/drivers/md/dm-cache-metadata.h
> +++ linux-2.6/drivers/md/dm-cache-metadata.h
> @@ -138,7 +138,6 @@ int dm_cache_write_hints(struct dm_cache
>  int dm_cache_metadata_needs_check(struct dm_cache_metadata *cmd, bool 
> *result);
>  int dm_cache_metadata_set_needs_check(struct dm_cache_metadata *cmd);
>  void dm_cache_metadata_set_read_only(struct dm_cache_metadata *cmd);
> -void dm_cache_metadata_set_read_write(struct dm_cache_metadata *cmd);
>  int dm_cache_metadata_abort(struct dm_cache_metadata *cmd);
>
>  /*
> Index: linux-2.6/drivers/md/dm-cache-target.c
> ===================================================================
> --- linux-2.6.orig/drivers/md/dm-cache-target.c
> +++ linux-2.6/drivers/md/dm-cache-target.c
> @@ -904,7 +904,6 @@ static void set_cache_mode(struct cache
>                 break;
>
>         case CM_WRITE:
> -               dm_cache_metadata_set_read_write(cache->cmd);
>                 break;
>         }
>
>

I plan to make it work properly in the read-only mode series, which is
currently in planning, so keeping it avoids re-adding it later. If
you'd prefer not to carry a no-op call in the meantime, I'm happy to
drop it here and re-introduce the updated logic with that series.


Hank

Reply via email to