Commit b948ad78 authored by Ilya Dryomov's avatar Ilya Dryomov

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 a32e236e ("Partially revert "block:
fail op_is_write() requests to read-only partitions"").
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
Reviewed-by: default avatarJason Dillaman <dillaman@redhat.com>
Reviewed-by: default avatarDongsheng Yang <dongsheng.yang@easystack.cn>
parent 39258aa2
...@@ -4837,12 +4837,15 @@ static void rbd_queue_workfn(struct work_struct *work) ...@@ -4837,12 +4837,15 @@ static void rbd_queue_workfn(struct work_struct *work)
goto err_rq; goto err_rq;
} }
if (op_type != OBJ_OP_READ && rbd_is_snap(rbd_dev)) { if (op_type != OBJ_OP_READ) {
rbd_warn(rbd_dev, "%s on read-only snapshot", if (rbd_is_ro(rbd_dev)) {
rbd_warn(rbd_dev, "%s on read-only mapping",
obj_op_name(op_type)); obj_op_name(op_type));
result = -EIO; result = -EIO;
goto err; goto err;
} }
rbd_assert(!rbd_is_snap(rbd_dev));
}
/* /*
* Quit early if the mapped snapshot no longer exists. It's * Quit early if the mapped snapshot no longer exists. It's
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment