Commit graph

38 commits

Author SHA1 Message Date
Casey Bodley
787202cb9d name cache: skip rename with same src and target
fileio tests 214,215 does lots of renames with the same source and target filename.  nfs41_name_cache_rename() would operate on the same pointer for both src and existing, and accidentally turn both into a negative entry

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2012-04-26 16:13:54 -04:00
Olga Kornievskaia
49580a8cfe handling hidden system archive file attributes
todo: still need to mask supported attributes while doing getattrs
2012-04-02 12:49:44 -04:00
Casey Bodley
bbb1ed696c license changed to LGPL: added COPYING file, changed source file comments
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2012-03-19 12:24:43 -04:00
Casey Bodley
a085a8979b deleg: fix for attributes in CB_GETATTR
CB_GETATTR specifies the delegation by filehandle, but deleg_fh_cmp() was comparing superblock and fileid.  renamed deleg_fh_cmp() to deleg_file_cmp(), and created new deleg_fh_cmp() to compare actual filehandles

call to nfs41_attr_cache_lookup() was not setting flags in info.attrmask, so the change and size attributes were not being encoded in the CB_GETATTR response

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2012-02-28 12:13:56 -05:00
Casey Bodley
63f499c4b7 cache: check for expiry on nfs41_attr_cache_lookup()
added expiration field to struct attr_cache_entry.  expiration timer is reset whenever attr_cache_update() is called with a 'change' attribute

new function attr_cache_entry_expired() is used by nfs41_attr_cache_lookup() and name_cache_lookup()/entry_invis() to prevent the use of expired attributes

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2012-02-03 18:26:34 -05:00
Olga Kornievskaia
9af1b590ff [cosmetic] dprintf changes in acl, getattr, name_cache, namespace 2011-11-07 10:50:00 -05:00
Casey Bodley
7f82baf13f namecache: fix for negative entries on rename
this addresses two error cases:

1) when the src entry is negative or does not exist: the dst entry could be negative or point to something else, so it needs to be removed
2) when the dst_parent entry is negative or does not exist: src needs to be made a negative entry

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-11-04 17:01:46 -04:00
Casey Bodley
f988c89bf4 namecache: fix for numlinks on remove
nfs41_name_cache_remove() needs to update the 'numlinks' attribute for other links, even if the file being removed is not found in the cache.  to search for its attr cache entry, nfs41_name_cache_remove() now requires a fileid argument.  nfs41_remove() only gets a pointer to the parent's filehandle, so it also needs the target fileid argument

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-11-04 13:14:40 -04:00
Casey Bodley
27fa6e93be namecache: fix for counting of delegations
the out_err_deleg: case of nfs41_name_cache_insert() was forgetting to increment cache->delegations, leading to a decrement past 0.  once that happens, the cache stops accepting delegations because it's comparing cache->max_delegations against UINT_MAX

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-09-06 17:58:23 -04:00
Casey Bodley
ead5bc78a2 namecache: cleanup name_cache_entry_update()
added goto out on attr_cache_find_or_create() failure to avoid calling name_cache_entry_updated()

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-08-26 13:06:01 -04:00
Casey Bodley
a4b39031b9 namecache: cleanup nfs41_name_cache_insert()
removed unused variable 'grandparent'
factored out the call to name_cache_entry_update() from root/non-root paths

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-08-26 13:05:49 -04:00
Casey Bodley
af80ded902 namecache: check for empty list before scavenging
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-08-26 13:05:38 -04:00
Casey Bodley
6c555e028b namecache: prefer to evict child entries over parents
renamed name_cache_entry_refresh() to name_cache_entry_updated().  this function resets the entry's expiration timer.  new function name_cache_entry_accessed() deals with moving the entry to the end of exp_entries to prevent eviction

name_cache_entry_accessed() now does the same for its parents as well.  cache consistency of the parents is maintained because their expiration timers are unchanged.  by 'refreshing' the parents of each name cache entry inserted, the eviction policy will always prefer child nodes (which are far less costly to evict)

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-08-25 14:04:54 -04:00
Casey Bodley
0d86c68138 namecache: delegation-related fixes
open_update_cache() wasn't retrying insert after the open_delegation_return() error case
nfs41_name_cache_delegreturn() needs a check for if (attributes->delegated) to avoid an extra deref when the call to nfs41_name_cache_insert() failed
added a TODO comment to nfs41_client_delegation_return_lru() for improvements to the naive algorithm

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-08-25 14:04:46 -04:00
Olga Kornievskaia
969783d46b removing unnecessary ZeroMemory calls
instead of calling ZeroMemory(foobar) to initialize the data structure,
during declaration do struct some_struct foobar = { 0 }
2011-08-24 17:43:20 -04:00
Casey Bodley
7b07dcebb8 namecache: limit the number of delegations
to prevent delegations from claiming all available slots in the attribute cache, nfs41_name_cache_insert() now returns ERROR_TOO_MANY_OPEN_FILES when the number of delegated entries reaches 50% of the cache capacity.  see comment 'delegations and cache feedback' in name_cache.c for details

