]> www.infradead.org Git - users/hch/block.git/commitdiff
block: propagate BLKROSET to all partitions
authorChristoph Hellwig <hch@lst.de>
Fri, 6 Nov 2020 14:04:45 +0000 (15:04 +0100)
committerChristoph Hellwig <hch@lst.de>
Sat, 14 Nov 2020 17:26:32 +0000 (18:26 +0100)
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 <hch@lst.de>
block/ioctl.c

index 6b785181344fe197d1b72f94367e319bfe320ed1..22f394d118c302e9104dbf56cacf601ad74ea641 100644 (file)
@@ -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;
 }