rbd: make 'add' modprobe rbd so it has a chance of success

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>
This commit is contained in:
Dan Mick 2013-01-10 18:46:13 -08:00
parent 15bb00cafc
commit e94b06a192

View 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) {