42 #define NAME_CACHE_EXPIRATION 20 45 #define NAME_CACHE_MAX_SIZE 262144 98 unsigned ref_count : 26;
100 unsigned invalidated : 1;
101 unsigned delegated : 1;
103 #define ATTR_ENTRY_SIZE sizeof(struct attr_cache_entry) 115 return lhs->fileid < rhs->fileid ? -1 : lhs->fileid > rhs->fileid;
121 #define attr_entry(pos) list_container(pos, struct attr_cache_entry, free_entry) 139 entry->fileid = fileid;
174 if (
entry->ref_count == 0)
181 return entry->invalidated ||
202 for (
i = 0;
i < max_entries;
i++) {
252 dprintf(
NCLVL1,
"--> attr_cache_find_or_create(%llu)\n", fileid);
272 dprintf(
NCLVL1,
"<-- attr_cache_find_or_create() returning %d\n",
294 entry->invalidated = 0;
310 entry->time_access_s =
info->time_access.seconds;
311 entry->time_access_ns =
info->time_access.nseconds;
314 entry->time_create_s =
info->time_create.seconds;
315 entry->time_create_ns =
info->time_create.nseconds;
318 entry->time_modify_s =
info->time_modify.seconds;
319 entry->time_modify_ns =
info->time_modify.nseconds;
333 dst->change =
src->change;
335 dst->time_access.seconds =
src->time_access_s;
336 dst->time_access.nseconds =
src->time_access_ns;
337 dst->time_create.seconds =
src->time_create_s;
338 dst->time_create.nseconds =
src->time_create_ns;
339 dst->time_modify.seconds =
src->time_modify_s;
340 dst->time_modify.nseconds =
src->time_modify_ns;
342 dst->numlinks =
src->numlinks;
344 dst->fileid =
src->fileid;
345 dst->hidden =
src->hidden;
346 dst->system =
src->system;
347 dst->archive =
src->archive;
349 dst->attrmask.count = 2;
366 struct name_tree rbchildren;
371 unsigned short component_len;
373 #define NAME_ENTRY_SIZE sizeof(struct name_cache_entry) 377 const int diff = rhs->component_len - lhs->component_len;
399 #define name_entry(pos) list_container(pos, struct name_cache_entry, exp_entry) 404 return cache->expiration > 0;
412 component->
name, component->len);
413 entry->component_len = component->len;
441 if (
entry->attributes) {
476 dprintf(
NCLVL2,
"name_cache_entry_create('%s') scavenged 0x%p\n",
547 cache->delegations++;
551 if (
entry->attributes->delegated)
553 }
else if (
entry->attributes) {
571 if (cinfo->after ==
entry->attributes->change ||
572 (cinfo->atomic && cinfo->before ==
entry->attributes->change)) {
573 entry->attributes->change = cinfo->after;
575 dprintf(
NCLVL1,
"name_cache_entry_changed('%s') has not changed. " 576 "updated change=%llu\n",
entry->component,
577 entry->attributes->change);
580 dprintf(
NCLVL1,
"name_cache_entry_changed('%s') has changed: was %llu, " 581 "got before=%llu\n",
entry->component,
582 entry->attributes->change, cinfo->before);
593 if (
entry->attributes) {
596 entry->attributes->invalidated = 1;
608 dprintf(
NCLVL2,
"--> name_cache_search('%.*s' under '%s')\n",
618 "found existing entry 0x%p\n",
entry);
635 if (is_negative) *is_negative = 1;
642 entry->attributes->fileid);
652 IN const char *path_end,
660 const char *path_pos;
689 if (remaining_path_out) *remaining_path_out =
component.name;
690 if (parent_out) *parent_out =
parent;
691 if (target_out) *target_out =
target;
720 dprintf(
NCLVL1,
"--> name_cache_find_or_create('%.*s' under '%s')\n",
736 dprintf(
NCLVL1,
"<-- name_cache_find_or_create() returning %d\n",
749 #define SIZE_PER_ENTRY (ATTR_ENTRY_SIZE + NAME_ENTRY_SIZE) 750 #define NAME_CACHE_MAX_ENTRIES (NAME_CACHE_MAX_SIZE / SIZE_PER_ENTRY) 827 IN const char *path_end,
835 const char *path_pos =
path;
855 if (remaining_path_out) *remaining_path_out = path_pos;
867 dprintf(
NCLVL1,
"--> nfs41_attr_cache_lookup(%llu)\n", fileid);
899 dprintf(
NCLVL1,
"--> nfs41_attr_cache_update(%llu)\n", fileid);
947 cache->delegations >=
cache->max_delegations) {
987 dprintf(
NCLVL1,
"<-- nfs41_name_cache_insert() returning %d\n",
1001 info->fileid, &attributes);
1004 cache->delegations++;
1022 dprintf(
NCLVL1,
"--> nfs41_name_cache_delegreturn(%llu, '%s')\n",
1039 attributes =
target->attributes;
1045 if (attributes ==
NULL) {
1051 if (attributes->delegated) {
1052 attributes->delegated =
FALSE;
1055 cache->delegations--;
1089 goto out_attributes;
1093 goto out_attributes;
1097 goto out_attributes;
1100 target->attributes->numlinks--;
1115 dprintf(
NCLVL1,
"nfs41_name_cache_remove: need to find attributes for %s\n",
path);
1118 attributes->numlinks--;
1124 IN const char *src_path,
1127 IN const char *dst_path,
1135 dprintf(
NCLVL1,
"--> nfs41_name_cache_rename('%s' to '%s')\n",
1136 src_path, dst_path);
1149 if (
status || dst_parent->attributes ==
NULL) {
1151 dprintf(
NCLVL1,
"nfs41_name_cache_rename: adding negative cache " 1152 "entry for %.*s\n", src_name->len, src_name->name);
1165 src_name->name + src_name->len,
NULL, &src_parent, &
src,
NULL);
1170 dprintf(
NCLVL1,
"nfs41_name_cache_rename: removing negative cache " 1171 "entry for %.*s\n", dst_name->len, dst_name->name);
1181 if (dst_parent == src_parent)
1187 if (existing ==
src)
1231 #define MAX_PUTFH_PER_COMPOUND 16 1236 IN OUT const char **path_pos,
1242 const char *path_end =
path->path +
path->len;
1257 for (
i = 0;
i < max_components;
i++) {
1258 files[
i].path =
path;
1308 putfh_args[
i].
file = &files[
i];
1365 const char *path_pos =
path->path;
1366 const char*
const path_end =
path->path +
path->len;
1375 path_pos = path_end;
static void attr_cache_free(IN struct attr_cache *cache)
#define MAX_PUTFH_PER_COMPOUND
#define ERROR_FILE_EXISTS
int nfs_to_windows_error(int status, int default_error)
static int name_cache_insert(IN struct name_cache_entry *entry, IN struct name_cache_entry *parent)
#define NAME_CACHE_EXPIRATION
static void copy_attrs(OUT nfs41_file_info *dst, IN const struct attr_cache_entry *src)
RB_HEAD(attr_tree, attr_cache_entry)
static void name_cache_entry_updated(IN struct nfs41_name_cache *cache, IN struct name_cache_entry *entry)
#define NFS41_MAX_COMPONENT_LEN
int nfs41_name_cache_free(IN struct nfs41_name_cache **cache_out)
#define RB_INSERT(name, x, y)
GLsizei const GLchar ** path
static __inline void attr_cache_entry_ref(IN struct attr_cache *cache, IN struct attr_cache_entry *entry)
GLuint GLuint GLsizei count
int compound_encode_send_decode(nfs41_session *session, nfs41_compound *compound, bool_t try_recovery)
static __inline bool_t name_cache_enabled(IN struct nfs41_name_cache *cache)
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
static int attr_cache_insert(IN struct attr_cache *cache, IN struct attr_cache_entry *entry)
#define RB_FIND(name, x, y)
DWORD WINAPI GetLastError(VOID)
static int attr_cache_find_or_create(IN struct attr_cache *cache, IN uint64_t fileid, OUT struct attr_cache_entry **entry_out)
int nfs41_name_cache_lookup(IN struct nfs41_name_cache *cache, IN const char *path, IN const char *path_end, OUT OPTIONAL const char **remaining_path_out, OUT OPTIONAL nfs41_fh *parent_out, OUT OPTIONAL nfs41_fh *target_out, OUT OPTIONAL nfs41_file_info *info_out, OUT OPTIONAL bool_t *is_negative)
static int attr_cache_entry_create(IN struct attr_cache *cache, IN uint64_t fileid, OUT struct attr_cache_entry **entry_out)
static __inline int attr_cache_entry_expired(IN const struct attr_cache_entry *entry)
#define RB_FOREACH_SAFE(x, name, head, y)
__WINE_SERVER_LIST_INLINE void list_add_tail(struct list *list, struct list *elem)
STRSAFEAPI StringCchCopyNA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc, size_t cchToCopy)
VOID WINAPI AcquireSRWLockShared(PSRWLOCK Lock)
static __inline uint32_t max_putfh_components(IN const nfs41_session *session)
int nfs41_name_cache_insert(IN struct nfs41_name_cache *cache, IN const char *path, IN const nfs41_component *name, IN OPTIONAL const nfs41_fh *fh, IN OPTIONAL const nfs41_file_info *info, IN OPTIONAL const change_info4 *cinfo, IN enum open_delegation_type4 delegation)
static __inline bool_t is_delegation(IN enum open_delegation_type4 type)
struct attr_cache_entry * pool
bool_t next_component(IN const char *path, IN const char *path_end, OUT nfs41_component *component)
int __cdecl system(_In_opt_z_ const char *_Command)
#define ERROR_FILE_NOT_FOUND
static int name_cache_lookup(IN struct nfs41_name_cache *cache, IN bool_t skip_invis, IN const char *path, IN const char *path_end, OUT OPTIONAL const char **remaining_path_out, OUT OPTIONAL struct name_cache_entry **parent_out, OUT OPTIONAL struct name_cache_entry **target_out, OUT OPTIONAL bool_t *is_negative)
#define NAME_CACHE_MAX_ENTRIES
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
char component[NFS41_MAX_COMPONENT_LEN]
VOID WINAPI ReleaseSRWLockExclusive(PSRWLOCK Lock)
int nfs41_attr_cache_update(IN struct nfs41_name_cache *cache, IN uint64_t fileid, IN const nfs41_file_info *info)
int nfs41_name_cache_delegreturn(IN struct nfs41_name_cache *cache, IN uint64_t fileid, IN const char *path, IN const nfs41_component *name)
static int name_cache_entry_create(IN struct nfs41_name_cache *cache, IN const nfs41_component *component, OUT struct name_cache_entry **entry_out)
static void free_entry(Entry *entry)
static void name_cache_entry_invalidate(IN struct nfs41_name_cache *cache, IN struct name_cache_entry *entry)
static int name_cache_find_or_create(IN struct nfs41_name_cache *cache, IN struct name_cache_entry *parent, IN const nfs41_component *component, OUT struct name_cache_entry **target_out)
struct name_cache_entry * pool
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
static void name_cache_unlink_children_recursive(IN struct nfs41_name_cache *cache, IN struct name_cache_entry *parent)
static bool_t get_path_fhs(IN struct nfs41_name_cache *cache, IN nfs41_abs_path *path, IN OUT const char **path_pos, IN uint32_t max_components, OUT nfs41_path_fh *files, OUT uint32_t *count)
static int name_cache_entry_changed(IN struct nfs41_name_cache *cache, IN struct name_cache_entry *entry, IN const change_info4 *cinfo)
#define RB_GENERATE(name, type, field, cmp)
static __inline void attr_cache_entry_deref(IN struct attr_cache *cache, IN struct attr_cache_entry *entry)
void fh_copy(OUT nfs41_fh *dst, IN const nfs41_fh *src)
static __inline void copy_fh(OUT nfs41_fh *dst, IN OPTIONAL const struct name_cache_entry *src)
void compound_add_op(nfs41_compound *compound, uint32_t opnum, void *arg, void *res)
static __inline void name_cache_entry_rename(OUT struct name_cache_entry *entry, IN const nfs41_component *component)
struct list_entry free_entries
static int name_cache_entry_update(IN struct nfs41_name_cache *cache, IN struct name_cache_entry *entry, IN OPTIONAL const nfs41_fh *fh, IN OPTIONAL const nfs41_file_info *info, IN enum open_delegation_type4 delegation)
__WINE_SERVER_LIST_INLINE int list_empty(const struct list *list)
#define ERROR_TOO_MANY_OPEN_FILES
unsigned char fh[NFS4_FHSIZE]
int nfs41_name_cache_rename(IN struct nfs41_name_cache *cache, IN const char *src_path, IN const nfs41_component *src_name, IN const change_info4 *src_cinfo, IN const char *dst_path, IN const nfs41_component *dst_name, IN const change_info4 *dst_cinfo)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
int name_cmp(struct name_cache_entry *lhs, struct name_cache_entry *rhs)
struct name_cache_entry * root
static __inline void name_cache_remove(IN struct name_cache_entry *entry, IN struct name_cache_entry *parent)
static int delete_stale_component(IN struct nfs41_name_cache *cache, IN nfs41_session *session, IN const nfs41_abs_path *path, IN const nfs41_component *component)
static struct name_cache_entry * name_cache_search(IN struct nfs41_name_cache *cache, IN struct name_cache_entry *parent, IN const nfs41_component *component)
#define RB_REMOVE(name, x, y)
void nfs41_session_sequence(struct __nfs41_sequence_args *args, nfs41_session *session, bool_t cachethis)
static void attr_cache_update(IN struct attr_cache_entry *entry, IN const nfs41_file_info *info, IN enum open_delegation_type4 delegation)
bool_t is_last_component(IN const char *path, IN const char *path_end)
static int rpc_array_putfh(IN nfs41_session *session, IN nfs41_path_fh *files, IN uint32_t count, OUT uint32_t *valid_out)
#define ERROR_NOT_SUPPORTED
void compound_init(nfs41_compound *compound, nfs_argop4 *argops, nfs_resop4 *resops, const char *tag)
static int attr_cache_init(IN struct attr_cache *cache, IN uint32_t max_entries)
VOID WINAPI InitializeSRWLock(PSRWLOCK Lock)
int nfs41_name_cache_remove(IN struct nfs41_name_cache *cache, IN const char *path, IN const nfs41_component *name, IN uint64_t fileid, IN const change_info4 *cinfo)
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
static void name_cache_entry_accessed(IN struct nfs41_name_cache *cache, IN struct name_cache_entry *entry)
#define ERROR_PATH_NOT_FOUND
static __inline void attr_cache_entry_free(IN struct attr_cache *cache, IN struct attr_cache_entry *entry)
GLuint GLuint GLsizei GLenum type
static int entry_invis(IN struct name_cache_entry *entry, OUT OPTIONAL bool_t *is_negative)
int nfs41_name_cache_remove_stale(IN struct nfs41_name_cache *cache, IN nfs41_session *session, IN nfs41_abs_path *path)
int attr_cmp(struct attr_cache_entry *lhs, struct attr_cache_entry *rhs)
int nfs41_attr_cache_lookup(IN struct nfs41_name_cache *cache, IN uint64_t fileid, OUT nfs41_file_info *info_out)
static SERVICE_STATUS status
static __inline void name_cache_unlink(IN struct nfs41_name_cache *cache, IN struct name_cache_entry *entry)
static struct attr_cache_entry * attr_cache_search(IN struct attr_cache *cache, IN uint64_t fileid)
VOID WINAPI ReleaseSRWLockShared(PSRWLOCK Lock)
VOID WINAPI AcquireSRWLockExclusive(PSRWLOCK Lock)
PULONG MinorVersion OPTIONAL
int nfs41_name_cache_create(OUT struct nfs41_name_cache **cache_out)
GLuint const GLchar * name