lderr(cct) << "could not release all objects from cache" << dendl;
}
+ void ImageCtx::clear_nonexistence_cache() {
+ if (!object_cacher)
+ return;
+ cache_lock.Lock();
+ object_cacher->clear_nonexistence(object_set);
+ cache_lock.Unlock();
+ }
+
int ImageCtx::register_watch() {
assert(!wctx);
wctx = new WatchCtx(this);
ictx->get_parent_pool_id(ictx->snap_id) ||
ictx->parent->id != ictx->get_parent_image_id(ictx->snap_id) ||
ictx->parent->snap_id != ictx->get_parent_snap_id(ictx->snap_id)) {
+ ictx->clear_nonexistence_cache();
close_image(ictx->parent);
ictx->parent = NULL;
}
def test_flatten_larger_order(self):
self.check_flatten_with_order(IMG_ORDER + 2)
+
+ def test_flatten_drops_cache(self):
+ global ioctx
+ global features
+ self.rbd.clone(ioctx, IMG_NAME, 'snap1', ioctx, 'clone2',
+ features, IMG_ORDER)
+ with Image(ioctx, 'clone2') as clone:
+ with Image(ioctx, 'clone2') as clone2:
+ # cache object non-existence
+ data = clone.read(IMG_SIZE / 2, 256)
+ clone2_data = clone2.read(IMG_SIZE / 2, 256)
+ eq(data, clone2_data)
+ clone.flatten()
+ assert_raises(ImageNotFound, clone.parent_info)
+ assert_raises(ImageNotFound, clone2.parent_info)
+ after_flatten = clone.read(IMG_SIZE / 2, 256)
+ eq(data, after_flatten)
+ after_flatten = clone2.read(IMG_SIZE / 2, 256)
+ eq(data, after_flatten)
+ self.rbd.remove(ioctx, 'clone2')