Skip to content

Commit f32866f

Browse files
djwongdchinner
authored andcommitted
xfs: store rmapbt block count in the AGF
Track the number of blocks used for the rmapbt in the AGF. When we get to the AG reservation code we need this counter to quickly make our reservation during mount. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
1 parent 8b2180b commit f32866f

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

fs/xfs/libxfs/xfs_alloc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,6 +2264,7 @@ xfs_alloc_log_agf(
22642264
offsetof(xfs_agf_t, agf_longest),
22652265
offsetof(xfs_agf_t, agf_btreeblks),
22662266
offsetof(xfs_agf_t, agf_uuid),
2267+
offsetof(xfs_agf_t, agf_rmap_blocks),
22672268
sizeof(xfs_agf_t)
22682269
};
22692270

fs/xfs/libxfs/xfs_format.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -640,12 +640,15 @@ typedef struct xfs_agf {
640640
__be32 agf_btreeblks; /* # of blocks held in AGF btrees */
641641
uuid_t agf_uuid; /* uuid of filesystem */
642642

643+
__be32 agf_rmap_blocks; /* rmapbt blocks used */
644+
__be32 agf_padding; /* padding */
645+
643646
/*
644647
* reserve some contiguous space for future logged fields before we add
645648
* the unlogged fields. This makes the range logging via flags and
646649
* structure offsets much simpler.
647650
*/
648-
__be64 agf_spare64[16];
651+
__be64 agf_spare64[15];
649652

650653
/* unlogged fields, written during buffer writeback. */
651654
__be64 agf_lsn; /* last write sequence */
@@ -670,7 +673,8 @@ typedef struct xfs_agf {
670673
#define XFS_AGF_LONGEST 0x00000400
671674
#define XFS_AGF_BTREEBLKS 0x00000800
672675
#define XFS_AGF_UUID 0x00001000
673-
#define XFS_AGF_NUM_BITS 13
676+
#define XFS_AGF_RMAP_BLOCKS 0x00002000
677+
#define XFS_AGF_NUM_BITS 14
674678
#define XFS_AGF_ALL_BITS ((1 << XFS_AGF_NUM_BITS) - 1)
675679

676680
#define XFS_AGF_FLAGS \
@@ -686,7 +690,8 @@ typedef struct xfs_agf {
686690
{ XFS_AGF_FREEBLKS, "FREEBLKS" }, \
687691
{ XFS_AGF_LONGEST, "LONGEST" }, \
688692
{ XFS_AGF_BTREEBLKS, "BTREEBLKS" }, \
689-
{ XFS_AGF_UUID, "UUID" }
693+
{ XFS_AGF_UUID, "UUID" }, \
694+
{ XFS_AGF_RMAP_BLOCKS, "RMAP_BLOCKS" }
690695

691696
/* disk block (xfs_daddr_t) in the AG */
692697
#define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log))

fs/xfs/libxfs/xfs_rmap_btree.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ xfs_rmapbt_alloc_block(
9898
union xfs_btree_ptr *new,
9999
int *stat)
100100
{
101+
struct xfs_buf *agbp = cur->bc_private.a.agbp;
102+
struct xfs_agf *agf = XFS_BUF_TO_AGF(agbp);
101103
int error;
102104
xfs_agblock_t bno;
103105

@@ -124,6 +126,8 @@ xfs_rmapbt_alloc_block(
124126

125127
xfs_trans_agbtree_delta(cur->bc_tp, 1);
126128
new->s = cpu_to_be32(bno);
129+
be32_add_cpu(&agf->agf_rmap_blocks, 1);
130+
xfs_alloc_log_agf(cur->bc_tp, agbp, XFS_AGF_RMAP_BLOCKS);
127131

128132
XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT);
129133
*stat = 1;
@@ -143,6 +147,8 @@ xfs_rmapbt_free_block(
143147
bno = xfs_daddr_to_agbno(cur->bc_mp, XFS_BUF_ADDR(bp));
144148
trace_xfs_rmapbt_free_block(cur->bc_mp, cur->bc_private.a.agno,
145149
bno, 1);
150+
be32_add_cpu(&agf->agf_rmap_blocks, -1);
151+
xfs_alloc_log_agf(cur->bc_tp, agbp, XFS_AGF_RMAP_BLOCKS);
146152
error = xfs_alloc_put_freelist(cur->bc_tp, agbp, NULL, bno, 1);
147153
if (error)
148154
return error;

fs/xfs/xfs_fsops.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ xfs_growfs_data_private(
248248
agf->agf_roots[XFS_BTNUM_RMAPi] =
249249
cpu_to_be32(XFS_RMAP_BLOCK(mp));
250250
agf->agf_levels[XFS_BTNUM_RMAPi] = cpu_to_be32(1);
251+
agf->agf_rmap_blocks = cpu_to_be32(1);
251252
}
252253

253254
agf->agf_flfirst = cpu_to_be32(1);

0 commit comments

Comments
 (0)