afs: Handle osi_NewVnode failures Currently, code inside afs_vcache.c assumes that osi_NewVnode always returns non-NULL, which means that osi_NewVnode must panic if it cannot create a new vnode. All of the callers of afs_GetVCache, afs_NewVCache, etc, already handle getting a NULL return, though (after all, the given fid may not exist or be inaccessible due to network errors, etc). So, just propagate NULL returns from osi_NewVnode up to our callers, to avoid panics in these situations. Modify osi_NewVnode on many arches to return an error on allocation failure, instead of panic'ing. Change-Id: Ib578b1747590bdf65327d4674e0849811ed999eb Reviewed-on: https://gerrit.openafs.org/13701 Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Reviewed-by: Yadavendra Yadav <yadayada@in.ibm.com> Tested-by: BuildBot <buildbot@rampaginggeek.com>
afs: Refactor osi_vnhold/AFS_FAST_HOLD Make a few changes to osi_vnhold and AFS_FAST_HOLD: - Currently, the second argument of osi_vnhold ("retry") is never used by any implementation. Get rid of it. - AFS_FAST_HOLD() is the same as osi_vnhold(). Get rid of AFS_FAST_HOLD, and just have all callers use osi_vnhold instead. - Allow osi_vnhold to return an error, and adjust callers to handle it. - Change osi_vnhold to be a real function, instead of a macro, to make nontrivial implementations less cumbersome. Most platforms never return an error from osi_vnhold(), so the added code paths to check the return value of osi_vnhold() will not trigger. However, this lets us add future commits that do make osi_vnhold() return an error. Change-Id: Id2f3717be6c305d06305685247ac789815e1ebf7 Reviewed-on: https://gerrit.openafs.org/13971 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
afs: Fix a few ARCH/osi_vcache.c style errors Most of the ARCH/osi_vcache.c implementations were defining functions like: void osi_foo(args) { /* impl */ } But our prevailing style is: void osi_foo(args) { /* impl */ } Fix them to follow our prevailing style, and fix a couple of the more obvious errors with identation and goto label. Change-Id: Ie752ee67aa6acfec3bf9a28d7da41151f95fbbf6 Reviewed-on: https://gerrit.openafs.org/13699 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Unix CM: Don't cast allocator returns All of our allocators return (void *) values, so there is no need to cast the returns - doing so is just noise. Change-Id: I6b1009efbb5034225a4af0e19d03b74c628dfb82 Reviewed-on: http://gerrit.openafs.org/7457 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Derrick Brashear <shadow@dementix.org>
linux: defer vcache evictions when sleep would be needed because we're only willing to loop 100 times worth of "sleeps", on a machine with heavy vcache demands we can end up just growing the list huge. in the first pass, just clean up as many entries which do not require sleeping as needed. if we need more entries, make a second pass. Change-Id: Ie5af42e7c0287d7a093f9a5884c10813dbb8cb11 Reviewed-on: http://gerrit.openafs.org/3971 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Derrick Brashear <shadow@dementia.org>
OpenBSD: Fix variable name typo in osi_vcache.c The osi_PostPopulateVCache() routine in the OpenBSD version of osi_vcache.c tries to use the non-existent variable "vc" instead of "avc". This fixes it. Change-Id: Idac09739d36e253518fbdbd600ab43c9ea87da3a Reviewed-on: http://gerrit.openafs.org/3418 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Derrick Brashear <shadow@dementia.org>
Refactor afs_NewVCache afs_NewVCache was a twisty turny maze of #ifdefs and duplicated code. This makes a number of sweeping changes to simplify this code, and to move platform specific elements out into their own directories. *) ShakeLooseVCaches is refactored so that the same code can be used both for platforms that support dynamic vcaches, and those which don't. *) afs_NewVCache, ShakeLooseVCaches, and afs_AllocVCache are all modified to remove platform specific code, and to call platform specific functions. *) A new platform file 'osi_vcache.c' is created to hold a number of platform specific vcache operations: *) osi_TryEvictVCache handles the decision of whether a vcache can be evicted or not, and does so if required *) osi_NewVnode allocates a new vnode *) osi_PrePopulateVCache does the necessary population of the vcache, before it's threaded onto the VLRUQ and associated hash tables. *) osi_AttachVnode handles attaching an OS vnode to our vcache, where that is necessary *) osi_PostPopulateVCache handles the vcache population that must occur after we're on the VLRUQ and have a vnode attached. Change-Id: I368e5fb500d012b44141aa8f8cf0516e63e58f57 Reviewed-on: http://gerrit.openafs.org/1881 Reviewed-by: Derrick Brashear <shadow@dementia.org> Tested-by: Derrick Brashear <shadow@dementia.org>