Commit 2c2b981b authored by Darrick J. Wong's avatar Darrick J. Wong

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: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 68db60bf
...@@ -31,6 +31,14 @@ xfs_extlen_to_rtxmod( ...@@ -31,6 +31,14 @@ xfs_extlen_to_rtxmod(
return len % mp->m_sb.sb_rextsize; return len % mp->m_sb.sb_rextsize;
} }
static inline xfs_rtxlen_t
xfs_extlen_to_rtxlen(
struct xfs_mount *mp,
xfs_extlen_t len)
{
return len / mp->m_sb.sb_rextsize;
}
/* /*
* Functions for walking free space rtextents in the realtime bitmap. * Functions for walking free space rtextents in the realtime bitmap.
*/ */
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_qm.h" #include "xfs_qm.h"
#include "xfs_trans_space.h" #include "xfs_trans_space.h"
#include "xfs_rtbitmap.h"
#define _ALLOC true #define _ALLOC true
#define _FREE false #define _FREE false
...@@ -220,7 +221,7 @@ xfs_rtalloc_block_count( ...@@ -220,7 +221,7 @@ xfs_rtalloc_block_count(
unsigned int blksz = XFS_FSB_TO_B(mp, 1); unsigned int blksz = XFS_FSB_TO_B(mp, 1);
unsigned int rtbmp_bytes; unsigned int rtbmp_bytes;
rtbmp_bytes = (XFS_MAX_BMBT_EXTLEN / mp->m_sb.sb_rextsize) / NBBY; rtbmp_bytes = xfs_extlen_to_rtxlen(mp, XFS_MAX_BMBT_EXTLEN) / NBBY;
return (howmany(rtbmp_bytes, blksz) + 1) * num_ops; return (howmany(rtbmp_bytes, blksz) + 1) * num_ops;
} }
......
...@@ -90,7 +90,7 @@ xfs_bmap_rtalloc( ...@@ -90,7 +90,7 @@ xfs_bmap_rtalloc(
align = xfs_get_extsz_hint(ap->ip); align = xfs_get_extsz_hint(ap->ip);
retry: retry:
prod = align / mp->m_sb.sb_rextsize; prod = xfs_extlen_to_rtxlen(mp, align);
error = xfs_bmap_extsize_align(mp, &ap->got, &ap->prev, error = xfs_bmap_extsize_align(mp, &ap->got, &ap->prev,
align, 1, ap->eof, 0, align, 1, ap->eof, 0,
ap->conv, &ap->offset, &ap->length); ap->conv, &ap->offset, &ap->length);
...@@ -117,17 +117,14 @@ xfs_bmap_rtalloc( ...@@ -117,17 +117,14 @@ xfs_bmap_rtalloc(
prod = 1; prod = 1;
/* /*
* Set ralen to be the actual requested length in rtextents. * Set ralen to be the actual requested length in rtextents.
*/ *
ralen = ap->length / mp->m_sb.sb_rextsize;
/*
* If the old value was close enough to XFS_BMBT_MAX_EXTLEN that * If the old value was close enough to XFS_BMBT_MAX_EXTLEN that
* we rounded up to it, cut it back so it's valid again. * we rounded up to it, cut it back so it's valid again.
* Note that if it's a really large request (bigger than * Note that if it's a really large request (bigger than
* XFS_BMBT_MAX_EXTLEN), we don't hear about that number, and can't * XFS_BMBT_MAX_EXTLEN), we don't hear about that number, and can't
* adjust the starting point to match it. * adjust the starting point to match it.
*/ */
if (xfs_rtxlen_to_extlen(mp, ralen) >= XFS_MAX_BMBT_EXTLEN) ralen = xfs_extlen_to_rtxlen(mp, min(ap->length, XFS_MAX_BMBT_EXTLEN));
ralen = XFS_MAX_BMBT_EXTLEN / mp->m_sb.sb_rextsize;
/* /*
* Lock out modifications to both the RT bitmap and summary inodes * Lock out modifications to both the RT bitmap and summary inodes
...@@ -164,7 +161,7 @@ xfs_bmap_rtalloc( ...@@ -164,7 +161,7 @@ xfs_bmap_rtalloc(
do_div(ap->blkno, mp->m_sb.sb_rextsize); do_div(ap->blkno, mp->m_sb.sb_rextsize);
rtx = ap->blkno; rtx = ap->blkno;
ap->length = ralen; ap->length = ralen;
raminlen = max_t(xfs_extlen_t, 1, minlen / mp->m_sb.sb_rextsize); raminlen = max_t(xfs_rtxlen_t, 1, xfs_extlen_to_rtxlen(mp, minlen));
error = xfs_rtallocate_extent(ap->tp, ap->blkno, raminlen, ap->length, error = xfs_rtallocate_extent(ap->tp, ap->blkno, raminlen, ap->length,
&ralen, ap->wasdel, prod, &rtx); &ralen, ap->wasdel, prod, &rtx);
if (error) if (error)
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "xfs_dquot_item.h" #include "xfs_dquot_item.h"
#include "xfs_dquot.h" #include "xfs_dquot.h"
#include "xfs_icache.h" #include "xfs_icache.h"
#include "xfs_rtbitmap.h"
struct kmem_cache *xfs_trans_cache; struct kmem_cache *xfs_trans_cache;
...@@ -1196,7 +1197,7 @@ xfs_trans_alloc_inode( ...@@ -1196,7 +1197,7 @@ xfs_trans_alloc_inode(
retry: retry:
error = xfs_trans_alloc(mp, resv, dblocks, error = xfs_trans_alloc(mp, resv, dblocks,
rblocks / mp->m_sb.sb_rextsize, xfs_extlen_to_rtxlen(mp, rblocks),
force ? XFS_TRANS_RESERVE : 0, &tp); force ? XFS_TRANS_RESERVE : 0, &tp);
if (error) if (error)
return error; return error;
......
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