Skip to content

Commit bd85af2

Browse files
author
Darrick J. Wong
committed
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: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
1 parent 97e9938 commit bd85af2

File tree

3 files changed

+43
-10
lines changed

3 files changed

+43
-10
lines changed

fs/xfs/libxfs/xfs_rtbitmap.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,3 +1146,32 @@ xfs_rtbitmap_wordcount(
11461146
blocks = xfs_rtbitmap_blockcount(mp, rtextents);
11471147
return XFS_FSB_TO_B(mp, blocks) >> XFS_WORDLOG;
11481148
}
1149+
1150+
/* Compute the number of rtsummary blocks needed to track the given rt space. */
1151+
xfs_filblks_t
1152+
xfs_rtsummary_blockcount(
1153+
struct xfs_mount *mp,
1154+
unsigned int rsumlevels,
1155+
xfs_extlen_t rbmblocks)
1156+
{
1157+
unsigned long long rsumwords;
1158+
1159+
rsumwords = (unsigned long long)rsumlevels * rbmblocks;
1160+
return XFS_B_TO_FSB(mp, rsumwords << XFS_WORDLOG);
1161+
}
1162+
1163+
/*
1164+
* Compute the number of rtsummary info words needed to populate every block of
1165+
* a summary file that is large enough to track the given rt space.
1166+
*/
1167+
unsigned long long
1168+
xfs_rtsummary_wordcount(
1169+
struct xfs_mount *mp,
1170+
unsigned int rsumlevels,
1171+
xfs_extlen_t rbmblocks)
1172+
{
1173+
xfs_filblks_t blocks;
1174+
1175+
blocks = xfs_rtsummary_blockcount(mp, rsumlevels, rbmblocks);
1176+
return XFS_FSB_TO_B(mp, blocks) >> XFS_WORDLOG;
1177+
}

fs/xfs/libxfs/xfs_rtbitmap.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,11 @@ xfs_filblks_t xfs_rtbitmap_blockcount(struct xfs_mount *mp, xfs_rtbxlen_t
308308
rtextents);
309309
unsigned long long xfs_rtbitmap_wordcount(struct xfs_mount *mp,
310310
xfs_rtbxlen_t rtextents);
311+
312+
xfs_filblks_t xfs_rtsummary_blockcount(struct xfs_mount *mp,
313+
unsigned int rsumlevels, xfs_extlen_t rbmblocks);
314+
unsigned long long xfs_rtsummary_wordcount(struct xfs_mount *mp,
315+
unsigned int rsumlevels, xfs_extlen_t rbmblocks);
311316
#else /* CONFIG_XFS_RT */
312317
# define xfs_rtfree_extent(t,b,l) (-ENOSYS)
313318
# define xfs_rtfree_blocks(t,rb,rl) (-ENOSYS)
@@ -322,6 +327,8 @@ xfs_rtbitmap_blockcount(struct xfs_mount *mp, xfs_rtbxlen_t rtextents)
322327
return 0;
323328
}
324329
# define xfs_rtbitmap_wordcount(mp, r) (0)
330+
# define xfs_rtsummary_blockcount(mp, l, b) (0)
331+
# define xfs_rtsummary_wordcount(mp, l, b) (0)
325332
#endif /* CONFIG_XFS_RT */
326333

327334
#endif /* __XFS_RTBITMAP_H__ */

fs/xfs/xfs_rtalloc.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,8 +1001,7 @@ xfs_growfs_rt(
10011001
nrbmblocks = xfs_rtbitmap_blockcount(mp, nrextents);
10021002
nrextslog = xfs_highbit32(nrextents);
10031003
nrsumlevels = nrextslog + 1;
1004-
nrsumsize = (uint)sizeof(xfs_suminfo_t) * nrsumlevels * nrbmblocks;
1005-
nrsumblocks = XFS_B_TO_FSB(mp, nrsumsize);
1004+
nrsumblocks = xfs_rtsummary_blockcount(mp, nrsumlevels, nrbmblocks);
10061005
nrsumsize = XFS_FSB_TO_B(mp, nrsumblocks);
10071006
/*
10081007
* New summary size can't be more than half the size of
@@ -1063,10 +1062,8 @@ xfs_growfs_rt(
10631062
ASSERT(nsbp->sb_rextents != 0);
10641063
nsbp->sb_rextslog = xfs_highbit32(nsbp->sb_rextents);
10651064
nrsumlevels = nmp->m_rsumlevels = nsbp->sb_rextslog + 1;
1066-
nrsumsize =
1067-
(uint)sizeof(xfs_suminfo_t) * nrsumlevels *
1068-
nsbp->sb_rbmblocks;
1069-
nrsumblocks = XFS_B_TO_FSB(mp, nrsumsize);
1065+
nrsumblocks = xfs_rtsummary_blockcount(mp, nrsumlevels,
1066+
nsbp->sb_rbmblocks);
10701067
nmp->m_rsumsize = nrsumsize = XFS_FSB_TO_B(mp, nrsumblocks);
10711068
/*
10721069
* Start a transaction, get the log reservation.
@@ -1272,6 +1269,7 @@ xfs_rtmount_init(
12721269
struct xfs_buf *bp; /* buffer for last block of subvolume */
12731270
struct xfs_sb *sbp; /* filesystem superblock copy in mount */
12741271
xfs_daddr_t d; /* address of last block of subvolume */
1272+
unsigned int rsumblocks;
12751273
int error;
12761274

12771275
sbp = &mp->m_sb;
@@ -1283,10 +1281,9 @@ xfs_rtmount_init(
12831281
return -ENODEV;
12841282
}
12851283
mp->m_rsumlevels = sbp->sb_rextslog + 1;
1286-
mp->m_rsumsize =
1287-
(uint)sizeof(xfs_suminfo_t) * mp->m_rsumlevels *
1288-
sbp->sb_rbmblocks;
1289-
mp->m_rsumsize = roundup(mp->m_rsumsize, sbp->sb_blocksize);
1284+
rsumblocks = xfs_rtsummary_blockcount(mp, mp->m_rsumlevels,
1285+
mp->m_sb.sb_rbmblocks);
1286+
mp->m_rsumsize = XFS_FSB_TO_B(mp, rsumblocks);
12901287
mp->m_rbmip = mp->m_rsumip = NULL;
12911288
/*
12921289
* Check that the realtime section is an ok size.

0 commit comments

Comments
 (0)