Skip to content

Commit b948ad7

Browse files
committed
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 a32e236 ("Partially revert "block: fail op_is_write() requests to read-only partitions""). Signed-off-by: Ilya Dryomov <[email protected]> Reviewed-by: Jason Dillaman <[email protected]> Reviewed-by: Dongsheng Yang <[email protected]>
1 parent 39258aa commit b948ad7

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

drivers/block/rbd.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4837,11 +4837,14 @@ static void rbd_queue_workfn(struct work_struct *work)
48374837
goto err_rq;
48384838
}
48394839

4840-
if (op_type != OBJ_OP_READ && rbd_is_snap(rbd_dev)) {
4841-
rbd_warn(rbd_dev, "%s on read-only snapshot",
4842-
obj_op_name(op_type));
4843-
result = -EIO;
4844-
goto err;
4840+
if (op_type != OBJ_OP_READ) {
4841+
if (rbd_is_ro(rbd_dev)) {
4842+
rbd_warn(rbd_dev, "%s on read-only mapping",
4843+
obj_op_name(op_type));
4844+
result = -EIO;
4845+
goto err;
4846+
}
4847+
rbd_assert(!rbd_is_snap(rbd_dev));
48454848
}
48464849

48474850
/*

0 commit comments

Comments
 (0)