From 27fa6e93bee8e68055fd21b448d0ec7a742bf085 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Thu, 1 Sep 2011 10:41:00 -0400 Subject: [PATCH] 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 --- daemon/name_cache.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/daemon/name_cache.c b/daemon/name_cache.c index 9a0e737..d437bea 100644 --- a/daemon/name_cache.c +++ b/daemon/name_cache.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "nfs41_ops.h" #include "nfs41_compound.h" @@ -136,6 +137,8 @@ static int attr_cache_entry_create( list_remove(&entry->free_entry); entry->fileid = fileid; + entry->invalidated = FALSE; + entry->delegated = FALSE; *entry_out = entry; out: return status; @@ -970,8 +973,10 @@ out_err_deleg: struct attr_cache_entry *attributes; status = attr_cache_find_or_create(&cache->attributes, info->fileid, &attributes); - if (status == NO_ERROR) + if (status == NO_ERROR) { attr_cache_update(attributes, info, delegation); + cache->delegations++; + } else status = ERROR_TOO_MANY_OPEN_FILES; } @@ -1020,6 +1025,7 @@ int nfs41_name_cache_delegreturn( if (attributes->delegated) { attributes->delegated = FALSE; attr_cache_entry_deref(&cache->attributes, attributes); + assert(cache->delegations > 0); cache->delegations--; } status = NO_ERROR;