@@ -30,6 +30,18 @@ struct xfs_fd {
/* filesystem geometry */
struct xfs_fsop_geom fsgeom;
+
+ /* log2 of sb_agblocks (rounded up) */
+ unsigned int agblklog;
+
+ /* log2 of sb_blocksize */
+ unsigned int blocklog;
+
+ /* log2 of sb_inodesize */
+ unsigned int inodelog;
+
+ /* log2 of sb_inopblock */
+ unsigned int inopblog;
};
/* Static initializers */
@@ -5,6 +5,7 @@
#include "libxfs.h"
#include "fsgeom.h"
#include "xfrog.h"
+#include "libfrog.h"
void
xfs_report_geom(
@@ -94,7 +95,17 @@ int
xfrog_prepare_geometry(
struct xfs_fd *xfd)
{
- return xfrog_geometry(xfd->fd, &xfd->fsgeom);
+ int ret;
+
+ ret = xfrog_geometry(xfd->fd, &xfd->fsgeom);
+ if (ret)
+ return ret;
+
+ xfd->agblklog = log2_roundup(xfd->fsgeom.agblocks);
+ xfd->blocklog = highbit32(xfd->fsgeom.blocksize);
+ xfd->inodelog = highbit32(xfd->fsgeom.inodesize);
+ xfd->inopblog = xfd->blocklog - xfd->inodelog;
+ return 0;
}
/* Release any resources associated with this xfrog structure. */
@@ -91,8 +91,8 @@ xfs_count_ag_inodes(
minor(ctx->fsinfo.fs_datadev),
agno);
- ag_ino = (__u64)agno << (ctx->inopblog + ctx->agblklog);
- next_ag_ino = (__u64)(agno + 1) << (ctx->inopblog + ctx->agblklog);
+ ag_ino = (__u64)agno << (ctx->mnt.inopblog + ctx->mnt.agblklog);
+ next_ag_ino = (__u64)(agno + 1) << (ctx->mnt.inopblog + ctx->mnt.agblklog);
moveon = xfs_count_inodes_range(ctx, descr, ag_ino, next_ag_ino - 1,
&ci->counters[agno]);
@@ -228,8 +228,8 @@ xfs_scan_ag_inodes(
minor(ctx->fsinfo.fs_datadev),
agno);
- ag_ino = (__u64)agno << (ctx->inopblog + ctx->agblklog);
- next_ag_ino = (__u64)(agno + 1) << (ctx->inopblog + ctx->agblklog);
+ ag_ino = (__u64)agno << (ctx->mnt.inopblog + ctx->mnt.agblklog);
+ next_ag_ino = (__u64)(agno + 1) << (ctx->mnt.inopblog + ctx->mnt.agblklog);
moveon = xfs_iterate_inodes_range(ctx, descr, ctx->fshandle, ag_ino,
next_ag_ino - 1, si->fn, si->arg);
@@ -140,11 +140,6 @@ _("Does not appear to be an XFS filesystem!"));
return false;
}
- ctx->agblklog = log2_roundup(ctx->mnt.fsgeom.agblocks);
- ctx->blocklog = highbit32(ctx->mnt.fsgeom.blocksize);
- ctx->inodelog = highbit32(ctx->mnt.fsgeom.inodesize);
- ctx->inopblog = ctx->blocklog - ctx->inodelog;
-
error = path_to_fshandle(ctx->mntpoint, &ctx->fshandle,
&ctx->fshandle_len);
if (error) {
@@ -52,8 +52,8 @@ xfs_scrub_inode_vfs_error(
xfs_agino_t agino;
int old_errno = errno;
- agno = bstat->bs_ino / (1ULL << (ctx->inopblog + ctx->agblklog));
- agino = bstat->bs_ino % (1ULL << (ctx->inopblog + ctx->agblklog));
+ agno = bstat->bs_ino / (1ULL << (ctx->mnt.inopblog + ctx->mnt.agblklog));
+ agino = bstat->bs_ino % (1ULL << (ctx->mnt.inopblog + ctx->mnt.agblklog));
snprintf(descr, DESCR_BUFSZ, _("inode %"PRIu64" (%u/%u)"),
(uint64_t)bstat->bs_ino, agno, agino);
errno = old_errno;
@@ -77,7 +77,7 @@ xfs_scrub_inode(
int error;
xfs_action_list_init(&alist);
- agno = bstat->bs_ino / (1ULL << (ctx->inopblog + ctx->agblklog));
+ agno = bstat->bs_ino / (1ULL << (ctx->mnt.inopblog + ctx->mnt.agblklog));
background_sleep();
/* Try to open the inode to pin it. */
@@ -239,8 +239,8 @@ xfs_scrub_connections(
int fd = -1;
int error;
- agno = bstat->bs_ino / (1ULL << (ctx->inopblog + ctx->agblklog));
- agino = bstat->bs_ino % (1ULL << (ctx->inopblog + ctx->agblklog));
+ agno = bstat->bs_ino / (1ULL << (ctx->mnt.inopblog + ctx->mnt.agblklog));
+ agino = bstat->bs_ino % (1ULL << (ctx->mnt.inopblog + ctx->mnt.agblklog));
snprintf(descr, DESCR_BUFSZ, _("inode %"PRIu64" (%u/%u)"),
(uint64_t)bstat->bs_ino, agno, agino);
background_sleep();
@@ -547,7 +547,7 @@ xfs_estimate_verify_work(
if (!moveon)
return moveon;
- *items = ((d_blocks - d_bfree) + (r_blocks - r_bfree)) << ctx->blocklog;
+ *items = ((d_blocks - d_bfree) + (r_blocks - r_bfree)) << ctx->mnt.blocklog;
*nr_threads = disk_heads(ctx->datadev);
*rshift = 20;
return moveon;
@@ -148,11 +148,11 @@ xfs_scan_summary(
* filesystem treats them as "free", but since we scanned
* them, we'll consider them used.
*/
- d_bfree -= totalcount.agbytes >> ctx->blocklog;
+ d_bfree -= totalcount.agbytes >> ctx->mnt.blocklog;
/* Report on what we found. */
- used_data = (d_blocks - d_bfree) << ctx->blocklog;
- used_rt = (r_blocks - r_bfree) << ctx->blocklog;
+ used_data = (d_blocks - d_bfree) << ctx->mnt.blocklog;
+ used_rt = (r_blocks - r_bfree) << ctx->mnt.blocklog;
used_files = f_files - f_free;
stat_data = totalcount.dbytes;
stat_rt = totalcount.rbytes;
@@ -63,10 +63,6 @@ struct scrub_ctx {
/* XFS specific geometry */
struct fs_path fsinfo;
- unsigned int agblklog;
- unsigned int blocklog;
- unsigned int inodelog;
- unsigned int inopblog;
void *fshandle;
size_t fshandle_len;