]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs_scrub: don't pass the io_end_arg around everywhere
authorDarrick J. Wong <djwong@kernel.org>
Mon, 16 Mar 2026 21:41:06 +0000 (14:41 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 9 Apr 2026 22:30:19 +0000 (15:30 -0700)
The value is the same across all callers and read-verify pools, so let's
just pass it into read_verify_pool_alloc instead of making temporary
aliases everywhere and increasing memory usage.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
scrub/phase6.c
scrub/read_verify.c
scrub/read_verify.h

index 82dadab5737919c1f48f00fdf73bac6cc6cb07ab..1bfc10f9f662ae3b671902415d209136a832bc6a 100644 (file)
@@ -645,7 +645,7 @@ check_rmap(
 
        /* Schedule the read verify command for (eventual) running. */
        scheduled = try_read_verify_schedule_io(rs, rvp, map->fmr_physical,
-                       map->fmr_length, vs);
+                       map->fmr_length);
        if (scheduled)
                return 0;
 
@@ -656,7 +656,7 @@ check_rmap(
        }
 
        scheduled = try_read_verify_schedule_io(rs, rvp, map->fmr_physical,
-                       map->fmr_length, vs);
+                       map->fmr_length);
        assert(scheduled);
        return 0;
 }
@@ -761,7 +761,7 @@ phase6_func(
                goto out_dbad;
        }
 
