]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
librbd/cache/pwl: handle invalid ImageCacheState json
authorIlya Dryomov <idryomov@gmail.com>
Thu, 7 Apr 2022 14:02:46 +0000 (16:02 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 13 Apr 2022 10:57:45 +0000 (12:57 +0200)
commita9f1c24bc0d5d5d9e5a1436f03cb9d7ac3591504
tree931f0a61f5b6a35eee2bd358dd2959c5de7bade4
parent841df61fa3f9ab33685b07a57bcac0eda1666db2
librbd/cache/pwl: handle invalid ImageCacheState json

get_json_format() and create_image_cache_state() attempt to get
particular keys which could result in an unhandled std::runtime_error
exception.  Conversely, ImageCacheState constructor just swallows that
exception which could leave the newly constructed object incorrectly
initialized.  Avoid doing parsing in the constructor and introduce
init_from_config() and init_from_metadata() methods instead.

While at it, move everything out from under "persistent_cache" key.
Also fix init_state_json_write test case which stopped working now
that types are enforced by json_spirit.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit 7678ee2490965a8a73c02a47283adaa5036dbcab)
src/librbd/cache/pwl/ImageCacheState.cc
src/librbd/cache/pwl/ImageCacheState.h
src/test/librbd/cache/pwl/test_mock_ReplicatedWriteLog.cc
src/test/librbd/cache/pwl/test_mock_SSDWriteLog.cc