From: Mathieu Desnoyers Date: Fri, 1 Dec 2023 14:52:08 +0000 (-0500) Subject: Fix: get_file_rcu is missing in kernels < 4.1 X-Git-Tag: v2.13.11~7 X-Git-Url: http://git.liburcu.org/?a=commitdiff_plain;h=451e062751f0574bbb33390b072f5615d084e309;p=lttng-modules.git Fix: get_file_rcu is missing in kernels < 4.1 Open-code the get_file_rcu using atomic_long_inc_not_zero() for kernel versions < 4.1. Signed-off-by: Mathieu Desnoyers Change-Id: I0fa905b078165ede8b1837bb8d77891d05d0e8ed --- diff --git a/include/wrapper/fdtable.h b/include/wrapper/fdtable.h index 9c11d02e..8b32c030 100644 --- a/include/wrapper/fdtable.h +++ b/include/wrapper/fdtable.h @@ -29,7 +29,7 @@ struct file *lttng_lookup_fdget_rcu(unsigned int fd) return NULL; return file; } -#else +#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,1,0)) static inline struct file *lttng_lookup_fdget_rcu(unsigned int fd) { @@ -39,6 +39,16 @@ struct file *lttng_lookup_fdget_rcu(unsigned int fd) return NULL; return file; } +#else +static inline +struct file *lttng_lookup_fdget_rcu(unsigned int fd) +{ + struct file* file = fcheck(fd); + + if (unlikely(!file || !atomic_long_inc_not_zero(&file->f_count))) + return NULL; + return file; +} #endif #if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,7,0))