Whamcloud - gitweb
LU-9558 llite: handle struct vm_operations changes
[fs/lustre-release.git] / lustre / include / lustre_compat.h
index bdd3d78..11217c2 100644 (file)
@@ -443,6 +443,56 @@ static inline void truncate_inode_pages_final(struct address_space *map)
 # define GET_POSIX_ACL_XATTR_ENTRY(head) ((head)->a_entries)
 #endif
 
+#ifdef HAVE_IOP_XATTR
+#ifdef HAVE_XATTR_HANDLER_FLAGS
+#define ll_setxattr     generic_setxattr
+#define ll_getxattr     generic_getxattr
+#define ll_removexattr  generic_removexattr
+#else
+int ll_setxattr(struct dentry *dentry, const char *name,
+               const void *value, size_t size, int flags);
+ssize_t ll_getxattr(struct dentry *dentry, const char *name,
+                   void *buf, size_t buf_size);
+int ll_removexattr(struct dentry *dentry, const char *name);
+#endif /* ! HAVE_XATTR_HANDLER_FLAGS */
+#endif /* HAVE_IOP_XATTR */
+
+#ifndef HAVE_VFS_SETXATTR
+const struct xattr_handler *get_xattr_type(const char *name);
+
+#ifdef HAVE_XATTR_HANDLER_FLAGS
+static inline int
+__vfs_setxattr(struct dentry *dentry, struct inode *inode, const char *name,
+              const void *value, size_t size, int flags)
+{
+       const struct xattr_handler *handler;
+       int rc;
+
+       handler = get_xattr_type(name);
+       if (!handler)
+               return -ENXIO;
+
+#if defined(HAVE_XATTR_HANDLER_INODE_PARAM)
+       rc = handler->set(handler, dentry, inode, name, value, size,
+                         XATTR_CREATE);
+#elif defined(HAVE_XATTR_HANDLER_SIMPLIFIED)
+       rc = handler->set(handler, dentry, name, value, size, XATTR_CREATE);
+#else
+       rc = handler->set(dentry, name, value, size, XATTR_CREATE,
+                         handler->flags);
+#endif /* !HAVE_XATTR_HANDLER_INODE_PARAM */
+       return rc;
+}
+#else /* !HAVE_XATTR_HANDLER_FLAGS */
+static inline int
+__vfs_setxattr(struct dentry *dentry, struct inode *inode, const char *name,
+              const void *value, size_t size, int flags)
+{
+       return ll_setxattr(dentry, name, value, size, flags);
+}
+#endif /* HAVE_XATTR_HANDLER_FLAGS */
+#endif /* HAVE_VFS_SETXATTR */
+
 #ifndef HAVE_IOV_ITER_TRUNCATE
 static inline void iov_iter_truncate(struct iov_iter *i, u64 count)
 {
@@ -568,4 +618,19 @@ __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *iter)
 }
 #endif /* HAVE_FILE_OPERATIONS_READ_WRITE_ITER */
 
+static inline void __user *get_vmf_address(struct vm_fault *vmf)
+{
+#ifdef HAVE_VM_FAULT_ADDRESS
+       return (void __user *)vmf->address;
+#else
+       return vmf->virtual_address;
+#endif
+}
+
+#ifdef HAVE_VM_OPS_USE_VM_FAULT_ONLY
+# define ll_filemap_fault(vma, vmf) filemap_fault(vmf)
+#else
+# define ll_filemap_fault(vma, vmf) filemap_fault(vma, vmf)
+#endif
+
 #endif /* _LUSTRE_COMPAT_H */