summaryrefslogtreecommitdiff
path: root/fs/nfs/internal.h
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@hammerspace.com>2023-01-20 00:33:41 +0300
committerAnna Schumaker <Anna.Schumaker@Netapp.com>2023-02-14 22:22:32 +0300
commitab75bff1140733f1b43e81f055acd7d27af7ac05 (patch)
treee115ad23d222151ab985359b82b44a206649cc08 /fs/nfs/internal.h
parent4b27232a6e064f3d779cfa76cd251d6023949d22 (diff)
downloadlinux-ab75bff1140733f1b43e81f055acd7d27af7ac05.tar.xz
NFS: Convert buffered reads to use folios
Perform a largely mechanical conversion of references to struct page and page-specific functions to use the folio equivalents. Note that the fscache functionality remains untouched. Instead we just pass in the folio page. This should be OK, as long as we use order 0 folios together with fscache. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Diffstat (limited to 'fs/nfs/internal.h')
-rw-r--r--fs/nfs/internal.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 6197b165c8c8..529b87336ffa 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -795,6 +795,24 @@ unsigned int nfs_page_length(struct page *page)
}
/*
+ * Determine the number of bytes of data the page contains
+ */
+static inline size_t nfs_folio_length(struct folio *folio)
+{
+ loff_t i_size = i_size_read(folio_file_mapping(folio)->host);
+
+ if (i_size > 0) {
+ pgoff_t index = folio_index(folio) >> folio_order(folio);
+ pgoff_t end_index = (i_size - 1) >> folio_shift(folio);
+ if (index < end_index)
+ return folio_size(folio);
+ if (index == end_index)
+ return offset_in_folio(folio, i_size - 1) + 1;
+ }
+ return 0;
+}
+
+/*
* Convert a umode to a dirent->d_type
*/
static inline