summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_cache.c
Commit message (Collapse)AuthorAgeFilesLines
* MFC r288336: save some bytes by using more concise SDT_PROBE<n>avg2015-10-231-45/+40
|
* Fix build with options DIAGNOSTIC.pho2015-10-161-3/+1
| | | | | Sponsored by: EMC / Isilon storage division In collaboration with: kib
* MFC of 281677:mckusick2015-09-221-12/+54
| | | | | | | | | | | | | | | | | | | | | | | More accurately collect name-cache statistics in sysctl functions sysctl_debug_hashstat_nchash() and sysctl_debug_hashstat_rawnchash(). These changes are in preparation for allowing changes in the size of the vnode hash tables driven by increases and decreases in the maximum number of vnodes in the system. Reviewed by: kib@ Phabric: D2265 MFC of 287497: Track changes to kern.maxvnodes and appropriately increase or decrease the size of the name cache hash table (mapping file names to vnodes) and the vnode hash table (mapping mount point and inode number to vnode). An appropriate locking strategy is the key to changing hash table sizes while they are in active use. Reviewed by: kib Tested by: Peter Holm Differential Revision: https://reviews.freebsd.org/D2265
* MFC r276564, r276654:dchagin2015-01-111-9/+1
| | | | | | | | | | | | | | | | Cast *path to silence clang -Wpointer-sign warning. Indeed, instead of hiding the kern___getcwd() bug by bogus cast in r276564, change path type to char * (pathnames are always char *). And remove bogus casts of malloc(). kern___getcwd() internally doesn't actually use or support u_char * paths, except to copy them to a normal char * path. These changes are not visible to libc as libc/gen/getcwd.c misdeclares __getcwd() as taking a plain char * path. While here remove _SYS_SYSPROTO_H_ for __getcwd() syscall as we always have sysproto.h.
* MFC r263710, r273377, r273378, r273423 and r273455:hselasky2014-10-271-1/+1
| | | | | | | - De-vnet hash sizes and hash masks. - Fix multiple issues related to arguments passed to SYSCTL macros. Sponsored by: Mellanox Technologies
* MFC r258622: dtrace sdt: remove the ugly sname parameter of SDT_PROBE_DEFINEavg2014-01-171-15/+15
|
* MFC r259953:kib2014-01-031-4/+10
| | | | Fix accounting for the negative cache entries when reusing v_cache_dd.
* namecache sdt: freebsd doesn't support structured characters yetavg2013-07-091-2/+2
| | | | | | :-) MFC after: 7 days
* When renaming a directory from one parent directory to another,mckusick2013-03-201-0/+22
| | | | | | | | | | | | | | we need to call ufs_checkpath() to walk from our new location to the root of the filesystem to ensure that we do not encounter ourselves along the way. Until now, we accomplished this by reading the ".." entries of each directory in our path until we reached the root (or encountered an error). This change tries to avoid the I/O of reading the ".." entries by first looking them up in the name cache and only doing the I/O when the name cache lookup fails. Reviewed by: kib Tested by: Peter Holm MFC after: 4 weeks
* Remove the support for using non-mpsafe filesystem modules.kib2012-10-221-37/+6
| | | | | | | | | | | | In particular, do not lock Giant conditionally when calling into the filesystem module, remove the VFS_LOCK_GIANT() and related macros. Stop handling buffers belonging to non-mpsafe filesystems. The VFS_VERSION is bumped to indicate the interface change which does not result in the interface signatures changes. Conducted and reviewed by: attilio Tested by: pho
* Post r230394, the Lookup RPC counts for both NFS clients increasedrmacklem2012-03-031-5/+41
| | | | | | | | | | | | | | | | | | | | | significantly. Upon investigation this was caused by name cache misses for lookups of "..". For name cache entries for non-".." directories, the cache entry serves double duty. It maps both the named directory plus ".." for the parent of the directory. As such, two ctime values (one for each of the directory and its parent) need to be saved in the name cache entry. This patch adds an entry for ctime of the parent directory to the name cache. It also adds an additional uma zone for large entries with this time value, in order to minimize memory wastage. As well, it fixes a couple of cases where the mtime of the parent directory was being saved instead of ctime for positive name cache entries. With this patch, Lookup RPC counts return to values similar to pre-r230394 kernels. Reported by: bde Discussed with: kib Reviewed by: jhb MFC after: 2 weeks
* o Reduce chances for integer overflow.maxim2012-02-251-2/+2
| | | | | | | o More verbose sysctl description added. MFC after: 2 weeks Sponsored by: Nginx, Inc.
* Rename cache_lookup_times() to cache_lookup() and retire the old API andjhb2012-02-061-12/+2
| | | | ABI stub for cache_lookup().
* Fix remaining calls to cache_enter() in both NFS clients to providekib2012-01-251-9/+5
| | | | | | | | appropriate timestamps. Restore the assertions which verify that NCF_TS is set when timestamp is asked for. Reviewed by: jhb (previous version) MFC after: 2 weeks
* Apparently, both nfs clients do not use cache_enter_time()kib2012-01-231-29/+23
| | | | | | | | | | | | | | consistently, creating some namecache entries without NCF_TS flag. This causes panic due to failed assertion. As a temporal relief, remove the assert. Return epoch timestamp for the entries without timestamp if asked. While there, consolidate the code which returns timestamps, into a helper cache_out_ts(). Discussed with: jhb MFC after: 2 weeks
* Remove the nc_time and nc_ticks elements from struct namecache, andkib2012-01-221-56/+131
| | | | | | | | | | | | | | | | | | provide struct namecache_ts which is the old struct namecache. Only allocate struct namecache_ts if non-null struct timespec *tsp was passed to cache_enter_time, otherwise use struct namecache. Change struct namecache allocation and deallocation macros into static functions, since logic becomes somewhat twisty. Provide accessor for the nc_name member of struct namecache to hide difference between struct namecache and namecache_ts. The aim of the change is to not waste 20 bytes per small namecache entry. Reviewed by: jhb MFC after: 2 weeks X-MFC-note: after r230394
* Close a race in NFS lookup processing that could result in stale name cachejhb2012-01-201-8/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | entries on one client when a directory was renamed on another client. The root cause for the stale entry being trusted is that each per-vnode nfsnode structure has a single 'n_ctime' timestamp used to validate positive name cache entries. However, if there are multiple entries for a single vnode, they all share a single timestamp. To fix this, extend the name cache to allow filesystems to optionally store a timestamp value in each name cache entry. The NFS clients now fetch the timestamp associated with each name cache entry and use that to validate cache hits instead of the timestamps previously stored in the nfsnode. Another part of the fix is that the NFS clients now use timestamps from the post-op attributes of RPCs when adding name cache entries rather than pulling the timestamps out of the file's attribute cache. The latter is subject to races with other lookups updating the attribute cache concurrently. Some more details: - Add a variant of nfsm_postop_attr() to the old NFS client that can return a vattr structure with a copy of the post-op attributes. - Handle lookups of "." as a special case in the NFS clients since the name cache does not store name cache entries for ".", so we cannot get a useful timestamp. It didn't really make much sense to recheck the attributes on the the directory to validate the namecache hit for "." anyway. - ABI compat shims for the name cache routines are present in this commit so that it is safe to MFC. MFC after: 2 weeks
* Fix missing in r230129:mm2012-01-151-1/+1
| | | | | | | | kern_jail.c: initialize fullpath_disabled to zero vfs_cache.c: add missing dot in comment Reported by: kib MFC after: 1 month
* Introduce vn_path_to_global_path()mm2012-01-151-0/+74
| | | | | | | | | | | | | This function updates path string to vnode's full global path and checks the size of the new path string against the pathlen argument. In vfs_domount(), sys_unmount() and kern_jail_set() this new function is used to update the supplied path argument to the respective global path. Unbreaks jailed zfs(8) with enforce_statfs set to 1. Reviewed by: kib MFC after: 1 month
* put sys/systm.h at its proper place or add it if missingavg2011-12-121-1/+1
| | | | | | | Reported by: lstewart, tinderbox Pointyhat to: avg, attilio MFC after: 1 week MFC with: r228430
* Existing VOP_VPTOCNP() interface has a fatal flow that is critical forkib2011-11-191-17/+48
| | | | | | | | | | | | | | | | | | | | | nullfs. The problem is that resulting vnode is only required to be held on return from the successfull call to vop, instead of being referenced. Nullfs VOP_INACTIVE() method reclaims the vnode, which in combination with the VOP_VPTOCNP() interface means that the directory vnode returned from VOP_VPTOCNP() is reclaimed in advance, causing vn_fullpath() to error with EBADF or like. Change the interface for VOP_VPTOCNP(), now the dvp must be referenced. Convert all in-tree implementations of VOP_VPTOCNP(), which is trivial, because vhold(9) and vref(9) are similar in the locking prerequisites. Out-of-tree fs implementation of VOP_VPTOCNP(), if any, should have no trouble with the fix. Tested by: pho Reviewed by: mckusick MFC after: 3 weeks (subject of re approval)
* Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.ed2011-11-071-1/+2
| | | | | | The SYSCTL_NODE macro defines a list that stores all child-elements of that node. If there's no SYSCTL_DECL macro anywhere else, there's no reason why it shouldn't be static.
* In order to maximize the re-usability of kernel code in user space thiskmacy2011-09-161-1/+1
| | | | | | | | | | | | | patch modifies makesyscalls.sh to prefix all of the non-compatibility calls (e.g. not linux_, freebsd32_) with sys_ and updates the kernel entry points and all places in the code that use them. It also fixes an additional name space collision between the kernel function psignal and the libc function of the same name by renaming the kernel psignal kern_psignal(). By introducing this change now we will ease future MFCs that change syscalls. Reviewed by: rwatson Approved by: re (bz)
* Fix some more style(9) issues.brucec2010-11-141-21/+21
|
* Fix style(9) issues from r215281 and r215282.brucec2010-11-141-14/+28
| | | | MFC after: 1 week
* Add some descriptions to sys/kern sysctls.brucec2010-11-141-23/+23
| | | | | | PR: kern/148710 Tested by: Chip Camden <sterling at camdensoftware.com> MFC after: 1 week
* Remove sysctl debug.ncnegfactor, it is renamed to vfs.ncnegfactor.kib2010-10-301-2/+0
| | | | MFC: do not
* Provide vfs.ncsizefactor instead of hard-coding namecache ratio.kib2010-10-161-12/+20
| | | | | | | | | Move debug.ncnegfactor to vfs.ncnegfactor [1]. Provide some descriptions for the namecache related sysctls [1]. Based on the submission by: Rogier R. Mulhuijzen <drwilco drwilco net> [1] MFC after: 2 weeks X-MFC-note: remove debug.ncnegfactor in HEAD after MFC
* Add an extra comment to the SDT probes definition. This allows us to getrpaulo2010-08-221-16/+16
| | | | | | | | | use '-' in probe names, matching the probe names in Solaris.[1] Add userland SDT probes definitions to sys/sdt.h. Sponsored by: The FreeBSD Foundation Discussed with: rwaston [1]
* Use ISO C99 integer types in sys/kern where possible.ed2010-06-211-2/+2
| | | | | | There are only about 100 occurences of the BSD-specific u_int*_t datatypes in sys/kern. The ISO C99 integer types are used here more often.
* The cache_enter(9) function shall not be called for doomed dvp.kib2010-04-201-0/+2
| | | | | | | | | | | | | | | | Assert this. In the reported panic, vdestroy() fired the assertion "vp has namecache for ..", because pseudofs may end up doing cache_enter() with reclaimed dvp, after dotdot lookup temporary unlocked dvp. Similar problem exists in ufs_lookup() for "." lookup, when vnode lock needs to be upgraded. Verify that dvp is not reclaimed before calling cache_enter(). Reported and tested by: pho Reviewed by: kan MFC after: 2 weeks
* Fix typo.kib2010-04-151-1/+1
| | | | MFC after: 3 days
* Correctly handle unlock for !MAKEENTRY case, after successfull attempt ofkib2009-08-141-1/+2
| | | | | | | | lock upgrade cache shall be unlocked from write. Reported by: Lucius Windschuh <lwindschuh googlemail com> Reviewed by: kan Approved by: re (rwatson)
* Add explicit struct ucred * argument for VOP_VPTOCNP, to be used bykib2009-06-211-7/+9
| | | | | | | | | | vn_open_cred in default implementation. Valid struct ucred is needed for audit and MAC, and curthread credentials may be wrong. This further requires modifying the interface of vn_fullpath(9), but it is out of scope of this change. Reviewed by: rwatson
* Unlock the cache lock before returning when we run out of buffer spacemarcus2009-06-051-1/+4
| | | | | | | trying to fill in the full path name. Reported by: David Naylor <naylor.b.david@gmail.com> Approved by: kib
* Unbreak the build. Add missed probes.kib2009-05-311-6/+12
| | | | | Reviewed by: rwatson Pointy hat to: me
* Eliminate code duplication in vn_fullpath1() around the cache lookupskib2009-05-311-85/+75
| | | | | | | | | | | | | | and calls to vn_vptocnp() by moving more of the common code to vn_vptocnp(). Rename vn_vptocnp() to vn_vptocnp_locked() to signify that cache is locked around the call. Do not track buffer position by both the pointer and offset, use only buflen to record the start of the free space. Export vn_vptocnp() for external consumers as a wrapper around vn_vptocnp_locked() that locks the cache and handles hold counts. Tested by: pho
* More fallout from negative dotdot caching. Negative entries shouldkan2009-04-171-8/+13
| | | | | | | be removed from and reinserted to proper ncneg list. Reported by: pho Submitted by: kib
* Redo previous change using simpler patch that happens to be alsokan2009-04-141-9/+3
| | | | | | more correct. Submitted by: tor
* Fix yet another negative dotodot entry fallout.kan2009-04-141-0/+12
| | | | Reported by: pho
* Fix v_cache_dd handling for negative entries. v_cache_dd pointer waskan2009-04-111-13/+14
| | | | | | | | | | not populated in parent directory if negative entry was being created, yet entry itself was added to the nc_neg list. It was possible for parent vnode to get discarded later, leaving negative entry pointing to now unused memory block. Reported by: dho Revewed by: kib
* When zapping v_cache_dd for !MAKEENTRY case in cache_lookup(), we shallkib2009-04-111-0/+2
| | | | | | lock cache as writer. Reviewed by: kan
* Cache_lookup() for DOTDOT drops dvp vnode lock, allowing dvp to be reclaimed.kib2009-04-101-1/+8
| | | | | | | | | Check the condition and return ENOENT then. In nfs_lookup(), respect ENOENT return from cache_lookup() when it is caused by dvp reclaim. Reported and tested by: pho
* Nul-terminate strings in the VFS name cache, which negligibly changerwatson2009-04-071-10/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the size and cost of name cache entries, but make adding debugging and tracing easier. Add SDT DTrace probes for various namecache events: vfs:namecache:enter:done - new entry in the name cache, passed parent directory vnode pointer, name added to the cache, and child vnode pointer. vfs:namecache:enter_negative:done - new negative entry in the name cache, passed parent vnode pointer, name added to the cache. vfs:namecache:fullpath:enter - call to vn_fullpath1() is made, passed the vnode to resolve to a name. vfs:namecache:fullpath:hit - vn_fullpath1() successfully resolved a search for the parent of an object using the namecache, passed the discovered parent directory vnode pointer, name, and child vnode pointer. vfs:namecache:fullpath:miss - vn_fullpath1() failed to resolve a search for the parent of an object using the namecache, passed the child vnode pointer. vfs:namecache:fullpath:return - vn_fullpath1() has completed, passed the error number, and if that is zero, the vnode to resolve, and the returned path. vfs:namecache:lookup:hit - postive name cache entry hit, passed the parent directory vnode pointer, name, and child vnode pointer. vfs:namecache:lookup:hit_negative - negative name cache entry hit, passed the parent directory vnode pointer and name. vfs:namecache:lookup:miss - name cache miss, passed the parent directory pointer and the full remaining component name (not terminated after the cache miss component). vfs:namecache:purge:done - name cache purge for a vnode, passed the vnode pointer to purge. vfs:namecache:purge_negative:done - name cache purge of negative entries for children of a vnode, passed the vnode pointer to purge. vfs:namecache:purgevfs - name cache purge for a mountpoint, passed the mount pointer. Separate probes will also be invoked for each cache entry zapped. vfs:namecache:zap:done - name cache entry zapped, passed the parent directory vnode pointer, name, and child vnode pointer. vfs:namecache:zap_negative:done - negative name cache entry zapped, passed the parent directory vnode pointer and name. For any probes involving an extant name cache entry (enter, hit, zapp), we use the nul-terminated string for the name component. For misses, the remainder of the path, including later components, is provided as an argument instead since there is no handy nul-terminated version of the string around. This is arguably a bug. MFC after: 1 month Sponsored by: Google, Inc. Reviewed by: jhb, kan, kib (earlier version)
* Revert change 190655 temporarily. It breaks many setups where nullfs iskan2009-04-041-1/+1
| | | | used and needs to be revisited.
* vn_vptocnp() unlocks the name cache and forgets to re-lock it beforepeter2009-04-021-1/+1
| | | | | returning in one error case, and mistakenly unlocks it for the umount -f case.
* Replace v_dd vnode pointer with v_cache_dd pointer to struct namecachekan2009-03-291-33/+90
| | | | | | | | | | | | in directory vnodes. Allow namecache dotdot entry to be created pointing from child vnode to parent vnode if no existing links in opposite direction exist. Use direct link from parent to child for dotdot lookups otherwise. This restores more efficient dotdot caching in NFS filesystems which was lost when vnodes stoppped being type stable. Reviewed by: kib
* When a file lookup fails due to encountering a doomed vnode from a forcedjhb2009-03-241-3/+3
| | | | | | | unmount, consistently return ENOENT rather than EBADF. Reviewed by: kib MFC after: 1 month
* Do not underflow the buffer and then report the problem. Check for thekib2009-03-201-6/+6
| | | | | | | | condition before the buffer write. Also, since buflen is unsigned, previous check was ignored. Reviewed by: marcus Tested by: pho
* Remove unneeded braces to reduce used vertical screen space.kib2009-03-201-2/+1
| | | | The location was missed in r190140.
OpenPOWER on IntegriCloud