]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libfrog: introduce xfs_fd to wrap an fd to a file on an xfs filesystem
authorDarrick J. Wong <darrick.wong@oracle.com>
Mon, 9 Sep 2019 19:37:04 +0000 (15:37 -0400)
committerEric Sandeen <sandeen@redhat.com>
Mon, 9 Sep 2019 19:37:04 +0000 (15:37 -0400)
Introduce a new "xfs_fd" context structure where we can store a file
descriptor and all the runtime fs context (geometry, which ioctls work,
etc.) that goes with it.  We're going to create wrappers for the
bulkstat and inumbers ioctls in subsequent patches; and when we
introduce the v5 bulkstat/inumbers ioctls we'll need all that context to
downgrade gracefully on old kernels.  Start the transition by adopting
xfs_fd natively in scrub.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
16 files changed:
include/fsgeom.h
libfrog/fsgeom.c
scrub/fscounters.c
scrub/inodes.c
scrub/phase1.c
scrub/phase2.c
scrub/phase3.c
scrub/phase4.c
scrub/phase5.c
scrub/phase6.c
scrub/phase7.c
scrub/repair.c
scrub/scrub.c
scrub/spacemap.c
scrub/vfs.c
scrub/xfs_scrub.h

index 8ea16a35a97e933ab78cdf05d2adc7577c141c4c..26f93b3c841a2ac4e4d78fd8d0a453de1175c498 100644 (file)
@@ -9,4 +9,24 @@ void xfs_report_geom(struct xfs_fsop_geom *geo, const char *mntpoint,
                const char *logname, const char *rtname);
 int xfrog_geometry(int fd, struct xfs_fsop_geom *fsgeo);
 
+/*
+ * Structure for recording whatever observations we want about the level of
+ * xfs runtime support for this fd.  Right now we only store the fd and fs
+ * geometry.
+ */
+struct xfs_fd {
+       /* ioctl file descriptor */
+       int                     fd;
+
+       /* filesystem geometry */
+       struct xfs_fsop_geom    fsgeom;
+};
+
+/* Static initializers */
+#define XFS_FD_INIT(_fd)       { .fd = (_fd), }
+#define XFS_FD_INIT_EMPTY      XFS_FD_INIT(-1)
+
+int xfd_prepare_geometry(struct xfs_fd *xfd);
+int xfd_close(struct xfs_fd *xfd);
+
 #endif /* _LIBFROG_FSGEOM_H_ */
index 20a92ec1ad9a938f54cf8f7632c7b9610b8acf50..9513faf57e9f02ebdb371ed3e4b00c4b683161a7 100644 (file)
@@ -92,3 +92,35 @@ xfrog_geometry(
 
        return errno;
 }
+
+/*
+ * Prepare xfs_fd structure for future ioctl operations by computing the xfs
+ * geometry for @xfd->fd.  Returns zero or a positive error code.
+ */
+int
+xfd_prepare_geometry(
+       struct xfs_fd           *xfd)
+{
+       return xfrog_geometry(xfd->fd, &xfd->fsgeom);
+}
+
+/*
+ * Release any resources associated with this xfs_fd structure.  Returns zero
+ * or a positive error code.
+ */
+int
+xfd_close(
+       struct xfs_fd           *xfd)
+{
+       int                     ret = 0;
+
+       if (xfd->fd < 0)
+               return 0;
+
+       ret = close(xfd->fd);
+       xfd->fd = -1;
+       if (ret < 0)
+               return errno;
+
+       return 0;
+}
index 9e93e2a6feb318dec0de6b76ef0013da83843675..f18d0e1992eb9e86b0c09a76a222ae04084d3129 100644 (file)
@@ -57,10 +57,10 @@ xfs_count_inodes_range(
        igrpreq.ocount  = &igrplen;
 
        igrp_ino = first_ino;
-       error = ioctl(ctx->mnt_fd, XFS_IOC_FSINUMBERS, &igrpreq);
+       error = ioctl(ctx->mnt.fd, XFS_IOC_FSINUMBERS, &igrpreq);
        while (!error && igrplen && inogrp.xi_startino < last_ino) {
                nr += inogrp.xi_alloccount;
-               error = ioctl(ctx->mnt_fd, XFS_IOC_FSINUMBERS, &igrpreq);
+               error = ioctl(ctx->mnt.fd, XFS_IOC_FSINUMBERS, &igrpreq);
        }
 
        if (error) {
@@ -113,7 +113,7 @@ xfs_count_all_inodes(
        int                     ret;
 
        ci = calloc(1, sizeof(struct xfs_count_inodes) +
-                       (ctx->geo.agcount * sizeof(uint64_t)));
+                       (ctx->mnt.fsgeom.agcount * sizeof(uint64_t)));
        if (!ci)
                return false;
        ci->moveon = true;
@@ -125,7 +125,7 @@ xfs_count_all_inodes(
                str_info(ctx, ctx->mntpoint, _("Could not create workqueue."));
                goto out_free;
        }
-       for (agno = 0; agno < ctx->geo.agcount; agno++) {
+       for (agno = 0; agno < ctx->mnt.fsgeom.agcount; agno++) {
                ret = workqueue_add(&wq, xfs_count_ag_inodes, agno, ci);
                if (ret) {
                        moveon = false;
@@ -136,7 +136,7 @@ _("Could not queue AG %u icount work."), agno);
        }
        workqueue_destroy(&wq);
 
-       for (agno = 0; agno < ctx->geo.agcount; agno++)
+       for (agno = 0; agno < ctx->mnt.fsgeom.agcount; agno++)
                *count += ci->counters[agno];
        moveon = ci->moveon;
 
@@ -162,14 +162,14 @@ xfs_scan_estimate_blocks(
        int                             error;
 
        /* Grab the fstatvfs counters, since it has to report accurately. */
-       error = fstatvfs(ctx->mnt_fd, &sfs);
+       error = fstatvfs(ctx->mnt.fd, &sfs);
        if (error) {
                str_errno(ctx, ctx->mntpoint);
                return false;
        }
 
        /* Fetch the filesystem counters. */
-       error = ioctl(ctx->mnt_fd, XFS_IOC_FSCOUNTS, &fc);
+       error = ioctl(ctx->mnt.fd, XFS_IOC_FSCOUNTS, &fc);
        if (error) {
                str_errno(ctx, ctx->mntpoint);
                return false;
@@ -179,14 +179,16 @@ xfs_scan_estimate_blocks(
         * XFS reserves some blocks to prevent hard ENOSPC, so add those
         * blocks back to the free data counts.
         */
-       error = ioctl(ctx->mnt_fd, XFS_IOC_GET_RESBLKS, &rb);
+       error = ioctl(ctx->mnt.fd, XFS_IOC_GET_RESBLKS, &rb);
        if (error)
                str_errno(ctx, ctx->mntpoint);
        sfs.f_bfree += rb.resblks_avail;
 
-       *d_blocks = sfs.f_blocks + (ctx->geo.logstart ? ctx->geo.logblocks : 0);
+       *d_blocks = sfs.f_blocks;
+       if (ctx->mnt.fsgeom.logstart > 0)
+               *d_blocks += ctx->mnt.fsgeom.logblocks;
        *d_bfree = sfs.f_bfree;
-       *r_blocks = ctx->geo.rtblocks;
+       *r_blocks = ctx->mnt.fsgeom.rtblocks;
        *r_bfree = fc.freertx;
        *f_files = sfs.f_files;
        *f_free = sfs.f_ffree;
index 442a597878f5402ef415480948a9103962a979c7..08f3d847841df604fb7b4f686e20eebcfacba679 100644 (file)
@@ -72,7 +72,7 @@ xfs_iterate_inodes_range_check(
                /* Load the one inode. */
                oneino = inogrp->xi_startino + i;
                onereq.ubuffer = bs;
-               error = ioctl(ctx->mnt_fd, XFS_IOC_FSBULKSTAT_SINGLE,
+               error = ioctl(ctx->mnt.fd, XFS_IOC_FSBULKSTAT_SINGLE,
                                &onereq);
                if (error || bs->bs_ino != inogrp->xi_startino + i) {
                        memset(bs, 0, sizeof(struct xfs_bstat));
@@ -134,7 +134,7 @@ xfs_iterate_inodes_range(
 
        /* Find the inode chunk & alloc mask */
        igrp_ino = first_ino;
-       error = ioctl(ctx->mnt_fd, XFS_IOC_FSINUMBERS, &igrpreq);
+       error = ioctl(ctx->mnt.fd, XFS_IOC_FSINUMBERS, &igrpreq);
        while (!error && igrplen) {
                /* Load the inodes. */
                ino = inogrp.xi_startino - 1;
@@ -145,7 +145,7 @@ xfs_iterate_inodes_range(
                 */
                if (inogrp.xi_alloccount == 0)
                        goto igrp_retry;
-               error = ioctl(ctx->mnt_fd, XFS_IOC_FSBULKSTAT, &bulkreq);
+               error = ioctl(ctx->mnt.fd, XFS_IOC_FSBULKSTAT, &bulkreq);
                if (error)
                        str_info(ctx, descr, "%s", strerror_r(errno,
                                                buf, DESCR_BUFSZ));
@@ -190,7 +190,7 @@ _("Changed too many times during scan; giving up."));
 
                stale_count = 0;
 igrp_retry:
-               error = ioctl(ctx->mnt_fd, XFS_IOC_FSINUMBERS, &igrpreq);
+               error = ioctl(ctx->mnt.fd, XFS_IOC_FSINUMBERS, &igrpreq);
        }
 
 err:
@@ -260,7 +260,7 @@ xfs_scan_all_inodes(
                return false;
        }
 
-       for (agno = 0; agno < ctx->geo.agcount; agno++) {
+       for (agno = 0; agno < ctx->mnt.fsgeom.agcount; agno++) {
                ret = workqueue_add(&wq, xfs_scan_ag_inodes, agno, &si);
                if (ret) {
                        si.moveon = false;
index 9a2edf29a2b6606d41abc65348601d2e73aba56f..10dde8e80947054393553140c8832dc320e2993a 100644 (file)
@@ -39,7 +39,7 @@ xfs_shutdown_fs(
 
        flag = XFS_FSOP_GOING_FLAGS_LOGFLUSH;
        str_info(ctx, ctx->mntpoint, _("Shutting down filesystem!"));
-       if (ioctl(ctx->mnt_fd, XFS_IOC_GOINGDOWN, &flag))
+       if (ioctl(ctx->mnt.fd, XFS_IOC_GOINGDOWN, &flag))
                str_errno(ctx, ctx->mntpoint);
 }
 
@@ -60,11 +60,9 @@ xfs_cleanup_fs(
        if (ctx->datadev)
                disk_close(ctx->datadev);
        fshandle_destroy();
-       if (ctx->mnt_fd >= 0) {
-               error = close(ctx->mnt_fd);
-               if (error)
-                       str_errno(ctx, _("closing mountpoint fd"));
-       }
+       error = xfd_close(&ctx->mnt);
+       if (error)
+               str_liberror(ctx, error, _("closing mountpoint fd"));
        fs_table_destroy();
 
        return true;
@@ -86,8 +84,8 @@ xfs_setup_fs(
         * CAP_SYS_ADMIN, which we probably need to do anything fancy
         * with the (XFS driver) kernel.
         */
-       ctx->mnt_fd = open(ctx->mntpoint, O_RDONLY | O_NOATIME | O_DIRECTORY);
-       if (ctx->mnt_fd < 0) {
+       ctx->mnt.fd = open(ctx->mntpoint, O_RDONLY | O_NOATIME | O_DIRECTORY);
+       if (ctx->mnt.fd < 0) {
                if (errno == EPERM)
                        str_info(ctx, ctx->mntpoint,
 _("Must be root to run scrub."));
@@ -96,23 +94,23 @@ _("Must be root to run scrub."));
                return false;
        }
 
-       error = fstat(ctx->mnt_fd, &ctx->mnt_sb);
+       error = fstat(ctx->mnt.fd, &ctx->mnt_sb);
        if (error) {
                str_errno(ctx, ctx->mntpoint);
                return false;
        }
-       error = fstatvfs(ctx->mnt_fd, &ctx->mnt_sv);
+       error = fstatvfs(ctx->mnt.fd, &ctx->mnt_sv);
        if (error) {
                str_errno(ctx, ctx->mntpoint);
                return false;
        }
-       error = fstatfs(ctx->mnt_fd, &ctx->mnt_sf);
+       error = fstatfs(ctx->mnt.fd, &ctx->mnt_sf);
        if (error) {
                str_errno(ctx, ctx->mntpoint);
                return false;
        }
 
-       if (!platform_test_xfs_fd(ctx->mnt_fd)) {
+       if (!platform_test_xfs_fd(ctx->mnt.fd)) {
                str_info(ctx, ctx->mntpoint,
 _("Does not appear to be an XFS filesystem!"));
                return false;
@@ -123,27 +121,28 @@ _("Does not appear to be an XFS filesystem!"));
         * This seems to reduce the incidence of stale file handle
         * errors when we open things by handle.
         */
-       error = syncfs(ctx->mnt_fd);
+       error = syncfs(ctx->mnt.fd);
        if (error) {
                str_errno(ctx, ctx->mntpoint);
                return false;
        }
 
        /* Retrieve XFS geometry. */
-       error = xfrog_geometry(ctx->mnt_fd, &ctx->geo);
+       error = xfd_prepare_geometry(&ctx->mnt);
        if (error) {
                str_liberror(ctx, error, _("Retrieving XFS geometry"));
                return false;
        }
 
-       if (!xfs_action_lists_alloc(ctx->geo.agcount, &ctx->action_lists)) {
+       if (!xfs_action_lists_alloc(ctx->mnt.fsgeom.agcount,
+                               &ctx->action_lists)) {
                str_error(ctx, ctx->mntpoint, _("Not enough memory."));
                return false;
        }
 
-       ctx->agblklog = log2_roundup(ctx->geo.agblocks);
-       ctx->blocklog = highbit32(ctx->geo.blocksize);
-       ctx->inodelog = highbit32(ctx->geo.inodesize);
+       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,
@@ -171,12 +170,12 @@ _("Kernel metadata repair facility is not available.  Use -n to scrub."));
        }
 
        /* Did we find the log and rt devices, if they're present? */
-       if (ctx->geo.logstart == 0 && ctx->fsinfo.fs_log == NULL) {
+       if (ctx->mnt.fsgeom.logstart == 0 && ctx->fsinfo.fs_log == NULL) {
                str_info(ctx, ctx->mntpoint,
 _("Unable to find log device path."));
                return false;
        }
-       if (ctx->geo.rtblocks && ctx->fsinfo.fs_rt == NULL) {
+       if (ctx->mnt.fsgeom.rtblocks && ctx->fsinfo.fs_rt == NULL) {
                str_info(ctx, ctx->mntpoint,
 _("Unable to find realtime device path."));
                return false;
index 653f666c17bada987a9ca7fabe4b88a0042a3ced..a80da7fd7858f81bb605d45b4cccafa056d2f14e 100644 (file)
@@ -141,7 +141,7 @@ xfs_scan_metadata(
        if (!moveon)
                goto out;
 
-       for (agno = 0; moveon && agno < ctx->geo.agcount; agno++) {
+       for (agno = 0; moveon && agno < ctx->mnt.fsgeom.agcount; agno++) {
                ret = workqueue_add(&wq, xfs_scan_ag_metadata, agno, &moveon);
                if (ret) {
                        moveon = false;
index 4963d675db4742c05784172cbe3ba661407c892d..a42d82133f06277002c5e850a6d06850bab7f790 100644 (file)
@@ -33,7 +33,7 @@ xfs_scrub_fd(
        struct xfs_bstat        *bs,
        struct xfs_action_list  *alist)
 {
-       return fn(ctx, bs->bs_ino, bs->bs_gen, ctx->mnt_fd, alist);
+       return fn(ctx, bs->bs_ino, bs->bs_gen, ctx->mnt.fd, alist);
 }
 
 struct scrub_inode_ctx {
@@ -115,7 +115,7 @@ xfs_scrub_inode(
        if (S_ISLNK(bstat->bs_mode)) {
                /* Check symlink contents. */
                moveon = xfs_scrub_symlink(ctx, bstat->bs_ino,
-                               bstat->bs_gen, ctx->mnt_fd, &alist);
+                               bstat->bs_gen, ctx->mnt.fd, &alist);
        } else if (S_ISDIR(bstat->bs_mode)) {
                /* Check the directory entries. */
                moveon = xfs_scrub_fd(ctx, xfs_scrub_dir, bstat, &alist);
index 79248326f861fe3ac43685b1a4abb5b125ab7659..49f00723cb5ca5e21aaea45487a5489c4e9593f7 100644 (file)
@@ -40,7 +40,7 @@ xfs_repair_ag(
 
        /* Repair anything broken until we fail to make progress. */
        do {
-               moveon = xfs_action_list_process(ctx, ctx->mnt_fd, alist, flags);
+               moveon = xfs_action_list_process(ctx, ctx->mnt.fd, alist, flags);
                if (!moveon) {
                        *pmoveon = false;
                        return;
@@ -56,7 +56,7 @@ xfs_repair_ag(
 
        /* Try once more, but this time complain if we can't fix things. */
        flags |= ALP_COMPLAIN_IF_UNFIXED;
-       moveon = xfs_action_list_process(ctx, ctx->mnt_fd, alist, flags);
+       moveon = xfs_action_list_process(ctx, ctx->mnt.fd, alist, flags);
        if (!moveon)
                *pmoveon = false;
 }
@@ -77,7 +77,7 @@ xfs_process_action_items(
                str_error(ctx, ctx->mntpoint, _("Could not create workqueue."));
                return false;
        }
-       for (agno = 0; agno < ctx->geo.agcount; agno++) {
+       for (agno = 0; agno < ctx->mnt.fsgeom.agcount; agno++) {
                if (xfs_action_list_length(&ctx->action_lists[agno]) > 0) {
                        ret = workqueue_add(&wq, xfs_repair_ag, agno, &moveon);
                        if (ret) {
@@ -121,7 +121,7 @@ xfs_estimate_repair_work(
        xfs_agnumber_t          agno;
        size_t                  need_fixing = 0;
 
-       for (agno = 0; agno < ctx->geo.agcount; agno++)
+       for (agno = 0; agno < ctx->mnt.fsgeom.agcount; agno++)
                need_fixing += xfs_action_list_length(&ctx->action_lists[agno]);
        need_fixing++;
        *items = need_fixing;
index 1743119d4fcfd5da36522fa6ceb088f48106501e..748885d4891406bd4d1b1e71bc8293713b7ca203 100644 (file)
@@ -306,7 +306,7 @@ xfs_scrub_fs_label(
                return false;
 
        /* Retrieve label; quietly bail if we don't support that. */
-       error = ioctl(ctx->mnt_fd, FS_IOC_GETFSLABEL, &label);
+       error = ioctl(ctx->mnt.fd, FS_IOC_GETFSLABEL, &label);
        if (error) {
                if (errno != EOPNOTSUPP && errno != ENOTTY) {
                        moveon = false;
index 66e6451c6d7c9144802f882985e15e759294c8db..e5a0b3c1eb34e8aa2177b5f9f991d4e2d1e91455 100644 (file)
@@ -468,7 +468,7 @@ xfs_scan_blocks(
        }
 
        vs.rvp_data = read_verify_pool_init(ctx, ctx->datadev,
-                       ctx->geo.blocksize, xfs_check_rmap_ioerr,
+                       ctx->mnt.fsgeom.blocksize, xfs_check_rmap_ioerr,
                        scrub_nproc(ctx));
        if (!vs.rvp_data) {
                str_info(ctx, ctx->mntpoint,
@@ -477,7 +477,7 @@ _("Could not create data device media verifier."));
        }
        if (ctx->logdev) {
                vs.rvp_log = read_verify_pool_init(ctx, ctx->logdev,
-                               ctx->geo.blocksize, xfs_check_rmap_ioerr,
+                               ctx->mnt.fsgeom.blocksize, xfs_check_rmap_ioerr,
                                scrub_nproc(ctx));
                if (!vs.rvp_log) {
                        str_info(ctx, ctx->mntpoint,
@@ -487,7 +487,7 @@ _("Could not create data device media verifier."));
        }
        if (ctx->rtdev) {
                vs.rvp_realtime = read_verify_pool_init(ctx, ctx->rtdev,
-                               ctx->geo.blocksize, xfs_check_rmap_ioerr,
+                               ctx->mnt.fsgeom.blocksize, xfs_check_rmap_ioerr,
                                scrub_nproc(ctx));
                if (!vs.rvp_realtime) {
                        str_info(ctx, ctx->mntpoint,
index 0c3202e464ac492b9d804c4e241ecb8598e32e42..13959ca88d35c360d6c28762a7653f136d01d1ac 100644 (file)
@@ -111,7 +111,7 @@ xfs_scan_summary(
        int                     error;
 
        /* Flush everything out to disk before we start counting. */
-       error = syncfs(ctx->mnt_fd);
+       error = syncfs(ctx->mnt.fd);
        if (error) {
                str_errno(ctx, ctx->mntpoint);
                return false;
index 4ed3c09a5007f0830a650955d956762a4749acc4..45450d8cce6a32b74d2e1dc231e7ef02274d952f 100644 (file)
@@ -262,7 +262,7 @@ xfs_action_list_defer(
        xfs_agnumber_t                  agno,
        struct xfs_action_list          *alist)
 {
-       ASSERT(agno < ctx->geo.agcount);
+       ASSERT(agno < ctx->mnt.fsgeom.agcount);
 
        xfs_action_list_splice(&ctx->action_lists[agno], alist);
 }
@@ -276,7 +276,7 @@ xfs_action_list_process_or_defer(
 {
        bool                            moveon;
 
-       moveon = xfs_action_list_process(ctx, ctx->mnt_fd, alist,
+       moveon = xfs_action_list_process(ctx, ctx->mnt.fd, alist,
                        ALP_REPAIR_ONLY | ALP_NOPROGRESS);
        if (!moveon)
                return moveon;
index 0f0c9639b41d7cf352c14e9f4c9dc383610ca9b5..136ed5294252d9cdf16aef9259df4f69e22d6a76 100644 (file)
@@ -363,7 +363,7 @@ xfs_scrub_metadata(
                background_sleep();
 
                /* Check the item. */
-               fix = xfs_check_metadata(ctx, ctx->mnt_fd, &meta, false);
+               fix = xfs_check_metadata(ctx, ctx->mnt.fd, &meta, false);
                progress_add(1);
                switch (fix) {
                case CHECK_ABORT:
@@ -399,7 +399,7 @@ xfs_scrub_primary_super(
        enum check_outcome              fix;
 
        /* Check the item. */
-       fix = xfs_check_metadata(ctx, ctx->mnt_fd, &meta, false);
+       fix = xfs_check_metadata(ctx, ctx->mnt.fd, &meta, false);
        switch (fix) {
        case CHECK_ABORT:
                return false;
@@ -460,7 +460,7 @@ xfs_scrub_estimate_ag_work(
                switch (sc->type) {
                case ST_AGHEADER:
                case ST_PERAG:
-                       estimate += ctx->geo.agcount;
+                       estimate += ctx->mnt.fsgeom.agcount;
                        break;
                case ST_FS:
                        estimate++;
@@ -605,9 +605,9 @@ __xfs_scrub_test(
        if (debug_tweak_on("XFS_SCRUB_NO_KERNEL"))
                return false;
        if (debug_tweak_on("XFS_SCRUB_FORCE_REPAIR") && !injected) {
-               inject.fd = ctx->mnt_fd;
+               inject.fd = ctx->mnt.fd;
                inject.errtag = XFS_ERRTAG_FORCE_SCRUB_REPAIR;
-               error = ioctl(ctx->mnt_fd, XFS_IOC_ERROR_INJECTION, &inject);
+               error = ioctl(ctx->mnt.fd, XFS_IOC_ERROR_INJECTION, &inject);
                if (error == 0)
                        injected = true;
        }
@@ -615,7 +615,7 @@ __xfs_scrub_test(
        meta.sm_type = type;
        if (repair)
                meta.sm_flags |= XFS_SCRUB_IFLAG_REPAIR;
-       error = ioctl(ctx->mnt_fd, XFS_IOC_SCRUB_METADATA, &meta);
+       error = ioctl(ctx->mnt.fd, XFS_IOC_SCRUB_METADATA, &meta);
        if (!error)
                return true;
        switch (errno) {
index d547a041cefe9b8ae5e2133fbe021d701ea59ac1..c3621a3ab292263e6acfb29e3fba1e4f10055a0b 100644 (file)
@@ -56,7 +56,7 @@ xfs_iterate_fsmap(
        memcpy(head->fmh_keys, keys, sizeof(struct fsmap) * 2);
        head->fmh_count = FSMAP_NR;
 
-       while ((error = ioctl(ctx->mnt_fd, FS_IOC_GETFSMAP, head)) == 0) {
+       while ((error = ioctl(ctx->mnt.fd, FS_IOC_GETFSMAP, head)) == 0) {
                for (i = 0, p = head->fmh_recs;
                     i < head->fmh_entries;
                     i++, p++) {
@@ -107,8 +107,8 @@ xfs_scan_ag_blocks(
        off64_t                 bperag;
        bool                    moveon;
 
-       bperag = (off64_t)ctx->geo.agblocks *
-                (off64_t)ctx->geo.blocksize;
+       bperag = (off64_t)ctx->mnt.fsgeom.agblocks *
+                (off64_t)ctx->mnt.fsgeom.blocksize;
 
        snprintf(descr, DESCR_BUFSZ, _("dev %d:%d AG %u fsmap"),
                                major(ctx->fsinfo.fs_datadev),
@@ -205,7 +205,7 @@ xfs_scan_all_spacemaps(
        }
        if (ctx->fsinfo.fs_rt) {
                ret = workqueue_add(&wq, xfs_scan_rt_blocks,
-                               ctx->geo.agcount + 1, &sbx);
+                               ctx->mnt.fsgeom.agcount + 1, &sbx);
                if (ret) {
                        sbx.moveon = false;
                        str_info(ctx, ctx->mntpoint,
@@ -215,7 +215,7 @@ _("Could not queue rtdev fsmap work."));
        }
        if (ctx->fsinfo.fs_log) {
                ret = workqueue_add(&wq, xfs_scan_log_blocks,
-                               ctx->geo.agcount + 2, &sbx);
+                               ctx->mnt.fsgeom.agcount + 2, &sbx);
                if (ret) {
                        sbx.moveon = false;
                        str_info(ctx, ctx->mntpoint,
@@ -223,7 +223,7 @@ _("Could not queue logdev fsmap work."));
                        goto out;
                }
        }
-       for (agno = 0; agno < ctx->geo.agcount; agno++) {
+       for (agno = 0; agno < ctx->mnt.fsgeom.agcount; agno++) {
                ret = workqueue_add(&wq, xfs_scan_ag_blocks, agno, &sbx);
                if (ret) {
                        sbx.moveon = false;
index 8bcc4e79d36141741c5490527cb610a559082a4f..7b0b5bcd91605021581e115b9e3f2415f45634bf 100644 (file)
@@ -232,7 +232,7 @@ fstrim(
        int                     error;
 
        range.len = ULLONG_MAX;
-       error = ioctl(ctx->mnt_fd, FITRIM, &range);
+       error = ioctl(ctx->mnt.fd, FITRIM, &range);
        if (error && errno != EOPNOTSUPP && errno != ENOTTY)
                perror(_("fstrim"));
 }
index a459e4b5765574a5e681fef94b59e7cbc278a8bf..2af106eadd8d7f418bcb0ef7fb65627885d75a34 100644 (file)
@@ -6,6 +6,8 @@
 #ifndef XFS_SCRUB_XFS_SCRUB_H_
 #define XFS_SCRUB_XFS_SCRUB_H_
 
+#include "fsgeom.h"
+
 extern char *progname;
 
 #define _PATH_PROC_MOUNTS      "/proc/mounts"
@@ -53,14 +55,13 @@ struct scrub_ctx {
        /* How does the user want us to react to errors? */
        enum error_action       error_action;
 
-       /* fd to filesystem mount point */
-       int                     mnt_fd;
+       /* xfrog context for the mount point */
+       struct xfs_fd           mnt;
 
        /* Number of threads for metadata scrubbing */
        unsigned int            nr_io_threads;
 
        /* XFS specific geometry */
-       struct xfs_fsop_geom    geo;
        struct fs_path          fsinfo;
        unsigned int            agblklog;
        unsigned int            blocklog;