when nfs41_open() sees this error from nfs41_name_cache_insert(), it calls new function nfs41_client_delegation_return_lru() to return the least-recently-used delegation and, if successful, loops back to nfs41_name_cache_insert().  nfs41_client_delegation_return_lru() returns NFS4ERR_BADHANDLE if all delegations are currently in use (associated with an existing open), in which case nfs41_open() returns the newly-granted delegation

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-08-22 11:51:46 -04:00
Casey Bodley
a0d4403a99 deleg: return delegation on attr cache failure
on opens that grant a delegation, return the delegation immediately if attribute cache insertion fails

nfs41_name_cache_insert() now returns success in the 'out_err_deleg' case, where name cache insertion failed but attr cache insertion was successful

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-08-22 11:49:52 -04:00
Casey Bodley
28032a0309 namecache: bug fix for name_cache_insert()
once the attribute cache fills up with delegated entries, attr_cache_find_or_create() will start returning ERROR_OUTOFMEMORY.  this is a problem for nfs41_name_cache_insert(), because name_cache_find_or_create() will succeed and then name_cache_entry_update() will fail.  this leaves behind a name cache entry with attributes=NULL, which is treated like a negative entry and causes later lookups to fail with ERROR_FILE_NOT_FOUND

added a call to name_cache_entry_invalidate() to clean up this entry if name_cache_entry_update() fails

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-08-16 17:53:19 -04:00
Olga Kornievskaia
04ab888492 [cosmetic] minor license changes
added 2011 year to the copyright line
added authors info to the license
added UofM license to libtirpc files that we modified
(but i probably missed some)
2011-08-12 13:20:12 -04:00
Casey Bodley
38259e0017 deleg: delegation support for name/attr cache
when a delegation is granted by OPEN, its delegation type is passed to nfs41_name_cache_insert().  as long as the delegation is held, its name_cache_entry is kept out of the cache.exp_entries list to prevent it from expiring.  an extra reference is held on the attr_cache_entry as well, so it sticks around even if the name_cache_entry is removed (a parent expires, for example).  new function nfs41_name_cache_delegreturn() adds the name_cache_entry back to the list, and releases the extra attr_cache_entry reference

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-07-18 15:24:23 -04:00
Casey Bodley
a4c726f92d name cache: no longer copies fh for negative entries
nfs41_name_cache_lookup() was returning FILE_NOT_FOUND on negative entries, but still copying the target filehandle

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-06-14 12:36:07 -04:00
Olga Kornievskaia
b9e369fac6 adding query for FileInternalInformation infoclass
this query asks for a file index which is unique identifier for a file which
we can satisfy from file attribute called "fileid"
2011-04-12 14:06:13 -04:00
Olga Kornievskaia
c596742659 fixing rbtree patch
name cache parent entry was never initialized. thus causing entries never to be removed from the name cache.
2010-12-07 16:50:45 -05:00
Casey Bodley
7c8f58b992 recovery: avoid recursive state recovery
avoid the recursive case where state recovery operations (OPEN for reclaim and RECLAIM_COMPLETE) return BADSESSION, which kicks off another round of recovery

added a 'bool_t try_recovery' argument to compound_encode_send_decode() in place of its unused 'bufsize_in' and 'bufsize_out'.  when try_recovery=FALSE, return BADSESSION/STALE_CLIENTID errors instead of attempting recovery.  nfs41_open_reclaim(), nfs41_reclaim_complete(), and nfs41_destroy_session() now pass try_recovery=FALSE

during state recovery, we can now check the return values of nfs41_open_reclaim() and nfs41_reclaim_complete() for BADSESSION, and use a goto to restart session recovery

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-12-06 14:29:01 -05:00
Casey Bodley
32f9fa9334 replace rbtree implementation with tree.h from freebsd
added tree.h from freebsd repository and ported our name cache and client owner code

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-12-01 10:25:29 -05:00
Casey Bodley
91f584ba4b name cache: avoid copying strings for dprintf
use printf("%.*s", len, string) to print non-null-terminated strings

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-11-24 12:06:11 -05:00
Olga Kornievskaia
e51ba46d8b adding tags to compounds
contributed by Tigran
2010-10-27 15:00:12 -04:00
Casey Bodley
f8885dbad0 warnings from WDK 6000
fixed a few cases of warning 4242: possible loss of data

