Linux 6.8: Use roken's strlcpy() in kernel module The Linux 6.8 commit 'string: Remove strlcpy()' (d26270061a) removed the the strlcpy function from the Linux kernel. The replacement function, strscpy(), cannot be used as a drop-in replacement as its currently a Linux kernel specific function and there are differences in the returned value. We can use roken's strlcpy() (provided in roken/strlcpy.c). Create a configure test to that defines its own strlcpy() to test if the kernel doesn't provide one itself. Note, we need to use a different function signature for strlcpy() from what the kernel might have otherwise the test build succeeds when the kernel does provide a strlcpy(). Update the OpenAFS kernel specific roken.h to define the prototype for strlcpy when it's not present in the Linux kernel. We need to match the defines used in the 'real' roken.h so the roken/strlcpy.c can build properly. Add defines for ROKEN_LIB_FUNCTION, ROKEN_LIB_CALL and ROKEN_LIB_VARIABLE to the kernel roken.h Update Linux's osi_machdep.h to include roken.h so the strlcpy protoype is available. Update the Linux MakefileProto to include the strcpy-kernel object when building the kernel module. Change-Id: I64a5743ba94134538853f51cd6e7a8df19127624 Reviewed-on: https://gerrit.openafs.org/15646 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Linux 6.8: Remove ctl_table sentinels The Linux 6.8 commit 'sysctl: Remove the now superfluous sentinel elements from ctl_table array' (c8a65501d3) was a clean up commit that removed the sentinel entry in the ctl_table array (e.g. the "null" entry at the end of the table). As of Linux 6.8, including the sentinel entry (.procname =) in the ctl_table is unnecessary, but doesn't yet break anything. But it is likely that including the sentinel will start to cause runtime errors in future Linux versions very soon, so avoid the sentinel when we can, to avoid possible problems in the future. Define a new macro that can be used as the last entry of a ctl_table that will either add a "null" entry, or nothing. There is not a specific build test we can use within configure, so we must explicitly test the Linux version to decide if we need to use a sentinel or not when defining the macro. We are selecting 6.8 to match the version where the Linux kernel is removing the sentinels from the in kernel filesystems. Note: See the Linux merge commits 'Merge tag 'sysctl-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux' (a05aea98d4) for more details behind the staged removal of the sentinels in the ctl_table structures and the potential future change for removing the actual check for the sentinel within the Linux kernel. Change-Id: I0f50872e7d08dc198584623337909a180002ab30 Reviewed-on: https://gerrit.openafs.org/15645 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Mark Vitale <mvitale@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Linux 6.8: use hlist iteration for dentry children Linux 6.8 commit 'dentry: switch the lists of children to hlist' (da549bdd15) replaces the dentry lists d_subdirs/d_child with the hlist d_children/d_sib. Add an autoconf test for a d_children member in the dentry structure. Define a macro that uses the applicable Linux function for iterating over a dentry's children. Change-Id: I6e8fb9a58c0afd9c383c07c294f64df1fc045585 Reviewed-on: https://gerrit.openafs.org/15632 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: Add static attribute to internal functions When building against a Linux 6.8 kernel, functions that are missing prototypes or declarations are flagged. We can add the static attribute to functions that are not referenced outside of the file that implements them to avoid having these functions flagged by the compiler. These functions are flagged due to missing prototypes 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. There are no functional changes in this commit. Change-Id: I24c78a3167f6a81da4f62267cf901024468ae6b3 Reviewed-on: https://gerrit.openafs.org/15625 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
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>
afs: Add includes to pick up function prototypes The functions defined in LINUX/osi_crypto.c, osi_pagecopy.c, osi_probe.c, and osi_syscall.c have function prototypes defined in existing header files, however either due to missing includes or preprocessor conditionals that skip the includes, these function prototypes are not being pulled in. These functions are flagged due to missing prototypes 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 necessary includes to osi_crypto.c and osi_pagecopy.c and re-arrange the includes in osi_probe.c and osi_syscall.c to ensure that the function prototypes are present when building the Linux kernel module. Change-Id: Idcb409b1c25354b1b8b3bff286000a189651bbf6 Reviewed-on: https://gerrit.openafs.org/15641 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Andrew Deason <adeason@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: Fix to use time_t instead of time64_t In commit 'Linux 6.6: convert to ctime accessor functions' (072c7934cd) the functiom afs_inode_set_ctime was defined to use time64_t when it should have used a time_t as the data type for the sec parameter. See the commit 'LINUX 5.6: define time_t and use timespec/timespec64' (78049987aa). The time64_t data type was introduced in Linux 3.17. A build failure will occur when building on kernels prior to Linux 3.17. Change-Id: I9b3ce32f8885cde969583cfc74294cdabc54e698 Reviewed-on: https://gerrit.openafs.org/15595 Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Tested-by: BuildBot <buildbot@rampaginggeek.com>
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: Use register_sysctl() The linux 6.5 commit: "sysctl: Remove register_sysctl_table" (b8cbc0855a) removed the Linux function register_sysctl_table(). The replacement function is register_sysctl(), which offers a simpler interface. Add an autoconf test for the Linux function register_sysctl and add a call to register_sysctl when available. Notes: The Linux function register_sysctl was added in Linux 3.3 with the commit: 'sysctl: Add register_sysctl for normal sysctl users' (fea478d410) with a note that it is a simpler interface. The function register_sysctl_table was marked as deprecated with the Linux 6.3 commit: 'proc_sysctl: enhance documentation' (1dc8689e4c) Change-Id: I657bee103cd1f4ab2e60b3f3471c3fc12d8b6be4 Reviewed-on: https://gerrit.openafs.org/15500 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
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: Make 'fs flush*' invalidate dentry Our 'fs flush' and related commands (flushall, flushvolume) clear the relevant entries in the OpenAFS stat cache and data cache, which can fix problems if the cache ever becomes incorrect for any reason. (This can happen after bugs, repairing corrupted volumes, disaster recovery scenarios, and similar edge cases.) However, on Linux, these commands don't affect the VFS dentry cache. If someone needs to use an 'fs flush' command to fix a problem, this will fix the OpenAFS cache, but the Linux dcache can still be wrong. The only way to manually flush dcache entries is to use the global 'drop_caches' mechanism, which is a very heavweight operation, only accessible to root. For example: $ ls -l ls: cannot access foo.1: No such file or directory total 2 drwxrwxr-x. 2 bin adeason 2048 Apr 6 14:20 dir -?????????? ? ? ? ? ? foo.1 $ fs flush . $ ls -l ls: cannot access foo.1: No such file or directory total 2 drwxrwxr-x. 2 bin adeason 2048 Apr 6 14:20 dir -?????????? ? ? ? ? ? foo.1 $ sudo sysctl -q -w vm.drop_caches=3 $ ls -l total 3 drwxrwxr-x. 2 bin adeason 2048 Apr 6 14:20 dir -rw-rw-r--. 1 bin adeason 29 Sep 22 2022 foo.1 To make the 'fs flush' commands be effective in more situations, change afs_ResetVCache() to also invalidate the dcache entries associated with each vcache we reset. To make things simpler and reduce locking complexity, do this by setting d_time to 0, and don't directly run dcache-managing functions like d_invalidate or d_drop, etc. The above example now becomes: $ ls -l ls: cannot access foo.1: No such file or directory total 2 drwxrwxr-x. 2 bin adeason 2048 Apr 6 14:20 dir -?????????? ? ? ? ? ? foo.1 $ fs flush . $ ls -l total 3 drwxrwxr-x. 2 bin adeason 2048 Apr 6 14:20 dir -rw-rw-r--. 1 bin adeason 29 Sep 22 2022 foo.1 Change-Id: Ic95ef6137f5b671baf68a4890ef1562f029af794 Reviewed-on: https://gerrit.openafs.org/15391 Reviewed-by: Cheyenne Wills <cwills@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Tested-by: BuildBot <buildbot@rampaginggeek.com>
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>