LINUX 5.6: use struct proc_ops for proc_create
[openafs.git] / src / afs / LINUX / osi_compat.h
index 60cfdc1..4999b89 100644 (file)
@@ -222,9 +222,15 @@ afs_linux_search_keyring(afs_ucred_t *cred, struct key_type *type)
     key_ref_t key_ref;
 
     if (afs_session_keyring(cred)) {
+#  if defined(KEYRING_SEARCH_TAKES_RECURSE)
+       key_ref = keyring_search(
+                     make_key_ref(afs_session_keyring(cred), 1),
+                     type, "_pag", 1);
+#  else
        key_ref = keyring_search(
                      make_key_ref(afs_session_keyring(cred), 1),
                      type, "_pag");
+#  endif
        if (IS_ERR(key_ref))
            return ERR_CAST(key_ref);
 
@@ -471,6 +477,33 @@ afs_linux_unlock_inode(struct inode *ip) {
 #endif
 }
 
+/* Use these to lock or unlock an inode for processing
+ * its dentry aliases en masse.
+ */
+#if defined(HAVE_DCACHE_LOCK)
+#define afs_d_alias_lock(ip)       spin_lock(&dcache_lock)
+#define afs_d_alias_unlock(ip)     spin_unlock(&dcache_lock)
+#else
+#define afs_d_alias_lock(ip)       spin_lock(&(ip)->i_lock)
+#define afs_d_alias_unlock(ip)     spin_unlock(&(ip)->i_lock)
+#endif
+
+
+/* Use this instead of dget for dentry operations
+ * that occur under a higher lock (e.g. alias processing).
+ * Requires that the higher lock (e.g. dcache_lock or
+ * inode->i_lock) is already held.
+ */
+static inline void
+afs_linux_dget(struct dentry *dp) {
+#if defined(HAVE_DCACHE_LOCK)
+    dget_locked(dp);
+#else
+    dget(dp);
+#endif
+}
+
+
 static inline int
 afs_inode_setattr(struct osi_file *afile, struct iattr *newattrs) {
 
@@ -594,14 +627,18 @@ afs_truncate(struct inode *inode, int len)
 }
 
 static inline struct proc_dir_entry *
-afs_proc_create(char *name, umode_t mode, struct proc_dir_entry *parent, struct file_operations *fops) {
+#if defined(HAVE_LINUX_STRUCT_PROC_OPS)
+afs_proc_create(char *name, umode_t mode, struct proc_dir_entry *parent, struct proc_ops *ops) {
+#else
+afs_proc_create(char *name, umode_t mode, struct proc_dir_entry *parent, struct file_operations *ops) {
+#endif
 #if defined(HAVE_LINUX_PROC_CREATE)
-    return proc_create(name, mode, parent, fops);
+    return proc_create(name, mode, parent, ops);
 #else
     struct proc_dir_entry *entry;
     entry = create_proc_entry(name, mode, parent);
     if (entry)
-       entry->proc_fops = fops;
+       entry->proc_fops = ops;
     return entry;
 #endif
 }
@@ -659,7 +696,11 @@ afs_file_read(struct file *filp, char __user *buf, size_t len, loff_t *pos)
 #if defined(HAVE_LINUX___VFS_WRITE)
     return __vfs_read(filp, buf, len, pos);
 #elif defined(HAVE_LINUX_KERNEL_WRITE)
+# if defined(KERNEL_READ_OFFSET_IS_LAST)
     return kernel_read(filp, buf, len, pos);
+# else
+    return kernel_read(filp, *pos, buf, len);
+# endif
 #else
     return filp->f_op->read(filp, buf, len, pos);
 #endif
@@ -671,7 +712,11 @@ afs_file_write(struct file *filp, char __user *buf, size_t len, loff_t *pos)
 #if defined(HAVE_LINUX___VFS_WRITE)
     return __vfs_write(filp, buf, len, pos);
 #elif defined(HAVE_LINUX_KERNEL_WRITE)
+# if defined(KERNEL_READ_OFFSET_IS_LAST)
     return kernel_write(filp, buf, len, pos);
+# else
+    return kernel_write(filp, buf, len, *pos);
+# endif
 #else
     return filp->f_op->write(filp, buf, len, pos);
 #endif