wincrypt.h appears to come with windows.h in later versions of the ddk, but nfs41_client.c fails to compile in WDK 6001 without #include <wincrypt.h>

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-19 11:17:29 -04:00
Casey Bodley
d345a7b12e name cache: bug fix for name_cache_search()
symptom: in certain cases, name_cache_find_or_create() was returning ERROR_FILE_EXISTS, which should never happen!

cause: the string comparisons in name_cache_search() and name_cache_insert() were returning different results when the argument to name_cache_search() is a) not null-terminated, and b) shorter than the other string.  this caused name_cache_search() to search the wrong branch of the rbtree and fail to find the component, while name_cache_insert() would correctly find it and return ERROR_FILE_EXISTS

fix: compare the string lengths before calling strncmp() to avoid comparing past the end of the component.  moved the comparisons to a separate component_cmp() function called by both name_cache_search() and name_cache_insert() to make sure they get the same result!

Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:48 -04:00
Casey Bodley
7db2d60c3b cosmetic: comment describing negative lookup caching
/* negative lookup caching
 *
 * by caching lookups that result in NOENT, we can avoid sending subsequent
 * lookups over the wire.  a name cache entry is negative when its attributes
 * pointer is NULL.  negative entries are created by three functions:
 * nfs41_name_cache_remove(), _insert() when called with NULL for the fh and
 * attributes, and _rename() for the source entry
 */

Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:47 -04:00
Casey Bodley
794dfeca49 name cache: lookup semantics match nfs41_lookup() on NOENT
previously, when the name cache encountered a missing/negative/expired entry, it returned the previous two entries as 'target' and 'parent', and nfs41_lookup() started new lookups from the filehandle in 'target'.  this differs from nfs41_lookup(), which on NOENT will return NULL for the 'target' and the previous entry as 'parent'.  modified name_cache_lookup() to do the same, and updated nfs41_lookup() to start new lookups from the filehandle in 'parent'

now when nfs41_lookup() gets the is_negative flag from nfs41_name_cache_lookup(), it can just return the error without needing to copy the 'target' to 'parent'

Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:47 -04:00
Casey Bodley
765bc0284b name cache: rename leaves behind a negative entry
as before, we move the src entry from src_parent to dst_parent.  but instead of unlinking the destination entry if it exists, we recycle it as a negative entry where src used to be.  if the destination entry doesn't exist, we create a new one for this negative entry

if the dst_parent entry is invalidated by the change_info, we just leave the original src entry in place and make it negative

Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:46 -04:00
Casey Bodley
bc81c3f6f5 name cache: negative entries ignore change_info
negative lookup entries don't have attributes, so we won't invalidate them based on 'change'.  name_cache_entry_changed() returns false if entry->attributes == NULL

Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:46 -04:00
Casey Bodley
61ddf671fa name cache: remove changes entry to negative
instead of calling name_cache_entry_unlink(), nfs41_name_cache_remove() calls name_cache_entry_update() with NULL for fh and info to make it a negative entry, then name_cache_unlink_children_recursive() to remove any children

Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:45 -04:00
Casey Bodley
6ee8bba79e name cache: merged entry_has_expired() into entry_invis()
Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:44 -04:00
Casey Bodley
6bc86c1bff name cache: insert supports negative entries
marked nfs41_name_cache_insert() parameters fh and info as OPTIONAL; passing NULL designates a negative lookup entry
name_cache_entry_create() no longer calls attr_cache_find_or_create(), and doesn't need the 'fileid' argument
name_cache_entry_update() also makes fh and info OPTIONAL, and handles the cases where we switch from a negative <-> positive entry, calling attr_cache_find_or_create() or attr_cache_entry_deref() as appropriate
removed unused function name_cache_find_or_create(); everything uses name_cache_entry_find_or_create() instead, so renamed that to name_cache_find_or_create()

Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:43 -04:00
Casey Bodley
112313bc45 name cache: lookup returns flag is_negative
added function entry_invis() in addition to entry_has_expired().  entry_invis() returns true if entry_has_expired() or for negative entries.  the is_negative flag is set for negative entries (defined as having entry->attributes == NULL), and returned by nfs41_name_cache_lookup().  when nfs41_lookup() sees this flag set, it returns the status without attempting to do any more lookups

Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:43 -04:00
Casey Bodley
0ad4db4fad fresh git tree for public release
we regretfully had to remove our git history for licensing reasons

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-12 10:15:48 -04:00