pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


readdir update namecache prototype001
Posted by Anonymous on Tue 16th Jul 2024 14:21
raw | new post

  1. diff --git a/daemon/name_cache.c b/daemon/name_cache.c
  2. index 9c389a6..73e1040 100644
  3. --- a/daemon/name_cache.c
  4. +++ b/daemon/name_cache.c
  5. @@ -39,10 +39,10 @@ enum {
  6.  };
  7.  
  8.  
  9. -#define NAME_CACHE_EXPIRATION 20 /* TODO: get from configuration */
  10. +#define NAME_CACHE_EXPIRATION 3600 /* TODO: get from configuration */
  11.  
  12.  /* allow up to 8M of memory for name and attribute cache entries */
  13. -#define NAME_CACHE_MAX_SIZE (8*1024*1024L)
  14. +#define NAME_CACHE_MAX_SIZE (64*1024*1024L)
  15.  
  16.  /* negative lookup caching
  17.   *
  18. @@ -797,7 +797,7 @@ int nfs41_name_cache_create(
  19.      struct nfs41_name_cache *cache;
  20.      int status = NO_ERROR;
  21.  
  22. -    DPRINTF(NCLVL1, ("nfs41_name_cache_create() with %ld entries\n",
  23. +    DPRINTF(0, ("nfs41_name_cache_create() with %ld entries\n",
  24.          (long)NAME_CACHE_MAX_ENTRIES));
  25.  
  26.      /* allocate the cache */
  27. @@ -988,6 +988,7 @@ int nfs41_name_cache_insert(
  28.      /* limit the number of delegations to prevent attr cache starvation */
  29.      if (is_delegation(delegation) &&
  30.          cache->delegations >= cache->max_delegations) {
  31. +        DPRINTF(0, ("nfs41_name_cache_insert: Delegation overflow: ERROR_TOO_MANY_OPEN_FILES\n"));
  32.          status = ERROR_TOO_MANY_OPEN_FILES;
  33.          goto out_unlock;
  34.      }
  35. @@ -1046,9 +1047,11 @@ out_err_deleg:
  36.              attr_cache_update(attributes, info, delegation);
  37.              cache->delegations++;
  38.          }
  39. -        else
  40. +        else {
  41. +            DPRINTF(0, ("nfs41_name_cache_insert: Cache attr_cache_find_or_create() failed: ERROR_TOO_MANY_OPEN_FILES\n"));
  42.              status = ERROR_TOO_MANY_OPEN_FILES;
  43.          }
  44. +    }
  45.      goto out_unlock;
  46.  }
  47.  
  48. diff --git a/daemon/open.c b/daemon/open.c
  49. index dfaf17f..8230faf 100644
  50. --- a/daemon/open.c
  51. +++ b/daemon/open.c
  52. @@ -35,6 +35,7 @@
  53.  #include "util.h"
  54.  #include "idmap.h"
  55.  #include "accesstoken.h"
  56. +#include "name_cache.h"
  57.  
  58.  static int create_open_state(
  59.      IN const char *path,
  60. @@ -802,6 +803,11 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  61.                  goto out_free_state;
  62.              }
  63.  
  64. +            if (nfs41_attr_cache_update(session_name_cache(state->session),
  65. +                state->file.fh.fileid, &og_info) == NO_ERROR) {
  66. +                DPRINTF(0, ("handle_open: nfs41_attr_cache_update() failed\n"));
  67. +            }
  68. +
  69.              info.owner = info.owner_buf;
  70.              (void)strcpy(info.owner, og_info.owner);
  71.              info.attrmask.arr[1] |= FATTR4_WORD1_OWNER;
  72. diff --git a/daemon/readdir.c b/daemon/readdir.c
  73. index a2d7772..e891855 100644
  74. --- a/daemon/readdir.c
  75. +++ b/daemon/readdir.c
  76. @@ -30,6 +30,7 @@
  77.  #include "daemon_debug.h"
  78.  #include "upcall.h"
  79.  #include "util.h"
  80. +#include "name_cache.h"
  81.  
  82.  
  83.  /*
  84. @@ -794,6 +795,58 @@ fetch_entries:
  85.              entry = (nfs41_readdir_entry*)entry_pos;
  86.              offset = (PULONG)dst_pos; /* ULONG NextEntryOffset */
  87.  
  88. +#if 1
  89. +            static volatile long long update_ok = 0LL;
  90. +            static volatile long long update_missed = 0LL;
  91. +
  92. +            if (nfs41_attr_cache_update(session_name_cache(state->session),
  93. +                entry->attr_info.fileid, &entry->attr_info) == NO_ERROR) {
  94. +                update_ok++;
  95. +            }
  96. +            else {
  97. +                update_missed++;
  98. +/*
  99. + * Does not work yet, this generates these errors:
  100. + * ---- snip ----
  101. + * get_stat_data: nfs41_getattr('\bigdisk\builds\bash') failed with 10020
  102. + * get_stat_data: nfs41_getattr('\bigdisk\builds\bash') failed with 10020
  103. + * ---- snip ----
  104. + */
  105. +#if DOES_NOT_WORK_YET
  106. +                nfs41_component nc;
  107. +                int nci_status;
  108. +                char name_buff[NFS41_MAX_PATH_LEN+1];
  109. +                char *nb_s = name_buff;
  110. +
  111. +                nb_s = stpcpy(nb_s, state->file.path->path);
  112. +                *nb_s++ = '\\';
  113. +                nc.name = nb_s;
  114. +                nb_s = stpcpy(nb_s, entry->name);
  115. +                EASSERT((nb_s - nc.name) < SHRT_MAX);
  116. +                nc.len = (unsigned short)(nb_s - nc.name);
  117. +                EASSERT_MSG((nc.len == strlen(nc.name)),
  118. +                    ("nc.len=%d, strlen(nc.name)=%d\n",
  119. +                        (int)nc.len, (int)strlen(nc.name)));
  120. +
  121. +                nci_status = nfs41_name_cache_insert(session_name_cache(state->session),
  122. +                    name_buff, &nc, NULL, &entry->attr_info, NULL,
  123. +                    OPEN_DELEGATE_NONE);
  124. +                if (nci_status != NO_ERROR) {
  125. +                    DPRINTF(0,
  126. +                        ("handle_readdir: nfs41_name_cache_insert() "
  127. +                        "failed for path='%s' nc.(name='%s', len=%d), status=%lx\n",
  128. +                            state->file.path->path,
  129. +                            nc.name, (int)nc.len,
  130. +                            (long)nci_status));
  131. +                }
  132. +#endif /* DOES_NOT_WORK_YET */
  133. +            }
  134. +
  135. +            if (((update_missed+update_ok) % 50LL) == 0LL) {
  136. +                DPRINTF(0, ("handle_readdir: cache update: ok=%lld\tmissed=%lld\n", update_ok, update_missed));
  137. +            }
  138. +#endif
  139. +
  140.              DPRINTF(2, ("filter '%s' looking at '%s' with cookie %d\n",
  141.                  args->filter, entry->name, entry->cookie));
  142.              if (readdir_filter((const char*)args->filter, entry->name)) {

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.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at