Lines Matching +full:down +full:- +full:counters
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
41 nb = in->newblocks; in xfs_growfs_data_private()
42 if (nb < mp->m_sb.sb_dblocks) in xfs_growfs_data_private()
43 return -EINVAL; in xfs_growfs_data_private()
44 if ((error = xfs_sb_validate_fsb_count(&mp->m_sb, nb))) in xfs_growfs_data_private()
46 error = xfs_buf_read_uncached(mp->m_ddev_targp, in xfs_growfs_data_private()
47 XFS_FSB_TO_BB(mp, nb) - XFS_FSS_TO_BB(mp, 1), in xfs_growfs_data_private()
54 nb_mod = do_div(new, mp->m_sb.sb_agblocks); in xfs_growfs_data_private()
57 nagcount--; in xfs_growfs_data_private()
58 nb = (xfs_rfsblock_t)nagcount * mp->m_sb.sb_agblocks; in xfs_growfs_data_private()
59 if (nb < mp->m_sb.sb_dblocks) in xfs_growfs_data_private()
60 return -EINVAL; in xfs_growfs_data_private()
62 new = nb - mp->m_sb.sb_dblocks; in xfs_growfs_data_private()
63 oagcount = mp->m_sb.sb_agcount; in xfs_growfs_data_private()
65 /* allocate the new per-ag structures */ in xfs_growfs_data_private()
72 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_growdata, in xfs_growfs_data_private()
78 * Write new AG headers to disk. Non-transactional, but need to be in xfs_growfs_data_private()
90 for (id.agno = nagcount - 1; in xfs_growfs_data_private()
92 id.agno--, new -= id.agsize) { in xfs_growfs_data_private()
94 if (id.agno == nagcount - 1) in xfs_growfs_data_private()
95 id.agsize = nb - in xfs_growfs_data_private()
96 (id.agno * (xfs_rfsblock_t)mp->m_sb.sb_agblocks); in xfs_growfs_data_private()
98 id.agsize = mp->m_sb.sb_agblocks; in xfs_growfs_data_private()
125 xfs_trans_mod_sb(tp, XFS_TRANS_SB_AGCOUNT, nagcount - oagcount); in xfs_growfs_data_private()
126 if (nb > mp->m_sb.sb_dblocks) in xfs_growfs_data_private()
128 nb - mp->m_sb.sb_dblocks); in xfs_growfs_data_private()
138 mp->m_maxagi = nagimax; in xfs_growfs_data_private()
140 mp->m_alloc_set_aside = xfs_alloc_set_aside(mp); in xfs_growfs_data_private()
143 * If we expanded the last AG, free the per-AG reservation in xfs_growfs_data_private()
162 if (error == -ENOSPC) in xfs_growfs_data_private()
178 nb = in->newblocks; in xfs_growfs_log_private()
180 return -EINVAL; in xfs_growfs_log_private()
181 if (nb == mp->m_sb.sb_logblocks && in xfs_growfs_log_private()
182 in->isint == (mp->m_sb.sb_logstart != 0)) in xfs_growfs_log_private()
183 return -EINVAL; in xfs_growfs_log_private()
190 return -ENOSYS; in xfs_growfs_log_private()
203 return -EINVAL; in xfs_growfs_imaxpct()
205 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_growdata, in xfs_growfs_imaxpct()
210 dpct = imaxpct - mp->m_sb.sb_imax_pct; in xfs_growfs_imaxpct()
218 * point - exported through ioctls: XFS_IOC_FSGROWFSDATA, XFS_IOC_FSGROWFSLOG,
229 return -EPERM; in xfs_growfs_data()
230 if (!mutex_trylock(&mp->m_growlock)) in xfs_growfs_data()
231 return -EWOULDBLOCK; in xfs_growfs_data()
234 if (in->imaxpct != mp->m_sb.sb_imax_pct) { in xfs_growfs_data()
235 error = xfs_growfs_imaxpct(mp, in->imaxpct); in xfs_growfs_data()
240 if (in->newblocks != mp->m_sb.sb_dblocks) { in xfs_growfs_data()
247 if (mp->m_sb.sb_imax_pct) { in xfs_growfs_data()
248 uint64_t icount = mp->m_sb.sb_dblocks * mp->m_sb.sb_imax_pct; in xfs_growfs_data()
250 M_IGEO(mp)->maxicount = XFS_FSB_TO_INO(mp, icount); in xfs_growfs_data()
252 M_IGEO(mp)->maxicount = 0; in xfs_growfs_data()
263 mp->m_generation++; in xfs_growfs_data()
264 mutex_unlock(&mp->m_growlock); in xfs_growfs_data()
276 return -EPERM; in xfs_growfs_log()
277 if (!mutex_trylock(&mp->m_growlock)) in xfs_growfs_log()
278 return -EWOULDBLOCK; in xfs_growfs_log()
280 mutex_unlock(&mp->m_growlock); in xfs_growfs_log()
293 cnt->allocino = percpu_counter_read_positive(&mp->m_icount); in xfs_fs_counts()
294 cnt->freeino = percpu_counter_read_positive(&mp->m_ifree); in xfs_fs_counts()
295 cnt->freedata = percpu_counter_read_positive(&mp->m_fdblocks) - in xfs_fs_counts()
296 mp->m_alloc_set_aside; in xfs_fs_counts()
298 spin_lock(&mp->m_sb_lock); in xfs_fs_counts()
299 cnt->freertx = mp->m_sb.sb_frextents; in xfs_fs_counts()
300 spin_unlock(&mp->m_sb_lock); in xfs_fs_counts()
307 * in the in-core mount table. The number of unused reserved blocks
333 return -EINVAL; in xfs_reserve_blocks()
334 outval->resblks = mp->m_resblks; in xfs_reserve_blocks()
335 outval->resblks_avail = mp->m_resblks_avail; in xfs_reserve_blocks()
342 * With per-cpu counters, this becomes an interesting problem. we need in xfs_reserve_blocks()
351 spin_lock(&mp->m_sb_lock); in xfs_reserve_blocks()
356 * counters directly since we shouldn't have any problems unreserving in xfs_reserve_blocks()
359 if (mp->m_resblks > request) { in xfs_reserve_blocks()
360 lcounter = mp->m_resblks_avail - request; in xfs_reserve_blocks()
363 mp->m_resblks_avail -= lcounter; in xfs_reserve_blocks()
365 mp->m_resblks = request; in xfs_reserve_blocks()
367 spin_unlock(&mp->m_sb_lock); in xfs_reserve_blocks()
369 spin_lock(&mp->m_sb_lock); in xfs_reserve_blocks()
377 * blocks before we update the reserve counters. Sample m_fdblocks and in xfs_reserve_blocks()
387 free = percpu_counter_sum(&mp->m_fdblocks) - in xfs_reserve_blocks()
389 delta = request - mp->m_resblks; in xfs_reserve_blocks()
390 mp->m_resblks = request; in xfs_reserve_blocks()
395 * here - we don't want to reserve the extra reserve blocks in xfs_reserve_blocks()
403 spin_unlock(&mp->m_sb_lock); in xfs_reserve_blocks()
404 error = xfs_mod_fdblocks(mp, -fdblks_delta, 0); in xfs_reserve_blocks()
407 spin_lock(&mp->m_sb_lock); in xfs_reserve_blocks()
411 outval->resblks = mp->m_resblks; in xfs_reserve_blocks()
412 outval->resblks_avail = mp->m_resblks_avail; in xfs_reserve_blocks()
415 spin_unlock(&mp->m_sb_lock); in xfs_reserve_blocks()
426 struct super_block *sb = freeze_bdev(mp->m_super->s_bdev); in xfs_fs_goingdown()
430 thaw_bdev(sb->s_bdev, sb); in xfs_fs_goingdown()
443 return -EINVAL; in xfs_fs_goingdown()
481 "User initiated shutdown received. Shutting down filesystem"); in xfs_do_force_shutdown()
491 "Corruption of in-memory data detected. Shutting down filesystem"); in xfs_do_force_shutdown()
496 "Log I/O Error Detected. Shutting down filesystem"); in xfs_do_force_shutdown()
499 "I/O Error Detected. Shutting down filesystem"); in xfs_do_force_shutdown()
507 * Reserve free space for per-AG metadata.
518 mp->m_finobt_nores = false; in xfs_fs_reserve_ag_blocks()
519 for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) { in xfs_fs_reserve_ag_blocks()
527 if (error && error != -ENOSPC) { in xfs_fs_reserve_ag_blocks()
529 "Error %d reserving per-AG metadata reserve pool.", error); in xfs_fs_reserve_ag_blocks()
537 * Free space reserved for per-AG metadata.
548 for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) { in xfs_fs_unreserve_ag_blocks()
558 "Error %d freeing per-AG metadata reserve pool.", error); in xfs_fs_unreserve_ag_blocks()