-       ret = read_verify_pool_alloc(ctx, ctx->datadev, remember_ioerr,
+       ret = read_verify_pool_alloc(ctx, ctx->datadev, remember_ioerr, &vs,
                        &vs.rvp_data);
        if (ret) {
                str_liberror(ctx, ret, _("creating datadev media verifier"));
@@ -769,7 +769,7 @@ phase6_func(
        }
        if (ctx->logdev) {
                ret = read_verify_pool_alloc(ctx, ctx->logdev, remember_ioerr,
-                               &vs.rvp_log);
+                               &vs, &vs.rvp_log);
                if (ret) {
                        str_liberror(ctx, ret,
                                        _("creating logdev media verifier"));
@@ -778,7 +778,7 @@ phase6_func(
        }
        if (ctx->rtdev) {
                ret = read_verify_pool_alloc(ctx, ctx->rtdev, remember_ioerr,
-                               &vs.rvp_realtime);
+                               &vs, &vs.rvp_realtime);
                if (ret) {
                        str_liberror(ctx, ret,
                                        _("creating rtdev media verifier"));
index 128df2be86898b9948e6ef369b85460749aa4288..bcd923e5f3cbc38b8270b31ac68e2bd6f1ab6705 100644 (file)
@@ -49,7 +49,6 @@ rvp_io_max_size(void)
 #define RVP_IO_BATCH_LOCALITY  (65536)
 
 struct read_verify {
-       void                    *io_end_arg;
        uint64_t                io_start;       /* bytes */
        uint64_t                io_length;      /* bytes */
 };
@@ -60,6 +59,7 @@ struct read_verify_pool {
        void                    *readbuf;       /* read buffer */
        struct ptcounter        *verified_bytes;
        struct disk             *disk;          /* which disk? */
+       void                    *ioerr_arg;
        read_verify_ioerr_fn_t  ioerr_fn;       /* io error callback */
        size_t                  miniosz;        /* minimum io size, bytes */
 
@@ -81,6 +81,7 @@ read_verify_pool_alloc(
        struct scrub_ctx                *ctx,
        struct disk                     *disk,
        read_verify_ioerr_fn_t          ioerr_fn,
+       void                            *ioerr_arg,
        struct read_verify_pool         **prvp)
 {
        struct read_verify_pool         *rvp;
@@ -105,6 +106,7 @@ read_verify_pool_alloc(
        rvp->ctx = ctx;
        rvp->disk = disk;
        rvp->ioerr_fn = ioerr_fn;
+       rvp->ioerr_arg = ioerr_arg;
        ret = -workqueue_create(&rvp->wq, (struct xfs_mount *)rvp,
                        verifier_threads == 1 ? 0 : verifier_threads);
        if (ret)
@@ -223,14 +225,14 @@ read_verify(
                                        rvp->disk->d_fd, rv->io_start, sz,
                                        read_error);
                        rvp->ioerr_fn(rvp->ctx, rvp->disk, rv->io_start, sz,
-                                       read_error, rv->io_end_arg);
+                                       read_error, rvp->ioerr_arg);
                } else if (sz == 0) {
                        /* No bytes at all?  Did we hit the end of the disk? */
                        dbg_printf("EOF %d @ %"PRIu64" %zu err %d\n",
                                        rvp->disk->d_fd, rv->io_start, sz,
                                        read_error);
                        rvp->ioerr_fn(rvp->ctx, rvp->disk, rv->io_start, sz,
-                                       read_error, rv->io_end_arg);
+                                       read_error, rvp->ioerr_arg);
                        break;
                } else if (sz < len) {
                        /*
@@ -291,7 +293,6 @@ read_verify_schedule_now(
                return errno;
        }
 
-       tmp->io_end_arg = rs->io_end_arg;
        tmp->io_start = rs->io_start;
        tmp->io_length = rs->io_length;
 
@@ -318,8 +319,7 @@ try_read_verify_schedule_io(
        struct read_verify_schedule     *rs,
        struct read_verify_pool         *rvp,
        uint64_t                        start,
-       uint64_t                        length,
-       void                            *end_arg)
+       uint64_t                        length)
 {
        uint64_t                        req_end;
        uint64_t                        rv_end;
@@ -338,7 +338,6 @@ try_read_verify_schedule_io(
                rs->rvp = rvp;
                rs->io_start = start;
                rs->io_length = length;
-               rs->io_end_arg = end_arg;
 
                return true;
        }
@@ -348,7 +347,7 @@ try_read_verify_schedule_io(
         * reporting is the same, and the two extents are close,
         * we can combine them.
         */
-       if (rs->rvp == rvp && rs->io_length > 0 && end_arg == rs->io_end_arg &&
+       if (rs->rvp == rvp && rs->io_length > 0 &&
            ((start >= rs->io_start && start <= rv_end + RVP_IO_BATCH_LOCALITY) ||
             (rs->io_start >= start &&
              rs->io_start <= req_end + RVP_IO_BATCH_LOCALITY))) {
index a46244334268defb13a713c8319c66815ebdbf35..165ad8f7af7b6cc9adfe84a247e37d7d222a55f1 100644 (file)
@@ -12,7 +12,6 @@ struct disk;
 
 struct read_verify_schedule {
        struct read_verify_pool *rvp;
-       void                    *io_end_arg;
        uint64_t                io_start;       /* bytes */
        uint64_t                io_length;      /* bytes */
 };
@@ -23,7 +22,7 @@ typedef void (*read_verify_ioerr_fn_t)(struct scrub_ctx *ctx,
                int error, void *arg);
 
 int read_verify_pool_alloc(struct scrub_ctx *ctx, struct disk *disk,
-               read_verify_ioerr_fn_t ioerr_fn,
+               read_verify_ioerr_fn_t ioerr_fn, void *ioerr_arg,
                struct read_verify_pool **prvp);
 void read_verify_pool_abort(struct read_verify_pool *rvp);
 int read_verify_pool_flush(struct read_verify_pool *rvp);
@@ -31,8 +30,7 @@ void read_verify_pool_destroy(struct read_verify_pool *rvp);
 
 int read_verify_schedule_now(struct read_verify_schedule *rs);
 bool try_read_verify_schedule_io(struct read_verify_schedule *rs,
-               struct read_verify_pool *rvp, uint64_t start, uint64_t length,
-               void *end_arg);
+               struct read_verify_pool *rvp, uint64_t start, uint64_t length);
 
 int read_verify_bytes(struct read_verify_pool *rvp, uint64_t *bytes);