mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 10:09:10 +02:00
xfs: Refactoring the nagcount and delta calculation
Introduce xfs_growfs_compute_delta() to calculate the nagcount and delta blocks and refactor the code from xfs_growfs_data_private(). No functional changes. Reviewed-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nirjhar Roy (IBM) <nirjhar.roy.lists@gmail.com> Signed-off-by: Carlos Maiolino <cem@kernel.org>
This commit is contained in:
parent
18c16f602a
commit
a49b7ff63f
|
|
@ -872,6 +872,34 @@ xfs_ag_shrink_space(
|
||||||
return err2;
|
return err2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xfs_growfs_compute_deltas(
|
||||||
|
struct xfs_mount *mp,
|
||||||
|
xfs_rfsblock_t nb,
|
||||||
|
int64_t *deltap,
|
||||||
|
xfs_agnumber_t *nagcountp)
|
||||||
|
{
|
||||||
|
xfs_rfsblock_t nb_div, nb_mod;
|
||||||
|
int64_t delta;
|
||||||
|
xfs_agnumber_t nagcount;
|
||||||
|
|
||||||
|
nb_div = nb;
|
||||||
|
nb_mod = do_div(nb_div, mp->m_sb.sb_agblocks);
|
||||||
|
if (nb_mod && nb_mod >= XFS_MIN_AG_BLOCKS)
|
||||||
|
nb_div++;
|
||||||
|
else if (nb_mod)
|
||||||
|
nb = nb_div * mp->m_sb.sb_agblocks;
|
||||||
|
|
||||||
|
if (nb_div > XFS_MAX_AGNUMBER + 1) {
|
||||||
|
nb_div = XFS_MAX_AGNUMBER + 1;
|
||||||
|
nb = nb_div * mp->m_sb.sb_agblocks;
|
||||||
|
}
|
||||||
|
nagcount = nb_div;
|
||||||
|
delta = nb - mp->m_sb.sb_dblocks;
|
||||||
|
*deltap = delta;
|
||||||
|
*nagcountp = nagcount;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Extent the AG indicated by the @id by the length passed in
|
* Extent the AG indicated by the @id by the length passed in
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -331,6 +331,9 @@ struct aghdr_init_data {
|
||||||
int xfs_ag_init_headers(struct xfs_mount *mp, struct aghdr_init_data *id);
|
int xfs_ag_init_headers(struct xfs_mount *mp, struct aghdr_init_data *id);
|
||||||
int xfs_ag_shrink_space(struct xfs_perag *pag, struct xfs_trans **tpp,
|
int xfs_ag_shrink_space(struct xfs_perag *pag, struct xfs_trans **tpp,
|
||||||
xfs_extlen_t delta);
|
xfs_extlen_t delta);
|
||||||
|
void
|
||||||
|
xfs_growfs_compute_deltas(struct xfs_mount *mp, xfs_rfsblock_t nb,
|
||||||
|
int64_t *deltap, xfs_agnumber_t *nagcountp);
|
||||||
int xfs_ag_extend_space(struct xfs_perag *pag, struct xfs_trans *tp,
|
int xfs_ag_extend_space(struct xfs_perag *pag, struct xfs_trans *tp,
|
||||||
xfs_extlen_t len);
|
xfs_extlen_t len);
|
||||||
int xfs_ag_get_geometry(struct xfs_perag *pag, struct xfs_ag_geometry *ageo);
|
int xfs_ag_get_geometry(struct xfs_perag *pag, struct xfs_ag_geometry *ageo);
|
||||||
|
|
|
||||||
|
|
@ -95,18 +95,17 @@ xfs_growfs_data_private(
|
||||||
struct xfs_growfs_data *in) /* growfs data input struct */
|
struct xfs_growfs_data *in) /* growfs data input struct */
|
||||||
{
|
{
|
||||||
xfs_agnumber_t oagcount = mp->m_sb.sb_agcount;
|
xfs_agnumber_t oagcount = mp->m_sb.sb_agcount;
|
||||||
|
xfs_rfsblock_t nb = in->newblocks;
|
||||||
struct xfs_buf *bp;
|
struct xfs_buf *bp;
|
||||||
int error;
|
int error;
|
||||||
xfs_agnumber_t nagcount;
|
xfs_agnumber_t nagcount;
|
||||||
xfs_agnumber_t nagimax = 0;
|
xfs_agnumber_t nagimax = 0;
|
||||||
xfs_rfsblock_t nb, nb_div, nb_mod;
|
|
||||||
int64_t delta;
|
int64_t delta;
|
||||||
bool lastag_extended = false;
|
bool lastag_extended = false;
|
||||||
struct xfs_trans *tp;
|
struct xfs_trans *tp;
|
||||||
struct aghdr_init_data id = {};
|
struct aghdr_init_data id = {};
|
||||||
struct xfs_perag *last_pag;
|
struct xfs_perag *last_pag;
|
||||||
|
|
||||||
nb = in->newblocks;
|
|
||||||
error = xfs_sb_validate_fsb_count(&mp->m_sb, nb);
|
error = xfs_sb_validate_fsb_count(&mp->m_sb, nb);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
@ -125,20 +124,8 @@ xfs_growfs_data_private(
|
||||||
mp->m_sb.sb_rextsize);
|
mp->m_sb.sb_rextsize);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
xfs_growfs_compute_deltas(mp, nb, &delta, &nagcount);
|
||||||
|
|
||||||
nb_div = nb;
|
|
||||||
nb_mod = do_div(nb_div, mp->m_sb.sb_agblocks);
|
|
||||||
if (nb_mod && nb_mod >= XFS_MIN_AG_BLOCKS)
|
|
||||||
nb_div++;
|
|
||||||
else if (nb_mod)
|
|
||||||
nb = nb_div * mp->m_sb.sb_agblocks;
|
|
||||||
|
|
||||||
if (nb_div > XFS_MAX_AGNUMBER + 1) {
|
|
||||||
nb_div = XFS_MAX_AGNUMBER + 1;
|
|
||||||
nb = nb_div * mp->m_sb.sb_agblocks;
|
|
||||||
}
|
|
||||||
nagcount = nb_div;
|
|
||||||
delta = nb - mp->m_sb.sb_dblocks;
|
|
||||||
/*
|
/*
|
||||||
* Reject filesystems with a single AG because they are not
|
* Reject filesystems with a single AG because they are not
|
||||||
* supported, and reject a shrink operation that would cause a
|
* supported, and reject a shrink operation that would cause a
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user