]> git.ipfire.org Git - people/ms/linux.git/blame - fs/xfs/xfs_fsops.c
xfs: fix overfilling of reserve pool
[people/ms/linux.git] / fs / xfs / xfs_fsops.c
CommitLineData
0b61f8a4 1// SPDX-License-Identifier: GPL-2.0
1da177e4 2/*
7b718769
NS
3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
1da177e4 5 */
1da177e4 6#include "xfs.h"
a844f451 7#include "xfs_fs.h"
70a9883c 8#include "xfs_shared.h"
239880ef 9#include "xfs_format.h"
a4fbe6ab 10#include "xfs_log_format.h"
239880ef 11#include "xfs_trans_resv.h"
1da177e4 12#include "xfs_sb.h"
1da177e4 13#include "xfs_mount.h"
239880ef 14#include "xfs_trans.h"
1da177e4
LT
15#include "xfs_error.h"
16#include "xfs_alloc.h"
1da177e4 17#include "xfs_fsops.h"
1da177e4 18#include "xfs_trans_space.h"
239880ef 19#include "xfs_log.h"
b16817b6 20#include "xfs_ag.h"
84d69619 21#include "xfs_ag_resv.h"
7f89c838 22#include "xfs_trace.h"
1da177e4 23
c789c83c
GX
24/*
25 * Write new AG headers to disk. Non-transactional, but need to be
26 * written and completed prior to the growfs transaction being logged.
27 * To do this, we use a delayed write buffer list and wait for
28 * submission and IO completion of the list as a whole. This allows the
29 * IO subsystem to merge all the AG headers in a single AG into a single
30 * IO and hide most of the latency of the IO from us.
31 *
32 * This also means that if we get an error whilst building the buffer
33 * list to write, we can cancel the entire list without having written
34 * anything.
35 */
36static int
37xfs_resizefs_init_new_ags(
38 struct xfs_trans *tp,
39 struct aghdr_init_data *id,
40 xfs_agnumber_t oagcount,
41 xfs_agnumber_t nagcount,
42 xfs_rfsblock_t delta,
43 bool *lastag_extended)
44{
45 struct xfs_mount *mp = tp->t_mountp;
46 xfs_rfsblock_t nb = mp->m_sb.sb_dblocks + delta;
47 int error;
48
49 *lastag_extended = false;
50
51 INIT_LIST_HEAD(&id->buffer_list);
52 for (id->agno = nagcount - 1;
53 id->agno >= oagcount;
54 id->agno--, delta -= id->agsize) {
55
56 if (id->agno == nagcount - 1)
57 id->agsize = nb - (id->agno *
58 (xfs_rfsblock_t)mp->m_sb.sb_agblocks);
59 else
60 id->agsize = mp->m_sb.sb_agblocks;
61
62 error = xfs_ag_init_headers(mp, id);
63 if (error) {
64 xfs_buf_delwri_cancel(&id->buffer_list);
65 return error;
66 }
67 }
68
69 error = xfs_buf_delwri_submit(&id->buffer_list);
70 if (error)
71 return error;
72
c789c83c
GX
73 if (delta) {
74 *lastag_extended = true;
75 error = xfs_ag_extend_space(mp, tp, id, delta);
76 }
77 return error;
78}
79
1da177e4 80/*
b16817b6 81 * growfs operations
1da177e4 82 */
1da177e4
LT
83static int
84xfs_growfs_data_private(
07aabd9c
GX
85 struct xfs_mount *mp, /* mount point for filesystem */
86 struct xfs_growfs_data *in) /* growfs data input struct */
1da177e4 87{
e8222613 88 struct xfs_buf *bp;
83a7f86e 89 int error;
1da177e4
LT
90 xfs_agnumber_t nagcount;
91 xfs_agnumber_t nagimax = 0;
ce5e1062 92 xfs_rfsblock_t nb, nb_div, nb_mod;
fb2fc172 93 int64_t delta;
c789c83c 94 bool lastag_extended;
1da177e4 95 xfs_agnumber_t oagcount;
07aabd9c 96 struct xfs_trans *tp;
0410c3bb 97 struct aghdr_init_data id = {};
1da177e4
LT
98
99 nb = in->newblocks;
fb2fc172
GX
100 error = xfs_sb_validate_fsb_count(&mp->m_sb, nb);
101 if (error)
4cc929ee 102 return error;
fb2fc172
GX
103
104 if (nb > mp->m_sb.sb_dblocks) {
105 error = xfs_buf_read_uncached(mp->m_ddev_targp,
1922c949 106 XFS_FSB_TO_BB(mp, nb) - XFS_FSS_TO_BB(mp, 1),
ba372674 107 XFS_FSS_TO_BB(mp, 1), 0, &bp, NULL);
fb2fc172
GX
108 if (error)
109 return error;
110 xfs_buf_relse(bp);
111 }
1da177e4 112
ce5e1062
GX
113 nb_div = nb;
114 nb_mod = do_div(nb_div, mp->m_sb.sb_agblocks);
115 nagcount = nb_div + (nb_mod != 0);
1da177e4
LT
116 if (nb_mod && nb_mod < XFS_MIN_AG_BLOCKS) {
117 nagcount--;
e6da7c9f 118 nb = (xfs_rfsblock_t)nagcount * mp->m_sb.sb_agblocks;
1da177e4 119 }
ce5e1062 120 delta = nb - mp->m_sb.sb_dblocks;
fb2fc172
GX
121 /*
122 * Reject filesystems with a single AG because they are not
123 * supported, and reject a shrink operation that would cause a
124 * filesystem to become unsupported.
125 */
126 if (delta < 0 && nagcount < 2)
127 return -EINVAL;
128
1da177e4 129 oagcount = mp->m_sb.sb_agcount;
0cc6eee1 130
1c1c6ebc
DC
131 /* allocate the new per-ag structures */
132 if (nagcount > oagcount) {
133 error = xfs_initialize_perag(mp, nagcount, &nagimax);
134 if (error)
135 return error;
fb2fc172
GX
136 } else if (nagcount < oagcount) {
137 /* TODO: shrinking the entire AGs hasn't yet completed */
138 return -EINVAL;
1da177e4 139 }
1c1c6ebc 140
253f4911 141 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_growdata,
fb2fc172
GX
142 (delta > 0 ? XFS_GROWFS_SPACE_RES(mp) : -delta), 0,
143 XFS_TRANS_RESERVE, &tp);
253f4911 144 if (error)
1da177e4 145 return error;
1da177e4 146
fb2fc172
GX
147 if (delta > 0) {
148 error = xfs_resizefs_init_new_ags(tp, &id, oagcount, nagcount,
149 delta, &lastag_extended);
150 } else {
151 static struct ratelimit_state shrink_warning = \
152 RATELIMIT_STATE_INIT("shrink_warning", 86400 * HZ, 1);
153 ratelimit_set_flags(&shrink_warning, RATELIMIT_MSG_ON_RELEASE);
154
155 if (__ratelimit(&shrink_warning))
156 xfs_alert(mp,
157 "EXPERIMENTAL online shrink feature in use. Use at your own risk!");
158
159 error = xfs_ag_shrink_space(mp, &tp, nagcount - 1, -delta);
160 }
9aebe805 161 if (error)
83a7f86e 162 goto out_trans_cancel;
9aebe805 163
1c1c6ebc
DC
164 /*
165 * Update changed superblock fields transactionally. These are not
166 * seen by the rest of the world until the transaction commit applies
167 * them atomically to the superblock.
168 */
1da177e4
LT
169 if (nagcount > oagcount)
170 xfs_trans_mod_sb(tp, XFS_TRANS_SB_AGCOUNT, nagcount - oagcount);
c789c83c
GX
171 if (delta)
172 xfs_trans_mod_sb(tp, XFS_TRANS_SB_DBLOCKS, delta);
0410c3bb
DC
173 if (id.nfree)
174 xfs_trans_mod_sb(tp, XFS_TRANS_SB_FDBLOCKS, id.nfree);
014695c0
GX
175
176 /*
177 * Sync sb counters now to reflect the updated values. This is
178 * particularly important for shrink because the write verifier
179 * will fail if sb_fdblocks is ever larger than sb_dblocks.
180 */
38c26bfd 181 if (xfs_has_lazysbcount(mp))
014695c0
GX
182 xfs_log_sb(tp);
183
f8079b85 184 xfs_trans_set_sync(tp);
70393313 185 error = xfs_trans_commit(tp);
1c1c6ebc 186 if (error)
1da177e4 187 return error;
1c1c6ebc 188
1da177e4
LT
189 /* New allocation groups fully initialized, so update mount struct */
190 if (nagimax)
191 mp->m_maxagi = nagimax;
055388a3 192 xfs_set_low_space_thresholds(mp);
52548852 193 mp->m_alloc_set_aside = xfs_alloc_set_aside(mp);
1c1c6ebc 194
fb2fc172
GX
195 if (delta > 0) {
196 /*
197 * If we expanded the last AG, free the per-AG reservation
198 * so we can reinitialize it with the new size.
199 */
200 if (lastag_extended) {
201 struct xfs_perag *pag;
202
203 pag = xfs_perag_get(mp, id.agno);
204 error = xfs_ag_resv_free(pag);
205 xfs_perag_put(pag);
206 if (error)
207 return error;
208 }
209 /*
210 * Reserve AG metadata blocks. ENOSPC here does not mean there
211 * was a growfs failure, just that there still isn't space for
212 * new user data after the grow has been run.
213 */
214 error = xfs_fs_reserve_ag_blocks(mp);
215 if (error == -ENOSPC)
216 error = 0;
20e73b00 217 }
83a7f86e
DC
218 return error;
219
220out_trans_cancel:
221 xfs_trans_cancel(tp);
222 return error;
223}
224
225static int
226xfs_growfs_log_private(
07aabd9c
GX
227 struct xfs_mount *mp, /* mount point for filesystem */
228 struct xfs_growfs_log *in) /* growfs log input struct */
83a7f86e
DC
229{
230 xfs_extlen_t nb;
231
232 nb = in->newblocks;
233 if (nb < XFS_MIN_LOG_BLOCKS || nb < XFS_B_TO_FSB(mp, XFS_MIN_LOG_BYTES))
234 return -EINVAL;
235 if (nb == mp->m_sb.sb_logblocks &&
236 in->isint == (mp->m_sb.sb_logstart != 0))
237 return -EINVAL;
238 /*
239 * Moving the log is hard, need new interfaces to sync
240 * the log first, hold off all activity while moving it.
241 * Can have shorter or longer log in the same space,
242 * or transform internal to external log or vice versa.
243 */
244 return -ENOSYS;
245}
246
247static int
248xfs_growfs_imaxpct(
249 struct xfs_mount *mp,
250 __u32 imaxpct)
251{
252 struct xfs_trans *tp;
253 int dpct;
254 int error;
255
256 if (imaxpct > 100)
257 return -EINVAL;
258
259 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_growdata,
260 XFS_GROWFS_SPACE_RES(mp), 0, XFS_TRANS_RESERVE, &tp);
261 if (error)
262 return error;
263
264 dpct = imaxpct - mp->m_sb.sb_imax_pct;
265 xfs_trans_mod_sb(tp, XFS_TRANS_SB_IMAXPCT, dpct);
266 xfs_trans_set_sync(tp);
267 return xfs_trans_commit(tp);
268}
269
1da177e4
LT
270/*
271 * protected versions of growfs function acquire and release locks on the mount
272 * point - exported through ioctls: XFS_IOC_FSGROWFSDATA, XFS_IOC_FSGROWFSLOG,
273 * XFS_IOC_FSGROWFSRT
274 */
1da177e4
LT
275int
276xfs_growfs_data(
87444b8c
DC
277 struct xfs_mount *mp,
278 struct xfs_growfs_data *in)
1da177e4 279{
87444b8c 280 int error = 0;
743bb465 281
282 if (!capable(CAP_SYS_ADMIN))
2451337d 283 return -EPERM;
cc92e7ac 284 if (!mutex_trylock(&mp->m_growlock))
2451337d 285 return -EWOULDBLOCK;
87444b8c
DC
286
287 /* update imaxpct separately to the physical grow of the filesystem */
288 if (in->imaxpct != mp->m_sb.sb_imax_pct) {
289 error = xfs_growfs_imaxpct(mp, in->imaxpct);
290 if (error)
291 goto out_error;
292 }
293
294 if (in->newblocks != mp->m_sb.sb_dblocks) {
295 error = xfs_growfs_data_private(mp, in);
296 if (error)
297 goto out_error;
298 }
299
300 /* Post growfs calculations needed to reflect new state in operations */
301 if (mp->m_sb.sb_imax_pct) {
302 uint64_t icount = mp->m_sb.sb_dblocks * mp->m_sb.sb_imax_pct;
303 do_div(icount, 100);
ef325959 304 M_IGEO(mp)->maxicount = XFS_FSB_TO_INO(mp, icount);
87444b8c 305 } else
ef325959 306 M_IGEO(mp)->maxicount = 0;
87444b8c 307
83a7f86e 308 /* Update secondary superblocks now the physical grow has completed */
b16817b6 309 error = xfs_update_secondary_sbs(mp);
83a7f86e 310
87444b8c 311out_error:
52785112
CH
312 /*
313 * Increment the generation unconditionally, the error could be from
314 * updating the secondary superblocks, in which case the new size
315 * is live already.
316 */
317 mp->m_generation++;
cc92e7ac 318 mutex_unlock(&mp->m_growlock);
1da177e4
LT
319 return error;
320}
321
322int
323xfs_growfs_log(
324 xfs_mount_t *mp,
07aabd9c 325 struct xfs_growfs_log *in)
1da177e4
LT
326{
327 int error;
743bb465 328
329 if (!capable(CAP_SYS_ADMIN))
2451337d 330 return -EPERM;
cc92e7ac 331 if (!mutex_trylock(&mp->m_growlock))
2451337d 332 return -EWOULDBLOCK;
1da177e4 333 error = xfs_growfs_log_private(mp, in);
cc92e7ac 334 mutex_unlock(&mp->m_growlock);
1da177e4
LT
335 return error;
336}
337
338/*
339 * exported through ioctl XFS_IOC_FSCOUNTS
340 */
341
91083269 342void
1da177e4
LT
343xfs_fs_counts(
344 xfs_mount_t *mp,
345 xfs_fsop_counts_t *cnt)
346{
501ab323 347 cnt->allocino = percpu_counter_read_positive(&mp->m_icount);
e88b64ea 348 cnt->freeino = percpu_counter_read_positive(&mp->m_ifree);
0d485ada 349 cnt->freedata = percpu_counter_read_positive(&mp->m_fdblocks) -
52548852 350 mp->m_alloc_set_aside;
501ab323 351
3685c2a1 352 spin_lock(&mp->m_sb_lock);
1da177e4 353 cnt->freertx = mp->m_sb.sb_frextents;
3685c2a1 354 spin_unlock(&mp->m_sb_lock);
1da177e4
LT
355}
356
357/*
358 * exported through ioctl XFS_IOC_SET_RESBLKS & XFS_IOC_GET_RESBLKS
359 *
360 * xfs_reserve_blocks is called to set m_resblks
361 * in the in-core mount table. The number of unused reserved blocks
c41564b5 362 * is kept in m_resblks_avail.
1da177e4
LT
363 *
364 * Reserve the requested number of blocks if available. Otherwise return
365 * as many as possible to satisfy the request. The actual number
366 * reserved are returned in outval
367 *
368 * A null inval pointer indicates that only the current reserved blocks
369 * available should be returned no settings are changed.
370 */
371
372int
373xfs_reserve_blocks(
374 xfs_mount_t *mp,
c8ce540d 375 uint64_t *inval,
1da177e4
LT
376 xfs_fsop_resblks_t *outval)
377{
c8ce540d
DW
378 int64_t lcounter, delta;
379 int64_t fdblks_delta = 0;
380 uint64_t request;
381 int64_t free;
408fd484 382 int error = 0;
1da177e4
LT
383
384 /* If inval is null, report current values and return */
c8ce540d 385 if (inval == (uint64_t *)NULL) {
84e1e99f 386 if (!outval)
2451337d 387 return -EINVAL;
1da177e4
LT
388 outval->resblks = mp->m_resblks;
389 outval->resblks_avail = mp->m_resblks_avail;
014c2544 390 return 0;
1da177e4
LT
391 }
392
393 request = *inval;
dbcabad1
DC
394
395 /*
408fd484
BF
396 * With per-cpu counters, this becomes an interesting problem. we need
397 * to work out if we are freeing or allocation blocks first, then we can
398 * do the modification as necessary.
dbcabad1 399 *
408fd484
BF
400 * We do this under the m_sb_lock so that if we are near ENOSPC, we will
401 * hold out any changes while we work out what to do. This means that
402 * the amount of free space can change while we do this, so we need to
403 * retry if we end up trying to reserve more space than is available.
dbcabad1 404 */
3685c2a1 405 spin_lock(&mp->m_sb_lock);
1da177e4
LT
406
407 /*
408 * If our previous reservation was larger than the current value,
408fd484
BF
409 * then move any unused blocks back to the free pool. Modify the resblks
410 * counters directly since we shouldn't have any problems unreserving
411 * space.
1da177e4 412 */
1da177e4
LT
413 if (mp->m_resblks > request) {
414 lcounter = mp->m_resblks_avail - request;
415 if (lcounter > 0) { /* release unused blocks */
dbcabad1 416 fdblks_delta = lcounter;
1da177e4
LT
417 mp->m_resblks_avail -= lcounter;
418 }
419 mp->m_resblks = request;
408fd484
BF
420 if (fdblks_delta) {
421 spin_unlock(&mp->m_sb_lock);
422 error = xfs_mod_fdblocks(mp, fdblks_delta, 0);
423 spin_lock(&mp->m_sb_lock);
424 }
425
426 goto out;
427 }
4be536de 428
408fd484
BF
429 /*
430 * If the request is larger than the current reservation, reserve the
431 * blocks before we update the reserve counters. Sample m_fdblocks and
432 * perform a partial reservation if the request exceeds free space.
15f04fdc
DW
433 *
434 * The code below estimates how many blocks it can request from
435 * fdblocks to stash in the reserve pool. This is a classic TOCTOU
436 * race since fdblocks updates are not always coordinated via
0baa2657
DW
437 * m_sb_lock. Set the reserve size even if there's not enough free
438 * space to fill it because mod_fdblocks will refill an undersized
439 * reserve when it can.
408fd484 440 */
15f04fdc 441 free = percpu_counter_sum(&mp->m_fdblocks) -
c8c56825 442 xfs_fdblocks_unavailable(mp);
15f04fdc 443 delta = request - mp->m_resblks;
0baa2657 444 mp->m_resblks = request;
15f04fdc 445 if (delta > 0 && free > 0) {
dbcabad1 446 /*
408fd484 447 * We'll either succeed in getting space from the free block
15f04fdc
DW
448 * count or we'll get an ENOSPC. Don't set the reserved flag
449 * here - we don't want to reserve the extra reserve blocks
450 * from the reserve.
82be38bc
DW
451 *
452 * The desired reserve size can change after we drop the lock.
453 * Use mod_fdblocks to put the space into the reserve or into
454 * fdblocks as appropriate.
dbcabad1 455 */
15f04fdc 456 fdblks_delta = min(free, delta);
408fd484
BF
457 spin_unlock(&mp->m_sb_lock);
458 error = xfs_mod_fdblocks(mp, -fdblks_delta, 0);
0baa2657 459 if (!error)
82be38bc
DW
460 xfs_mod_fdblocks(mp, fdblks_delta, 0);
461 spin_lock(&mp->m_sb_lock);
dbcabad1 462 }
408fd484
BF
463out:
464 if (outval) {
465 outval->resblks = mp->m_resblks;
466 outval->resblks_avail = mp->m_resblks_avail;
467 }
468
469 spin_unlock(&mp->m_sb_lock);
470 return error;
1da177e4
LT
471}
472
1da177e4
LT
473int
474xfs_fs_goingdown(
475 xfs_mount_t *mp,
c8ce540d 476 uint32_t inflags)
1da177e4
LT
477{
478 switch (inflags) {
479 case XFS_FSOP_GOING_FLAGS_DEFAULT: {
040f04bd 480 if (!freeze_bdev(mp->m_super->s_bdev)) {
7d04a335 481 xfs_force_shutdown(mp, SHUTDOWN_FORCE_UMOUNT);
040f04bd 482 thaw_bdev(mp->m_super->s_bdev);
1da177e4 483 }
1da177e4
LT
484 break;
485 }
486 case XFS_FSOP_GOING_FLAGS_LOGFLUSH:
7d04a335 487 xfs_force_shutdown(mp, SHUTDOWN_FORCE_UMOUNT);
1da177e4
LT
488 break;
489 case XFS_FSOP_GOING_FLAGS_NOLOGFLUSH:
7d04a335
NS
490 xfs_force_shutdown(mp,
491 SHUTDOWN_FORCE_UMOUNT | SHUTDOWN_LOG_IO_ERROR);
1da177e4
LT
492 break;
493 default:
2451337d 494 return -EINVAL;
1da177e4
LT
495 }
496
497 return 0;
498}
2af51f3a
DC
499
500/*
501 * Force a shutdown of the filesystem instantly while keeping the filesystem
502 * consistent. We don't do an unmount here; just shutdown the shop, make sure
503 * that absolutely nothing persistent happens to this filesystem after this
504 * point.
b36d4651
DC
505 *
506 * The shutdown state change is atomic, resulting in the first and only the
507 * first shutdown call processing the shutdown. This means we only shutdown the
508 * log once as it requires, and we don't spam the logs when multiple concurrent
509 * shutdowns race to set the shutdown flags.
2af51f3a
DC
510 */
511void
512xfs_do_force_shutdown(
56668a5c 513 struct xfs_mount *mp,
2af51f3a
DC
514 int flags,
515 char *fname,
516 int lnnum)
517{
b36d4651
DC
518 int tag;
519 const char *why;
2af51f3a 520
2e973b2c 521 if (test_and_set_bit(XFS_OPSTATE_SHUTDOWN, &mp->m_opstate))
56668a5c 522 return;
b36d4651
DC
523 if (mp->m_sb_bp)
524 mp->m_sb_bp->b_flags |= XBF_DONE;
b36d4651
DC
525
526 if (flags & SHUTDOWN_FORCE_UMOUNT)
527 xfs_alert(mp, "User initiated shutdown received.");
56668a5c 528
b36d4651
DC
529 if (xlog_force_shutdown(mp->m_log, flags)) {
530 tag = XFS_PTAG_SHUTDOWN_LOGERROR;
531 why = "Log I/O Error";
532 } else if (flags & SHUTDOWN_CORRUPT_INCORE) {
533 tag = XFS_PTAG_SHUTDOWN_CORRUPT;
534 why = "Corruption of in-memory data";
28d84620 535 } else {
b36d4651
DC
536 tag = XFS_PTAG_SHUTDOWN_IOERROR;
537 why = "Metadata I/O Error";
2af51f3a 538 }
56668a5c 539
7f89c838
DW
540 trace_xfs_force_shutdown(mp, tag, flags, fname, lnnum);
541
b36d4651
DC
542 xfs_alert_tag(mp, tag,
543"%s (0x%x) detected at %pS (%s:%d). Shutting down filesystem.",
544 why, flags, __return_address, fname, lnnum);
56668a5c
DC
545 xfs_alert(mp,
546 "Please unmount the filesystem and rectify the problem(s)");
b36d4651
DC
547 if (xfs_error_level >= XFS_ERRLEVEL_HIGH)
548 xfs_stack_trace();
2af51f3a 549}
84d69619
DW
550
551/*
552 * Reserve free space for per-AG metadata.
553 */
554int
555xfs_fs_reserve_ag_blocks(
556 struct xfs_mount *mp)
557{
558 xfs_agnumber_t agno;
559 struct xfs_perag *pag;
560 int error = 0;
561 int err2;
562
15a268d9 563 mp->m_finobt_nores = false;
f250eedc 564 for_each_perag(mp, agno, pag) {
ebcbef3a 565 err2 = xfs_ag_resv_init(pag, NULL);
84d69619
DW
566 if (err2 && !error)
567 error = err2;
568 }
569
570 if (error && error != -ENOSPC) {
571 xfs_warn(mp,
572 "Error %d reserving per-AG metadata reserve pool.", error);
573 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
574 }
575
576 return error;
577}
578
579/*
580 * Free space reserved for per-AG metadata.
581 */
582int
583xfs_fs_unreserve_ag_blocks(
584 struct xfs_mount *mp)
585{
586 xfs_agnumber_t agno;
587 struct xfs_perag *pag;
588 int error = 0;
589 int err2;
590
f250eedc 591 for_each_perag(mp, agno, pag) {
84d69619 592 err2 = xfs_ag_resv_free(pag);
84d69619
DW
593 if (err2 && !error)
594 error = err2;
595 }
596
597 if (error)
598 xfs_warn(mp,
599 "Error %d freeing per-AG metadata reserve pool.", error);
600
601 return error;
602}