]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commit
librbd/cache/pwl: fix parsing of cache_type in create_image_cache_state()
authorIlya Dryomov <idryomov@gmail.com>
Wed, 5 May 2021 10:29:44 +0000 (12:29 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 5 May 2021 22:55:50 +0000 (00:55 +0200)
commitec7af7ede9beacec91140996abe343a5db48004f
treec6c9537b36b921dd046391ce4f72ea095a94a2a2
parent2e412cfddfc43d50a1dbf293a8e3f6dd7bd88d9a
librbd/cache/pwl: fix parsing of cache_type in create_image_cache_state()

cache_type is a string (currently "ssd" or "rwl"), not an int.  When
coerced to an int, the result is 0 -- JSONFormattable ends up calling
atoi() under the hood and atoi() does not detect errors...

As the value of rbd_persistent_cache_mode option is validated by the
option parser (enum type) and, separately, ImageCacheState::cache_type
is validated in InitRequest::get_image_cache_state() when creating
an instance of the approprate WriteLog, don't attempt to validate it
in ImageCacheState::create_image_cache_state().

Fixes: https://tracker.ceph.com/issues/50668
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
src/librbd/cache/pwl/ImageCacheState.cc