Commit 9aebe805 authored by Dave Chinner's avatar Dave Chinner Committed by Darrick J. Wong

xfs: convert growfs AG header init to use buffer lists

We currently write all new AG headers synchronously, which can be
slow for large grow operations. All we really need to do is ensure
all the headers are on disk before we run the growfs transaction, so
convert this to a buffer list and a delayed write operation. We
block waiting for the delayed write buffer submission to complete,
so this will fulfill the requirement to have all the buffers written
correctly before proceeding.
Signed-Off-By: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent cce77bcf
...@@ -81,7 +81,8 @@ xfs_grow_ag_headers( ...@@ -81,7 +81,8 @@ xfs_grow_ag_headers(
struct xfs_mount *mp, struct xfs_mount *mp,
xfs_agnumber_t agno, xfs_agnumber_t agno,
xfs_extlen_t agsize, xfs_extlen_t agsize,
xfs_rfsblock_t *nfree) xfs_rfsblock_t *nfree,
struct list_head *buffer_list)
{ {
struct xfs_agf *agf; struct xfs_agf *agf;
struct xfs_agi *agi; struct xfs_agi *agi;
...@@ -135,11 +136,8 @@ xfs_grow_ag_headers( ...@@ -135,11 +136,8 @@ xfs_grow_ag_headers(
agf->agf_refcount_level = cpu_to_be32(1); agf->agf_refcount_level = cpu_to_be32(1);
agf->agf_refcount_blocks = cpu_to_be32(1); agf->agf_refcount_blocks = cpu_to_be32(1);
} }
xfs_buf_delwri_queue(bp, buffer_list);
error = xfs_bwrite(bp);
xfs_buf_relse(bp); xfs_buf_relse(bp);
if (error)
goto out_error;
/* /*
* AG freelist header block * AG freelist header block
...@@ -164,10 +162,8 @@ xfs_grow_ag_headers( ...@@ -164,10 +162,8 @@ xfs_grow_ag_headers(
for (bucket = 0; bucket < xfs_agfl_size(mp); bucket++) for (bucket = 0; bucket < xfs_agfl_size(mp); bucket++)
agfl_bno[bucket] = cpu_to_be32(NULLAGBLOCK); agfl_bno[bucket] = cpu_to_be32(NULLAGBLOCK);
error = xfs_bwrite(bp); xfs_buf_delwri_queue(bp, buffer_list);
xfs_buf_relse(bp); xfs_buf_relse(bp);
if (error)
goto out_error;
/* /*
* AG inode header block * AG inode header block
...@@ -201,10 +197,8 @@ xfs_grow_ag_headers( ...@@ -201,10 +197,8 @@ xfs_grow_ag_headers(
for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++) for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++)
agi->agi_unlinked[bucket] = cpu_to_be32(NULLAGINO); agi->agi_unlinked[bucket] = cpu_to_be32(NULLAGINO);
error = xfs_bwrite(bp); xfs_buf_delwri_queue(bp, buffer_list);
xfs_buf_relse(bp); xfs_buf_relse(bp);
if (error)
goto out_error;
/* /*
* BNO btree root block * BNO btree root block
...@@ -226,10 +220,8 @@ xfs_grow_ag_headers( ...@@ -226,10 +220,8 @@ xfs_grow_ag_headers(
arec->ar_blockcount = cpu_to_be32( arec->ar_blockcount = cpu_to_be32(
agsize - be32_to_cpu(arec->ar_startblock)); agsize - be32_to_cpu(arec->ar_startblock));
error = xfs_bwrite(bp); xfs_buf_delwri_queue(bp, buffer_list);
xfs_buf_relse(bp); xfs_buf_relse(bp);
if (error)
goto out_error;
/* /*
* CNT btree root block * CNT btree root block
...@@ -251,10 +243,8 @@ xfs_grow_ag_headers( ...@@ -251,10 +243,8 @@ xfs_grow_ag_headers(
agsize - be32_to_cpu(arec->ar_startblock)); agsize - be32_to_cpu(arec->ar_startblock));
*nfree += be32_to_cpu(arec->ar_blockcount); *nfree += be32_to_cpu(arec->ar_blockcount);
error = xfs_bwrite(bp); xfs_buf_delwri_queue(bp, buffer_list);
xfs_buf_relse(bp); xfs_buf_relse(bp);
if (error)
goto out_error;
/* RMAP btree root block */ /* RMAP btree root block */
if (xfs_sb_version_hasrmapbt(&mp->m_sb)) { if (xfs_sb_version_hasrmapbt(&mp->m_sb)) {
...@@ -326,10 +316,8 @@ xfs_grow_ag_headers( ...@@ -326,10 +316,8 @@ xfs_grow_ag_headers(
be16_add_cpu(&block->bb_numrecs, 1); be16_add_cpu(&block->bb_numrecs, 1);
} }
error = xfs_bwrite(bp); xfs_buf_delwri_queue(bp, buffer_list);
xfs_buf_relse(bp); xfs_buf_relse(bp);
if (error)
goto out_error;
} }
/* /*
...@@ -345,11 +333,8 @@ xfs_grow_ag_headers( ...@@ -345,11 +333,8 @@ xfs_grow_ag_headers(
} }
xfs_btree_init_block(mp, bp, XFS_BTNUM_INO , 0, 0, agno, 0); xfs_btree_init_block(mp, bp, XFS_BTNUM_INO , 0, 0, agno, 0);
xfs_buf_delwri_queue(bp, buffer_list);
error = xfs_bwrite(bp);
xfs_buf_relse(bp); xfs_buf_relse(bp);
if (error)
goto out_error;
/* /*
* FINO btree root block * FINO btree root block
...@@ -364,13 +349,9 @@ xfs_grow_ag_headers( ...@@ -364,13 +349,9 @@ xfs_grow_ag_headers(
goto out_error; goto out_error;
} }
xfs_btree_init_block(mp, bp, XFS_BTNUM_FINO, xfs_btree_init_block(mp, bp, XFS_BTNUM_FINO, 0, 0, agno, 0);
0, 0, agno, 0); xfs_buf_delwri_queue(bp, buffer_list);
error = xfs_bwrite(bp);
xfs_buf_relse(bp); xfs_buf_relse(bp);
if (error)
goto out_error;
} }
/* /*
...@@ -386,13 +367,9 @@ xfs_grow_ag_headers( ...@@ -386,13 +367,9 @@ xfs_grow_ag_headers(
goto out_error; goto out_error;
} }
xfs_btree_init_block(mp, bp, XFS_BTNUM_REFC, xfs_btree_init_block(mp, bp, XFS_BTNUM_REFC, 0, 0, agno, 0);
0, 0, agno, 0); xfs_buf_delwri_queue(bp, buffer_list);
error = xfs_bwrite(bp);
xfs_buf_relse(bp); xfs_buf_relse(bp);
if (error)
goto out_error;
} }
out_error: out_error:
...@@ -419,6 +396,7 @@ xfs_growfs_data_private( ...@@ -419,6 +396,7 @@ xfs_growfs_data_private(
xfs_agnumber_t oagcount; xfs_agnumber_t oagcount;
int pct; int pct;
xfs_trans_t *tp; xfs_trans_t *tp;
LIST_HEAD (buffer_list);
nb = in->newblocks; nb = in->newblocks;
pct = in->imaxpct; pct = in->imaxpct;
...@@ -459,9 +437,16 @@ xfs_growfs_data_private( ...@@ -459,9 +437,16 @@ xfs_growfs_data_private(
return error; return error;
/* /*
* Write new AG headers to disk. Non-transactional, but written * Write new AG headers to disk. Non-transactional, but need to be
* synchronously so they are completed prior to the growfs transaction * written and completed prior to the growfs transaction being logged.
* being logged. * To do this, we use a delayed write buffer list and wait for
* submission and IO completion of the list as a whole. This allows the
* IO subsystem to merge all the AG headers in a single AG into a single
* IO and hide most of the latency of the IO from us.
*
* This also means that if we get an error whilst building the buffer
* list to write, we can cancel the entire list without having written
* anything.
*/ */
nfree = 0; nfree = 0;
for (agno = nagcount - 1; agno >= oagcount; agno--, new -= agsize) { for (agno = nagcount - 1; agno >= oagcount; agno--, new -= agsize) {
...@@ -472,10 +457,17 @@ xfs_growfs_data_private( ...@@ -472,10 +457,17 @@ xfs_growfs_data_private(
else else
agsize = mp->m_sb.sb_agblocks; agsize = mp->m_sb.sb_agblocks;
error = xfs_grow_ag_headers(mp, agno, agsize, &nfree); error = xfs_grow_ag_headers(mp, agno, agsize, &nfree,
if (error) &buffer_list);
if (error) {
xfs_buf_delwri_cancel(&buffer_list);
goto error0; goto error0;
}
} }
error = xfs_buf_delwri_submit(&buffer_list);
if (error)
goto error0;
xfs_trans_agblocks_delta(tp, nfree); xfs_trans_agblocks_delta(tp, nfree);
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment