/* Bitmap of rt group inodes */
static struct bitmap *rtg_inodes[XFS_RTG_MAX];
-void
-rtinit(xfs_mount_t *mp)
-{
- unsigned long long wordcnt;
-
- if (mp->m_sb.sb_rblocks == 0)
- return;
-
- /*
- * Allocate buffers for formatting the collected rt free space
- * information. The rtbitmap buffer must be large enough to compare
- * against any unused bytes in the last block of the file.
- */
- wordcnt = libxfs_rtbitmap_wordcount(mp, mp->m_sb.sb_rextents);
- btmcompute = calloc(wordcnt, sizeof(union xfs_rtword_raw));
- if (!btmcompute)
- do_error(
- _("couldn't allocate memory for incore realtime bitmap.\n"));
-
- wordcnt = libxfs_rtsummary_wordcount(mp, mp->m_rsumlevels,
- mp->m_sb.sb_rbmblocks);
- sumcompute = calloc(wordcnt, sizeof(union xfs_suminfo_raw));
- if (!sumcompute)
- do_error(
- _("couldn't allocate memory for incore realtime summary info.\n"));
-}
+/* Computed rt bitmap/summary data */
+static union xfs_rtword_raw *btmcompute;
+static union xfs_suminfo_raw *sumcompute;
static inline void
set_rtword(
* generate the real-time bitmap and summary info based on the
* incore realtime extent map.
*/
-int
+void
generate_rtinfo(
- struct xfs_mount *mp,
- union xfs_rtword_raw *words,
- union xfs_suminfo_raw *sumcompute)
+ struct xfs_mount *mp)
{
- xfs_rtxnum_t extno;
- xfs_rtxnum_t start_ext;
- int bitsperblock;
- int bmbno;
- xfs_rtword_t freebit;
- xfs_rtword_t bits;
- int start_bmbno;
- int i;
- int offs;
- int log;
- int len;
- int in_extent;
+ unsigned int bitsperblock =
+ mp->m_blockwsize << XFS_NBWORDLOG;
+ xfs_rtxnum_t extno = 0;
+ xfs_rtxnum_t start_ext = 0;
+ int bmbno = 0;
+ int start_bmbno = 0;
+ bool in_extent = false;
+ union xfs_rtword_raw *words;
+
+ btmcompute = calloc(libxfs_rtbitmap_wordcount(mp, mp->m_sb.sb_rextents),
+ sizeof(union xfs_rtword_raw));
+ if (!btmcompute)
+ do_error(
+_("couldn't allocate memory for incore realtime bitmap.\n"));
+ words = btmcompute;
- ASSERT(mp->m_rbmip == NULL);
+ sumcompute = calloc(libxfs_rtsummary_wordcount(mp, mp->m_rsumlevels,
+ mp->m_sb.sb_rbmblocks), sizeof(union xfs_suminfo_raw));
+ if (!sumcompute)
+ do_error(
+_("couldn't allocate memory for incore realtime summary info.\n"));
- bitsperblock = mp->m_blockwsize << XFS_NBWORDLOG;
- extno = start_ext = 0;
- bmbno = in_extent = start_bmbno = 0;
+ ASSERT(mp->m_rbmip == NULL);
/*
- * slower but simple, don't play around with trying to set
- * things one word at a time, just set bit as required.
- * Have to * track start and end (size) of each range of
- * free extents to set the summary info properly.
+ * Slower but simple, don't play around with trying to set things one
+ * word at a time, just set bit as required. Have to track start and
+ * end (size) of each range of free extents to set the summary info
+ * properly.
*/
while (extno < mp->m_sb.sb_rextents) {
- freebit = 1;
+ xfs_rtword_t freebit = 1;
+ xfs_rtword_t bits = 0;
+ int i;
+
set_rtword(mp, words, 0);
- bits = 0;
for (i = 0; i < sizeof(xfs_rtword_t) * NBBY &&
extno < mp->m_sb.sb_rextents; i++, extno++) {
if (get_rtbmap(extno) == XR_E_FREE) {
sb_frextents++;
bits |= freebit;
- if (in_extent == 0) {
+ if (!in_extent) {
start_ext = extno;
start_bmbno = bmbno;
- in_extent = 1;
+ in_extent = true;
}
- } else if (in_extent == 1) {
- len = (int) (extno - start_ext);
- log = libxfs_highbit64(len);
- offs = xfs_rtsumoffs(mp, log, start_bmbno);
+ } else if (in_extent) {
+ uint64_t len = extno - start_ext;
+ xfs_rtsumoff_t offs;
+
+ offs = xfs_rtsumoffs(mp, libxfs_highbit64(len),
+ start_bmbno);
inc_sumcount(mp, sumcompute, offs);
- in_extent = 0;
+ in_extent = false;
}
freebit <<= 1;
if (extno % bitsperblock == 0)
bmbno++;
}
- if (in_extent == 1) {
- len = (int) (extno - start_ext);
- log = libxfs_highbit64(len);
- offs = xfs_rtsumoffs(mp, log, start_bmbno);
+
+ if (in_extent) {
+ uint64_t len = extno - start_ext;
+ xfs_rtsumoff_t offs;
+
+ offs = xfs_rtsumoffs(mp, libxfs_highbit64(len), start_bmbno);
inc_sumcount(mp, sumcompute, offs);
}
do_warn(_("sb_frextents %" PRIu64 ", counted %" PRIu64 "\n"),
mp->m_sb.sb_frextents, sb_frextents);
}
-
- return(0);
}
static void