Skip to content

Commit b31c2bd

Browse files
committed
xfs: reserve blocks for refcount / rmap log item recovery
During log recovery, the per-AG reservations aren't yet set up, so log recovery has to reserve enough blocks to handle all possible btree splits. Reported-by: Dave Chinner <david@fromorbit.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com>
1 parent 86516ef commit b31c2bd

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

fs/xfs/xfs_refcount_item.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "xfs_log_format.h"
2424
#include "xfs_trans_resv.h"
2525
#include "xfs_bit.h"
26+
#include "xfs_shared.h"
2627
#include "xfs_mount.h"
2728
#include "xfs_defer.h"
2829
#include "xfs_trans.h"
@@ -456,10 +457,12 @@ xfs_cui_recover(
456457
* transaction. Normally, any work that needs to be deferred
457458
* gets attached to the same defer_ops that scheduled the
458459
* refcount update. However, we're in log recovery here, so we
459-
* we create our own defer_ops and use that to finish up any
460-
* work that doesn't fit.
460+
* we use the passed in defer_ops and to finish up any work that
461+
* doesn't fit. We need to reserve enough blocks to handle a
462+
* full btree split on either end of the refcount range.
461463
*/
462-
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp);
464+
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate,
465+
mp->m_refc_maxlevels * 2, 0, XFS_TRANS_RESERVE, &tp);
463466
if (error)
464467
return error;
465468
cudp = xfs_trans_get_cud(tp, cuip);

fs/xfs/xfs_rmap_item.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "xfs_log_format.h"
2424
#include "xfs_trans_resv.h"
2525
#include "xfs_bit.h"
26+
#include "xfs_shared.h"
2627
#include "xfs_mount.h"
2728
#include "xfs_defer.h"
2829
#include "xfs_trans.h"
@@ -470,7 +471,8 @@ xfs_rui_recover(
470471
}
471472
}
472473

473-
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp);
474+
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate,
475+
mp->m_rmap_maxlevels, 0, XFS_TRANS_RESERVE, &tp);
474476
if (error)
475477
return error;
476478
rudp = xfs_trans_get_rud(tp, ruip);

0 commit comments

Comments
 (0)