From: Jianpeng Ma Date: Wed, 1 Dec 2021 08:58:25 +0000 (+0800) Subject: librbd/cache/pwl: it should in apply_metadata set discard_granularity for pwl cache. X-Git-Tag: v17.1.0~311^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=86223d039b587e768d71ce1266e85dde8a46a50a;p=ceph.git librbd/cache/pwl: it should in apply_metadata set discard_granularity for pwl cache. Function apply_meta can overwrite discard_granularity_bytes based on option. Fixes:https://tracker.ceph.com/issues/53434 Signed-off-by: Jianpeng Ma --- diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index 8a8e87a33625..7d41376325e6 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -802,7 +802,9 @@ librados::IoCtx duplicate_io_ctx(librados::IoCtx& io_ctx) { if (sparse_read_threshold_bytes == 0) { sparse_read_threshold_bytes = get_object_size(); } - if (!skip_partial_discard) { + + bool dirty_cache = test_features(RBD_FEATURE_DIRTY_CACHE); + if (!skip_partial_discard || dirty_cache) { discard_granularity_bytes = 0; } diff --git a/src/librbd/cache/pwl/InitRequest.cc b/src/librbd/cache/pwl/InitRequest.cc index a6d0fb44a1de..13fc539dce90 100644 --- a/src/librbd/cache/pwl/InitRequest.cc +++ b/src/librbd/cache/pwl/InitRequest.cc @@ -178,12 +178,6 @@ void InitRequest::handle_set_feature_bit(int r) { shutdown_image_cache(); } - if (m_image_ctx.discard_granularity_bytes) { - ldout(cct, 1) << "RWL image cache is enabled and " - << "set discard_granularity_bytes = 0." << dendl; - m_image_ctx.discard_granularity_bytes = 0; - } - // Register RWL dispatch auto image_dispatch = new cache::WriteLogImageDispatch( &m_image_ctx, m_image_cache, m_plugin_api);