From: Mathieu Desnoyers Date: Mon, 13 Apr 2020 16:49:11 +0000 (-0400) Subject: wrapper: remove kref_get wrapper X-Git-Tag: for-upstreaming-review-1~96 X-Git-Url: http://git.lttng.org/?p=lttng-modules.git;a=commitdiff_plain;h=2d70eed13e3c9a656eec50677940f8ef99eccabf wrapper: remove kref_get wrapper --- diff --git a/lib/ringbuffer/ring_buffer_frontend.c b/lib/ringbuffer/ring_buffer_frontend.c index f9397878..664e8652 100644 --- a/lib/ringbuffer/ring_buffer_frontend.c +++ b/lib/ringbuffer/ring_buffer_frontend.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -48,7 +49,6 @@ #include #include #include -#include #include #include @@ -1021,10 +1021,7 @@ int lib_ring_buffer_open_read(struct lib_ring_buffer *buf) if (!atomic_long_add_unless(&buf->active_readers, 1, 1)) return -EBUSY; - if (!lttng_kref_get(&chan->ref)) { - atomic_long_dec(&buf->active_readers); - return -EOVERFLOW; - } + kref_get(&chan->ref); lttng_smp_mb__after_atomic(); return 0; } diff --git a/lttng-abi.c b/lttng-abi.c index baaf34d3..3be91fcf 100644 --- a/lttng-abi.c +++ b/lttng-abi.c @@ -30,12 +30,12 @@ #include #include #include +#include #include #include #include #include #include -#include #include #include #include @@ -1177,11 +1177,7 @@ int lttng_abi_open_metadata_stream(struct file *channel_file) goto notransport; } - if (!lttng_kref_get(&session->metadata_cache->refcount)) { - ret = -EOVERFLOW; - goto kref_error; - } - + kref_get(&session->metadata_cache->refcount); ret = lttng_abi_create_stream_fd(channel_file, stream_priv, <tng_metadata_ring_buffer_file_operations); if (ret < 0) @@ -1193,7 +1189,6 @@ int lttng_abi_open_metadata_stream(struct file *channel_file) fd_error: kref_put(&session->metadata_cache->refcount, metadata_cache_destroy); -kref_error: module_put(metadata_stream->transport->owner); notransport: kfree(metadata_stream); diff --git a/wrapper/kref.h b/wrapper/kref.h deleted file mode 100644 index f3b5053f..00000000 --- a/wrapper/kref.h +++ /dev/null @@ -1,39 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only - * - * wrapper/kref.h - * - * wrapper around linux/kref.h. - * - * Copyright (C) 2016 Mathieu Desnoyers - * - * This wrapper code is derived from Linux 3.19.2 include/linux/list.h - * and include/linux/rculist.h, hence the GPLv2 license applied to this - * file. - */ - -#ifndef _LTTNG_WRAPPER_KREF_H -#define _LTTNG_WRAPPER_KREF_H - -#include -#include -#include - -/* - * lttng_kref_get: get reference count, checking for overflow. - * - * Return 1 if reference is taken, 0 otherwise (overflow). - */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) -static inline int lttng_kref_get(struct kref *kref) -{ - kref_get(kref); - return 1; -} -#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */ -static inline int lttng_kref_get(struct kref *kref) -{ - return atomic_add_unless(&kref->refcount, 1, INT_MAX); -} -#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */ - -#endif /* _LTTNG_WRAPPER_KREF_H */