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>
This commit is contained in:
Casey Bodley 2011-08-26 12:16:07 -04:00 committed by unknown
parent af80ded902
commit a4b39031b9

View file

@ -898,7 +898,7 @@ int nfs41_name_cache_insert(
IN OPTIONAL const change_info4 *cinfo, IN OPTIONAL const change_info4 *cinfo,
IN enum open_delegation_type4 delegation) IN enum open_delegation_type4 delegation)
{ {
struct name_cache_entry *grandparent, *parent, *target; struct name_cache_entry *parent, *target;
int status; int status;
dprintf(NCLVL1, "--> nfs41_name_cache_insert('%.*s')\n", dprintf(NCLVL1, "--> nfs41_name_cache_insert('%.*s')\n",
@ -927,29 +927,28 @@ int nfs41_name_cache_insert(
if (status) if (status)
goto out_err_deleg; goto out_err_deleg;
} }
target = cache->root;
} else {
/* find/create an entry under its parent */
status = name_cache_lookup(cache, 0, path,
name->name, NULL, NULL, &parent, NULL);
if (status)
goto out_err_deleg;
status = name_cache_entry_update(cache, if (cinfo && name_cache_entry_changed(cache, parent, cinfo)) {
cache->root, fh, info, delegation); name_cache_entry_invalidate(cache, parent);
goto out_err_deleg; goto out_err_deleg;
}
status = name_cache_find_or_create(cache, parent, name, &target);
if (status)
goto out_err_deleg;
} }
status = name_cache_lookup(cache, 0, path, name->name, /* pass in the new fh/attributes */
NULL, &grandparent, &parent, NULL);
if (status)
goto out_err_deleg;
if (cinfo && name_cache_entry_changed(cache, parent, cinfo)) {
name_cache_entry_invalidate(cache, parent);
goto out_err_deleg;
}
status = name_cache_find_or_create(cache, parent, name, &target);
if (status)
goto out_err_deleg;
status = name_cache_entry_update(cache, target, fh, info, delegation); status = name_cache_entry_update(cache, target, fh, info, delegation);
if (status) if (status)
name_cache_entry_invalidate(cache, target); goto out_err_update;
out_unlock: out_unlock:
ReleaseSRWLockExclusive(&cache->lock); ReleaseSRWLockExclusive(&cache->lock);
@ -958,6 +957,11 @@ out_unlock:
status); status);
return status; return status;
out_err_update:
/* a failure in name_cache_entry_update() leaves a negative entry
* where there shouldn't be one; remove it from the cache */
name_cache_entry_invalidate(cache, target);
out_err_deleg: out_err_deleg:
if (is_delegation(delegation)) { if (is_delegation(delegation)) {
/* we still need a reference to the attributes for the delegation */ /* we still need a reference to the attributes for the delegation */