Skip to content

Commit 2c2b981

Browse files
author
Darrick J. Wong
committed
xfs: create a helper to convert extlen to rtextlen
Create a helper to compute the realtime extent (xfs_rtxlen_t) from an extent length (xfs_extlen_t) value. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
1 parent 68db60b commit 2c2b981

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

fs/xfs/libxfs/xfs_rtbitmap.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ xfs_extlen_to_rtxmod(
3131
return len % mp->m_sb.sb_rextsize;
3232
}
3333

34+
static inline xfs_rtxlen_t
35+
xfs_extlen_to_rtxlen(
36+
struct xfs_mount *mp,
37+
xfs_extlen_t len)
38+
{
39+
return len / mp->m_sb.sb_rextsize;
40+
}
41+
3442
/*
3543
* Functions for walking free space rtextents in the realtime bitmap.
3644
*/

fs/xfs/libxfs/xfs_trans_resv.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "xfs_trans.h"
2020
#include "xfs_qm.h"
2121
#include "xfs_trans_space.h"
22+
#include "xfs_rtbitmap.h"
2223

2324
#define _ALLOC true
2425
#define _FREE false
@@ -220,7 +221,7 @@ xfs_rtalloc_block_count(
220221
unsigned int blksz = XFS_FSB_TO_B(mp, 1);
221222
unsigned int rtbmp_bytes;
222223

223-
rtbmp_bytes = (XFS_MAX_BMBT_EXTLEN / mp->m_sb.sb_rextsize) / NBBY;
224+
rtbmp_bytes = xfs_extlen_to_rtxlen(mp, XFS_MAX_BMBT_EXTLEN) / NBBY;
224225
return (howmany(rtbmp_bytes, blksz) + 1) * num_ops;
225226
}
226227

fs/xfs/xfs_bmap_util.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ xfs_bmap_rtalloc(
9090

9191
align = xfs_get_extsz_hint(ap->ip);
9292
retry:
93-
prod = align / mp->m_sb.sb_rextsize;
93+
prod = xfs_extlen_to_rtxlen(mp, align);
9494
error = xfs_bmap_extsize_align(mp, &ap->got, &ap->prev,
9595
align, 1, ap->eof, 0,
9696
ap->conv, &ap->offset, &ap->length);
@@ -117,17 +117,14 @@ xfs_bmap_rtalloc(
117117
prod = 1;
118118
/*
119119
* Set ralen to be the actual requested length in rtextents.
120-
*/
121-
ralen = ap->length / mp->m_sb.sb_rextsize;
122-
/*
120+
*
123121
* If the old value was close enough to XFS_BMBT_MAX_EXTLEN that
124122
* we rounded up to it, cut it back so it's valid again.
125123
* Note that if it's a really large request (bigger than
126124
* XFS_BMBT_MAX_EXTLEN), we don't hear about that number, and can't
127125
* adjust the starting point to match it.
128126
*/
129-
if (xfs_rtxlen_to_extlen(mp, ralen) >= XFS_MAX_BMBT_EXTLEN)
130-
ralen = XFS_MAX_BMBT_EXTLEN / mp->m_sb.sb_rextsize;
127+
ralen = xfs_extlen_to_rtxlen(mp, min(ap->length, XFS_MAX_BMBT_EXTLEN));
131128

132129
/*
133130
* Lock out modifications to both the RT bitmap and summary inodes
@@ -164,7 +161,7 @@ xfs_bmap_rtalloc(
164161
do_div(ap->blkno, mp->m_sb.sb_rextsize);
165162
rtx = ap->blkno;
166163
ap->length = ralen;
167-
raminlen = max_t(xfs_extlen_t, 1, minlen / mp->m_sb.sb_rextsize);
164+
raminlen = max_t(xfs_rtxlen_t, 1, xfs_extlen_to_rtxlen(mp, minlen));
168165
error = xfs_rtallocate_extent(ap->tp, ap->blkno, raminlen, ap->length,
169166
&ralen, ap->wasdel, prod, &rtx);
170167
if (error)

fs/xfs/xfs_trans.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "xfs_dquot_item.h"
2525
#include "xfs_dquot.h"
2626
#include "xfs_icache.h"
27+
#include "xfs_rtbitmap.h"
2728

2829
struct kmem_cache *xfs_trans_cache;
2930

@@ -1196,7 +1197,7 @@ xfs_trans_alloc_inode(
11961197

11971198
retry:
11981199
error = xfs_trans_alloc(mp, resv, dblocks,
1199-
rblocks / mp->m_sb.sb_rextsize,
1200+
xfs_extlen_to_rtxlen(mp, rblocks),
12001201
force ? XFS_TRANS_RESERVE : 0, &tp);
12011202
if (error)
12021203
return error;

0 commit comments

Comments
 (0)