@@ -402,7 +402,10 @@ static int blkdev_roset(struct block_device *bdev, unsigned cmd,
if (ret)
return ret;
}
- bdev->bd_read_only = n;
+ if (n)
+ bdev_set_flag(bdev, BD_READ_ONLY);
+ else
+ bdev_clear_flag(bdev, BD_READ_ONLY);
return 0;
}
@@ -46,7 +46,6 @@ struct block_device {
struct disk_stats __percpu *bd_stats;
unsigned long bd_stamp;
u32 __bd_flags; // partition number + flags
- bool bd_read_only; /* read-only policy */
bool bd_write_holder;
bool bd_has_submit_bio;
dev_t bd_dev;
@@ -86,6 +85,10 @@ struct block_device {
#define bdev_kobj(_bdev) \
(&((_bdev)->bd_device.kobj))
+enum {
+ BD_READ_ONLY, // read-only policy
+};
+
/*
* Block error status values. See block/blk-core:blk_errors for the details.
* Alpha cannot write a byte atomically, so we need to use 32-bit value.
@@ -758,13 +758,13 @@ static inline void bdev_clear_flag(struct block_device *bdev, int flag)
static inline int get_disk_ro(struct gendisk *disk)
{
- return disk->part0->bd_read_only ||
+ return bdev_test_flag(disk->part0, BD_READ_ONLY) ||
test_bit(GD_READ_ONLY, &disk->state);
}
static inline int bdev_read_only(struct block_device *bdev)
{
- return bdev->bd_read_only || get_disk_ro(bdev->bd_disk);
+ return bdev_test_flag(bdev, BD_READ_ONLY) || get_disk_ro(bdev->bd_disk);
}
bool set_capacity_and_notify(struct gendisk *disk, sector_t size);
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> --- block/ioctl.c | 5 ++++- include/linux/blk_types.h | 5 ++++- include/linux/blkdev.h | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-)