afs: Add afs_xioctl prototyes to afs_prototypes.h Several .c files have external function prototypes for the afs_xioctl function, while the implementing files do not have the prototype. Move these prototypes into afs_prototypes.h so that the prototypes are available to both the caller and the implementation. Because the file holding the implementation does not have a prototypes, afs_xioctl() is being flagged when building against a Linux 6.8 kernel (which sets the -Wmissing-declarations and -Wmissing-prototypes compiler flags as default). Linux 6.8 commit: 'Makefile.extrawarn: turn on missing-prototypes globally' (0fcb70851f). When building against a Linux kernel with CONFIG_WERROR=y, the build fails. Note that the function afs_xioctl() has platform specific implementations. Change-Id: I0956daace8c9036a924b928e387eb4a2ea542bf1 Reviewed-on: https://gerrit.openafs.org/15643 Reviewed-by: Andrew Deason <adeason@sinenomine.net> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Mark Vitale <mvitale@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
afs: Move function prototypes into headers Several .c files contain external function prototypes, while the implementing files do not have these prototypes. Move these prototypes into header files so that the prototypes are available to both the caller and the implementation. Because the file holding the implementation does not have prototypes, these functions are flagged when building against a Linux 6.8 kernel (which sets the -Wmissing-declarations and -Wmissing-prototypes compiler flags as default). Linux 6.8 commit: 'Makefile.extrawarn: turn on missing-prototypes globally' (0fcb70851f). When building against a kernel with CONFIG_WERROR=y, the build fails. Add the prototypes for the following to afs_prototypes.h: exporter_add afs_syscall (AFS_LINUX_ENV) BlobScan Remove the prototypes from the .c files where they are referenced. Change-Id: Ifc75cafe0132bb4cb8714062253f08874be7c06d Reviewed-on: https://gerrit.openafs.org/15642 Reviewed-by: Andrew Deason <adeason@sinenomine.net> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Mark Vitale <mvitale@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Linux 6.7: convert to inode a/mtime accessor funcs The Linux 6.7 commit "fs: new accessor methods for atime and mtime" (077c212f03) is a follow up to the Linux 6.6 commit "fs: add ctime accessors infrastructure" (9b6304c1d5) With the above 6.7 commit, the inode's i_atime and i_mtime are renamed to __i_atime and __i_mtime and accessing these members should use the new accessor functions. This commit is similar to the OpenAFS commit "Linux 6.6: convert to ctime accessor functions" (072c7934cd1) Add autoconf tests to detect when we need to use the new accessors and introduce new wrapper functions to get and set an inode's atime and mtime. Note, unlike the (072c7934cd1) commit, we need to add support for reading an inode's atime and mtime, so this commit has the getters for the atime and mtime members. Change-Id: Ide818c946ed98a1401ef59864c2cdb4eccee9c99 Reviewed-on: https://gerrit.openafs.org/15597 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
dir: Introduce struct DirEntryFlex The directory package as implemented in AFS-2 allocates space for each directory entry as a DirEntry struct followed by 0-8 contiguous DirXEntry structs, as needed. This is implemented by: - afs_dir_NameBlobs calculates the number of blocks needed - FindBlobs allocates and returns index of entry - afs_dir_GetBlob returns pointer to 1st DirEntry struct After this, we populate DirEntry (and any contiguous DirXEntry blocks) with open code. Most existing code writes the entry's name via a string copy operation to DirEntry->name, which is only 16 bytes long. Therefore, for dir entry names that are 16 bytes or longer, OpenAFS routinely does string copies that look like buffer overruns. This has not previously caused problems because the OpenAFS code has arranged for a sufficiently large amount of contiguous memory to be available. However, this remains undefined behavior in the C abstract virtual machine; thus compilers are not required to produce safe operation. Recent changes in the OpenAFS build chain have made this approach no longer viable: 1) Linux 6.5 commit df8fc4e934c12b 'kbuild: Enable -fstrict-flex-arrays=3' modified the hardening of several kernel string operations when running with CONFIG_FORTIFY_SOURCE=y. 2) gcc 13 commit 79a89108dd352cd9288f5de35481b1280c7588a5 '__builtin_dynamic_object_size: Recognize builtin' provides some enhancements to _builtin_object_size. The Linux commit above will now use these when the kernel is built with gcc 13. When OpenAFS is built under Linux 6.5 or higher and gcc 13 or higher, the hardened strlcpy will BUG for directory entry names longer than 16 characters. Since there are multiple places where OpenAFS writes directory names, there are several symptoms that may manifest. However, the first one is usually a kernel BUG at cache manager initialization if running with afsd -dynroot _and_ there are any cell names 15 characters or longer in the client CellServDB. (A 15-character cellname reaches the 16 character limit when -dyrnoot adds the RW mountpoint ".<cellname>".) Address this by using flexible arrays (standardized with C99). A flexible array is a variable-length array that is declared with no size at all, e.g., name[]. Create an autoconf test to determine whether the compiler supports flexible arrays. Create a new struct DirEntryFlex. If the compiler supports flexible arrays, define name[]; otherwise retain the name[16] definition. Whenever we write a directory name, use DirEntryFlex so that any hardening will be satisfied that there is sufficient space for the name. However, the actual guarantee that this is true is still provided by the OpenAFS directory routines mentioned above - all of these remain unchanged. The DirEntry struct remains unchanged for continued use in OpenAFS, as well as for any out-of-tree users of the directory package. Change-Id: I6da5c6c295f051be90017084e5b3a3ef24d1271f Reviewed-on: https://gerrit.openafs.org/15573 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Cheyenne Wills <cwills@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Linux 6.6: Pass request_mask to generic_fillattr The Linux 6.6 commit: "fs: pass the request_mask to generic_fillattr" (0d72b92883) added an additional parameter to Linux's generic_fillattr() function. For openafs, generic_fillattr() is called from the inode_operations method "getattr", which is implemented in afs_linux_getattr(). The value for the request_mask parameter is an existing parameter that is passed to the inode_operations "getattr" method. Add an autoconf test for 4 parameters to the generic_fillattr function and update afs_linux_getattr() to pass the request_mask to generic_fillattr(). Change-Id: Ie1e6b15bd85931debe0fd446760674ddd0492578 Reviewed-on: https://gerrit.openafs.org/15561 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Mark Vitale <mvitale@sinenomine.net> Tested-by: Mark Vitale <mvitale@sinenomine.net> Reviewed-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Kailas Zadbuke <kailashsz@in.ibm.com> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Linux 6.6: convert to ctime accessor functions The Linux 6.6 commit "fs: add ctime accessors infrastructure" (9b6304c1d5) added accessor functions for an inode's ctime member. A follow on commit "fs: rename i_ctime field to __i_ctime" (13bc244578) changed the name of the inode member ctime to __i_ctime to indicate it's a private member. Add an autoconf test for the ctime accessor function 'inode_set_ctime()'. Add an afs_inode_set_ctime to LINUX/osi_machdep.h that is either defined as a macro to Linux's inode_set_ctime, or implements a static inline function to set a inode's ctime. Convert the setting of an inode's ctime to use afs_inode_set_ctime(). For more information behind the Linux change, see the commit message for: "Merge tag 'v6.6-vfs.ctime' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs" (615e95831) Change-Id: I920aac8029fc3e2c9b7741341b434802403a4577 Reviewed-on: https://gerrit.openafs.org/15560 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Mark Vitale <mvitale@sinenomine.net> Tested-by: Mark Vitale <mvitale@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
linux: Remove use of wrap_directory_iterator The commit 'linux: Replace fop iterate with fop iterate_shared' (gerrit 15528) uses a Linux provided wrapper for the file_operations iterate_shared member. The wrapper is provided by Linux to give filesystem time to migrate to using the iterate_shared directly. Review of the locking done by the afs_linux_readdir shows that it is unnecessary to use the migration wrapper. Note: Removing the use of the wrapper as a separate commit from the 15528 commit in case there is a need to use the wrapper. In addition, we would like to use the wrapper with the current openafs stable release and use the development branch for additional testing. Change-Id: I662f95f69c2d06948f764b9520567efbca8f692c Reviewed-on: https://gerrit.openafs.org/15550 Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Tested-by: BuildBot <buildbot@rampaginggeek.com>
linux: Replace fop iterate with fop iterate_shared The Linux 6.5 commit: 'vfs: get rid of old '->iterate' directory operation' (3e32715496) removed the filesystem_operations iterate method. The replacement method, iterate_shared, was introduced with the Linux 4.6 commit: 'introduce a parallel variant of ->iterate()' (6192269444) The above commits indicate that the iterate_shared is an "almost" drop-in replacement for iterate. The vfs documentation for iterate_shared has caveats on the implementation (serializing in-core per-inode or per-dentry modifications and using d_alloc_parallel if doing dcache pre-seeding). A wrapper is provided to assist filesystems with the migration from iterate to iterate_shared. Until it can be verified that afs_linux_readdir meets the above requirements, we will use the wrapper (ref 3e32715496 commit) Add configure tests for the iterate_shared file_operations member and for the wrap_directory_iterator function. Update osi_vnodeops.c to use iterate_shared and the wrapper if they are both available. Change-Id: I60d7605a79947198a429def5bce77cd09a16c304 Reviewed-on: https://gerrit.openafs.org/15528 Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Reviewed-by: Andrew Deason <adeason@sinenomine.net> Tested-by: BuildBot <buildbot@rampaginggeek.com>
Linux 6.5: Replace generic_file_splice_read The Linux 6.5 commit: 'splice: Remove generic_file_splice_read()' (c6585011bc) replaces the function generic_file_splice_read() with the function filemap_splice_read(). The Linux function 'filemap_splice_read()' was introduced with the Linux 6.3 commits: 'splice: Add a func to do a splice from a buffered file without ITER_PIPE' (07073eb01c) 'splice: Export filemap/direct_splice_read()' (7c8e01ebf2) With updates in Linux 6.5: 'splice: Fix filemap_splice_read() to use the correct inode' (c37222082f) -- which fixes a problem in the code. 'splice: Make filemap_splice_read() check s_maxbytes' (83aeff881e) Due to the fact that there could be problems with splice support prior to Linux 6.5 (where filemap_splice_read()'s use was expanded to additional filesystems other than just cifs), we only want to use 'filemap_splice_read()' in Linux 6.5 and later. The LINUX/osi_vnodeops.c file is updated to use 'filemap_splice_read()', for Linux 6.5 and later, for the splice_read member of the file_operations structure. Change-Id: Ia07c66ddc5d4f836f230b5d03567803e124b93b8 Reviewed-on: https://gerrit.openafs.org/15486 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
LINUX: Set .getattr for symlinks On Linux, we can define a .getattr callback for files and directories, which is called when a caller requests metadata for the file, such as during lstat(). For regular files and directories, we set this to afs_linux_getattr(), which updates the metadata for the file in question if it's out of date (CStatd not set). For symlinks, however, we don't set .getattr at all. This would seem to allow symlink metadata to become stale if another client changes it, but the metadata often happens to stay up to date via other means. For example, we can see the following happen: - Another client changes, for example, the owner of a symlink we have cached. - The fileserver sends us a callback break, and so we clear CStatd for the vcache for the symlink. - lstat() is called for the symlink, which causes afs_linux_dentry_revalidate() to be called for the cached dentry. Since CStatd is not set for the vcache, we verify the entry by calling afs_lookup(), and then update the symlink's metadata via afs_getattr() and vattr2inode(). However, if CStatd _is_ set for the symlink when lstat() is called, afs_linux_dentry_revalidate() will not update anything, and will just return success. So, if we manage to set CStatd for the symlink without updating it's Linux VFS metadata, the Linux metadata won't be updated, and we'll report the old metadata to the caller of lstat(). We can set CStatd without updating the Linux VFS info in a few different ways. A few pioctls such as PRemoveMount or PFlushMount can do this if they encounter an error, but the only code paths that call these pioctls in OpenAFS (via the 'fs' utility) also lstat() the relevant path, so this doesn't happen in practice. A more common way that this can occur is via afs_DoBulkStat(). If userspace triggers a bulkstat that includes the symlink in question, the symlink would gain the CStatd flag without any interaction with the Linux VFS. For example, say a symlink was chown'd from 'adeason' to 'root'. On another client with the symlink cached, running 'ls -l' on the symlink itself would show the updated owner, because afs_linux_dentry_revalidate() updates the metadata: $ ls -l dir.slink lrwxr-xr-x. 1 root root 3 May 5 14:48 dir.slink -> dir But if we 'ls -l' the entire directory, which contains other entries, we will bulkstat many of the entries, possibly including the symlink. And so we may see the old metadata: $ ls -l total 9 [...] lrwxr-xr-x. 1 adeason root 3 May 5 14:48 dir.slink -> dir Triggering this behavior requires a bulkstat to be triggered before we access the symlink itself, and so triggering this behavior depends on the order of the entries in the directory as well as whether the other items in the dir are cached. As such, triggering this behavior during normal operation tends to be inconsistent and confusing. The only lstat() info for symlinks that can change like this is the owner, group, and modtime; mode bits cannot change, and neither can the length/size (or the contents in general). So, stale metadata tends to not be very noticeable. To fix all of this, set .getattr to afs_linux_getattr() for symlinks, just like we do for regular files and directories. This ensures that we will update the Linux VFS metadata for the symlink when it is requested, so we won't return stale metadata to callers. This behavior appears to have existed for symlinks on Linux for quite a while, possibly since our Linux 2.6 support was added. The behavoir may have been introduced around commit b860b359d58 (initial-linux24-support-20001105) or commit 00543744955 (linux22-fix-20040405). Before those commits, we defined a .revalidate callback for symlinks, which was called on older Linux versions before fetching file metadata, and so probably ensured that an lstat() on a symlink returned properly updated info. Change-Id: I90d751e3175e24e9f9409cea6c079b097c78b51b Reviewed-on: https://gerrit.openafs.org/15423 Reviewed-by: Cheyenne Wills <cwills@sinenomine.net> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
LINUX: Introduce afs_d_alias_foreach We have a couple of places in the code that iterate over the dentry aliases of an inode, and each of these involves a small #ifdef ladder to handle slightly different ways of traversing the relevant list. Split this logic into its own compatibility macro, afs_d_alias_foreach[_reverse], to contain this ugliness in osi_compat.h and make the callers more readable. This commit should incur no functional change; it is just code reorganization. Change-Id: I0babe22fffb23e100af5cdd50f38ab2b8f3ee2c6 Reviewed-on: https://gerrit.openafs.org/15390 Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Reviewed-by: Cheyenne Wills <cwills@sinenomine.net> Tested-by: BuildBot <buildbot@rampaginggeek.com>
Linux 6.3: Use mnt_idmap for inode op functions Through a series of Linux 6.3 commits starting with: 'f2fs: project ids aren't idmapped' (64b4cdf22f) and ending with 'fs: move mnt_idmap' (3707d84c13) the inode operations functions were changed to take a mnt_idmap structure instead of a user_namespace structure. These were pulled in via the the merge commit: 'Pull vfs idmapping updates from Christian Brauner' (05e6295f7b) The commit message for the merge contains background and overall information for this conversion. The above change simply changes the functions to use a different structure (mnt_idmap instead of user_namespace). For afs, it is a simple change to swap the structures. But for some of the Linux calls (generic_fillattr(), setattr_prepare(), and inode_op->setattr()) we would like to use the Linux symbol nop_mnt_idmap, but that symbol is exported as GPL only. Instead, we will obtain its address from the current task structure at libafs initialization (much the same way as obtaining current user namespace for afs_ns). Add autoconf tests to determine if inode_operations.create() uses the mnt_idmap structure. If so set a generic configure define for "IOP_TAKES_MNT_IDMAP". Update afs's inode operations functions to take and use a mnt_idmap instead of a user_namespace. At libafs initialization, obtain the mnt_idmap from the current task and save it as an afs global variable, afs_mnt_idmap, to be used where needed. Change-Id: Ie48b3941860998ddc7f54be48959fc62119bf48e Reviewed-on: https://gerrit.openafs.org/15347 Reviewed-by: Mark Vitale <mvitale@sinenomine.net> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Cheyenne Wills <cwills@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Linux: Replace lru_cache_add with folio_add_lru The Linux 6.2 commit: "folio-compat: remove lru_cache_add()" (6e1ca48d0) removed the lru_cache_add() function (which was introduced in Linux 5.8) The replacement function is folio_add_lru(), which was introduced with the Linux 5.16 commit: "mm/lru: Add folio_add_lru()" (0d31125d2d) Change-Id: I4615e6bde0253618c13ec1eb067e23b2c3e3ff42 Reviewed-on: https://gerrit.openafs.org/15227 Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Tested-by: Benjamin Kaduk <kaduk@mit.edu>
Linux: Check for block_dirty_folio The build for the openafs Linux kernel module fails on RHEL9.1 with an undefined function reference for block_dirty_folio(). RedHat 9.1 includes the Linux commit: fs: Add aops->dirty_folio (6f31a5a261db) which added the dirty_folio member to the address_space_operations structure. However RedHat 9.1 does not include the following 2 Linux commits: fs: Convert __set_page_dirty_buffers to block_dirty_folio (e621900ad2) which introduced block_dirty_folio() as a function that could be used to handle the address_space_operations's dirty_folio operation. And fs: Remove aops ->set_page_dirty (3a3bae50af) which removed the set_page_dirty member in the address_space_operations structure. The openafs commit: Linux-5.18 replace set_page_dirty with dirty_folio (6aa129e743e88) introduced an autoconf test that checks for the presence of aops' dirty_folio member and assumed that the Linux function block_dirty_folio() was also provided (since all three of the above Linux commits were added in Linux-5.18-rc1). Without the (e621900ad2) commit, the openafs Linux kernel module fails to build since block_dirty_folio() is not defined by Linux. Introduce new autoconf tests that checks for the presence of the block_dirty_folio() function. Change the preprocessor conditional within LINUX/osi_vnodeops.c to only use dirty_folio if aops has dirty_folio and block_dirty_folio() is available. When block_dirty_folio() is not available, we continue to use the older set_page_dirty method, which remains a valid method until its removal by the (3a3bae50af) Linux commit. Note: Reviewing the Linux source for RedHat 9.1 shows that there is only one location that is defining the dirty_folio member and it is providing its own function instead of relying on block_dirty_folio. Change-Id: If8f7bba3fa779e344ba1d51f7a837197586142bd Reviewed-on: https://gerrit.openafs.org/15199 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Linux-6.0: Replace add_to_page_cache Linux 6.0 removed the add_to_page_cache function in the Linux commit: 'filemap: Remove add_to_page_cache() and add_to_page_cache_locked()' (2bb876b58d593d7f2522ec0f41f20a74fde76822) The replacement function, filemap_add_folio function is exported as GPL, but a non-GPL wrapper was provided in the Linux 5.15 commit: 'mm/filemap: Add filemap_add_folio()' (9dd3d069406cea073fc633e77bc59abbfde8c6c4) which changed the GPL exported function add_to_page_cache_lru to a non-GPL exported function. The function add_to_page_cache_lru functionally combines the add_to_page_cache with lru_cache_add. Within afs, all the calls to add_to_page_cache follow the pattern of calling the lru_cache_add via the wrapper afs_lru_cache_add immediately after (except in one case noted below). Add an autoconf check to see if add_to_page_cache_lru is available. Introduce a new wrapper function afs_add_to_page_cache_lru that handles calling either add_to_page_cache/afs_lru_cache_add or add_to_page_cache_lru. As noted above there is one function, afs_linux_bypass_readpages, that calls add_to_page_cache but does not immediately call afs_lru_cache_add. This function is only used in Linux kernels prior to 5.18, see the commit: 'Linux-5.18: replace readpages with readahead' (7a181415db) Since this code path is only built for a Linux kernel level where add_to_page_cache should also exists, we do not replace this call. NOTE: The add_to_page_cache_lru was moved into mm/folio-compat.c which has a comment indicating that callers of these functions should migrate to folio calls. However the replacement folio call that is needed by afs, filemap_add_folio, is exported as GPL. Change-Id: I10087ebeb8b08309e6c1bab4fc43f7e9f50bd105 Reviewed-on: https://gerrit.openafs.org/15132 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Michael Meffie <mmeffie@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
LINUX: Use bitwise & for f_flags test This code is clearly supposed to be masking f_flags with O_ACCMODE, and so should be using a bitwise &, not the boolean &&. Clang complains about this, causing a warning (which breaks the build with --enable-checking): error: use of logical '&&' with constant operand [-Werror, -Wconstant-logical-operand] } else if ((file->f_flags && O_ACCMODE) != O_WRONLY) { ^ ~~~~~~~~~ .../osi_vnodeops.c:3192:28: note: use '&' for a bitwise operation For the current code without this commit the behavior of this check is as follows: When f_flags is: The check is: ==================== ============= O_RDONLY True (as expected) O_WRONLY False (as expected) O_RDWR False (incorrect) has some non-O_ACCMODE False (incorrect) bit is set The incorrect check doesn't cause any problems for overall correctness, but it does mean that in those cases afs_linux_fillpage will not be called and that partially-written pages will be left out of date and any reader will need to fill the page again. Fix this by using the bitwise &. There is also an out of date link to the Linux documentation. Update the comment to point to the current documentation that is in the Linux source tree. Change-Id: I193b30e837075ef18d0559c6b28ac8ce222c1a5a Reviewed-on: https://gerrit.openafs.org/14903 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Michael Meffie <mmeffie@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
linux: Call put_page if errors in aops->readpages Within the address_space_operations readpages function, when we remove a page from the page->lru list, we must ensure that the page reference count is decremented via put_page. There are two cases within the flow of the afs_linux_readpages where we remove a page from the page->lru list, but fail to put_page() it. - If we go through afs_linux_bypass_readpages we fail to call put_page() if the page index is larger than the index calculated from i_size_read for the cache file. - If get_dcache_readahead returns an error in afs_linux_readpages, we fail to put_page(). This can happen if there was a problem opening the cache file, or if the cache file has no a_ops->readpage. Add a call to put_page in afs_linux_bypass_readpages when the page index is greater than the index calculated from the i_size_read for the cache file. Add a call to put_page in afs_linux_readpages if get_dcache_readahead returns an error. Note: The condition of not calling put_page if there was an error opening the cache file was introduced by commit 'LINUX: Don't panic on some file open errors' (af73b9a3b1f), which replaced an assert with code that handled the error. The other conditions have existed since the relevant code was introduced. In addition, the problems addressed by this commit are not present in Linux kernels 5.8 and greater when the commit 'Linux-5.18: replace readpages with readahead' (7a181415db1) is present, because we call afs_linux_readahead instead of afs_linux_readpages. Change-Id: Ibabd6519601366d7d944138b1f663fbb6002a879 Reviewed-on: https://gerrit.openafs.org/15068 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Cheyenne Wills <cwills@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Linux-5.19: Remove flags from aops->write_begin The Linux 5.19 commits: fs: Remove aop flags parameter from grab_cache_page_write_begin() (b7446e7c) fs: Remove flags parameter from aops->write_begin (9d6b0cd7) removed the flags parameter from the address space operations 'write_begin' as well as removing the flags parameter from the Linux function 'grab_cache_page_write_begin'. Add an autoconf test to see if grab_cache_page_write_begin takes 2 or 3 parameters. Use this as a test to determine if the address space operations 'write_begin' takes a flags parameter. Create a version of afs_linux_write_begin that does not take a flags parameter, which also calls grab_cache_page_write_begin without flags. Change-Id: Ib98c615e6964202748c78037c9ecac459fc3372b Reviewed-on: https://gerrit.openafs.org/15041 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Michael Meffie <mmeffie@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Linux-5.19: Rename aops readpage to read_folio With Linux commits: mm,fs: Remove aops->readpage (7e0a126519) fs: Introduce aops->read_folio (5efe7448a1) the address space operations method 'readpage' was replaced with read_folio. The operation behaves the same, except instead of taking a struct page parameter, the new function takes a folio structure. Add an autoconf test for the address space operation entry read_folio Replace the references to an address space operations' readpage with read_folio. Note that the function Linux page_folio can be used to obtain the required pointer to the folio for a given page. Introduce afs_linux_read_folio that accepts a folio and calls afs_linux_readpage with the page associated with that folio. Change-Id: I2c43a9bfb26042f7cc2c55807d46b33769f2594a Reviewed-on: https://gerrit.openafs.org/15040 Reviewed-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Reviewed-by: Michael Meffie <mmeffie@sinenomine.net> Tested-by: BuildBot <buildbot@rampaginggeek.com>
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>