38#define PATH_CACHE_HASH_MASK (LOSCFG_MAX_PATH_CACHE_SIZE - 1)
40#ifdef LOSCFG_DEBUG_VERSION
43#define TRACE_TRY_CACHE() do { g_totalPathCacheTry++; } while (0)
44#define TRACE_HIT_CACHE(pc) do { pc->hit++; g_totalPathCacheHit++; } while (0)
54#define TRACE_TRY_CACHE()
55#define TRACE_HIT_CACHE(pc)
60 for (
int i = 0; i < LOSCFG_MAX_PATH_CACHE_SIZE; i++) {
68 PRINTK(
"-------->pathCache dump in\n");
69 for (
int i = 0; i < LOSCFG_MAX_PATH_CACHE_SIZE; i++) {
74 PRINTK(
" pathCache dump hash %d item %s %p %p %d\n", i,
78 PRINTK(
"-------->pathCache dump out\n");
85 for (
int i = 0; i < LOSCFG_MAX_PATH_CACHE_SIZE; i++) {
94 PRINTK(
"pathCache number = %d\n", pathCacheNum);
95 PRINTK(
"pathCache memory size = %d(B)\n", pathCacheNum *
sizeof(
struct PathCache) + nameSum);
108 int hash =
NameHash(
name, len, parent) & PATH_CACHE_HASH_MASK;
115 size_t pathCacheSize;
118 if (
name == NULL || len > NAME_MAX || parent == NULL || vnode == NULL) {
121 pathCacheSize =
sizeof(
struct PathCache) + len + 1;
125 PRINT_ERR(
"pathCache alloc failed, no memory!\n");
129 ret = strncpy_s(pc->
name, len + 1,
name, len);
150 PRINT_ERR(
"pathCache free: invalid pathCache\n");
165 int hash =
NameHash(
name, len, parent) & PATH_CACHE_HASH_MASK;
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListInit(LOS_DL_LIST *list)
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListDelete(LOS_DL_LIST *node)
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListAdd(LOS_DL_LIST *list, LOS_DL_LIST *node)
Insert a new node to a doubly linked list.
LITE_OS_SEC_ALW_INLINE STATIC INLINE UINT32 LOS_HashFNV32aBuf(const VOID *buf, size_t len, UINT32 hval)
void * zalloc(size_t size)
void free(void *ptr)
释放ptr所指向的内存空间
void PathCacheMemoryDump(void)
void VnodePathCacheFree(struct Vnode *vnode)
和长辈,晚辈告别,从此不再是父亲和孩子.
static int g_totalPathCacheHit
void ResetPathCacheHitInfo(int *hit, int *try)
int PathCacheFree(struct PathCache *pc)
static void FreeParentPathCache(struct Vnode *vnode)
static uint32_t NameHash(const char *name, int len, struct Vnode *dvp)
static void FreeChildPathCache(struct Vnode *vnode)
static int g_totalPathCacheTry
LIST_HEAD * GetPathCacheList()
int PathCacheLookup(struct Vnode *parent, const char *name, int len, struct Vnode **vnode)
static void PathCacheInsert(struct Vnode *parent, struct PathCache *cache, const char *name, int len)
LIST_HEAD g_pathCacheHashEntrys[LOSCFG_MAX_PATH_CACHE_SIZE]
struct PathCache * PathCacheAlloc(struct Vnode *parent, struct Vnode *vnode, const char *name, uint8_t len)
struct Vnode * childVnode
struct Vnode * parentVnode
vnode并不包含文件名,因为 vnode和文件名是 1:N 的关系
LIST_HEAD childPathCaches
LIST_HEAD parentPathCaches