Per mapping (block device) `rbd device map` options:
-* rw - Map the image read-write (default).
+* rw - Map the image read-write (default). Overridden by --read-only.
* ro - Map the image read-only. Equivalent to --read-only.
discards (since 4.9).
* exclusive - Disable automatic exclusive lock transitions (since 4.12).
+ Equivalent to --exclusive.
* lock_timeout=x - A timeout on waiting for the acquisition of exclusive lock
(since 4.17, default is 0 seconds, meaning no timeout).
$ sudo rbd unmap $DEV
+"-o rw --read-only" should result in read-only mapping
+======================================================
+
+ $ DEV=$(sudo rbd map -o rw --read-only img)
+ $ blockdev --getro $DEV
+ 1
+ $ sudo rbd unmap $DEV
+
+
Teardown
========
}
MapOptions map_options;
- if (vm["quiesce"].as<bool>()) {
- std::cerr << "rbd: warning: quiesce is not supported" << std::endl;
+ if (vm.count("options")) {
+ for (auto &options : vm["options"].as<std::vector<std::string>>()) {
+ r = parse_map_options(options, &map_options);
+ if (r < 0) {
+ std::cerr << "rbd: couldn't parse map options" << std::endl;
+ return r;
+ }
+ }
}
+
+ // parse options common to all device types after parsing krbd-specific
+ // options so that common options win (in particular "-o rw --read-only"
+ // should result in read-only mapping)
if (vm["read-only"].as<bool>()) {
put_map_option("rw", "ro", &map_options);
}
if (vm["exclusive"].as<bool>()) {
put_map_option("exclusive", "exclusive", &map_options);
}
-
+ if (vm["quiesce"].as<bool>()) {
+ std::cerr << "rbd: warning: quiesce is not supported" << std::endl;
+ }
if (vm.count("quiesce-hook")) {
std::cerr << "rbd: warning: quiesce-hook is not supported" << std::endl;
}
- if (vm.count("options")) {
- for (auto &options : vm["options"].as<std::vector<std::string>>()) {
- r = parse_map_options(options, &map_options);
- if (r < 0) {
- std::cerr << "rbd: couldn't parse map options" << std::endl;
- return r;
- }
- }
- }
-
// connect to the cluster to get the default pool and the default map
// options
librados::Rados rados;