aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/block/rbd.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index fb7cb38a6d83..53b1ced21a13 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -348,7 +348,6 @@ struct rbd_client_id {
348struct rbd_mapping { 348struct rbd_mapping {
349 u64 size; 349 u64 size;
350 u64 features; 350 u64 features;
351 bool read_only;
352}; 351};
353 352
354/* 353/*
@@ -608,9 +607,6 @@ static int rbd_open(struct block_device *bdev, fmode_t mode)
608 struct rbd_device *rbd_dev = bdev->bd_disk->private_data; 607 struct rbd_device *rbd_dev = bdev->bd_disk->private_data;
609 bool removing = false; 608 bool removing = false;
610 609
611 if ((mode & FMODE_WRITE) && rbd_dev->mapping.read_only)
612 return -EROFS;
613
614 spin_lock_irq(&rbd_dev->lock); 610 spin_lock_irq(&rbd_dev->lock);
615 if (test_bit(RBD_DEV_FLAG_REMOVING, &rbd_dev->flags)) 611 if (test_bit(RBD_DEV_FLAG_REMOVING, &rbd_dev->flags))
616 removing = true; 612 removing = true;
@@ -4028,15 +4024,8 @@ static void rbd_queue_workfn(struct work_struct *work)
4028 goto err_rq; 4024 goto err_rq;
4029 } 4025 }
4030 4026
4031 /* Only reads are allowed to a read-only device */ 4027 rbd_assert(op_type == OBJ_OP_READ ||
4032 4028 rbd_dev->spec->snap_id == CEPH_NOSNAP);
4033 if (op_type != OBJ_OP_READ) {
4034 if (rbd_dev->mapping.read_only) {
4035 result = -EROFS;
4036 goto err_rq;
4037 }
4038 rbd_assert(rbd_dev->spec->snap_id == CEPH_NOSNAP);
4039 }
4040 4029
4041 /* 4030 /*
4042 * Quit early if the mapped snapshot no longer exists. It's 4031 * Quit early if the mapped snapshot no longer exists. It's
@@ -5972,7 +5961,7 @@ static int rbd_dev_device_setup(struct rbd_device *rbd_dev)
5972 goto err_out_disk; 5961 goto err_out_disk;
5973 5962
5974 set_capacity(rbd_dev->disk, rbd_dev->mapping.size / SECTOR_SIZE); 5963 set_capacity(rbd_dev->disk, rbd_dev->mapping.size / SECTOR_SIZE);
5975 set_disk_ro(rbd_dev->disk, rbd_dev->mapping.read_only); 5964 set_disk_ro(rbd_dev->disk, rbd_dev->opts->read_only);
5976 5965
5977 ret = dev_set_name(&rbd_dev->dev, "%d", rbd_dev->dev_id); 5966 ret = dev_set_name(&rbd_dev->dev, "%d", rbd_dev->dev_id);
5978 if (ret) 5967 if (ret)
@@ -6123,7 +6112,6 @@ static ssize_t do_rbd_add(struct bus_type *bus,
6123 struct rbd_options *rbd_opts = NULL; 6112 struct rbd_options *rbd_opts = NULL;
6124 struct rbd_spec *spec = NULL; 6113 struct rbd_spec *spec = NULL;
6125 struct rbd_client *rbdc; 6114 struct rbd_client *rbdc;
6126 bool read_only;
6127 int rc; 6115 int rc;
6128 6116
6129 if (!try_module_get(THIS_MODULE)) 6117 if (!try_module_get(THIS_MODULE))
@@ -6172,11 +6160,8 @@ static ssize_t do_rbd_add(struct bus_type *bus,
6172 } 6160 }
6173 6161
6174 /* If we are mapping a snapshot it must be marked read-only */ 6162 /* If we are mapping a snapshot it must be marked read-only */
6175
6176 read_only = rbd_dev->opts->read_only;
6177 if (rbd_dev->spec->snap_id != CEPH_NOSNAP) 6163 if (rbd_dev->spec->snap_id != CEPH_NOSNAP)
6178 read_only = true; 6164 rbd_dev->opts->read_only = true;
6179 rbd_dev->mapping.read_only = read_only;
6180 6165
6181 rc = rbd_dev_device_setup(rbd_dev); 6166 rc = rbd_dev_device_setup(rbd_dev);
6182 if (rc) 6167 if (rc)