From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from verein.lst.de ([213.95.11.211]:51694 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726812AbgKFOIX (ORCPT ); Fri, 6 Nov 2020 09:08:23 -0500 Date: Fri, 6 Nov 2020 15:08:17 +0100 From: Christoph Hellwig Subject: [PATCH, RFC 11/10] block: propagate BLKROSET to all partitions Message-ID: <20201106140817.GA23557@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline List-ID: To: Jens Axboe Cc: Ilya Dryomov , Song Liu , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Stefan Haberland , Jan Hoeppner , linux-block@vger.kernel.org, ceph-devel@vger.kernel.org, linux-bcache@vger.kernel.org, linux-raid@vger.kernel.org, linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org, martin.petersen@oracle.com When setting the whole device read-only (or clearing the read-only state), also update the policy for all partitions. The s390 dasd driver has awlways been doing this and it makes a lot of sense. Signed-off-by: Christoph Hellwig --- block/ioctl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/block/ioctl.c b/block/ioctl.c index 6b785181344fe1..22f394d118c302 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -354,7 +354,10 @@ static int blkdev_roset(struct block_device *bdev, fmode_t mode, if (ret) return ret; } - bdev->bd_part->policy = n; + if (bdev_is_partition(bdev)) + bdev->bd_part->policy = n; + else + set_disk_ro(bdev->bd_disk, n); return 0; } -- 2.28.0