Whamcloud - gitweb
LU-17524 llite: DIO and writev and readv syscalls
[fs/lustre-release.git] / lustre / include / lustre_compat.h
index 4969b39..5f4c497 100644 (file)
@@ -642,9 +642,26 @@ static inline bool is_root_inode(struct inode *inode)
 }
 #endif
 
-#ifndef HAVE_IOV_ITER_GET_PAGES_ALLOC2
-#define iov_iter_get_pages_alloc2(i, p, m, s) \
-       iov_iter_get_pages_alloc((i), (p), (m), (s))
+#if defined(HAVE_DIRECTIO_ITER) || defined(HAVE_IOV_ITER_RW) || \
+       defined(HAVE_DIRECTIO_2ARGS) || defined(HAVE_IOV_ITER_GET_PAGES_ALLOC2)
+#define HAVE_DIO_ITER 1
+#endif
+
+#if !defined HAVE_IOV_ITER_GET_PAGES_ALLOC2 && defined HAVE_DIO_ITER
+static inline ssize_t iov_iter_get_pages_alloc2(struct iov_iter *i,
+                                                  struct page ***pages,
+                                                  size_t maxsize,
+                                                  size_t *start)
+{
+       ssize_t result = 0;
+
+       /* iov_iter_get_pages_alloc is non advancing version of alloc2 */
+       result = iov_iter_get_pages_alloc(i, pages, maxsize, start);
+       if (result > 0 && user_backed_iter(i))
+               iov_iter_advance(i, result);
+
+       return result;
+}
 #endif
 
 #ifdef HAVE_AOPS_MIGRATE_FOLIO