wrapper: remove kref_get wrapper
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 13 Apr 2020 16:49:11 +0000 (12:49 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 13 Apr 2020 18:09:24 +0000 (14:09 -0400)
lib/ringbuffer/ring_buffer_frontend.c
lttng-abi.c
wrapper/kref.h [deleted file]

index f939787837c6fbb46ab501fcf75ff6c7d81c586a..664e8652012fece589dac16b1ca3338113a8f9ed 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/delay.h>
 #include <linux/module.h>
 #include <linux/percpu.h>
+#include <linux/kref.h>
 #include <asm/cacheflush.h>
 
 #include <wrapper/ringbuffer/config.h>
@@ -48,7 +49,6 @@
 #include <wrapper/ringbuffer/iterator.h>
 #include <wrapper/ringbuffer/nohz.h>
 #include <wrapper/atomic.h>
-#include <wrapper/kref.h>
 #include <wrapper/percpu-defs.h>
 #include <wrapper/timer.h>
 
@@ -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;
 }
index baaf34d31952a2b0db6b732fc0c580891a059b35..3be91fcfaf48ade8c42bf228038e109184fafb45 100644 (file)
 #include <linux/uaccess.h>
 #include <linux/slab.h>
 #include <linux/err.h>
+#include <linux/kref.h>
 #include <wrapper/ringbuffer/vfs.h>
 #include <wrapper/ringbuffer/backend.h>
 #include <wrapper/ringbuffer/frontend.h>
 #include <wrapper/poll.h>
 #include <wrapper/file.h>
-#include <wrapper/kref.h>
 #include <lttng-string-utils.h>
 #include <lttng-abi.h>
 #include <lttng-abi-old.h>
@@ -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,
                        &lttng_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 (file)
index f3b5053..0000000
+++ /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 <mathieu.desnoyers@efficios.com>
- *
- * 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 <linux/kref.h>
-#include <linux/rculist.h>
-#include <linux/version.h>
-
-/*
- * 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 */
This page took 0.027828 seconds and 4 git commands to generate.