1
0
Fork 0

rbd: don't establish watch for read-only mappings

With exclusive lock out of the way, watch is the only thing left that
prevents a read-only mapping from being used with read-only OSD caps.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Jason Dillaman <dillaman@redhat.com>
Reviewed-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
alistair/sunxi64-5.5-dsi
Ilya Dryomov 2019-11-12 20:20:04 +01:00
parent 3fe69921db
commit b9ef2b8858
1 changed files with 27 additions and 14 deletions

View File

@ -6961,6 +6961,24 @@ static int rbd_dev_header_name(struct rbd_device *rbd_dev)
return ret; return ret;
} }
static void rbd_print_dne(struct rbd_device *rbd_dev, bool is_snap)
{
if (!is_snap) {
pr_info("image %s/%s%s%s does not exist\n",
rbd_dev->spec->pool_name,
rbd_dev->spec->pool_ns ?: "",
rbd_dev->spec->pool_ns ? "/" : "",
rbd_dev->spec->image_name);
} else {
pr_info("snap %s/%s%s%s@%s does not exist\n",
rbd_dev->spec->pool_name,
rbd_dev->spec->pool_ns ?: "",
rbd_dev->spec->pool_ns ? "/" : "",
rbd_dev->spec->image_name,
rbd_dev->spec->snap_name);
}
}
static void rbd_dev_image_release(struct rbd_device *rbd_dev) static void rbd_dev_image_release(struct rbd_device *rbd_dev)
{ {
rbd_dev_unprobe(rbd_dev); rbd_dev_unprobe(rbd_dev);
@ -6979,6 +6997,7 @@ static void rbd_dev_image_release(struct rbd_device *rbd_dev)
*/ */
static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth) static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth)
{ {
bool need_watch = !rbd_is_ro(rbd_dev);
int ret; int ret;
/* /*
@ -6995,22 +7014,21 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth)
if (ret) if (ret)
goto err_out_format; goto err_out_format;
if (!depth) { if (need_watch) {
ret = rbd_register_watch(rbd_dev); ret = rbd_register_watch(rbd_dev);
if (ret) { if (ret) {
if (ret == -ENOENT) if (ret == -ENOENT)
pr_info("image %s/%s%s%s does not exist\n", rbd_print_dne(rbd_dev, false);
rbd_dev->spec->pool_name,
rbd_dev->spec->pool_ns ?: "",
rbd_dev->spec->pool_ns ? "/" : "",
rbd_dev->spec->image_name);
goto err_out_format; goto err_out_format;
} }
} }
ret = rbd_dev_header_info(rbd_dev); ret = rbd_dev_header_info(rbd_dev);
if (ret) if (ret) {
if (ret == -ENOENT && !need_watch)
rbd_print_dne(rbd_dev, false);
goto err_out_watch; goto err_out_watch;
}
/* /*
* If this image is the one being mapped, we have pool name and * If this image is the one being mapped, we have pool name and
@ -7024,12 +7042,7 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth)
ret = rbd_spec_fill_names(rbd_dev); ret = rbd_spec_fill_names(rbd_dev);
if (ret) { if (ret) {
if (ret == -ENOENT) if (ret == -ENOENT)
pr_info("snap %s/%s%s%s@%s does not exist\n", rbd_print_dne(rbd_dev, true);
rbd_dev->spec->pool_name,
rbd_dev->spec->pool_ns ?: "",
rbd_dev->spec->pool_ns ? "/" : "",
rbd_dev->spec->image_name,
rbd_dev->spec->snap_name);
goto err_out_probe; goto err_out_probe;
} }
@ -7061,7 +7074,7 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth)
err_out_probe: err_out_probe:
rbd_dev_unprobe(rbd_dev); rbd_dev_unprobe(rbd_dev);
err_out_watch: err_out_watch:
if (!depth) if (need_watch)
rbd_unregister_watch(rbd_dev); rbd_unregister_watch(rbd_dev);
err_out_format: err_out_format:
rbd_dev->image_format = 0; rbd_dev->image_format = 0;