From: Mikulas Patocka <mpatocka@redhat.com>
To: "Łukasz Patron" <priv.luk@gmail.com>
Cc: Alasdair Kergon <agk@redhat.com>,
Mike Snitzer <snitzer@kernel.org>,
dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dm: Implement set_read_only
Date: Tue, 27 Aug 2024 19:52:05 +0200 (CEST) [thread overview]
Message-ID: <da447e8f-0068-d847-b712-47081fa9f2e7@redhat.com> (raw)
In-Reply-To: <20240821213048.726082-1-priv.luk@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1649 bytes --]
On Wed, 21 Aug 2024, Łukasz Patron wrote:
> This lets us change the read-only flag for device mapper block devices
> via the BLKROSET ioctl.
>
> Signed-off-by: Łukasz Patron <priv.luk@gmail.com>
> ---
> drivers/md/dm.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/md/dm.c b/drivers/md/dm.c
> index 87bb90303435..538a93e596d7 100644
> --- a/drivers/md/dm.c
> +++ b/drivers/md/dm.c
> @@ -410,6 +410,12 @@ static int dm_blk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
> return dm_get_geometry(md, geo);
> }
>
> +static int dm_blk_set_read_only(struct block_device *bdev, bool ro)
> +{
> + set_disk_ro(bdev->bd_disk, ro);
> + return 0;
> +}
> +
> static int dm_prepare_ioctl(struct mapped_device *md, int *srcu_idx,
> struct block_device **bdev)
> {
> @@ -3666,6 +3672,7 @@ static const struct block_device_operations dm_blk_dops = {
> .release = dm_blk_close,
> .ioctl = dm_blk_ioctl,
> .getgeo = dm_blk_getgeo,
> + .set_read_only = dm_blk_set_read_only,
> .report_zones = dm_blk_report_zones,
> .pr_ops = &dm_pr_ops,
> .owner = THIS_MODULE
> --
> 2.46.0
Hi
Device mapper already calls set_disk_ro in the do_resume function. So, the
problem here is that the value set using set_read_only will be overwritten
as soon as a new table will be loaded.
I'd like to ask why is this patch needed? Why do you want to set read-only
status using this ioctl instead of using the existing table flag?
If this is needed, we need to add another flag that is being set by
dm_blk_set_read_only, so that dm_blk_set_read_only and dm_resume won't
step over each other's changes.
Mikulas
next prev parent reply other threads:[~2024-08-27 17:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-21 21:30 Łukasz Patron
2024-08-27 17:52 ` Mikulas Patocka [this message]
2024-08-28 9:21 ` Łukasz Patron
2024-08-28 13:49 ` Mikulas Patocka
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=da447e8f-0068-d847-b712-47081fa9f2e7@redhat.com \
--to=mpatocka@redhat.com \
--cc=agk@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=priv.luk@gmail.com \
--cc=snitzer@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®