usage: rbd nbd map [--pool <pool>] [--image <image>] [--snap <snap>]
[--read-only] [--exclusive] [--device <device>]
[--nbds_max <nbds_max>] [--max_part <max_part>]
+ [--timeout <timeout>]
<image-or-snap-spec>
Map image to a nbd device.
--device arg specify nbd device
--nbds_max arg override module param nbds_max
--max_part arg override module param max_part
+ --timeout arg set nbd request timeout (seconds)
rbd help nbd unmap
usage: rbd nbd unmap
("exclusive", po::bool_switch(), "forbid writes by other clients")
("device", po::value<std::string>(), "specify nbd device")
("nbds_max", po::value<std::string>(), "override module param nbds_max")
- ("max_part", po::value<std::string>(), "override module param max_part");
+ ("max_part", po::value<std::string>(), "override module param max_part")
+ ("timeout", po::value<std::string>(), "set nbd request timeout (seconds)");
}
int execute_map(const po::variables_map &vm)
args.push_back("--max_part");
args.push_back(vm["max_part"].as<std::string>().c_str());
}
+ if (vm.count("timeout")) {
+ args.push_back("--timeout");
+ args.push_back(vm["timeout"].as<std::string>().c_str());
+ }
return call_nbd_cmd(vm, args);
}
struct Config {
int nbds_max = 0;
int max_part = 255;
+ int timeout = -1;
bool exclusive = false;
bool readonly = false;
<< " --nbds_max <limit> Override for module param nbds_max\n"
<< " --max_part <limit> Override for module param max_part\n"
<< " --exclusive Forbid writes by other clients\n"
+ << " --timeout <seconds> Set nbd request timeout\n"
<< std::endl;
generic_server_usage();
}
goto close_nbd;
}
+ if (cfg->timeout >= 0) {
+ r = ioctl(nbd, NBD_SET_TIMEOUT, (unsigned long)cfg->timeout);
+ if (r < 0) {
+ r = -errno;
+ cerr << "rbd-nbd: failed to set timeout: " << cpp_strerror(r)
+ << std::endl;
+ goto close_nbd;
+ }
+ }
+
{
uint64_t handle;
cfg->readonly = true;
} else if (ceph_argparse_flag(args, i, "--exclusive", (char *)NULL)) {
cfg->exclusive = true;
+ } else if (ceph_argparse_witharg(args, i, &cfg->timeout, err, "--timeout",
+ (char *)NULL)) {
+ if (!err.str().empty()) {
+ *err_msg << "rbd-nbd: " << err.str();
+ return -EINVAL;
+ }
+ if (cfg->timeout < 0) {
+ *err_msg << "rbd-nbd: Invalid argument for timeout!";
+ return -EINVAL;
+ }
} else {
++i;
}