Skip to content

Commit f8c5a84

Browse files
Christoph HellwigDarrick J. Wong
authored andcommitted
xfs: refactor xfs_rtsummary_blockcount
Make xfs_rtsummary_blockcount take all the required information from the mount structure and return the number of summary levels from it as well. This cleans up many of the callers and prepares for making the rtsummary files per-rtgroup where they need to look at different value. This means we recalculate some values in some callers, but as all these calculations are outside the fast path and cheap, which seems like a price worth paying. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent 5a7566c commit f8c5a84

File tree

5 files changed

+17
-22
lines changed

5 files changed

+17
-22
lines changed

fs/xfs/libxfs/xfs_rtbitmap.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "xfs_error.h"
2121
#include "xfs_rtbitmap.h"
2222
#include "xfs_health.h"
23+
#include "xfs_sb.h"
2324

2425
/*
2526
* Realtime allocator bitmap functions shared with userspace.
@@ -1166,16 +1167,20 @@ xfs_rtbitmap_blockcount(
11661167
return xfs_rtbitmap_blockcount_len(mp, mp->m_sb.sb_rextents);
11671168
}
11681169

1169-
/* Compute the number of rtsummary blocks needed to track the given rt space. */
1170+
/*
1171+
* Compute the geometry of the rtsummary file needed to track the given rt
1172+
* space.
1173+
*/
11701174
xfs_filblks_t
11711175
xfs_rtsummary_blockcount(
11721176
struct xfs_mount *mp,
1173-
unsigned int rsumlevels,
1174-
xfs_extlen_t rbmblocks)
1177+
unsigned int *rsumlevels)
11751178
{
11761179
unsigned long long rsumwords;
11771180

1178-
rsumwords = (unsigned long long)rsumlevels * rbmblocks;
1181+
*rsumlevels = xfs_compute_rextslog(mp->m_sb.sb_rextents) + 1;
1182+
1183+
rsumwords = xfs_rtbitmap_blockcount(mp) * (*rsumlevels);
11791184
return XFS_B_TO_FSB(mp, rsumwords << XFS_WORDLOG);
11801185
}
11811186

fs/xfs/libxfs/xfs_rtbitmap.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ xfs_filblks_t xfs_rtbitmap_blockcount(struct xfs_mount *mp);
311311
xfs_filblks_t xfs_rtbitmap_blockcount_len(struct xfs_mount *mp,
312312
xfs_rtbxlen_t rtextents);
313313
xfs_filblks_t xfs_rtsummary_blockcount(struct xfs_mount *mp,
314-
unsigned int rsumlevels, xfs_extlen_t rbmblocks);
314+
unsigned int *rsumlevels);
315315

316316
int xfs_rtfile_initialize_blocks(struct xfs_rtgroup *rtg,
317317
enum xfs_rtg_inodes type, xfs_fileoff_t offset_fsb,
@@ -342,7 +342,6 @@ xfs_rtbitmap_blockcount_len(struct xfs_mount *mp, xfs_rtbxlen_t rtextents)
342342
/* shut up gcc */
343343
return 0;
344344
}
345-
# define xfs_rtsummary_blockcount(mp, l, b) (0)
346345
#endif /* CONFIG_XFS_RT */
347346

348347
#endif /* __XFS_RTBITMAP_H__ */

fs/xfs/scrub/rtsummary.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,10 @@ xchk_setup_rtsummary(
102102
*/
103103
xchk_rtgroup_lock(&sc->sr, XFS_RTGLOCK_BITMAP);
104104
if (mp->m_sb.sb_rblocks) {
105-
int rextslog;
106-
107105
rts->rextents = xfs_rtb_to_rtx(mp, mp->m_sb.sb_rblocks);
108-
rextslog = xfs_compute_rextslog(mp->m_sb.sb_rextents);
109-
rts->rsumlevels = rextslog + 1;
110106
rts->rbmblocks = xfs_rtbitmap_blockcount(mp);
111-
rts->rsumblocks = xfs_rtsummary_blockcount(mp, rts->rsumlevels,
112-
rts->rbmblocks);
107+
rts->rsumblocks =
108+
xfs_rtsummary_blockcount(mp, &rts->rsumlevels);
113109
}
114110

115111
return 0;

fs/xfs/xfs_mount.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ typedef struct xfs_mount {
173173
uint m_allocsize_blocks; /* min write size blocks */
174174
int m_logbufs; /* number of log buffers */
175175
int m_logbsize; /* size of each log buffer */
176-
uint m_rsumlevels; /* rt summary levels */
176+
unsigned int m_rsumlevels; /* rt summary levels */
177177
xfs_filblks_t m_rsumblocks; /* size of rt summary, FSBs */
178178
uint32_t m_rgblocks; /* size of rtgroup in rtblocks */
179179
int m_fixedfsid[2]; /* unchanged for life of FS */

fs/xfs/xfs_rtalloc.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -751,9 +751,7 @@ xfs_growfs_rt_alloc_fake_mount(
751751
nmp->m_sb.sb_rextents = xfs_rtb_to_rtx(nmp, nmp->m_sb.sb_rblocks);
752752
nmp->m_sb.sb_rbmblocks = xfs_rtbitmap_blockcount(nmp);
753753
nmp->m_sb.sb_rextslog = xfs_compute_rextslog(nmp->m_sb.sb_rextents);
754-
nmp->m_rsumlevels = nmp->m_sb.sb_rextslog + 1;
755-
nmp->m_rsumblocks = xfs_rtsummary_blockcount(nmp, nmp->m_rsumlevels,
756-
nmp->m_sb.sb_rbmblocks);
754+
nmp->m_rsumblocks = xfs_rtsummary_blockcount(nmp, &nmp->m_rsumlevels);
757755

758756
if (rblocks > 0)
759757
nmp->m_features |= XFS_FEAT_REALTIME;
@@ -1138,21 +1136,18 @@ xfs_rtmount_init(
11381136
struct xfs_mount *mp) /* file system mount structure */
11391137
{
11401138
struct xfs_buf *bp; /* buffer for last block of subvolume */
1141-
struct xfs_sb *sbp; /* filesystem superblock copy in mount */
11421139
xfs_daddr_t d; /* address of last block of subvolume */
11431140
int error;
11441141

1145-
sbp = &mp->m_sb;
1146-
if (sbp->sb_rblocks == 0)
1142+
if (mp->m_sb.sb_rblocks == 0)
11471143
return 0;
11481144
if (mp->m_rtdev_targp == NULL) {
11491145
xfs_warn(mp,
11501146
"Filesystem has a realtime volume, use rtdev=device option");
11511147
return -ENODEV;
11521148
}
1153-
mp->m_rsumlevels = sbp->sb_rextslog + 1;
1154-
mp->m_rsumblocks = xfs_rtsummary_blockcount(mp, mp->m_rsumlevels,
1155-
mp->m_sb.sb_rbmblocks);
1149+
1150+
mp->m_rsumblocks = xfs_rtsummary_blockcount(mp, &mp->m_rsumlevels);
11561151

11571152
/*
11581153
* Check that the realtime section is an ok size.

0 commit comments

Comments
 (0)