ceph-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Christoph Hellwig <hch@lst.de>, Jens Axboe <axboe@kernel.dk>
Cc: "Martin K . Petersen" <martin.petersen@oracle.com>,
	Oleksii Kurochko <olkuroch@cisco.com>,
	Sagi Grimberg <sagi@grimberg.me>,
	Mike Snitzer <snitzer@redhat.com>,
	Ilya Dryomov <idryomov@gmail.com>,
	Dongsheng Yang <dongsheng.yang@easystack.cn>,
	ceph-devel@vger.kernel.org, dm-devel@redhat.com,
	linux-block@vger.kernel.org, linux-nvme@lists.infradead.org
Subject: Re: [PATCH 4/6] block: propagate BLKROSET on the whole device to all partitions
Date: Tue, 8 Dec 2020 17:47:35 +0100	[thread overview]
Message-ID: <8df170f5-3000-7eba-0482-0066cc24ae71@suse.de> (raw)
In-Reply-To: <20201208162829.2424563-5-hch@lst.de>

On 12/8/20 5:28 PM, Christoph Hellwig wrote:
> Change the policy so that a BLKROSET on the whole device also affects
> partitions.  To quote Martin K. Petersen:
> 
> It's very common for database folks to twiddle the read-only state of
> block devices and partitions. I know that our users will find it very
> counter-intuitive that setting /dev/sda read-only won't prevent writes
> to /dev/sda1.
> 
> The existing behavior is inconsistent in the sense that doing:
> 
>    # blockdev --setro /dev/sda
>    # echo foo > /dev/sda1
> 
> permits writes. But:
> 
>    # blockdev --setro /dev/sda
>    <something triggers revalidate>
>    # echo foo > /dev/sda1
> 
> doesn't.
> 
> And a subsequent:
> 
>    # blockdev --setrw /dev/sda
>    # echo foo > /dev/sda1
> 
> doesn't work either since sda1's read-only policy has been inherited
> from the whole-disk device.
> 
> You need to do:
> 
>    # blockdev --rereadpt
> 
> after setting the whole-disk device rw to effectuate the same change on
> the partitions, otherwise they are stuck being read-only indefinitely.
> 
> However, setting the read-only policy on a partition does *not* require
> the revalidate step. As a matter of fact, doing the revalidate will blow
> away the policy setting you just made.
> 
> So the user needs to take different actions depending on whether they
> are trying to read-protect a whole-disk device or a partition. Despite
> using the same ioctl. That is really confusing.
> 
> I have lost count how many times our customers have had data clobbered
> because of ambiguity of the existing whole-disk device policy. The
> current behavior violates the principle of least surprise by letting the
> user think they write protected the whole disk when they actually
> didn't.
> 
> Suggested-by: Martin K. Petersen <martin.petersen@oracle.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
> ---
>   block/genhd.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/block/genhd.c b/block/genhd.c
> index d9f989c1514123..6e51ecb9280aca 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -1656,8 +1656,7 @@ EXPORT_SYMBOL(set_disk_ro);
>   
>   int bdev_read_only(struct block_device *bdev)
>   {
> -	return bdev->bd_read_only ||
> -		test_bit(GD_READ_ONLY, &bdev->bd_disk->state);
> +	return bdev->bd_read_only || get_disk_ro(bdev->bd_disk);
>   }
>   EXPORT_SYMBOL(bdev_read_only);
>   
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare@suse.de                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer

  reply	other threads:[~2020-12-08 16:48 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-08 16:28 split hard read-only vs read-only policy v3 Christoph Hellwig
2020-12-08 16:28 ` [PATCH 1/6] dm: use bdev_read_only to check if a device is read-only Christoph Hellwig
2020-12-08 16:28 ` [PATCH 2/6] block: remove the NULL bdev check in bdev_read_only Christoph Hellwig
2020-12-08 16:45   ` Hannes Reinecke
2020-12-08 16:28 ` [PATCH 3/6] block: add a hard-readonly flag to struct gendisk Christoph Hellwig
2020-12-08 16:28 ` [PATCH 4/6] block: propagate BLKROSET on the whole device to all partitions Christoph Hellwig
2020-12-08 16:47   ` Hannes Reinecke [this message]
2020-12-09  2:51   ` Ming Lei
2020-12-08 16:28 ` [PATCH 5/6] rbd: remove the ->set_read_only method Christoph Hellwig
2020-12-09  2:52   ` Ming Lei
2020-12-08 16:28 ` [PATCH 6/6] nvme: allow revalidate to set a namespace read-only Christoph Hellwig
2020-12-08 16:49   ` Hannes Reinecke
2020-12-09  2:54   ` Ming Lei
  -- strict thread matches above, loose matches on Subject: below --
2021-01-09 10:42 split hard read-only vs read-only policy v3 (resend) Christoph Hellwig
2021-01-09 10:42 ` [PATCH 4/6] block: propagate BLKROSET on the whole device to all partitions Christoph Hellwig
2021-01-10 15:00   ` Hannes Reinecke
2020-12-07 13:19 split hard read-only vs read-only policy v2 Christoph Hellwig
2020-12-07 13:19 ` [PATCH 4/6] block: propagate BLKROSET on the whole device to all partitions Christoph Hellwig
2020-12-08  5:27   ` Martin K. Petersen
2020-12-08  9:25     ` Christoph Hellwig
2020-12-08 12:41       ` Johannes Thumshirn
2020-12-08 10:29   ` Ming Lei
2020-12-08 10:59     ` Christoph Hellwig
2020-12-09  1:23       ` Ming Lei

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=8df170f5-3000-7eba-0482-0066cc24ae71@suse.de \
    --to=hare@suse.de \
    --cc=axboe@kernel.dk \
    --cc=ceph-devel@vger.kernel.org \
    --cc=dm-devel@redhat.com \
    --cc=dongsheng.yang@easystack.cn \
    --cc=hch@lst.de \
    --cc=idryomov@gmail.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=martin.petersen@oracle.com \
    --cc=olkuroch@cisco.com \
    --cc=sagi@grimberg.me \
    --cc=snitzer@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).