Page MenuHomeFreeBSD

D48756.diff
No OneTemporary

D48756.diff

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

Mime Type
text/plain
Expires
Sat, Feb 1, 9:00 PM (21 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16388693
Default Alt Text
D48756.diff (1 KB)

Event Timeline