X-Git-Url: http://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fconsumer%2Fconsumer-metadata-cache.h;h=b207cc79c233df23fb926aec7382b83094700a0d;hp=7dcf6976f3ada26eb4adf05beba86e710bc28752;hb=9eac98281fd4923ea52b94abffd0cf8cfa27588e;hpb=93ec662e687dc15a3601704a1e0c96c51ad228c9 diff --git a/src/common/consumer/consumer-metadata-cache.h b/src/common/consumer/consumer-metadata-cache.h index 7dcf6976f..b207cc79c 100644 --- a/src/common/consumer/consumer-metadata-cache.h +++ b/src/common/consumer/consumer-metadata-cache.h @@ -1,41 +1,46 @@ /* - * Copyright (C) 2013 - Julien Desfossez - * David Goulet + * Copyright (C) 2013 Julien Desfossez + * Copyright (C) 2013 David Goulet * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2 only, - * as published by the Free Software Foundation. + * SPDX-License-Identifier: GPL-2.0-only * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef CONSUMER_METADATA_CACHE_H #define CONSUMER_METADATA_CACHE_H #include +#include -struct consumer_metadata_cache { - char *data; - uint64_t cache_alloc_size; +enum consumer_metadata_cache_write_status { + CONSUMER_METADATA_CACHE_WRITE_STATUS_ERROR = -1, + /* + * New metadata content was appended to the cache successfully. + * Previously available content remains valid. + */ + CONSUMER_METADATA_CACHE_WRITE_STATUS_APPENDED_CONTENT = 0, + /* + * The new content pushed to the cache invalidated the content that + * was already present. The contents of the cache should be re-read. + */ + CONSUMER_METADATA_CACHE_WRITE_STATUS_INVALIDATED, /* - * Current version of the metadata cache. + * A metadata cache write can simply overwrite an already existing + * section of the cache (and it should be a write-through with identical + * data). From the caller's standpoint, there is no change to the state + * of the cache. */ + CONSUMER_METADATA_CACHE_WRITE_STATUS_NO_CHANGE, +}; + +struct consumer_metadata_cache { + /* Current version of the metadata cache. */ uint64_t version; /* - * The upper-limit of data written inside the buffer. - * - * With the total_bytes_written it allows us to keep track of when the - * cache contains contiguous metadata ready to be sent to the RB. + * Size is the upper-limit of data written inside the buffer. * All cached data is contiguous. */ - uint64_t max_offset; + struct lttng_dynamic_buffer contents; /* * Lock to update the metadata cache and push into the ring_buffer * (ustctl_write_metadata_to_channel). @@ -45,9 +50,10 @@ struct consumer_metadata_cache { pthread_mutex_t lock; }; -int consumer_metadata_cache_write(struct lttng_consumer_channel *channel, +enum consumer_metadata_cache_write_status +consumer_metadata_cache_write(struct consumer_metadata_cache *cache, unsigned int offset, unsigned int len, uint64_t version, - char *data); + const char *data); int consumer_metadata_cache_allocate(struct lttng_consumer_channel *channel); void consumer_metadata_cache_destroy(struct lttng_consumer_channel *channel); int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel,