Lines Matching +full:ip +full:- +full:core

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) 2018-2024 Oracle. All Rights Reserved.
50 struct xfs_inode *ip, in xfs_metafile_set_iflag() argument
53 VFS_I(ip)->i_mode &= ~0777; in xfs_metafile_set_iflag()
54 VFS_I(ip)->i_uid = GLOBAL_ROOT_UID; in xfs_metafile_set_iflag()
55 VFS_I(ip)->i_gid = GLOBAL_ROOT_GID; in xfs_metafile_set_iflag()
56 if (S_ISDIR(VFS_I(ip)->i_mode)) in xfs_metafile_set_iflag()
57 ip->i_diflags |= XFS_METADIR_DIFLAGS; in xfs_metafile_set_iflag()
59 ip->i_diflags |= XFS_METAFILE_DIFLAGS; in xfs_metafile_set_iflag()
60 ip->i_diflags2 &= ~XFS_DIFLAG2_DAX; in xfs_metafile_set_iflag()
61 ip->i_diflags2 |= XFS_DIFLAG2_METADATA; in xfs_metafile_set_iflag()
62 ip->i_metatype = metafile_type; in xfs_metafile_set_iflag()
63 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_metafile_set_iflag()
70 struct xfs_inode *ip) in xfs_metafile_clear_iflag() argument
72 ASSERT(xfs_is_metadir_inode(ip)); in xfs_metafile_clear_iflag()
73 ASSERT(VFS_I(ip)->i_nlink == 0); in xfs_metafile_clear_iflag()
75 ip->i_diflags2 &= ~XFS_DIFLAG2_METADATA; in xfs_metafile_clear_iflag()
76 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_metafile_clear_iflag()
91 * touching the per-cpu counter. in xfs_metafile_resv_can_cover()
93 if (mp->m_metafile_resv_avail >= rhs) in xfs_metafile_resv_can_cover()
101 rhs - mp->m_metafile_resv_avail, 2048) >= 0; in xfs_metafile_resv_can_cover()
117 if (!xfs_metafile_resv_can_cover(mp, mp->m_rtbtree_maxlevels)) in xfs_metafile_resv_critical()
121 div_u64(mp->m_metafile_resv_target, 10))) in xfs_metafile_resv_critical()
130 struct xfs_inode *ip, in xfs_metafile_resv_alloc_space() argument
133 struct xfs_mount *mp = ip->i_mount; in xfs_metafile_resv_alloc_space()
134 int64_t len = args->len; in xfs_metafile_resv_alloc_space()
136 ASSERT(xfs_is_metadir_inode(ip)); in xfs_metafile_resv_alloc_space()
137 ASSERT(args->resv == XFS_AG_RESV_METAFILE); in xfs_metafile_resv_alloc_space()
139 trace_xfs_metafile_resv_alloc_space(mp, args->len); in xfs_metafile_resv_alloc_space()
145 mutex_lock(&mp->m_metafile_resv_lock); in xfs_metafile_resv_alloc_space()
146 if (mp->m_metafile_resv_avail > 0) { in xfs_metafile_resv_alloc_space()
149 from_resv = min_t(int64_t, len, mp->m_metafile_resv_avail); in xfs_metafile_resv_alloc_space()
150 mp->m_metafile_resv_avail -= from_resv; in xfs_metafile_resv_alloc_space()
151 xfs_mod_delalloc(ip, 0, -from_resv); in xfs_metafile_resv_alloc_space()
152 xfs_trans_mod_sb(args->tp, XFS_TRANS_SB_RES_FDBLOCKS, in xfs_metafile_resv_alloc_space()
153 -from_resv); in xfs_metafile_resv_alloc_space()
154 len -= from_resv; in xfs_metafile_resv_alloc_space()
158 * Any allocation in excess of the reservation requires in-core and in xfs_metafile_resv_alloc_space()
159 * on-disk fdblocks updates. If we can grab @len blocks from the in xfs_metafile_resv_alloc_space()
160 * in-core fdblocks then all we need to do is update the on-disk in xfs_metafile_resv_alloc_space()
168 error = xfs_dec_fdblocks(ip->i_mount, len, true); in xfs_metafile_resv_alloc_space()
174 xfs_trans_mod_sb(args->tp, field, -len); in xfs_metafile_resv_alloc_space()
177 mp->m_metafile_resv_used += args->len; in xfs_metafile_resv_alloc_space()
178 mutex_unlock(&mp->m_metafile_resv_lock); in xfs_metafile_resv_alloc_space()
180 ip->i_nblocks += args->len; in xfs_metafile_resv_alloc_space()
181 xfs_trans_log_inode(args->tp, ip, XFS_ILOG_CORE); in xfs_metafile_resv_alloc_space()
187 struct xfs_inode *ip, in xfs_metafile_resv_free_space() argument
191 struct xfs_mount *mp = ip->i_mount; in xfs_metafile_resv_free_space()
194 ASSERT(xfs_is_metadir_inode(ip)); in xfs_metafile_resv_free_space()
198 ip->i_nblocks -= len; in xfs_metafile_resv_free_space()
199 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_metafile_resv_free_space()
201 mutex_lock(&mp->m_metafile_resv_lock); in xfs_metafile_resv_free_space()
202 mp->m_metafile_resv_used -= len; in xfs_metafile_resv_free_space()
208 to_resv = mp->m_metafile_resv_target - in xfs_metafile_resv_free_space()
209 (mp->m_metafile_resv_used + mp->m_metafile_resv_avail); in xfs_metafile_resv_free_space()
212 mp->m_metafile_resv_avail += to_resv; in xfs_metafile_resv_free_space()
213 xfs_mod_delalloc(ip, 0, to_resv); in xfs_metafile_resv_free_space()
215 len -= to_resv; in xfs_metafile_resv_free_space()
217 mutex_unlock(&mp->m_metafile_resv_lock); in xfs_metafile_resv_free_space()
220 * Everything else goes back to the filesystem, so update the in-core in xfs_metafile_resv_free_space()
221 * and on-disk counters. in xfs_metafile_resv_free_space()
231 if (mp->m_metafile_resv_avail) { in __xfs_metafile_resv_free()
232 xfs_mod_sb_delalloc(mp, -(int64_t)mp->m_metafile_resv_avail); in __xfs_metafile_resv_free()
233 xfs_add_fdblocks(mp, mp->m_metafile_resv_avail); in __xfs_metafile_resv_free()
235 mp->m_metafile_resv_avail = 0; in __xfs_metafile_resv_free()
236 mp->m_metafile_resv_used = 0; in __xfs_metafile_resv_free()
237 mp->m_metafile_resv_target = 0; in __xfs_metafile_resv_free()
250 mutex_lock(&mp->m_metafile_resv_lock); in xfs_metafile_resv_free()
252 mutex_unlock(&mp->m_metafile_resv_lock); in xfs_metafile_resv_free()
263 xfs_rfsblock_t dblocks_avail = mp->m_sb.sb_dblocks / 4; in xfs_metafile_resv_init()
272 mutex_lock(&mp->m_metafile_resv_lock); in xfs_metafile_resv_init()
282 used += rtg_rmap(rtg)->i_nblocks; in xfs_metafile_resv_init()
286 used += rtg_refcount(rtg)->i_nblocks; in xfs_metafile_resv_init()
295 * Space taken by the per-AG metadata btrees are accounted on-disk as in xfs_metafile_resv_init()
303 hidden_space = target - used; in xfs_metafile_resv_init()
313 mp->m_metafile_resv_target = target; in xfs_metafile_resv_init()
314 mp->m_metafile_resv_used = used; in xfs_metafile_resv_init()
315 mp->m_metafile_resv_avail = hidden_space; in xfs_metafile_resv_init()
320 mutex_unlock(&mp->m_metafile_resv_lock); in xfs_metafile_resv_init()