Commit b948ad78 authored by Ilya Dryomov's avatar Ilya Dryomov
Browse files

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
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -4837,12 +4837,15 @@ 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",
	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));
	}

	/*
	 * Quit early if the mapped snapshot no longer exists.  It's