]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: make 'add' modprobe rbd so it has a chance of success
authorDan Mick <dan.mick@inktank.com>
Fri, 11 Jan 2013 02:46:13 +0000 (18:46 -0800)
committerDan Mick <dan.mick@inktank.com>
Fri, 11 Jan 2013 22:28:50 +0000 (14:28 -0800)
Check for existence of /sys/bus/rbd first to avoid unnecessary calls

Fixes: #3784
Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Alex Elder <elder@inktank.com>
src/rbd.cc

index c2c61811ce7e1dd2b0eec982942dd5afee0dace8..a1b79ea2de1c490ad6a7bb7761e62fc4aa95f231 100644 (file)
@@ -1194,6 +1194,11 @@ static int do_kernel_add(const char *poolname, const char *imgname, const char *
     oss << " " << snapname;
   }
 
+  // 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)))
+    system("/sbin/modprobe rbd");
+
   // write to /sys/bus/rbd/add
   int fd = open("/sys/bus/rbd/add", O_WRONLY);
   if (fd < 0) {