Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F148380652
D48756.1786547093.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D48756.1786547093.diff
View Options
diff --git a/sys/compat/linuxkpi/common/include/linux/fs.h b/sys/compat/linuxkpi/common/include/linux/fs.h
--- a/sys/compat/linuxkpi/common/include/linux/fs.h
+++ b/sys/compat/linuxkpi/common/include/linux/fs.h
@@ -264,12 +264,17 @@
return (f);
}
+struct linux_file * linux67_get_file_rcu(struct linux_file **f);
+#if defined(LINUXKPI_VERSION) && LINUXKPI_VERSION >= 60700
+#define get_file_rcu(f) linux67_get_file_rcu(f)
+#else
static inline bool
get_file_rcu(struct linux_file *f)
{
return (refcount_acquire_if_not_zero(
f->_file == NULL ? &f->f_count : &f->_file->f_count));
}
+#endif
static inline struct inode *
igrab(struct inode *inode)
diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c
--- a/sys/compat/linuxkpi/common/src/linux_compat.c
+++ b/sys/compat/linuxkpi/common/src/linux_compat.c
@@ -75,6 +75,7 @@
#include <linux/moduleparam.h>
#include <linux/cdev.h>
#include <linux/file.h>
+#include <linux/fs.h>
#include <linux/sysfs.h>
#include <linux/mm.h>
#include <linux/io.h>
@@ -1082,6 +1083,44 @@
spin_unlock(&filp->f_kqlock);
}
+static struct linux_file *
+__get_file_rcu(struct linux_file **f)
+{
+ struct linux_file *file1, *file2;
+
+ file1 = READ_ONCE(*f);
+ if (file1 == NULL)
+ return (NULL);
+
+ if (!refcount_acquire_if_not_zero(
+ file1->_file == NULL ? &file1->f_count : &file1->_file->f_count))
+ return (ERR_PTR(-EAGAIN));
+
+ file2 = READ_ONCE(*f);
+ if (file2 == file1)
+ return (file2);
+
+ fput(file1);
+ return (ERR_PTR(-EAGAIN));
+}
+
+struct linux_file *
+linux67_get_file_rcu(struct linux_file **f)
+{
+ struct linux_file *file1;
+
+ for (;;) {
+ file1 = __get_file_rcu(f);
+ if (file1 == NULL)
+ return (NULL);
+
+ if (IS_ERR(file1))
+ continue;
+
+ return (file1);
+ }
+}
+
static void
linux_file_kqfilter_detach(struct knote *kn)
{
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Aug 12, 3:04 PM (9 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29399499
Default Alt Text
D48756.1786547093.diff (1 KB)
Attached To
Mode
D48756: linuxkpi: Add Linux 6.7 `get_file_rcu()` variant
Attached
Detach File
Event Timeline
Log In to Comment