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: clarify cold and warm shutdown logic Currently, any code that wants to perform a cold shutdown must first set global afs_cold_shutdown = 1, then call afs_shutdown(void). Instead, modify afs_shutdown() to accept a single parm which specifies AFS_WARM or AFS_COLD shutdown, and to set the value of global afs_cold_shutdown based on this parm. Remove all other assignments for afs_cold_shutdown. Modify all callers of afs_shutdown() to specify AFS_WARM or AFS_COLD as needed to maintain equivalent function. This should make it much easier to tell at a glance what type of shutdown is being requested by each caller to afs_shutdown(). No functional change should be incurred by this commit. Change-Id: I921eca5b4d2659209154fbe37d575db69bf708b8 Reviewed-on: https://gerrit.openafs.org/12182 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
FBSD: Use syscall "helper" functions syscall_register/syscall_deregister were effectively removed in r329647. Use syscall_helper_register/syscall_helper_unregister instead, which have existed since r205321 in FreeBSD 9. Change-Id: I2d5e3101024a44c18395d7eb95c644df6005e0aa Reviewed-on: https://gerrit.openafs.org/13858 Reviewed-by: Tim Creech <tcreech@tcreech.com> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Tested-by: BuildBot <buildbot@rampaginggeek.com>
FBSD: Declare vnops/vfsops static Declare our vnode and vfs operations as static functions, since they are not referenced outside of osi_vfsops.c/osi_vnodeops.c. Shuffle around the definitions in osi_vnodeops.c so that we don't need forward declarations for the functions. Change-Id: Idbbe05a8b248ac29c2795c365be6a4e99da536dd Reviewed-on: https://gerrit.openafs.org/13973 Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Tested-by: BuildBot <buildbot@rampaginggeek.com>
FBSD: Remove support for 8.x and 9.x According to <https://www.freebsd.org/security/unsupported.html>, FreeBSD 8.x EoL was on August 1, 2015, and FreeBSD 9.x EoL was on December 31, 2016. Remove our support for these versions, since they haven't been supported by FreeBSD itself for a while. FreeBSD 10.x EoL was on October 31, 2018, which has passed, but was less than a year ago. So keep 10.x in for now. Adjust our preprocessor checks accordingly: - In FBSD-specific dirs, assume AFS_FBSD100_ENV and lower is always true. Assume __FreeBSD_version is always at least 1000000. - In non-FBSD dirs, convert AFS_FBSD100_ENV and lower to AFS_FBSD_ENV. Change-Id: I965e65d3b95573bb374661217b24b686c7b68ed2 Reviewed-on: https://gerrit.openafs.org/13842 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
FBSD: Remove pre-8 code Commit 123f0fb1 (config: remove support for old FreeBSD releases) removed our support for FreeBSD releases before FreeBSD 8. However, various areas of code still reference the symbols from those old versions (e.g. AFS_FBSD53_ENV). Remove our ifdef logic for these old symbols, according to the following rules: - In FBSD-specific dirs, assume AFS_FBSD80_ENV is always true (as well as the symbols for earlier versions) - In non-FBSD dirs, convert AFS_FBSD80_ENV to AFS_FBSD_ENV (and do the same for all earlier versions) This allows us to remove code that was specific to older FreeBSD versions, and simplify some ifdef conditionals. Also remove the definitions for AFS_FBSD80_ENV and earlier versions in our existing param.h files. With this commit, the functions afs_start, afs_vop_lock, afs_vop_unlock, and afs_vop_islocked are now always unreferenced, so remove them. Change-Id: Ia5a5ba5ee5b71a86cb4514305e20f1bb34487100 Reviewed-on: https://gerrit.openafs.org/13812 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Tim Creech <tcreech@tcreech.com> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
FBSD: Give 0 'rootrefs' to vflush on unmount Currently, in afs_unmount, we give vflush a 'rootrefs' arg of 1, indicating that we hold 1 reference on the root vnode. But ever since commit 6eb1088a (freebsd: properly track vcache references), we drop the ref for the root vnode at the beginning of this function. What happens currently in afs_unmount for a normal successful umount is something like this (at least, on FreeBSD 11.2-RELEASE): - We afs_PutVCache the afs_globalVp vcache, reducing its v_usecount and v_holdcnt to 0, and afs_globalVp is set to NULL. - vflush calls afs_root() to get the root vnode, which sees that afs_globalVp is NULL, and so calls afs_GetVCache for the root fid and returns it (and sets afs_globalVp to that vcache), with a v_usecount of 1. - vflush tries to vgonel() all of our vnodes, which calls our afs_vop_reclaim, which calls afs_FlushVCache(). For the root vnode specifically, vflush() sees that v_usecount is nonzero, and so skips calling vgonel() at first, but later calls vgone() on it specifically because we gave a nonzero 'rootrefs'. The resulting afs_FlushVCache() for the root vnode fails, because the root vnode's v_usecount is still 1. Since a failure from afs_vop_reclaim would cause a panic, we just log a warning and try to continue on anyway. - vflush() calls vrele() on the root vnode, right before returning. All of this allows the unmount to proceed, but this means that most of afs_FlushVCache() doesn't actually run for the root vcache, and it means we always log a warning like this on unmount: afs_vop_reclaim: afs_FlushVCache failed code 16 [...] In addition, this means that setting afs_globalVp at the beginning of afs_unmount() is largely pointless, since it gets set to a vcache again near the beginning of vflush(). To avoid all of this, stop lying to vflush about how many references to the root vnode we hold, and just say that we hold 0 references. Change-Id: Ib434c5fc48e67c3863fcad41279c3d9e0e0b8c2b Reviewed-on: https://gerrit.openafs.org/13709 Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Tested-by: Benjamin Kaduk <kaduk@mit.edu>
afs: Remove useless afs_GetVCache arguments The 'avc' argument in afs_GetVCache has never been used, all the way back to OpenAFS 1.0. The 'cached' argument was set correctly, but none of its callers ever looked at the result of 'cached'. Remove these useless arguments. afs_LookupVCache and afs_GetRootVCache also had the same 'cached' argument, which was also never used by callers. Remove it for those, as well. Change-Id: I3536259f26536acc02fbb058787f417bf0f50b9a Reviewed-on: https://gerrit.openafs.org/13681 Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Tested-by: BuildBot <buildbot@rampaginggeek.com>
afs: Stop abusing ENOENT When looking up a file, the ENOENT error code is supposed to be used if we know that the target filename does not exist. That is, the situation is a user or application error; they specified a filename that was not previously created. Currently, though, we use ENOENT for a variety of different situations, such as: - After successfully looking up a directory entry, we fail to afs_GetDCache or afs_GetVCache on the FID for that entry. - We encounter an invalid mount point, in certain code paths. In each of these situations, an ENOENT error code is incorrect, since the target filename does indeed exist and these situations may be caused by network or administrative errors. An ENOENT error implies that the user may be able to then create the target filename, which is not true most of the time in the above situations. In addition, on LINUX we return a negative dcache entry when we encounter an ENOENT error on lookup. This means that if any of the above scenarios occur, Linux would cache the fact that that directory entry did not exist, and return ENOENT for future lookups. This was worked around in one of the changes in commit 652f3bd9cb7a5d7833a760ba50ef7c2c67214bba to always invalidate such negative dentries, but at the cost of performance (since this caused negative lookups to never be cached). To avoid all of these issues, just don't use ENOENT in these situations. For simple non-disconnected afs_GetDCache or afs_GetVCache errors, return EIO, since we have encountered an error that is internal to AFS (either the underlying data is inconsistent, or we have a network error, or something else). In disconnected operation, return ENETDOWN like in other disconnected code paths, since often the root cause is due to us not having network access. When a bad mountpoint is encountered, return ENODEV, since that is what we use elsewhere in the code when encountering a bad mountpoint. It is also noteworthy that this changes removes the translation of VNOVNODE into ENOENT, since a nonexistent vnode is not the same as a nonexistent filename, as described above. Some code paths have special behavior for this situation (ignoring the error in some cases where it does not matter). These code paths should be okay with this change, since all of them examine error codes that have not been translated through afs_CheckCode. Some useless references to ENOENT were also removed in src/afs/LINUX*/osi_misc.c. These did not result in incorrect behavior, but removing them makes searching for bad ENOENT references easier. Change-Id: Ib01e4309e44b532f843d53c8de2eae613e397bf6 Reviewed-on: http://gerrit.openafs.org/11788 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Build fix for recent FreeBSD -current r273707 added a flags argument to syscall_register(), so add the appropriate version check in param.generic_fbsd.h and ues that in the main code. Change-Id: I7ddf6e1295d7ed94625f19fdeee4e38ef5fd511e Reviewed-on: http://gerrit.openafs.org/11565 Tested-by: Benjamin Kaduk <kaduk@mit.edu> Reviewed-by: D Brashear <shadow@your-file-system.com>
afs: Raise fake free space reporting We report 'fake' values for free space, free file nodes, etc for the 'AFS' filesystem, since these values are not meaningful for AFS itself. Currently we report about 9G of free space for most platforms, and a few different values for a few others. Raise all of these to 2^32-1, so that trying to copy over 9G of data into AFS does not fail for those applications that check the destination free space with statfs(2). Note that one such application is KDE 4.8.x. Consolidate all places that do this, and put the 'fake' value in one place, AFS_VFS_FAKEFREE, along with the relevant comments. Related issues reported by Lars Schimmer, Richard Brittain, and others. Change-Id: Ia15175da32744e11f62489c29bedfe1f5560d2b4 Reviewed-on: http://gerrit.openafs.org/9688 Reviewed-by: Andrew Deason <adeason@sinenomine.net> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Markus Koeberl <markus.koeberl@tugraz.at> Tested-by: Markus Koeberl <markus.koeberl@tugraz.at> Reviewed-by: D Brashear <shadow@your-file-system.com>
Catch up to FreeBSD KPI for vfs_cmount Almost a year ago, mckusick changed the VFS KPI/KBI for the cmount VFS operation, making the flags argument a 64-bit quantity. Introduce appropriate conditionals for our prototype of afs_cmount for the change on the 10.x and 9.x branches. Change-Id: Ia0b8759f027e64f98f087daabbf1a51030171f21 Reviewed-on: http://gerrit.openafs.org/8907 Reviewed-by: Garrett Wollman <wollman@csail.mit.edu> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Catch up to FreeBSD non-MPSAFE deorbit All filesystems must have their own locking now. We have been MPSAFE for quite some time, but the preprocessor macro "MPSAFE" has been removed and we must catch up in order to compile. The MNTK_MPSAFE macro has not yet been removed, but it is toothless now, so we can preemptively stop using it. Change-Id: I9d9090fd1afc020670a0cf874baacf483fd34915 Reviewed-on: http://gerrit.openafs.org/8366 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
FBSD: complete the build fix for 8.1 libafs Strangely enough, nosys() also needs a cast to sy_call_t *. Change-Id: I7fee2278c228da3ddb2c3ccc9758681cd0abc01d Reviewed-on: http://gerrit.openafs.org/5105 Reviewed-by: Derrick Brashear <shadow@dementia.org> Tested-by: Derrick Brashear <shadow@dementia.org>
FBSD: cast lkmnosys appropriately lkmnosys is a function, and as such has its own prototype which includes a named struct specific to it (struct nosys_args). When comparing its address to an entry in the syscall table, we must cast it to a sy_call_t to correctly do the comparison, lest gcc warn us about comparing distinct pointer types without a cast. This warning recently became an error due to bsd.kmod.mk, so it causes the build to fail on 8.1 and earlier, which do not use syscall_register() due to a conflicting entry for our syscall in syscalls.master. Change-Id: I606aaf73e433a50ea41adaab842d61ee69653bd5 Reported-by: Garrett Wollman Reviewed-on: http://gerrit.openafs.org/5087 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Garrett Wollman <wollman@csail.mit.edu> Reviewed-by: Derrick Brashear <shadow@dementia.org> Tested-by: Derrick Brashear <shadow@dementia.org>
FBSD: remove vestiges of Giant We do not support versions of FreeBSD that used Giant to serialize access to vnode fields, and we always use the same locking (which really ought to be MPSAFE). Always set the MPSAFE flags as needed, and do not bother to call VFS_[UN]LOCK_GIANT which will never do anything for us. Change-Id: I973a24d43563f289d4a2baa6e067fbba72d17ed9 Reviewed-on: http://gerrit.openafs.org/3656 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Derrick Brashear <shadow@dementia.org>
freebsd: properly track vcache references previously both root and reclaim could end up leaking refs. fix it. Change-Id: Ib3c9dab2f31b988a2887821f5192ff1fad0e732c Reviewed-on: http://gerrit.openafs.org/3424 Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Reviewed-by: Derrick Brashear <shadow@dementia.org> Tested-by: Derrick Brashear <shadow@dementia.org>
FBSD: close race in afs_root Previously, we called afs_PutVCache(afs_globalVp) directly. This is unsafe because PutVCache acquires locks which can sleep, losing the serialization of the GLOCK. In rare circumstances, this can result in two threads simultaneously making that call, and the second one would panic in vputx() with a negative refcount. Close the race by using a local variable for the afs_PutVCache() calls, applying the change to afs_globalVp before dropping the GLOCK. While here, fix up other race conditions. Change-Id: Id62f27d4469a96c9becd9b031125bd6c910c3e9b Reviewed-on: http://gerrit.openafs.org/3275 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Derrick Brashear <shadow@dementia.org>
More FBSD syscall tweaking We're now properly registered in syscalls.master for HEAD (i.e. proto-9.0) and RELENG_8 (proto-8.2), which means that afs3_syscall is prototyped in sys/sysproto.h . Accordingly, don't declare it in afs_prototypes.h for those cases. Also add FBSD82_ENV checks for the new syscall-registration code, and cast afs3_syscall to sy_call_t* for the sysent structure. Change-Id: I0e7427274b018043c3a6a8ca6181a78a385d9aa2 Reviewed-on: http://gerrit.openafs.org/2864 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Derrick Brashear <shadow@dementia.org>
FBSD restore old syscall register logic for older kernels The syscall_register code appears to depend on coordination with FreeBSD upstream, which hopefully can be completed by RELENG_9. Use the original code for installation of the AFS syscall everything older than that. Change-Id: I2954cf1a2ae3587a311e8133ec5cdc500b4e2e24 Reviewed-on: http://gerrit.openafs.org/2618 Reviewed-by: Derrick Brashear <shadow@dementia.org> Tested-by: Derrick Brashear <shadow@dementia.org>