]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
librbd/cache/pwl: fix parsing of cache_type in create_image_cache_state() 41244/head
authorIlya Dryomov <idryomov@gmail.com>
Wed, 5 May 2021 10:29:44 +0000 (12:29 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Sun, 9 May 2021 20:10:16 +0000 (22:10 +0200)
commit859d62f4d6a1dbb9c7c5f25de06bed90aca22ead
treea35e5523fc9736d963e51222148fb1eb41c28a47
parent9b70e932b3dad62a7660cc75d5b6cafe54feb1e1
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>
(cherry picked from commit ec7af7ede9beacec91140996abe343a5db48004f)
src/librbd/cache/pwl/ImageCacheState.cc