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>
This commit is contained in:
Casey Bodley 2011-09-01 10:41:00 -04:00 committed by unknown
parent f1311b1108
commit 27fa6e93be

View file

@ -26,6 +26,7 @@
#include <Windows.h> #include <Windows.h>
#include <strsafe.h> #include <strsafe.h>
#include <time.h> #include <time.h>
#include <assert.h>
#include "nfs41_ops.h" #include "nfs41_ops.h"
#include "nfs41_compound.h" #include "nfs41_compound.h"
@ -136,6 +137,8 @@ static int attr_cache_entry_create(
list_remove(&entry->free_entry); list_remove(&entry->free_entry);
entry->fileid = fileid; entry->fileid = fileid;
entry->invalidated = FALSE;
entry->delegated = FALSE;
*entry_out = entry; *entry_out = entry;
out: out:
return status; return status;
@ -970,8 +973,10 @@ out_err_deleg:
struct attr_cache_entry *attributes; struct attr_cache_entry *attributes;
status = attr_cache_find_or_create(&cache->attributes, status = attr_cache_find_or_create(&cache->attributes,
info->fileid, &attributes); info->fileid, &attributes);
if (status == NO_ERROR) if (status == NO_ERROR) {
attr_cache_update(attributes, info, delegation); attr_cache_update(attributes, info, delegation);
cache->delegations++;
}
else else
status = ERROR_TOO_MANY_OPEN_FILES; status = ERROR_TOO_MANY_OPEN_FILES;
} }
@ -1020,6 +1025,7 @@ int nfs41_name_cache_delegreturn(
if (attributes->delegated) { if (attributes->delegated) {
attributes->delegated = FALSE; attributes->delegated = FALSE;
attr_cache_entry_deref(&cache->attributes, attributes); attr_cache_entry_deref(&cache->attributes, attributes);
assert(cache->delegations > 0);
cache->delegations--; cache->delegations--;
} }
status = NO_ERROR; status = NO_ERROR;