Whamcloud - gitweb
LU-7340 mdd: changelogs garbage collection
[fs/lustre-release.git] / lustre / include / lustre_compat.h
index 498d27b..9bb08dd 100644 (file)
@@ -290,19 +290,6 @@ static inline int ll_namei_to_lookup_intent_flag(int flag)
        return flag;
 }
 
-#ifdef HAVE_QC_MAKE_REQUEST_FN
-# define ll_mrf_ret blk_qc_t
-# define LL_MRF_RETURN(rc) RETURN(BLK_QC_T_NONE)
-#else
-# ifdef HAVE_VOID_MAKE_REQUEST_FN
-#  define ll_mrf_ret void
-#  define LL_MRF_RETURN(rc)
-# else
-#  define ll_mrf_ret int
-#  define LL_MRF_RETURN(rc) RETURN(rc)
-# endif
-#endif
-
 #include <linux/fs.h>
 #ifndef HAVE_PROTECT_I_NLINK
 static inline void set_nlink(struct inode *inode, unsigned int nlink)
@@ -443,6 +430,80 @@ 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 */
+
+#ifdef HAVE_IOP_SET_ACL
+#ifdef CONFIG_FS_POSIX_ACL
+#ifndef HAVE_POSIX_ACL_UPDATE_MODE
+static inline int posix_acl_update_mode(struct inode *inode, umode_t *mode_p,
+                         struct posix_acl **acl)
+{
+       umode_t mode = inode->i_mode;
+       int error;
+
+       error = posix_acl_equiv_mode(*acl, &mode);
+       if (error < 0)
+               return error;
+       if (error == 0)
+               *acl = NULL;
+       if (!in_group_p(inode->i_gid) &&
+           !capable_wrt_inode_uidgid(inode, CAP_FSETID))
+               mode &= ~S_ISGID;
+       *mode_p = mode;
+       return 0;
+}
+#endif /* HAVE_POSIX_ACL_UPDATE_MODE */
+#endif
+#endif
+
 #ifndef HAVE_IOV_ITER_TRUNCATE
 static inline void iov_iter_truncate(struct iov_iter *i, u64 count)
 {
@@ -462,6 +523,13 @@ static inline bool is_sxid(umode_t mode)
 #define IS_NOSEC(inode)        (!is_sxid(inode->i_mode))
 #endif
 
+#ifndef MS_NOSEC
+static inline void inode_has_no_xattr(struct inode *inode)
+{
+       return;
+}
+#endif
+
 #ifndef HAVE_FILE_OPERATIONS_READ_WRITE_ITER
 static inline void iov_iter_reexpand(struct iov_iter *i, size_t count)
 {
@@ -561,4 +629,44 @@ __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
+
+#ifndef HAVE_CURRENT_TIME
+static inline struct timespec current_time(struct inode *inode)
+{
+       return CURRENT_TIME;
+}
+#endif
+
+#ifndef time_after32
+/**
+ * time_after32 - compare two 32-bit relative times
+ * @a: the time which may be after @b
+ * @b: the time which may be before @a
+ *
+ * time_after32(a, b) returns true if the time @a is after time @b.
+ * time_before32(b, a) returns true if the time @b is before time @a.
+ *
+ * Similar to time_after(), compare two 32-bit timestamps for relative
+ * times.  This is useful for comparing 32-bit seconds values that can't
+ * be converted to 64-bit values (e.g. due to disk format or wire protocol
+ * issues) when it is known that the times are less than 68 years apart.
+ */
+#define time_after32(a, b)     ((s32)((u32)(b) - (u32)(a)) < 0)
+#define time_before32(b, a)    time_after32(a, b)
+#endif
+
 #endif /* _LUSTRE_COMPAT_H */