From 794dfeca493e6f62240c6a4bb321186564876930 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Mon, 11 Oct 2010 16:07:53 -0400 Subject: [PATCH] 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 --- daemon/lookup.c | 10 +++++----- daemon/name_cache.c | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/daemon/lookup.c b/daemon/lookup.c index 8f81b0b..17a800f 100644 --- a/daemon/lookup.c +++ b/daemon/lookup.c @@ -458,14 +458,14 @@ int nfs41_lookup( if (status == NO_ERROR || negative) goto out; - if (target_out->fh.len) { + if (parent_out->fh.len) { /* start where the name cache left off */ - if (target_out != &target) { + if (&parent != parent_out) { /* must make a copy for server_start, because - * server_lookup_loop() will overwrite target_out */ - path_fh_copy(&target, target_out); + * server_lookup_loop() will overwrite parent_out */ + path_fh_copy(&parent, parent_out); } - server_start = ⌖ + server_start = &parent; } else { /* start with PUTROOTFH */ server_start = NULL; diff --git a/daemon/name_cache.c b/daemon/name_cache.c index dd5f128..3d55ddf 100644 --- a/daemon/name_cache.c +++ b/daemon/name_cache.c @@ -595,7 +595,7 @@ static int name_cache_lookup( OUT OPTIONAL struct name_cache_entry **target_out, OUT OPTIONAL bool_t *is_negative) { - struct name_cache_entry *parent, *target, *tmp; + struct name_cache_entry *parent, *target; nfs41_component component; const char *path_pos; int status = NO_ERROR; @@ -613,17 +613,16 @@ static int name_cache_lookup( } while (next_component(path_pos, path_end, &component)) { - tmp = name_cache_search(cache, target, &component); - if (tmp == NULL || (skip_invis && entry_invis(tmp, is_negative))) { + parent = target; + target = name_cache_search(cache, parent, &component); + path_pos = component.name + component.len; + if (target == NULL || (skip_invis && entry_invis(target, is_negative))) { if (is_last_component(component.name, path_end)) status = ERROR_FILE_NOT_FOUND; else status = ERROR_PATH_NOT_FOUND; break; } - parent = target; - target = tmp; - path_pos = component.name + component.len; } out: if (remaining_path_out) *remaining_path_out = component.name; @@ -812,7 +811,8 @@ int nfs41_name_cache_lookup( if (parent_out) copy_fh(parent_out, parent); if (target_out) copy_fh(target_out, target); - if (info_out && target) copy_attrs(info_out, target->attributes); + if (info_out && target && target->attributes) + copy_attrs(info_out, target->attributes); out_unlock: ReleaseSRWLockShared(&cache->lock);