Home | History | Annotate | Download | only in tmpfs

Lines Matching refs:mp

52 tmpfs_mntmem_init(struct tmpfs_mount *mp, uint64_t memlimit)
55 mutex_init(&mp->tm_acc_lock, MUTEX_DEFAULT, IPL_NONE);
56 mp->tm_mem_limit = memlimit;
57 mp->tm_bytes_used = 0;
61 tmpfs_mntmem_destroy(struct tmpfs_mount *mp)
64 KASSERT(mp->tm_bytes_used == 0);
65 mutex_destroy(&mp->tm_acc_lock);
69 tmpfs_mntmem_set(struct tmpfs_mount *mp, uint64_t memlimit)
73 mutex_enter(&mp->tm_acc_lock);
74 if (round_page(mp->tm_bytes_used) >= memlimit)
78 mp->tm_mem_limit = memlimit;
80 mutex_exit(&mp->tm_acc_lock);
113 tmpfs_bytes_max(struct tmpfs_mount *mp)
124 avail_mem = round_page(mp->tm_bytes_used) + (freepages << PAGE_SHIFT);
125 return MIN(mp->tm_mem_limit, avail_mem);
129 tmpfs_pages_avail(struct tmpfs_mount *mp)
132 return (tmpfs_bytes_max(mp) - mp->tm_bytes_used) >> PAGE_SHIFT;
136 tmpfs_mem_incr(struct tmpfs_mount *mp, size_t sz)
140 mutex_enter(&mp->tm_acc_lock);
141 lim = tmpfs_bytes_max(mp);
142 if (mp->tm_bytes_used + sz >= lim) {
143 mutex_exit(&mp->tm_acc_lock);
146 mp->tm_bytes_used += sz;
147 mutex_exit(&mp->tm_acc_lock);
152 tmpfs_mem_decr(struct tmpfs_mount *mp, size_t sz)
155 mutex_enter(&mp->tm_acc_lock);
156 KASSERT(mp->tm_bytes_used >= sz);
157 mp->tm_bytes_used -= sz;
158 mutex_exit(&mp->tm_acc_lock);
162 tmpfs_dirent_get(struct tmpfs_mount *mp)
165 if (!tmpfs_mem_incr(mp, sizeof(struct tmpfs_dirent))) {
172 tmpfs_dirent_put(struct tmpfs_mount *mp, struct tmpfs_dirent *de)
175 tmpfs_mem_decr(mp, sizeof(struct tmpfs_dirent));
180 tmpfs_node_get(struct tmpfs_mount *mp)
183 if (atomic_inc_uint_nv(&mp->tm_nodes_cnt) >= mp->tm_nodes_max) {
184 atomic_dec_uint(&mp->tm_nodes_cnt);
187 if (!tmpfs_mem_incr(mp, sizeof(struct tmpfs_node))) {
188 atomic_dec_uint(&mp->tm_nodes_cnt);
195 tmpfs_node_put(struct tmpfs_mount *mp, struct tmpfs_node *tn)
198 atomic_dec_uint(&mp->tm_nodes_cnt);
199 tmpfs_mem_decr(mp, sizeof(struct tmpfs_node));
210 tmpfs_strname_alloc(struct tmpfs_mount *mp, size_t len)
215 if (!tmpfs_mem_incr(mp, sz)) {
222 tmpfs_strname_free(struct tmpfs_mount *mp, char *str, size_t len)
227 tmpfs_mem_decr(mp, sz);