• Home
  • Raw
  • Download

Lines Matching +full:down +full:- +full:counters

1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
46 nb = in->newblocks; in xfs_growfs_data_private()
47 if (nb < mp->m_sb.sb_dblocks) in xfs_growfs_data_private()
48 return -EINVAL; in xfs_growfs_data_private()
49 if ((error = xfs_sb_validate_fsb_count(&mp->m_sb, nb))) in xfs_growfs_data_private()
51 error = xfs_buf_read_uncached(mp->m_ddev_targp, in xfs_growfs_data_private()
52 XFS_FSB_TO_BB(mp, nb) - XFS_FSS_TO_BB(mp, 1), in xfs_growfs_data_private()
59 nb_mod = do_div(new, mp->m_sb.sb_agblocks); in xfs_growfs_data_private()
62 nagcount--; in xfs_growfs_data_private()
63 nb = (xfs_rfsblock_t)nagcount * mp->m_sb.sb_agblocks; in xfs_growfs_data_private()
64 if (nb < mp->m_sb.sb_dblocks) in xfs_growfs_data_private()
65 return -EINVAL; in xfs_growfs_data_private()
67 new = nb - mp->m_sb.sb_dblocks; in xfs_growfs_data_private()
68 oagcount = mp->m_sb.sb_agcount; in xfs_growfs_data_private()
70 /* allocate the new per-ag structures */ in xfs_growfs_data_private()
77 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_growdata, in xfs_growfs_data_private()
83 * Write new AG headers to disk. Non-transactional, but need to be in xfs_growfs_data_private()
95 for (id.agno = nagcount - 1; in xfs_growfs_data_private()
97 id.agno--, new -= id.agsize) { in xfs_growfs_data_private()
99 if (id.agno == nagcount - 1) in xfs_growfs_data_private()
100 id.agsize = nb - in xfs_growfs_data_private()
101 (id.agno * (xfs_rfsblock_t)mp->m_sb.sb_agblocks); in xfs_growfs_data_private()
103 id.agsize = mp->m_sb.sb_agblocks; in xfs_growfs_data_private()
130 xfs_trans_mod_sb(tp, XFS_TRANS_SB_AGCOUNT, nagcount - oagcount); in xfs_growfs_data_private()
131 if (nb > mp->m_sb.sb_dblocks) in xfs_growfs_data_private()
133 nb - mp->m_sb.sb_dblocks); in xfs_growfs_data_private()
143 mp->m_maxagi = nagimax; in xfs_growfs_data_private()
145 mp->m_alloc_set_aside = xfs_alloc_set_aside(mp); in xfs_growfs_data_private()
148 * If we expanded the last AG, free the per-AG reservation in xfs_growfs_data_private()
167 if (error == -ENOSPC) in xfs_growfs_data_private()
183 nb = in->newblocks; in xfs_growfs_log_private()
185 return -EINVAL; in xfs_growfs_log_private()
186 if (nb == mp->m_sb.sb_logblocks && in xfs_growfs_log_private()
187 in->isint == (mp->m_sb.sb_logstart != 0)) in xfs_growfs_log_private()
188 return -EINVAL; in xfs_growfs_log_private()
195 return -ENOSYS; in xfs_growfs_log_private()
208 return -EINVAL; in xfs_growfs_imaxpct()
210 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_growdata, in xfs_growfs_imaxpct()
215 dpct = imaxpct - mp->m_sb.sb_imax_pct; in xfs_growfs_imaxpct()
223 * point - exported through ioctls: XFS_IOC_FSGROWFSDATA, XFS_IOC_FSGROWFSLOG,
234 return -EPERM; in xfs_growfs_data()
235 if (!mutex_trylock(&mp->m_growlock)) in xfs_growfs_data()
236 return -EWOULDBLOCK; in xfs_growfs_data()
239 if (in->imaxpct != mp->m_sb.sb_imax_pct) { in xfs_growfs_data()
240 error = xfs_growfs_imaxpct(mp, in->imaxpct); in xfs_growfs_data()
245 if (in->newblocks != mp->m_sb.sb_dblocks) { in xfs_growfs_data()
252 if (mp->m_sb.sb_imax_pct) { in xfs_growfs_data()
253 uint64_t icount = mp->m_sb.sb_dblocks * mp->m_sb.sb_imax_pct; in xfs_growfs_data()
255 mp->m_maxicount = icount << mp->m_sb.sb_inopblog; in xfs_growfs_data()
257 mp->m_maxicount = 0; in xfs_growfs_data()
268 mp->m_generation++; in xfs_growfs_data()
269 mutex_unlock(&mp->m_growlock); in xfs_growfs_data()
281 return -EPERM; in xfs_growfs_log()
282 if (!mutex_trylock(&mp->m_growlock)) in xfs_growfs_log()
283 return -EWOULDBLOCK; in xfs_growfs_log()
285 mutex_unlock(&mp->m_growlock); in xfs_growfs_log()
298 cnt->allocino = percpu_counter_read_positive(&mp->m_icount); in xfs_fs_counts()
299 cnt->freeino = percpu_counter_read_positive(&mp->m_ifree); in xfs_fs_counts()
300 cnt->freedata = percpu_counter_read_positive(&mp->m_fdblocks) - in xfs_fs_counts()
301 mp->m_alloc_set_aside; in xfs_fs_counts()
303 spin_lock(&mp->m_sb_lock); in xfs_fs_counts()
304 cnt->freertx = mp->m_sb.sb_frextents; in xfs_fs_counts()
305 spin_unlock(&mp->m_sb_lock); in xfs_fs_counts()
313 * in the in-core mount table. The number of unused reserved blocks
339 return -EINVAL; in xfs_reserve_blocks()
340 outval->resblks = mp->m_resblks; in xfs_reserve_blocks()
341 outval->resblks_avail = mp->m_resblks_avail; in xfs_reserve_blocks()
348 * With per-cpu counters, this becomes an interesting problem. we need in xfs_reserve_blocks()
357 spin_lock(&mp->m_sb_lock); in xfs_reserve_blocks()
362 * counters directly since we shouldn't have any problems unreserving in xfs_reserve_blocks()
365 if (mp->m_resblks > request) { in xfs_reserve_blocks()
366 lcounter = mp->m_resblks_avail - request; in xfs_reserve_blocks()
369 mp->m_resblks_avail -= lcounter; in xfs_reserve_blocks()
371 mp->m_resblks = request; in xfs_reserve_blocks()
373 spin_unlock(&mp->m_sb_lock); in xfs_reserve_blocks()
375 spin_lock(&mp->m_sb_lock); in xfs_reserve_blocks()
383 * blocks before we update the reserve counters. Sample m_fdblocks and in xfs_reserve_blocks()
386 error = -ENOSPC; in xfs_reserve_blocks()
388 free = percpu_counter_sum(&mp->m_fdblocks) - in xfs_reserve_blocks()
389 mp->m_alloc_set_aside; in xfs_reserve_blocks()
393 delta = request - mp->m_resblks; in xfs_reserve_blocks()
394 lcounter = free - delta; in xfs_reserve_blocks()
408 * Don't set the reserved flag here - we don't want to reserve in xfs_reserve_blocks()
411 spin_unlock(&mp->m_sb_lock); in xfs_reserve_blocks()
412 error = xfs_mod_fdblocks(mp, -fdblks_delta, 0); in xfs_reserve_blocks()
413 spin_lock(&mp->m_sb_lock); in xfs_reserve_blocks()
414 } while (error == -ENOSPC); in xfs_reserve_blocks()
417 * Update the reserve counters if blocks have been successfully in xfs_reserve_blocks()
421 mp->m_resblks += fdblks_delta; in xfs_reserve_blocks()
422 mp->m_resblks_avail += fdblks_delta; in xfs_reserve_blocks()
427 outval->resblks = mp->m_resblks; in xfs_reserve_blocks()
428 outval->resblks_avail = mp->m_resblks_avail; in xfs_reserve_blocks()
431 spin_unlock(&mp->m_sb_lock); in xfs_reserve_blocks()
442 struct super_block *sb = freeze_bdev(mp->m_super->s_bdev); in xfs_fs_goingdown()
446 thaw_bdev(sb->s_bdev, sb); in xfs_fs_goingdown()
459 return -EINVAL; in xfs_fs_goingdown()
504 "Corruption of in-memory data detected. Shutting down filesystem"); in xfs_do_force_shutdown()
510 "Log I/O Error Detected. Shutting down filesystem"); in xfs_do_force_shutdown()
513 "All device paths lost. Shutting down filesystem"); in xfs_do_force_shutdown()
516 "I/O Error Detected. Shutting down filesystem"); in xfs_do_force_shutdown()
526 * Reserve free space for per-AG metadata.
537 mp->m_finobt_nores = false; in xfs_fs_reserve_ag_blocks()
538 for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) { in xfs_fs_reserve_ag_blocks()
546 if (error && error != -ENOSPC) { in xfs_fs_reserve_ag_blocks()
548 "Error %d reserving per-AG metadata reserve pool.", error); in xfs_fs_reserve_ag_blocks()
556 * Free space reserved for per-AG metadata.
567 for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) { in xfs_fs_unreserve_ag_blocks()
577 "Error %d freeing per-AG metadata reserve pool.", error); in xfs_fs_unreserve_ag_blocks()