/* Compute the misalignment between an extent length and a realtime extent .*/ staticinlineunsignedint
xfs_extlen_to_rtxmod( struct xfs_mount *mp,
xfs_extlen_t len)
{ if (mp->m_rtxblklog >= 0) return len & mp->m_rtxblkmask;
return len % mp->m_sb.sb_rextsize;
}
staticinline xfs_rtxlen_t
xfs_extlen_to_rtxlen( struct xfs_mount *mp,
xfs_extlen_t len)
{ if (mp->m_rtxblklog >= 0) return len >> mp->m_rtxblklog;
return len / mp->m_sb.sb_rextsize;
}
/* Convert an rt block count into an rt extent count. */ staticinline xfs_rtbxlen_t
xfs_blen_to_rtbxlen( struct xfs_mount *mp,
uint64_t blen)
{ if (likely(mp->m_rtxblklog >= 0)) return blen >> mp->m_rtxblklog;
return div_u64(blen, mp->m_sb.sb_rextsize);
}
/* Return the offset of a file block length within an rt extent. */ staticinline xfs_extlen_t
xfs_blen_to_rtxoff( struct xfs_mount *mp,
xfs_filblks_t blen)
{ if (likely(mp->m_rtxblklog >= 0)) return blen & mp->m_rtxblkmask;
return do_div(blen, mp->m_sb.sb_rextsize);
}
/* Round this block count up to the nearest rt extent size. */ staticinline xfs_filblks_t
xfs_blen_roundup_rtx( struct xfs_mount *mp,
xfs_filblks_t blen)
{ return roundup_64(blen, mp->m_sb.sb_rextsize);
}
/* Convert an rt block number into an rt extent number. */ staticinline xfs_rtxnum_t
xfs_rtb_to_rtx( struct xfs_mount *mp,
xfs_rtblock_t rtbno)
{ /* open-coded 64-bit masking operation */
rtbno &= mp->m_groups[XG_TYPE_RTG].blkmask; if (likely(mp->m_rtxblklog >= 0)) return rtbno >> mp->m_rtxblklog; return div_u64(rtbno, mp->m_sb.sb_rextsize);
}
/* Return the offset of a rtgroup block number within an rt extent. */ staticinline xfs_extlen_t
xfs_rgbno_to_rtxoff( struct xfs_mount *mp,
xfs_rgblock_t rgbno)
{ return rgbno % mp->m_sb.sb_rextsize;
}
/* Return the offset of an rt block number within an rt extent. */ staticinline xfs_extlen_t
xfs_rtb_to_rtxoff( struct xfs_mount *mp,
xfs_rtblock_t rtbno)
{ /* open-coded 64-bit masking operation */
rtbno &= mp->m_groups[XG_TYPE_RTG].blkmask; if (likely(mp->m_rtxblklog >= 0)) return rtbno & mp->m_rtxblkmask; return do_div(rtbno, mp->m_sb.sb_rextsize);
}
/* Round this file block offset up to the nearest rt extent size. */ staticinline xfs_rtblock_t
xfs_fileoff_roundup_rtx( struct xfs_mount *mp,
xfs_fileoff_t off)
{ return roundup_64(off, mp->m_sb.sb_rextsize);
}
/* Round this file block offset down to the nearest rt extent size. */ staticinline xfs_rtblock_t
xfs_fileoff_rounddown_rtx( struct xfs_mount *mp,
xfs_fileoff_t off)
{ return rounddown_64(off, mp->m_sb.sb_rextsize);
}
/* Convert an rt extent number to a file block offset in the rt bitmap file. */ staticinline xfs_fileoff_t
xfs_rtx_to_rbmblock( struct xfs_mount *mp,
xfs_rtxnum_t rtx)
{ if (xfs_has_rtgroups(mp)) return div_u64(rtx, mp->m_rtx_per_rbmblock);
return rtx >> mp->m_blkbit_log;
}
/* Convert an rt extent number to a word offset within an rt bitmap block. */ staticinlineunsignedint
xfs_rtx_to_rbmword( struct xfs_mount *mp,
xfs_rtxnum_t rtx)
{ if (xfs_has_rtgroups(mp)) { unsignedint mod;
/* Convert a file block offset in the rt bitmap file to an rt extent number. */ staticinline xfs_rtxnum_t
xfs_rbmblock_to_rtx( struct xfs_mount *mp,
xfs_fileoff_t rbmoff)
{ if (xfs_has_rtgroups(mp)) return rbmoff * mp->m_rtx_per_rbmblock;
return rbmoff << mp->m_blkbit_log;
}
/* Return a pointer to a bitmap word within a rt bitmap block. */ staticinlineunion xfs_rtword_raw *
xfs_rbmblock_wordptr( struct xfs_rtalloc_args *args, unsignedint index)
{ struct xfs_mount *mp = args->mp; union xfs_rtword_raw *words; struct xfs_rtbuf_blkinfo *hdr = args->rbmbp->b_addr;
if (xfs_has_rtgroups(mp))
words = (union xfs_rtword_raw *)(hdr + 1); else
words = args->rbmbp->b_addr;
return words + index;
}
/* Convert an ondisk bitmap word to its incore representation. */ staticinline xfs_rtword_t
xfs_rtbitmap_getword( struct xfs_rtalloc_args *args, unsignedint index)
{ union xfs_rtword_raw *word = xfs_rbmblock_wordptr(args, index);
if (xfs_has_rtgroups(args->mp)) return be32_to_cpu(word->rtg); return word->old;
}
/* Set an ondisk bitmap word from an incore representation. */ staticinlinevoid
xfs_rtbitmap_setword( struct xfs_rtalloc_args *args, unsignedint index,
xfs_rtword_t value)
{ union xfs_rtword_raw *word = xfs_rbmblock_wordptr(args, index);
if (xfs_has_rtgroups(args->mp))
word->rtg = cpu_to_be32(value); else
word->old = value;
}
/* * Convert a rt extent length and rt bitmap block number to a xfs_suminfo_t * offset within the rt summary file.
*/ staticinline xfs_rtsumoff_t
xfs_rtsumoffs( struct xfs_mount *mp, int log2_len,
xfs_fileoff_t rbmoff)
{ return log2_len * mp->m_sb.sb_rbmblocks + rbmoff;
}
/* * Convert an xfs_suminfo_t offset to a file block offset within the rt summary * file.
*/ staticinline xfs_fileoff_t
xfs_rtsumoffs_to_block( struct xfs_mount *mp,
xfs_rtsumoff_t rsumoff)
{ if (xfs_has_rtgroups(mp)) return rsumoff / mp->m_blockwsize;
/* * Convert an xfs_suminfo_t offset to an info word offset within an rt summary * block.
*/ staticinlineunsignedint
xfs_rtsumoffs_to_infoword( struct xfs_mount *mp,
xfs_rtsumoff_t rsumoff)
{ unsignedint mask = mp->m_blockmask >> XFS_SUMINFOLOG;
if (xfs_has_rtgroups(mp)) return rsumoff % mp->m_blockwsize;
return rsumoff & mask;
}
/* Return a pointer to a summary info word within a rt summary block. */ staticinlineunion xfs_suminfo_raw *
xfs_rsumblock_infoptr( struct xfs_rtalloc_args *args, unsignedint index)
{ union xfs_suminfo_raw *info; struct xfs_rtbuf_blkinfo *hdr = args->sumbp->b_addr;
if (xfs_has_rtgroups(args->mp))
info = (union xfs_suminfo_raw *)(hdr + 1); else
info = args->sumbp->b_addr;
return info + index;
}
/* Get the current value of a summary counter. */ staticinline xfs_suminfo_t
xfs_suminfo_get( struct xfs_rtalloc_args *args, unsignedint index)
{ union xfs_suminfo_raw *info = xfs_rsumblock_infoptr(args, index);
if (xfs_has_rtgroups(args->mp)) return be32_to_cpu(info->rtg); return info->old;
}
/* Add to the current value of a summary counter and return the new value. */ staticinline xfs_suminfo_t
xfs_suminfo_add( struct xfs_rtalloc_args *args, unsignedint index, int delta)
{ union xfs_suminfo_raw *info = xfs_rsumblock_infoptr(args, index);
if (xfs_has_rtgroups(args->mp)) {
be32_add_cpu(&info->rtg, delta); return be32_to_cpu(info->rtg);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.