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
========
return r;
}
- if (vm["read-only"].as<bool>()) {
- put_map_option("rw", "ro");
- }
- if (vm["exclusive"].as<bool>()) {
- put_map_option("exclusive", "exclusive");
- }
-
// parse default options first so they can be overwritten by cli options
r = parse_map_options(
g_conf().get_val<std::string>("rbd_default_map_options"));
}
}
+ // 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");
+ }
+ if (vm["exclusive"].as<bool>()) {
+ put_map_option("exclusive", "exclusive");
+ }
+
utils::init_context();
r = do_kernel_map(pool_name.c_str(), nspace_name.c_str(), image_name.c_str(),