Skip to content

Commit a684c53

Browse files
author
Darrick J. Wong
committed
xfs: convert xfs_extlen_t to xfs_rtxlen_t in the rt allocator
In most of the filesystem, we use xfs_extlen_t to store the length of a file (or AG) space mapping in units of fs blocks. Unfortunately, the realtime allocator also uses it to store the length of a rt space mapping in units of rt extents. This is confusing, since one rt extent can consist of many fs blocks. Separate the two by introducing a new type (xfs_rtxlen_t) to store the length of a space mapping (in units of realtime extents) that would be found in a file. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
1 parent 1392811 commit a684c53

File tree

7 files changed

+50
-50
lines changed

7 files changed

+50
-50
lines changed

fs/xfs/libxfs/xfs_rtbitmap.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ xfs_rtmodify_range(
534534
xfs_mount_t *mp, /* file system mount point */
535535
xfs_trans_t *tp, /* transaction pointer */
536536
xfs_rtblock_t start, /* starting block to modify */
537-
xfs_extlen_t len, /* length of extent to modify */
537+
xfs_rtxlen_t len, /* length of extent to modify */
538538
int val) /* 1 for free, 0 for allocated */
539539
{
540540
xfs_rtword_t *b; /* current word in buffer */
@@ -690,7 +690,7 @@ xfs_rtfree_range(
690690
xfs_mount_t *mp, /* file system mount point */
691691
xfs_trans_t *tp, /* transaction pointer */
692692
xfs_rtblock_t start, /* starting block to free */
693-
xfs_extlen_t len, /* length to free */
693+
xfs_rtxlen_t len, /* length to free */
694694
struct xfs_buf **rbpp, /* in/out: summary block buffer */
695695
xfs_fsblock_t *rsb) /* in/out: summary block number */
696696
{
@@ -766,7 +766,7 @@ xfs_rtcheck_range(
766766
xfs_mount_t *mp, /* file system mount point */
767767
xfs_trans_t *tp, /* transaction pointer */
768768
xfs_rtblock_t start, /* starting block number of extent */
769-
xfs_extlen_t len, /* length of extent */
769+
xfs_rtxlen_t len, /* length of extent */
770770
int val, /* 1 for free, 0 for allocated */
771771
xfs_rtblock_t *new, /* out: first block not matching */
772772
int *stat) /* out: 1 for matches, 0 for not */
@@ -942,7 +942,7 @@ xfs_rtcheck_alloc_range(
942942
xfs_mount_t *mp, /* file system mount point */
943943
xfs_trans_t *tp, /* transaction pointer */
944944
xfs_rtblock_t bno, /* starting block number of extent */
945-
xfs_extlen_t len) /* length of extent */
945+
xfs_rtxlen_t len) /* length of extent */
946946
{
947947
xfs_rtblock_t new; /* dummy for xfs_rtcheck_range */
948948
int stat;
@@ -965,7 +965,7 @@ int /* error */
965965
xfs_rtfree_extent(
966966
xfs_trans_t *tp, /* transaction pointer */
967967
xfs_rtblock_t bno, /* starting block number to free */
968-
xfs_extlen_t len) /* length of extent freed */
968+
xfs_rtxlen_t len) /* length of extent freed */
969969
{
970970
int error; /* error value */
971971
xfs_mount_t *mp; /* file system mount structure */
@@ -1116,7 +1116,7 @@ xfs_rtalloc_extent_is_free(
11161116
struct xfs_mount *mp,
11171117
struct xfs_trans *tp,
11181118
xfs_rtblock_t start,
1119-
xfs_extlen_t len,
1119+
xfs_rtxlen_t len,
11201120
bool *is_free)
11211121
{
11221122
xfs_rtblock_t end;

fs/xfs/libxfs/xfs_rtbitmap.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ typedef int (*xfs_rtalloc_query_range_fn)(
2626
int xfs_rtbuf_get(struct xfs_mount *mp, struct xfs_trans *tp,
2727
xfs_rtblock_t block, int issum, struct xfs_buf **bpp);
2828
int xfs_rtcheck_range(struct xfs_mount *mp, struct xfs_trans *tp,
29-
xfs_rtblock_t start, xfs_extlen_t len, int val,
29+
xfs_rtblock_t start, xfs_rtxlen_t len, int val,
3030
xfs_rtblock_t *new, int *stat);
3131
int xfs_rtfind_back(struct xfs_mount *mp, struct xfs_trans *tp,
3232
xfs_rtblock_t start, xfs_rtblock_t limit,
@@ -35,7 +35,7 @@ int xfs_rtfind_forw(struct xfs_mount *mp, struct xfs_trans *tp,
3535
xfs_rtblock_t start, xfs_rtblock_t limit,
3636
xfs_rtblock_t *rtblock);
3737
int xfs_rtmodify_range(struct xfs_mount *mp, struct xfs_trans *tp,
38-
xfs_rtblock_t start, xfs_extlen_t len, int val);
38+
xfs_rtblock_t start, xfs_rtxlen_t len, int val);
3939
int xfs_rtmodify_summary_int(struct xfs_mount *mp, struct xfs_trans *tp,
4040
int log, xfs_rtblock_t bbno, int delta,
4141
struct xfs_buf **rbpp, xfs_fsblock_t *rsb,
@@ -44,7 +44,7 @@ int xfs_rtmodify_summary(struct xfs_mount *mp, struct xfs_trans *tp, int log,
4444
xfs_rtblock_t bbno, int delta, struct xfs_buf **rbpp,
4545
xfs_fsblock_t *rsb);
4646
int xfs_rtfree_range(struct xfs_mount *mp, struct xfs_trans *tp,
47-
xfs_rtblock_t start, xfs_extlen_t len,
47+
xfs_rtblock_t start, xfs_rtxlen_t len,
4848
struct xfs_buf **rbpp, xfs_fsblock_t *rsb);
4949
int xfs_rtalloc_query_range(struct xfs_mount *mp, struct xfs_trans *tp,
5050
const struct xfs_rtalloc_rec *low_rec,
@@ -53,9 +53,8 @@ int xfs_rtalloc_query_range(struct xfs_mount *mp, struct xfs_trans *tp,
5353
int xfs_rtalloc_query_all(struct xfs_mount *mp, struct xfs_trans *tp,
5454
xfs_rtalloc_query_range_fn fn,
5555
void *priv);
56-
bool xfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno);
5756
int xfs_rtalloc_extent_is_free(struct xfs_mount *mp, struct xfs_trans *tp,
58-
xfs_rtblock_t start, xfs_extlen_t len,
57+
xfs_rtblock_t start, xfs_rtxlen_t len,
5958
bool *is_free);
6059
/*
6160
* Free an extent in the realtime subvolume. Length is expressed in
@@ -65,7 +64,7 @@ int /* error */
6564
xfs_rtfree_extent(
6665
struct xfs_trans *tp, /* transaction pointer */
6766
xfs_rtblock_t bno, /* starting block number to free */
68-
xfs_extlen_t len); /* length of extent freed */
67+
xfs_rtxlen_t len); /* length of extent freed */
6968

7069
/* Same as above, but in units of rt blocks. */
7170
int xfs_rtfree_blocks(struct xfs_trans *tp, xfs_fsblock_t rtbno,

fs/xfs/libxfs/xfs_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ typedef uint32_t prid_t; /* project ID */
1111
typedef uint32_t xfs_agblock_t; /* blockno in alloc. group */
1212
typedef uint32_t xfs_agino_t; /* inode # within allocation grp */
1313
typedef uint32_t xfs_extlen_t; /* extent length in blocks */
14+
typedef uint32_t xfs_rtxlen_t; /* file extent length in rtextents */
1415
typedef uint32_t xfs_agnumber_t; /* allocation group number */
1516
typedef uint64_t xfs_extnum_t; /* # of extents in a file */
1617
typedef uint32_t xfs_aextnum_t; /* # extents in an attribute fork */

fs/xfs/scrub/rtbitmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ xchk_xref_is_used_rt_space(
133133
{
134134
xfs_rtblock_t startext;
135135
xfs_rtblock_t endext;
136-
xfs_rtblock_t extcount;
136+
xfs_rtxlen_t extcount;
137137
bool is_free;
138138
int error;
139139

fs/xfs/xfs_bmap_util.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ xfs_bmap_rtalloc(
7676
struct xfs_mount *mp = ap->ip->i_mount;
7777
xfs_fileoff_t orig_offset = ap->offset;
7878
xfs_rtblock_t rtb;
79-
xfs_extlen_t prod = 0; /* product factor for allocators */
79+
xfs_rtxlen_t prod = 0; /* product factor for allocators */
8080
xfs_extlen_t mod = 0; /* product factor for allocators */
81-
xfs_extlen_t ralen = 0; /* realtime allocation length */
81+
xfs_rtxlen_t ralen = 0; /* realtime allocation length */
8282
xfs_extlen_t align; /* minimum allocation alignment */
8383
xfs_extlen_t orig_length = ap->length;
8484
xfs_extlen_t minlen = mp->m_sb.sb_rextsize;
85-
xfs_extlen_t raminlen;
85+
xfs_rtxlen_t raminlen;
8686
bool rtlocked = false;
8787
bool ignore_locality = false;
8888
int error;

fs/xfs/xfs_rtalloc.c

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ xfs_rtallocate_range(
144144
xfs_mount_t *mp, /* file system mount point */
145145
xfs_trans_t *tp, /* transaction pointer */
146146
xfs_rtblock_t start, /* start block to allocate */
147-
xfs_extlen_t len, /* length to allocate */
147+
xfs_rtxlen_t len, /* length to allocate */
148148
struct xfs_buf **rbpp, /* in/out: summary block buffer */
149149
xfs_fsblock_t *rsb) /* in/out: summary block number */
150150
{
@@ -216,14 +216,14 @@ xfs_rtallocate_range(
216216
* Make sure we don't run off the end of the rt volume. Be careful that
217217
* adjusting maxlen downwards doesn't cause us to fail the alignment checks.
218218
*/
219-
static inline xfs_extlen_t
219+
static inline xfs_rtxlen_t
220220
xfs_rtallocate_clamp_len(
221221
struct xfs_mount *mp,
222222
xfs_rtblock_t startrtx,
223-
xfs_extlen_t rtxlen,
224-
xfs_extlen_t prod)
223+
xfs_rtxlen_t rtxlen,
224+
xfs_rtxlen_t prod)
225225
{
226-
xfs_extlen_t ret;
226+
xfs_rtxlen_t ret;
227227

228228
ret = min(mp->m_sb.sb_rextents, startrtx + rtxlen) - startrtx;
229229
return rounddown(ret, prod);
@@ -240,13 +240,13 @@ xfs_rtallocate_extent_block(
240240
xfs_mount_t *mp, /* file system mount point */
241241
xfs_trans_t *tp, /* transaction pointer */
242242
xfs_rtblock_t bbno, /* bitmap block number */
243-
xfs_extlen_t minlen, /* minimum length to allocate */
244-
xfs_extlen_t maxlen, /* maximum length to allocate */
245-
xfs_extlen_t *len, /* out: actual length allocated */
243+
xfs_rtxlen_t minlen, /* minimum length to allocate */
244+
xfs_rtxlen_t maxlen, /* maximum length to allocate */
245+
xfs_rtxlen_t *len, /* out: actual length allocated */
246246
xfs_rtblock_t *nextp, /* out: next block to try */
247247
struct xfs_buf **rbpp, /* in/out: summary block buffer */
248248
xfs_fsblock_t *rsb, /* in/out: summary block number */
249-
xfs_extlen_t prod, /* extent product factor */
249+
xfs_rtxlen_t prod, /* extent product factor */
250250
xfs_rtblock_t *rtblock) /* out: start block allocated */
251251
{
252252
xfs_rtblock_t besti; /* best rtblock found so far */
@@ -319,7 +319,7 @@ xfs_rtallocate_extent_block(
319319
* Searched the whole thing & didn't find a maxlen free extent.
320320
*/
321321
if (minlen < maxlen && besti != -1) {
322-
xfs_extlen_t p; /* amount to trim length by */
322+
xfs_rtxlen_t p; /* amount to trim length by */
323323

324324
/*
325325
* If size should be a multiple of prod, make that so.
@@ -360,16 +360,16 @@ xfs_rtallocate_extent_exact(
360360
xfs_mount_t *mp, /* file system mount point */
361361
xfs_trans_t *tp, /* transaction pointer */
362362
xfs_rtblock_t bno, /* starting block number to allocate */
363-
xfs_extlen_t minlen, /* minimum length to allocate */
364-
xfs_extlen_t maxlen, /* maximum length to allocate */
365-
xfs_extlen_t *len, /* out: actual length allocated */
363+
xfs_rtxlen_t minlen, /* minimum length to allocate */
364+
xfs_rtxlen_t maxlen, /* maximum length to allocate */
365+
xfs_rtxlen_t *len, /* out: actual length allocated */
366366
struct xfs_buf **rbpp, /* in/out: summary block buffer */
367367
xfs_fsblock_t *rsb, /* in/out: summary block number */
368-
xfs_extlen_t prod, /* extent product factor */
368+
xfs_rtxlen_t prod, /* extent product factor */
369369
xfs_rtblock_t *rtblock) /* out: start block allocated */
370370
{
371371
int error; /* error value */
372-
xfs_extlen_t i; /* extent length trimmed due to prod */
372+
xfs_rtxlen_t i; /* extent length trimmed due to prod */
373373
int isfree; /* extent is free */
374374
xfs_rtblock_t next; /* next block to try (dummy) */
375375

@@ -440,12 +440,12 @@ xfs_rtallocate_extent_near(
440440
xfs_mount_t *mp, /* file system mount point */
441441
xfs_trans_t *tp, /* transaction pointer */
442442
xfs_rtblock_t bno, /* starting block number to allocate */
443-
xfs_extlen_t minlen, /* minimum length to allocate */
444-
xfs_extlen_t maxlen, /* maximum length to allocate */
445-
xfs_extlen_t *len, /* out: actual length allocated */
443+
xfs_rtxlen_t minlen, /* minimum length to allocate */
444+
xfs_rtxlen_t maxlen, /* maximum length to allocate */
445+
xfs_rtxlen_t *len, /* out: actual length allocated */
446446
struct xfs_buf **rbpp, /* in/out: summary block buffer */
447447
xfs_fsblock_t *rsb, /* in/out: summary block number */
448-
xfs_extlen_t prod, /* extent product factor */
448+
xfs_rtxlen_t prod, /* extent product factor */
449449
xfs_rtblock_t *rtblock) /* out: start block allocated */
450450
{
451451
int any; /* any useful extents from summary */
@@ -644,12 +644,12 @@ STATIC int /* error */
644644
xfs_rtallocate_extent_size(
645645
xfs_mount_t *mp, /* file system mount point */
646646
xfs_trans_t *tp, /* transaction pointer */
647-
xfs_extlen_t minlen, /* minimum length to allocate */
648-
xfs_extlen_t maxlen, /* maximum length to allocate */
649-
xfs_extlen_t *len, /* out: actual length allocated */
647+
xfs_rtxlen_t minlen, /* minimum length to allocate */
648+
xfs_rtxlen_t maxlen, /* maximum length to allocate */
649+
xfs_rtxlen_t *len, /* out: actual length allocated */
650650
struct xfs_buf **rbpp, /* in/out: summary block buffer */
651651
xfs_fsblock_t *rsb, /* in/out: summary block number */
652-
xfs_extlen_t prod, /* extent product factor */
652+
xfs_rtxlen_t prod, /* extent product factor */
653653
xfs_rtblock_t *rtblock) /* out: start block allocated */
654654
{
655655
int error; /* error value */
@@ -1197,11 +1197,11 @@ int /* error */
11971197
xfs_rtallocate_extent(
11981198
xfs_trans_t *tp, /* transaction pointer */
11991199
xfs_rtblock_t bno, /* starting block number to allocate */
1200-
xfs_extlen_t minlen, /* minimum length to allocate */
1201-
xfs_extlen_t maxlen, /* maximum length to allocate */
1202-
xfs_extlen_t *len, /* out: actual length allocated */
1200+
xfs_rtxlen_t minlen, /* minimum length to allocate */
1201+
xfs_rtxlen_t maxlen, /* maximum length to allocate */
1202+
xfs_rtxlen_t *len, /* out: actual length allocated */
12031203
int wasdel, /* was a delayed allocation extent */
1204-
xfs_extlen_t prod, /* extent product factor */
1204+
xfs_rtxlen_t prod, /* extent product factor */
12051205
xfs_rtblock_t *rtblock) /* out: start block allocated */
12061206
{
12071207
xfs_mount_t *mp = tp->t_mountp;
@@ -1217,7 +1217,7 @@ xfs_rtallocate_extent(
12171217
* If prod is set then figure out what to do to minlen and maxlen.
12181218
*/
12191219
if (prod > 1) {
1220-
xfs_extlen_t i;
1220+
xfs_rtxlen_t i;
12211221

12221222
if ((i = maxlen % prod))
12231223
maxlen -= i;
@@ -1444,7 +1444,7 @@ int /* error */
14441444
xfs_rtpick_extent(
14451445
xfs_mount_t *mp, /* file system mount point */
14461446
xfs_trans_t *tp, /* transaction pointer */
1447-
xfs_extlen_t len, /* allocation length (rtextents) */
1447+
xfs_rtxlen_t len, /* allocation length (rtextents) */
14481448
xfs_rtblock_t *pick) /* result rt extent */
14491449
{
14501450
xfs_rtblock_t b; /* result block */

fs/xfs/xfs_rtalloc.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ int /* error */
2525
xfs_rtallocate_extent(
2626
struct xfs_trans *tp, /* transaction pointer */
2727
xfs_rtblock_t bno, /* starting block number to allocate */
28-
xfs_extlen_t minlen, /* minimum length to allocate */
29-
xfs_extlen_t maxlen, /* maximum length to allocate */
30-
xfs_extlen_t *len, /* out: actual length allocated */
28+
xfs_rtxlen_t minlen, /* minimum length to allocate */
29+
xfs_rtxlen_t maxlen, /* maximum length to allocate */
30+
xfs_rtxlen_t *len, /* out: actual length allocated */
3131
int wasdel, /* was a delayed allocation extent */
32-
xfs_extlen_t prod, /* extent product factor */
32+
xfs_rtxlen_t prod, /* extent product factor */
3333
xfs_rtblock_t *rtblock); /* out: start block allocated */
3434

3535

@@ -62,7 +62,7 @@ int /* error */
6262
xfs_rtpick_extent(
6363
struct xfs_mount *mp, /* file system mount point */
6464
struct xfs_trans *tp, /* transaction pointer */
65-
xfs_extlen_t len, /* allocation length (rtextents) */
65+
xfs_rtxlen_t len, /* allocation length (rtextents) */
6666
xfs_rtblock_t *pick); /* result rt extent */
6767

6868
/*

0 commit comments

Comments
 (0)