From b2a86bd50fb6a993452b4728ba6e60b9c7617c7a Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Wed, 17 Jun 2020 14:13:12 +0200 Subject: [PATCH] rbd: recognize compression_hint map option Signed-off-by: Ilya Dryomov (cherry picked from commit 4983eabd6fe75bb6f669d9d18388349f342a5d27) --- doc/man/8/rbd.rst | 10 ++++++++++ src/tools/rbd/action/Kernel.cc | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/doc/man/8/rbd.rst b/doc/man/8/rbd.rst index ffc651546e944..52a684fcdfe7a 100644 --- a/doc/man/8/rbd.rst +++ b/doc/man/8/rbd.rst @@ -833,6 +833,16 @@ Per mapping (block device) `rbd device map` options: require-osd-release octopus"). Otherwise it should be limited to read-only workloads such as images mapped read-only everywhere or snapshots. +* compression_hint=none - Don't set compression hints (since 5.8, default). + +* compression_hint=compressible - Hint to the underlying OSD object store + backend that the data is compressible, enabling compression in passive mode + (since 5.8). + +* compression_hint=incompressible - Hint to the underlying OSD object store + backend that the data is incompressible, disabling compression in aggressive + mode (since 5.8). + `rbd device unmap` options: * force - Force the unmapping of a block device that is open (since 4.9). The diff --git a/src/tools/rbd/action/Kernel.cc b/src/tools/rbd/action/Kernel.cc index 6013067ac9af2..eb57bfa1f37eb 100644 --- a/src/tools/rbd/action/Kernel.cc +++ b/src/tools/rbd/action/Kernel.cc @@ -78,6 +78,15 @@ static std::string map_option_read_from_replica_cb(const char *value_char) return ""; } +static std::string map_option_compression_hint_cb(const char *value_char) +{ + if (!strcmp(value_char, "none") || !strcmp(value_char, "compressible") || + !strcmp(value_char, "incompressible")) { + return value_char; + } + return ""; +} + static void put_map_option(const std::string &key, const std::string &val) { map_options[key] = val; @@ -175,6 +184,10 @@ static int parse_map_options(const std::string &options_string) if (put_map_option_value("read_from_replica", value_char, map_option_read_from_replica_cb)) return -EINVAL; + } else if (!strcmp(this_char, "compression_hint")) { + if (put_map_option_value("compression_hint", value_char, + map_option_compression_hint_cb)) + return -EINVAL; } else { std::cerr << "rbd: unknown map option '" << this_char << "'" << std::endl; return -EINVAL; -- 2.39.5