From: Ilya Dryomov Date: Fri, 13 Dec 2013 15:40:52 +0000 (+0200) Subject: rbd: modprobe with single_major=Y on newer kernels X-Git-Tag: v0.75~113^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F936%2Fhead;p=ceph.git 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 --- diff --git a/src/rbd.cc b/src/rbd.cc index 5de6d85134e3..81a46733fcfe 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;