Commit fa5a3872 authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: create a helper to convert rtextents to rtblocks

Create a helper to convert a realtime extent to a realtime block.  Later
on we'll change the helper to use bit shifts when possible.
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 2d5f216b
...@@ -6,6 +6,22 @@ ...@@ -6,6 +6,22 @@
#ifndef __XFS_RTBITMAP_H__ #ifndef __XFS_RTBITMAP_H__
#define __XFS_RTBITMAP_H__ #define __XFS_RTBITMAP_H__
static inline xfs_rtblock_t
xfs_rtx_to_rtb(
struct xfs_mount *mp,
xfs_rtxnum_t rtx)
{
return rtx * mp->m_sb.sb_rextsize;
}
static inline xfs_extlen_t
xfs_rtxlen_to_extlen(
struct xfs_mount *mp,
xfs_rtxlen_t rtxlen)
{
return rtxlen * 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.
*/ */
......
...@@ -50,8 +50,8 @@ xchk_rtbitmap_rec( ...@@ -50,8 +50,8 @@ xchk_rtbitmap_rec(
xfs_rtblock_t startblock; xfs_rtblock_t startblock;
xfs_filblks_t blockcount; xfs_filblks_t blockcount;
startblock = rec->ar_startext * mp->m_sb.sb_rextsize; startblock = xfs_rtx_to_rtb(mp, rec->ar_startext);
blockcount = rec->ar_extcount * mp->m_sb.sb_rextsize; blockcount = xfs_rtx_to_rtb(mp, rec->ar_extcount);
if (!xfs_verify_rtbext(mp, startblock, blockcount)) if (!xfs_verify_rtbext(mp, startblock, blockcount))
xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, 0); xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, 0);
......
...@@ -134,8 +134,8 @@ xchk_rtsum_record_free( ...@@ -134,8 +134,8 @@ xchk_rtsum_record_free(
lenlog = XFS_RTBLOCKLOG(rec->ar_extcount); lenlog = XFS_RTBLOCKLOG(rec->ar_extcount);
offs = XFS_SUMOFFS(mp, lenlog, rbmoff); offs = XFS_SUMOFFS(mp, lenlog, rbmoff);
rtbno = rec->ar_startext * mp->m_sb.sb_rextsize; rtbno = xfs_rtx_to_rtb(mp, rec->ar_startext);
rtlen = rec->ar_extcount * mp->m_sb.sb_rextsize; rtlen = xfs_rtx_to_rtb(mp, rec->ar_extcount);
if (!xfs_verify_rtbext(mp, rtbno, rtlen)) { if (!xfs_verify_rtbext(mp, rtbno, rtlen)) {
xchk_ino_xref_set_corrupt(sc, mp->m_rbmip->i_ino); xchk_ino_xref_set_corrupt(sc, mp->m_rbmip->i_ino);
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "xfs_icache.h" #include "xfs_icache.h"
#include "xfs_iomap.h" #include "xfs_iomap.h"
#include "xfs_reflink.h" #include "xfs_reflink.h"
#include "xfs_rtbitmap.h"
/* Kernel only BMAP related definitions and functions */ /* Kernel only BMAP related definitions and functions */
...@@ -125,7 +126,7 @@ xfs_bmap_rtalloc( ...@@ -125,7 +126,7 @@ xfs_bmap_rtalloc(
* 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 (ralen * mp->m_sb.sb_rextsize >= XFS_MAX_BMBT_EXTLEN) if (xfs_rtxlen_to_extlen(mp, ralen) >= XFS_MAX_BMBT_EXTLEN)
ralen = XFS_MAX_BMBT_EXTLEN / mp->m_sb.sb_rextsize; ralen = XFS_MAX_BMBT_EXTLEN / mp->m_sb.sb_rextsize;
/* /*
...@@ -147,7 +148,7 @@ xfs_bmap_rtalloc( ...@@ -147,7 +148,7 @@ xfs_bmap_rtalloc(
error = xfs_rtpick_extent(mp, ap->tp, ralen, &rtx); error = xfs_rtpick_extent(mp, ap->tp, ralen, &rtx);
if (error) if (error)
return error; return error;
ap->blkno = rtx * mp->m_sb.sb_rextsize; ap->blkno = xfs_rtx_to_rtb(mp, rtx);
} else { } else {
ap->blkno = 0; ap->blkno = 0;
} }
...@@ -170,8 +171,8 @@ xfs_bmap_rtalloc( ...@@ -170,8 +171,8 @@ xfs_bmap_rtalloc(
return error; return error;
if (rtx != NULLRTEXTNO) { if (rtx != NULLRTEXTNO) {
ap->blkno = rtx * mp->m_sb.sb_rextsize; ap->blkno = xfs_rtx_to_rtb(mp, rtx);
ap->length = ralen * mp->m_sb.sb_rextsize; ap->length = xfs_rtxlen_to_extlen(mp, ralen);
ap->ip->i_nblocks += ap->length; ap->ip->i_nblocks += ap->length;
xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE); xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE);
if (ap->wasdel) if (ap->wasdel)
......
...@@ -483,11 +483,11 @@ xfs_getfsmap_rtdev_rtbitmap_helper( ...@@ -483,11 +483,11 @@ xfs_getfsmap_rtdev_rtbitmap_helper(
xfs_rtblock_t rtbno; xfs_rtblock_t rtbno;
xfs_daddr_t rec_daddr, len_daddr; xfs_daddr_t rec_daddr, len_daddr;
rtbno = rec->ar_startext * mp->m_sb.sb_rextsize; rtbno = xfs_rtx_to_rtb(mp, rec->ar_startext);
rec_daddr = XFS_FSB_TO_BB(mp, rtbno); rec_daddr = XFS_FSB_TO_BB(mp, rtbno);
irec.rm_startblock = rtbno; irec.rm_startblock = rtbno;
rtbno = rec->ar_extcount * mp->m_sb.sb_rextsize; rtbno = xfs_rtx_to_rtb(mp, rec->ar_extcount);
len_daddr = XFS_FSB_TO_BB(mp, rtbno); len_daddr = XFS_FSB_TO_BB(mp, rtbno);
irec.rm_blockcount = rtbno; irec.rm_blockcount = rtbno;
...@@ -514,7 +514,7 @@ xfs_getfsmap_rtdev_rtbitmap( ...@@ -514,7 +514,7 @@ xfs_getfsmap_rtdev_rtbitmap(
uint64_t eofs; uint64_t eofs;
int error; int error;
eofs = XFS_FSB_TO_BB(mp, mp->m_sb.sb_rextents * mp->m_sb.sb_rextsize); eofs = XFS_FSB_TO_BB(mp, xfs_rtx_to_rtb(mp, mp->m_sb.sb_rextents));
if (keys[0].fmr_physical >= eofs) if (keys[0].fmr_physical >= eofs)
return 0; return 0;
start_rtb = XFS_BB_TO_FSBT(mp, start_rtb = XFS_BB_TO_FSBT(mp,
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "xfs_xattr.h" #include "xfs_xattr.h"
#include "xfs_iunlink_item.h" #include "xfs_iunlink_item.h"
#include "xfs_dahash_test.h" #include "xfs_dahash_test.h"
#include "xfs_rtbitmap.h"
#include "scrub/stats.h" #include "scrub/stats.h"
#include <linux/magic.h> #include <linux/magic.h>
...@@ -890,7 +891,7 @@ xfs_fs_statfs( ...@@ -890,7 +891,7 @@ xfs_fs_statfs(
statp->f_blocks = sbp->sb_rblocks; statp->f_blocks = sbp->sb_rblocks;
freertx = percpu_counter_sum_positive(&mp->m_frextents); freertx = percpu_counter_sum_positive(&mp->m_frextents);
statp->f_bavail = statp->f_bfree = freertx * sbp->sb_rextsize; statp->f_bavail = statp->f_bfree = xfs_rtx_to_rtb(mp, freertx);
} }
return 0; return 0;
......
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