]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: modprobe with single_major=Y on newer kernels 936/head
authorIlya Dryomov <ilya.dryomov@inktank.com>
Fri, 13 Dec 2013 15:40:52 +0000 (17:40 +0200)
committerIlya Dryomov <ilya.dryomov@inktank.com>
Fri, 13 Dec 2013 15:40:52 +0000 (17:40 +0200)
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 <ilya.dryomov@inktank.com>
src/rbd.cc

index 5de6d85134e3337171991235e996a043ae20a464..81a46733fcfe32896e9595d1444352b8e1b153c7 100644 (file)
@@ -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;