From: Ilya Dryomov Date: Thu, 17 Oct 2019 14:23:41 +0000 (+0200) Subject: krbd: modprobe before calling build_map_buf() X-Git-Tag: v15.1.0~1225^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=286bdbfe248e4d7a4a621cf39f01e010719f6ce8;p=ceph.git krbd: modprobe before calling build_map_buf() Otherwise add_key() in set_kernel_secret() fails as if running against an ancient kernel and we fall back to secret= in options for the first image being mapped on the machine. Signed-off-by: Ilya Dryomov --- diff --git a/qa/rbd/krbd_modprobe.t b/qa/rbd/krbd_modprobe.t new file mode 100644 index 0000000000000..a0e04d39461d0 --- /dev/null +++ b/qa/rbd/krbd_modprobe.t @@ -0,0 +1,10 @@ + + $ sudo modprobe -r rbd + $ sudo modprobe -r libceph + $ lsmod | grep libceph + [1] + $ rbd create --size 1 img + $ DEV=$(sudo rbd map img) + $ sudo grep -q ',key=' /sys/bus/rbd/devices/${DEV#/dev/rbd}/config_info + $ sudo rbd unmap $DEV + $ rbd rm --no-progress img diff --git a/qa/suites/krbd/basic/tasks/krbd_modprobe.yaml b/qa/suites/krbd/basic/tasks/krbd_modprobe.yaml new file mode 100644 index 0000000000000..22f02cd402b79 --- /dev/null +++ b/qa/suites/krbd/basic/tasks/krbd_modprobe.yaml @@ -0,0 +1,5 @@ +tasks: +- cram: + clients: + client.0: + - qa/rbd/krbd_modprobe.t diff --git a/src/krbd.cc b/src/krbd.cc index f766a4e8c90fb..7f9faa6893636 100644 --- a/src/krbd.cc +++ b/src/krbd.cc @@ -357,13 +357,12 @@ static int map_image(struct krbd_ctx *ctx, const krbd_spec& spec, string buf; int r; - r = build_map_buf(ctx->cct, spec, options, &buf); - if (r < 0) - return r; - /* * Modprobe rbd kernel module. If it supports single-major device * number allocation scheme, make sure it's turned on. + * + * Do this before calling build_map_buf() - it wants "ceph" key type + * registered. */ if (access("/sys/bus/rbd", F_OK) != 0) { const char *module_options = NULL; @@ -381,6 +380,10 @@ static int map_image(struct krbd_ctx *ctx, const krbd_spec& spec, } } + r = build_map_buf(ctx->cct, spec, options, &buf); + if (r < 0) + return r; + return do_map(ctx->udev, spec, buf, pname); }