]> 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>
Mon, 11 Apr 2022 06:26:47 +0000 (08:26 +0200)
commit7678ee2490965a8a73c02a47283adaa5036dbcab
treeef724181e699cf5cfa6dd3cbead11cc65b09e0a5
parent769f3a06ecf85249c1473cbb6bab7503beb1ba78
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>
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