From eae8531e42f2f18528530d3966588c653e70a0bd Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Fri, 13 Dec 2013 17:40:52 +0200 Subject: [PATCH] rbd: modprobe with single_major=Y on newer kernels On kernels that support it, and if 'rbd map' is given a chance to modprobe, turn on single-major device number allocation scheme. For users who for some reason don't want it, the workaround is to insert the rbd module manually before executing the first 'rbd map' command. Signed-off-by: Ilya Dryomov --- src/rbd.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/rbd.cc b/src/rbd.cc index 5de6d85134e33..81a46733fcfe3 100644 --- a/src/rbd.cc +++ b/src/rbd.cc @@ -1695,7 +1695,17 @@ static int do_kernel_add(const char *poolname, const char *imgname, // modprobe the rbd module if /sys/bus/rbd doesn't exist struct stat sb; if ((stat("/sys/bus/rbd", &sb) < 0) || (!S_ISDIR(sb.st_mode))) { - r = system("/sbin/modprobe rbd"); + // turn on single-major device number allocation scheme if the + // kernel supports it + const char *cmd = "/sbin/modprobe rbd"; + r = system("/sbin/modinfo -F parm rbd | /bin/grep -q ^single_major:"); + if (r == 0) { + cmd = "/sbin/modprobe rbd single_major=Y"; + } else if (r < 0) { + cerr << "rbd: error executing modinfo as shell command!" << std::endl; + } + + r = system(cmd); if (r) { if (r < 0) cerr << "rbd: error executing modprobe as shell command!" << std::endl; -- 2.39.5