+/*
+ * Reset the metadata cache.
+ */
+static
+void metadata_cache_reset(struct consumer_metadata_cache *cache)
+{
+ memset(cache->data, 0, cache->cache_alloc_size);
+ cache->max_offset = 0;
+}
+
+/*
+ * Check if the metadata cache version changed.
+ * If it did, reset the metadata cache.
+ * The metadata cache lock MUST be held.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+static
+int metadata_cache_check_version(struct consumer_metadata_cache *cache,
+ struct lttng_consumer_channel *channel, uint64_t version)
+{
+ int ret = 0;
+
+ if (cache->version == version) {
+ goto end;
+ }
+
+ DBG("Metadata cache version update to %" PRIu64, version);
+ metadata_cache_reset(cache);
+ cache->version = version;
+
+end:
+ return ret;
+}
+