diff options
Diffstat (limited to '0003-Linux-Introduce-file-mapping-readpage-helpers.patch')
-rw-r--r-- | 0003-Linux-Introduce-file-mapping-readpage-helpers.patch | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/0003-Linux-Introduce-file-mapping-readpage-helpers.patch b/0003-Linux-Introduce-file-mapping-readpage-helpers.patch new file mode 100644 index 000000000000..da1f03cbb0de --- /dev/null +++ b/0003-Linux-Introduce-file-mapping-readpage-helpers.patch @@ -0,0 +1,103 @@ +From 97054ed3d994f8d6218bf8db05c41ead218200e3 Mon Sep 17 00:00:00 2001 +From: Cheyenne Wills <cwills@sinenomine.net> +Date: Tue, 5 Jul 2022 10:28:10 -0600 +Subject: [PATCH 3/6] Linux: Introduce file mapping readpage helpers + +Create a helper function that determines if a file's + i_mapping->a_ops->readpage +is NULL. + +Create a helper function that calls a file's + i_mapping->a_ops->readpage + +There are no functional changes with this commit. + +Note: This commit isolates references to 'readpage' so that future +commits can change the name in a more straight forward manner. + +Change-Id: If3ad33766c7a3bce27c2aa3c3b409157264230b1 +Reviewed-on: https://gerrit.openafs.org/15039 +Tested-by: BuildBot <buildbot@rampaginggeek.com> +Reviewed-by: Andrew Deason <adeason@sinenomine.net> +Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> +(cherry picked from commit a81f7300f08d6e515adbde4bce4b72a3102b60f9) +--- + src/afs/LINUX/osi_vnodeops.c | 34 +++++++++++++++++++++++++++++----- + 1 file changed, 29 insertions(+), 5 deletions(-) + +diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c +index 54118637f..b834a405c 100644 +--- a/src/afs/LINUX/osi_vnodeops.c ++++ b/src/afs/LINUX/osi_vnodeops.c +@@ -2206,6 +2206,18 @@ afs_linux_put_link(struct dentry *dentry, struct nameidata *nd) + + #endif /* USABLE_KERNEL_PAGE_SYMLINK_CACHE */ + ++/* ++ * Call the mapping function that reads data for a given page. ++ * Note: When we return, it is expected that the page is unlocked. It is the ++ * responsibility of the called function (e.g. ->readpage) to unlock the given ++ * page, even when an error occurs. ++ */ ++static int ++mapping_read_page(struct address_space *mapping, struct page *page) ++{ ++ return mapping->a_ops->readpage(NULL, page); ++} ++ + /* Populate a page by filling it from the cache file pointed at by cachefp + * (which contains indicated chunk) + * If task is NULL, the page copy occurs syncronously, and the routine +@@ -2272,9 +2284,9 @@ afs_linux_read_cache(struct file *cachefp, struct page *page, + + if (!PageUptodate(cachepage)) { + ClearPageError(cachepage); +- /* Note that ->readpage always handles unlocking the given page, even +- * when an error is returned. */ +- code = cachemapping->a_ops->readpage(NULL, cachepage); ++ /* Note that mapping_read_page always handles unlocking the given page, ++ * even when an error is returned. */ ++ code = mapping_read_page(cachemapping, cachepage); + if (!code && !task) { + wait_on_page_locked(cachepage); + } +@@ -2308,6 +2320,17 @@ afs_linux_read_cache(struct file *cachefp, struct page *page, + return code; + } + ++/* ++ * Return true if the file has a mapping that can read pages ++ */ ++static int inline ++file_can_read_pages(struct file *fp) ++{ ++ if (fp->f_dentry->d_inode->i_mapping->a_ops->readpage != NULL) ++ return 1; ++ return 0; ++} ++ + static int inline + afs_linux_readpage_fastpath(struct file *fp, struct page *pp, int *codep) + { +@@ -2403,7 +2426,8 @@ afs_linux_readpage_fastpath(struct file *fp, struct page *pp, int *codep) + AFS_GLOCK(); + goto out; + } +- if (!cacheFp->f_dentry->d_inode->i_mapping->a_ops->readpage) { ++ ++ if (!file_can_read_pages(cacheFp)) { + cachefs_noreadpage = 1; + AFS_GLOCK(); + goto out; +@@ -2871,7 +2895,7 @@ get_dcache_readahead(struct dcache **adc, struct file **acacheFp, + code = -1; + goto out; + } +- if (cacheFp->f_dentry->d_inode->i_mapping->a_ops->readpage == NULL) { ++ if (!file_can_read_pages(cacheFp)) { + cachefs_noreadpage = 1; + /* No mapping function */ + code = -1; +-- +2.37.1 + |