Lines Matching refs:mp

50 tmpfs_mntmem_init(struct tmpfs_mount *mp, uint64_t memlimit)  in tmpfs_mntmem_init()  argument
53 rw_init(&mp->tm_acc_lock, "tacclk"); in tmpfs_mntmem_init()
54 mp->tm_mem_limit = memlimit; in tmpfs_mntmem_init()
55 mp->tm_bytes_used = 0; in tmpfs_mntmem_init()
59 tmpfs_mntmem_destroy(struct tmpfs_mount *mp) in tmpfs_mntmem_destroy() argument
62 KASSERT(mp->tm_bytes_used == 0); in tmpfs_mntmem_destroy()
100 tmpfs_bytes_max(struct tmpfs_mount *mp) in tmpfs_bytes_max() argument
110 avail_mem = round_page(mp->tm_bytes_used) + (freepages << PAGE_SHIFT); in tmpfs_bytes_max()
111 return MIN(mp->tm_mem_limit, avail_mem); in tmpfs_bytes_max()
115 tmpfs_pages_avail(struct tmpfs_mount *mp) in tmpfs_pages_avail() argument
118 return (tmpfs_bytes_max(mp) - mp->tm_bytes_used) >> PAGE_SHIFT; in tmpfs_pages_avail()
122 tmpfs_mem_incr(struct tmpfs_mount *mp, size_t sz) in tmpfs_mem_incr() argument
126 rw_enter_write(&mp->tm_acc_lock); in tmpfs_mem_incr()
127 lim = tmpfs_bytes_max(mp); in tmpfs_mem_incr()
128 if (mp->tm_bytes_used + sz >= lim) { in tmpfs_mem_incr()
129 rw_exit_write(&mp->tm_acc_lock); in tmpfs_mem_incr()
132 mp->tm_bytes_used += sz; in tmpfs_mem_incr()
133 rw_exit_write(&mp->tm_acc_lock); in tmpfs_mem_incr()
138 tmpfs_mem_decr(struct tmpfs_mount *mp, size_t sz) in tmpfs_mem_decr() argument
141 rw_enter_write(&mp->tm_acc_lock); in tmpfs_mem_decr()
142 KASSERT(mp->tm_bytes_used >= sz); in tmpfs_mem_decr()
143 mp->tm_bytes_used -= sz; in tmpfs_mem_decr()
144 rw_exit_write(&mp->tm_acc_lock); in tmpfs_mem_decr()
148 tmpfs_dirent_get(struct tmpfs_mount *mp) in tmpfs_dirent_get() argument
151 if (!tmpfs_mem_incr(mp, sizeof(struct tmpfs_dirent))) { in tmpfs_dirent_get()
158 tmpfs_dirent_put(struct tmpfs_mount *mp, struct tmpfs_dirent *de) in tmpfs_dirent_put() argument
161 tmpfs_mem_decr(mp, sizeof(struct tmpfs_dirent)); in tmpfs_dirent_put()
166 tmpfs_node_get(struct tmpfs_mount *mp) in tmpfs_node_get() argument
169 mp->tm_nodes_cnt++; in tmpfs_node_get()
170 if (mp->tm_nodes_cnt > mp->tm_nodes_max) { in tmpfs_node_get()
171 mp->tm_nodes_cnt--; in tmpfs_node_get()
174 if (!tmpfs_mem_incr(mp, sizeof(struct tmpfs_node))) { in tmpfs_node_get()
181 tmpfs_node_put(struct tmpfs_mount *mp, struct tmpfs_node *tn) in tmpfs_node_put() argument
184 mp->tm_nodes_cnt--; in tmpfs_node_put()
185 tmpfs_mem_decr(mp, sizeof(struct tmpfs_node)); in tmpfs_node_put()
197 tmpfs_strname_alloc(struct tmpfs_mount *mp, size_t len) in tmpfs_strname_alloc() argument
202 if (!tmpfs_mem_incr(mp, sz)) { in tmpfs_strname_alloc()
209 tmpfs_strname_free(struct tmpfs_mount *mp, char *str, size_t len) in tmpfs_strname_free() argument
214 tmpfs_mem_decr(mp, sz); in tmpfs_strname_free()