Commit bd85af28 authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: create helpers for rtsummary block/wordcount computations

Create helper functions that compute the number of blocks or words
necessary to store the rt summary file.
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 97e99383
...@@ -1146,3 +1146,32 @@ xfs_rtbitmap_wordcount( ...@@ -1146,3 +1146,32 @@ xfs_rtbitmap_wordcount(
blocks = xfs_rtbitmap_blockcount(mp, rtextents); blocks = xfs_rtbitmap_blockcount(mp, rtextents);
return XFS_FSB_TO_B(mp, blocks) >> XFS_WORDLOG; return XFS_FSB_TO_B(mp, blocks) >> XFS_WORDLOG;
} }
/* Compute the number of rtsummary blocks needed to track the given rt space. */
xfs_filblks_t
xfs_rtsummary_blockcount(
struct xfs_mount *mp,
unsigned int rsumlevels,
xfs_extlen_t rbmblocks)
{
unsigned long long rsumwords;
rsumwords = (unsigned long long)rsumlevels * rbmblocks;
return XFS_B_TO_FSB(mp, rsumwords << XFS_WORDLOG);
}
/*
* Compute the number of rtsummary info words needed to populate every block of
* a summary file that is large enough to track the given rt space.
*/
unsigned long long
xfs_rtsummary_wordcount(
struct xfs_mount *mp,
unsigned int rsumlevels,
xfs_extlen_t rbmblocks)
{
xfs_filblks_t blocks;
blocks = xfs_rtsummary_blockcount(mp, rsumlevels, rbmblocks);
return XFS_FSB_TO_B(mp, blocks) >> XFS_WORDLOG;
}
...@@ -308,6 +308,11 @@ xfs_filblks_t xfs_rtbitmap_blockcount(struct xfs_mount *mp, xfs_rtbxlen_t ...@@ -308,6 +308,11 @@ xfs_filblks_t xfs_rtbitmap_blockcount(struct xfs_mount *mp, xfs_rtbxlen_t
rtextents); rtextents);
unsigned long long xfs_rtbitmap_wordcount(struct xfs_mount *mp, unsigned long long xfs_rtbitmap_wordcount(struct xfs_mount *mp,
xfs_rtbxlen_t rtextents); xfs_rtbxlen_t rtextents);
xfs_filblks_t xfs_rtsummary_blockcount(struct xfs_mount *mp,
unsigned int rsumlevels, xfs_extlen_t rbmblocks);
unsigned long long xfs_rtsummary_wordcount(struct xfs_mount *mp,
unsigned int rsumlevels, xfs_extlen_t rbmblocks);
#else /* CONFIG_XFS_RT */ #else /* CONFIG_XFS_RT */
# define xfs_rtfree_extent(t,b,l) (-ENOSYS) # define xfs_rtfree_extent(t,b,l) (-ENOSYS)
# define xfs_rtfree_blocks(t,rb,rl) (-ENOSYS) # define xfs_rtfree_blocks(t,rb,rl) (-ENOSYS)
...@@ -322,6 +327,8 @@ xfs_rtbitmap_blockcount(struct xfs_mount *mp, xfs_rtbxlen_t rtextents) ...@@ -322,6 +327,8 @@ xfs_rtbitmap_blockcount(struct xfs_mount *mp, xfs_rtbxlen_t rtextents)
return 0; return 0;
} }
# define xfs_rtbitmap_wordcount(mp, r) (0) # define xfs_rtbitmap_wordcount(mp, r) (0)
# define xfs_rtsummary_blockcount(mp, l, b) (0)
# define xfs_rtsummary_wordcount(mp, l, b) (0)
#endif /* CONFIG_XFS_RT */ #endif /* CONFIG_XFS_RT */
#endif /* __XFS_RTBITMAP_H__ */ #endif /* __XFS_RTBITMAP_H__ */
...@@ -1001,8 +1001,7 @@ xfs_growfs_rt( ...@@ -1001,8 +1001,7 @@ xfs_growfs_rt(
nrbmblocks = xfs_rtbitmap_blockcount(mp, nrextents); nrbmblocks = xfs_rtbitmap_blockcount(mp, nrextents);
nrextslog = xfs_highbit32(nrextents); nrextslog = xfs_highbit32(nrextents);
nrsumlevels = nrextslog + 1; nrsumlevels = nrextslog + 1;
nrsumsize = (uint)sizeof(xfs_suminfo_t) * nrsumlevels * nrbmblocks; nrsumblocks = xfs_rtsummary_blockcount(mp, nrsumlevels, nrbmblocks);
nrsumblocks = XFS_B_TO_FSB(mp, nrsumsize);
nrsumsize = XFS_FSB_TO_B(mp, nrsumblocks); nrsumsize = XFS_FSB_TO_B(mp, nrsumblocks);
/* /*
* New summary size can't be more than half the size of * New summary size can't be more than half the size of
...@@ -1063,10 +1062,8 @@ xfs_growfs_rt( ...@@ -1063,10 +1062,8 @@ xfs_growfs_rt(
ASSERT(nsbp->sb_rextents != 0); ASSERT(nsbp->sb_rextents != 0);
nsbp->sb_rextslog = xfs_highbit32(nsbp->sb_rextents); nsbp->sb_rextslog = xfs_highbit32(nsbp->sb_rextents);
nrsumlevels = nmp->m_rsumlevels = nsbp->sb_rextslog + 1; nrsumlevels = nmp->m_rsumlevels = nsbp->sb_rextslog + 1;
nrsumsize = nrsumblocks = xfs_rtsummary_blockcount(mp, nrsumlevels,
(uint)sizeof(xfs_suminfo_t) * nrsumlevels * nsbp->sb_rbmblocks);
nsbp->sb_rbmblocks;
nrsumblocks = XFS_B_TO_FSB(mp, nrsumsize);
nmp->m_rsumsize = nrsumsize = XFS_FSB_TO_B(mp, nrsumblocks); nmp->m_rsumsize = nrsumsize = XFS_FSB_TO_B(mp, nrsumblocks);
/* /*
* Start a transaction, get the log reservation. * Start a transaction, get the log reservation.
...@@ -1272,6 +1269,7 @@ xfs_rtmount_init( ...@@ -1272,6 +1269,7 @@ xfs_rtmount_init(
struct xfs_buf *bp; /* buffer for last block of subvolume */ struct xfs_buf *bp; /* buffer for last block of subvolume */
struct xfs_sb *sbp; /* filesystem superblock copy in mount */ struct xfs_sb *sbp; /* filesystem superblock copy in mount */
xfs_daddr_t d; /* address of last block of subvolume */ xfs_daddr_t d; /* address of last block of subvolume */
unsigned int rsumblocks;
int error; int error;
sbp = &mp->m_sb; sbp = &mp->m_sb;
...@@ -1283,10 +1281,9 @@ xfs_rtmount_init( ...@@ -1283,10 +1281,9 @@ xfs_rtmount_init(
return -ENODEV; return -ENODEV;
} }
mp->m_rsumlevels = sbp->sb_rextslog + 1; mp->m_rsumlevels = sbp->sb_rextslog + 1;
mp->m_rsumsize = rsumblocks = xfs_rtsummary_blockcount(mp, mp->m_rsumlevels,
(uint)sizeof(xfs_suminfo_t) * mp->m_rsumlevels * mp->m_sb.sb_rbmblocks);
sbp->sb_rbmblocks; mp->m_rsumsize = XFS_FSB_TO_B(mp, rsumblocks);
mp->m_rsumsize = roundup(mp->m_rsumsize, sbp->sb_blocksize);
mp->m_rbmip = mp->m_rsumip = NULL; mp->m_rbmip = mp->m_rsumip = NULL;
/* /*
* Check that the realtime section is an ok size. * Check that the realtime section is an ok size.
......
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