- diff --git a/daemon/name_cache.c b/daemon/name_cache.c
- index 9c389a6..73e1040 100644
- --- a/daemon/name_cache.c
- +++ b/daemon/name_cache.c
- @@ -39,10 +39,10 @@ enum {
- };
- -#define NAME_CACHE_EXPIRATION 20 /* TODO: get from configuration */
- +#define NAME_CACHE_EXPIRATION 3600 /* TODO: get from configuration */
- /* allow up to 8M of memory for name and attribute cache entries */
- -#define NAME_CACHE_MAX_SIZE (8*1024*1024L)
- +#define NAME_CACHE_MAX_SIZE (64*1024*1024L)
- /* negative lookup caching
- *
- @@ -797,7 +797,7 @@ int nfs41_name_cache_create(
- struct nfs41_name_cache *cache;
- int status = NO_ERROR;
- - DPRINTF(NCLVL1, ("nfs41_name_cache_create() with %ld entries\n",
- + DPRINTF(0, ("nfs41_name_cache_create() with %ld entries\n",
- (long)NAME_CACHE_MAX_ENTRIES));
- /* allocate the cache */
- @@ -988,6 +988,7 @@ int nfs41_name_cache_insert(
- /* limit the number of delegations to prevent attr cache starvation */
- if (is_delegation(delegation) &&
- cache->delegations >= cache->max_delegations) {
- + DPRINTF(0, ("nfs41_name_cache_insert: Delegation overflow: ERROR_TOO_MANY_OPEN_FILES\n"));
- status = ERROR_TOO_MANY_OPEN_FILES;
- goto out_unlock;
- }
- @@ -1046,9 +1047,11 @@ out_err_deleg:
- attr_cache_update(attributes, info, delegation);
- cache->delegations++;
- }
- - else
- + else {
- + DPRINTF(0, ("nfs41_name_cache_insert: Cache attr_cache_find_or_create() failed: ERROR_TOO_MANY_OPEN_FILES\n"));
- status = ERROR_TOO_MANY_OPEN_FILES;
- }
- + }
- goto out_unlock;
- }
- diff --git a/daemon/open.c b/daemon/open.c
- index dfaf17f..8230faf 100644
- --- a/daemon/open.c
- +++ b/daemon/open.c
- @@ -35,6 +35,7 @@
- #include "util.h"
- #include "idmap.h"
- #include "accesstoken.h"
- +#include "name_cache.h"
- static int create_open_state(
- IN const char *path,
- @@ -802,6 +803,11 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
- goto out_free_state;
- }
- + if (nfs41_attr_cache_update(session_name_cache(state->session),
- + state->file.fh.fileid, &og_info) == NO_ERROR) {
- + DPRINTF(0, ("handle_open: nfs41_attr_cache_update() failed\n"));
- + }
- +
- info.owner = info.owner_buf;
- (void)strcpy(info.owner, og_info.owner);
- info.attrmask.arr[1] |= FATTR4_WORD1_OWNER;
- diff --git a/daemon/readdir.c b/daemon/readdir.c
- index a2d7772..e891855 100644
- --- a/daemon/readdir.c
- +++ b/daemon/readdir.c
- @@ -30,6 +30,7 @@
- #include "daemon_debug.h"
- #include "upcall.h"
- #include "util.h"
- +#include "name_cache.h"
- /*
- @@ -794,6 +795,58 @@ fetch_entries:
- entry = (nfs41_readdir_entry*)entry_pos;
- offset = (PULONG)dst_pos; /* ULONG NextEntryOffset */
- +#if 1
- + static volatile long long update_ok = 0LL;
- + static volatile long long update_missed = 0LL;
- +
- + if (nfs41_attr_cache_update(session_name_cache(state->session),
- + entry->attr_info.fileid, &entry->attr_info) == NO_ERROR) {
- + update_ok++;
- + }
- + else {
- + update_missed++;
- +/*
- + * Does not work yet, this generates these errors:
- + * ---- snip ----
- + * get_stat_data: nfs41_getattr('\bigdisk\builds\bash') failed with 10020
- + * get_stat_data: nfs41_getattr('\bigdisk\builds\bash') failed with 10020
- + * ---- snip ----
- + */
- +#if DOES_NOT_WORK_YET
- + nfs41_component nc;
- + int nci_status;
- + char name_buff[NFS41_MAX_PATH_LEN+1];
- + char *nb_s = name_buff;
- +
- + nb_s = stpcpy(nb_s, state->file.path->path);
- + *nb_s++ = '\\';
- + nc.name = nb_s;
- + nb_s = stpcpy(nb_s, entry->name);
- + EASSERT((nb_s - nc.name) < SHRT_MAX);
- + nc.len = (unsigned short)(nb_s - nc.name);
- + EASSERT_MSG((nc.len == strlen(nc.name)),
- + ("nc.len=%d, strlen(nc.name)=%d\n",
- + (int)nc.len, (int)strlen(nc.name)));
- +
- + nci_status = nfs41_name_cache_insert(session_name_cache(state->session),
- + name_buff, &nc, NULL, &entry->attr_info, NULL,
- + OPEN_DELEGATE_NONE);
- + if (nci_status != NO_ERROR) {
- + DPRINTF(0,
- + ("handle_readdir: nfs41_name_cache_insert() "
- + "failed for path='%s' nc.(name='%s', len=%d), status=%lx\n",
- + state->file.path->path,
- + nc.name, (int)nc.len,
- + (long)nci_status));
- + }
- +#endif /* DOES_NOT_WORK_YET */
- + }
- +
- + if (((update_missed+update_ok) % 50LL) == 0LL) {
- + DPRINTF(0, ("handle_readdir: cache update: ok=%lld\tmissed=%lld\n", update_ok, update_missed));
- + }
- +#endif
- +
- DPRINTF(2, ("filter '%s' looking at '%s' with cookie %d\n",
- args->filter, entry->name, entry->cookie));
- if (readdir_filter((const char*)args->filter, entry->name)) {
readdir update namecache prototype001
Posted by Anonymous on Tue 16th Jul 2024 14:21
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.