diff options
author | Ilya Dryomov <idryomov@gmail.com> | 2019-11-08 15:26:51 +0100 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2019-11-25 11:44:02 +0100 |
commit | b948ad78971fb2c6ed6b53b0edbdd720cfe08d9f (patch) | |
tree | 156192d5d3ce5a560a8c29af39af4e4dd4fe96fd /drivers/block/rbd.c | |
parent | rbd: introduce RBD_DEV_FLAG_READONLY (diff) | |
download | linux-b948ad78971fb2c6ed6b53b0edbdd720cfe08d9f.tar.xz linux-b948ad78971fb2c6ed6b53b0edbdd720cfe08d9f.zip |
rbd: treat images mapped read-only seriously
Even though -o ro/-o read_only/--read-only options are very old, we
have never really treated them seriously (on par with snapshots). As
a first step, fail writes to images mapped read-only just like we do
for snapshots.
We need this check in rbd because the block layer basically ignores
read-only setting, see commit a32e236eb93e ("Partially revert "block:
fail op_is_write() requests to read-only partitions"").
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Jason Dillaman <dillaman@redhat.com>
Reviewed-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
Diffstat (limited to 'drivers/block/rbd.c')
-rw-r--r-- | drivers/block/rbd.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 978549d21f4f..02cd2a7df6dd 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -4837,11 +4837,14 @@ static void rbd_queue_workfn(struct work_struct *work) goto err_rq; } - if (op_type != OBJ_OP_READ && rbd_is_snap(rbd_dev)) { - rbd_warn(rbd_dev, "%s on read-only snapshot", - obj_op_name(op_type)); - result = -EIO; - goto err; + if (op_type != OBJ_OP_READ) { + if (rbd_is_ro(rbd_dev)) { + rbd_warn(rbd_dev, "%s on read-only mapping", + obj_op_name(op_type)); + result = -EIO; + goto err; + } + rbd_assert(!rbd_is_snap(rbd_dev)); } /* |