#define __LIBCFS_LINUX_MISC_H__
#include <linux/fs.h>
+/* Since Commit 2f8b544477e6 ("block,fs: untangle fs.h and blk_types.h")
+ * fs.h doesn't include blk_types.h, but we need it.
+ */
+#include <linux/blk_types.h>
#include <linux/mutex.h>
#include <linux/user_namespace.h>
#include <linux/uio.h>
}
#endif /* ! HAVE_KERNEL_PARAM_LOCK */
+int cfs_apply_workqueue_attrs(struct workqueue_struct *wq,
+ const struct workqueue_attrs *attrs);
+
#ifndef HAVE_KSTRTOBOOL_FROM_USER
#define kstrtobool strtobool
int kstrtobool_from_user(const char __user *s, size_t count, bool *res);
+#endif /* HAVE_KSTRTOBOOL_FROM_USER */
+
+#ifndef HAVE_KREF_READ
+static inline int kref_read(const struct kref *kref)
+{
+ return atomic_read(&kref->refcount);
+}
+#endif /* HAVE_KREF_READ */
+
+#ifdef HAVE_FORCE_SIG_WITH_TASK
+#define cfs_force_sig(sig, task) force_sig((sig), (task))
+#else
+#define cfs_force_sig(sig, task) \
+do { \
+ unsigned long flags; \
+ \
+ spin_lock_irqsave(&task->sighand->siglock, flags); \
+ task->sighand->action[sig - 1].sa.sa_handler = SIG_DFL; \
+ send_sig(sig, task, 1); \
+ spin_unlock_irqrestore(&task->sighand->siglock, flags); \
+} while (0)
#endif
+
+void cfs_arch_init(void);
+
+#ifndef container_of_safe
+/**
+ * container_of_safe - cast a member of a structure out to the containing structure
+ * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ *
+ * If IS_ERR_OR_NULL(ptr), ptr is returned unchanged.
+ *
+ * Note: Copied from Linux 5.6, with BUILD_BUG_ON_MSG section removed.
+ */
+#define container_of_safe(ptr, type, member) ({ \
+ void *__mptr = (void *)(ptr); \
+ IS_ERR_OR_NULL(__mptr) ? ERR_CAST(__mptr) : \
+ ((type *)(__mptr - offsetof(type, member))); })
#endif
+
+#endif /* __LIBCFS_LINUX_MISC_H__ */