Skip to content

Commit 8e18f35

Browse files
GorrayLiRbb666
authored andcommitted
[components/dfs]add doxygen comments for dfs pcache file in dfs_v2.
1 parent ae50e40 commit 8e18f35

File tree

2 files changed

+649
-42
lines changed

2 files changed

+649
-42
lines changed

components/dfs/dfs_v2/include/dfs_pcache.h

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006-2023, RT-Thread Development Team
2+
* Copyright (c) 2006-2025 RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -29,72 +29,77 @@ struct dfs_vnode;
2929
struct dfs_dentry;
3030
struct dfs_aspace;
3131

32+
/* Memory mapping structure for page cache */
3233
struct dfs_mmap
3334
{
34-
rt_list_t mmap_node;
35-
struct rt_aspace *aspace;
36-
void *vaddr;
35+
rt_list_t mmap_node; /* List node for address space's mmap list */
36+
struct rt_aspace *aspace; /* Address space this mapping belongs to */
37+
void *vaddr; /* Virtual address where the page is mapped */
3738
};
3839

40+
/* Page structure for file system page cache */
3941
struct dfs_page
4042
{
41-
rt_list_t space_node;
42-
rt_list_t dirty_node;
43-
struct util_avl_struct avl_node;
44-
rt_list_t mmap_head;
43+
rt_list_t space_node; /* Node for address space's page list */
44+
rt_list_t dirty_node; /* Node for dirty page list */
45+
struct util_avl_struct avl_node; /* Node for AVL tree in address space */
46+
rt_list_t mmap_head; /* Head of memory mappings list */
4547

46-
rt_atomic_t ref_count;
48+
rt_atomic_t ref_count; /* Reference count for this page */
4749

48-
void *page;
49-
off_t fpos;
50-
size_t size;
51-
size_t len;
52-
int is_dirty;
53-
rt_tick_t tick_ms;
50+
void *page; /* Pointer to physical page data */
51+
off_t fpos; /* File position this page represents */
52+
size_t size; /* Total size of the page */
53+
size_t len; /* Valid data length in the page */
54+
int is_dirty; /* Dirty flag indicating if page needs writeback */
55+
rt_tick_t tick_ms; /* Last access timestamp */
5456

55-
struct dfs_aspace *aspace;
57+
struct dfs_aspace *aspace; /* Address space this page belongs to */
5658
};
5759

60+
/* Address space operations interface */
5861
struct dfs_aspace_ops
5962
{
60-
ssize_t (*read)(struct dfs_file *file, struct dfs_page *page);
61-
ssize_t (*write)(struct dfs_page *page);
63+
ssize_t (*read)(struct dfs_file *file, struct dfs_page *page); /* Read operation for page cache */
64+
ssize_t (*write)(struct dfs_page *page); /* Write operation for page cache */
6265
};
6366

67+
/* Address space structure for page cache management */
6468
struct dfs_aspace
6569
{
66-
rt_list_t hash_node, cache_node;
67-
char *fullpath, *pathname;
68-
struct dfs_mnt *mnt;
70+
rt_list_t hash_node, cache_node; /* Nodes for hash table and cache lists */
71+
char *fullpath, *pathname; /* Full path and relative path strings */
72+
struct dfs_mnt *mnt; /* Mount point this space belongs to */
6973

70-
rt_list_t list_active, list_inactive;
71-
rt_list_t list_dirty;
72-
size_t pages_count;
74+
rt_list_t list_active, list_inactive; /* Active and inactive page lists */
75+
rt_list_t list_dirty; /* Dirty page list */
76+
size_t pages_count; /* Total pages in this space */
7377

74-
struct util_avl_root avl_root;
75-
struct dfs_page *avl_page;
78+
struct util_avl_root avl_root; /* AVL tree root for page lookup */
79+
struct dfs_page *avl_page; /* Current AVL tree page */
7680

77-
rt_bool_t is_active;
81+
rt_bool_t is_active; /* Active/inactive status flag */
7882

79-
struct rt_mutex lock;
80-
rt_atomic_t ref_count;
83+
struct rt_mutex lock; /* Mutex for thread safety */
84+
rt_atomic_t ref_count; /* Reference counter */
8185

82-
struct dfs_vnode *vnode;
83-
const struct dfs_aspace_ops *ops;
86+
struct dfs_vnode *vnode; /* Associated vnode */
87+
const struct dfs_aspace_ops *ops; /* Operations interface */
8488
};
8589

8690
#ifndef RT_PAGECACHE_HASH_NR
8791
#define RT_PAGECACHE_HASH_NR 1024
8892
#endif
8993

94+
/* Global page cache management structure */
9095
struct dfs_pcache
9196
{
92-
rt_list_t head[RT_PAGECACHE_HASH_NR];
93-
rt_list_t list_active, list_inactive;
94-
rt_atomic_t pages_count;
95-
struct rt_mutex lock;
96-
struct rt_messagequeue *mqueue;
97-
rt_tick_t last_time_wb;
97+
rt_list_t head[RT_PAGECACHE_HASH_NR]; /* Hash table buckets for address spaces */
98+
rt_list_t list_active, list_inactive; /* Active and inactive space lists */
99+
rt_atomic_t pages_count; /* Total cached pages count */
100+
struct rt_mutex lock; /* Global lock for thread safety */
101+
struct rt_messagequeue *mqueue; /* Message queue for sending GC/WB command.*/
102+
rt_tick_t last_time_wb; /* Last writeback timestamp */
98103
};
99104

100105
struct dfs_aspace *dfs_aspace_create(struct dfs_dentry *dentry, struct dfs_vnode *vnode, const struct dfs_aspace_ops *ops);
@@ -126,4 +131,4 @@ void dfs_pcache_clean(struct dfs_mnt *mnt);
126131

127132
#endif
128133

129-
#endif
134+
#endif

0 commit comments

Comments
 (0)