]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: simplify rt_lock handling
authorChristoph Hellwig <hch@lst.de>
Thu, 21 Nov 2024 00:24:34 +0000 (16:24 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 24 Dec 2024 02:01:33 +0000 (18:01 -0800)
No need to cacheline align rt_lock if we move it next to the data
it protects.  Also reduce the critical section to just where those
data structures are accessed.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
repair/dinode.c
repair/globals.c
repair/globals.h
repair/incore.c

index 56c7257d3766f158541848f03c40641f51cdeb98..8c593da545cd7ff007f2d0aea414dfb2a244d736 100644 (file)
@@ -304,7 +304,7 @@ process_rt_rec(
        bool                    zap_metadata)
 {
        xfs_fsblock_t           lastb;
-       int                     bad;
+       int                     bad = 0;
 
        /*
         * check numeric validity of the extent
@@ -338,10 +338,12 @@ _("inode %" PRIu64 " - bad rt extent overflows - start %" PRIu64 ", "
                return 1;
        }
 
+       pthread_mutex_lock(&rt_lock);
        if (check_dups)
                bad = process_rt_rec_dups(mp, ino, irec);
        else
                bad = process_rt_rec_state(mp, ino, zap_metadata, irec);
+       pthread_mutex_unlock(&rt_lock);
        if (bad)
                return bad;
 
@@ -451,10 +453,8 @@ _("zero length extent (off = %" PRIu64 ", fsbno = %" PRIu64 ") in ino %" PRIu64
                }
 
                if (type == XR_INO_RTDATA && whichfork == XFS_DATA_FORK) {
-                       pthread_mutex_lock(&rt_lock.lock);
                        error2 = process_rt_rec(mp, &irec, ino, tot, check_dups,
                                        zap_metadata);
-                       pthread_mutex_unlock(&rt_lock.lock);
                        if (error2)
                                return error2;
 
index bd07a9656d193b44f669288c2ff2fa33ff3426bc..d97e2a8d2d6d9baf0daafcd4184a56e43d24b4d7 100644 (file)
@@ -112,7 +112,6 @@ uint32_t    sb_unit;
 uint32_t       sb_width;
 
 struct aglock  *ag_locks;
-struct aglock  rt_lock;
 
 time_t         report_interval;
 uint64_t       *prog_rpt_done;
index ebe8d5ee132b8d1fbc72364fd646023e682ebb9d..db8afabd9f0fc99af34641fc6c8240fc22e11a94 100644 (file)
@@ -156,7 +156,7 @@ struct aglock {
        pthread_mutex_t lock __attribute__((__aligned__(64)));
 };
 extern struct aglock   *ag_locks;
-extern struct aglock   rt_lock;
+extern pthread_mutex_t rt_lock;
 
 extern time_t          report_interval;
 extern uint64_t                *prog_rpt_done;
index 06edaf0d60526285a60afa175490ea88906ebaff..21f5b05d3e93e4eb9e4609976463ab38a168687f 100644 (file)
@@ -166,6 +166,7 @@ get_bmap_ext(
 
 static uint64_t                *rt_bmap;
 static size_t          rt_bmap_size;
+pthread_mutex_t                rt_lock;
 
 /* block records fit into uint64_t's units */
 #define XR_BB_UNIT     64                      /* number of bits/unit */
@@ -209,6 +210,7 @@ init_rt_bmap(
        if (mp->m_sb.sb_rextents == 0)
                return;
 
+       pthread_mutex_init(&rt_lock, NULL);
        rt_bmap_size = roundup(howmany(mp->m_sb.sb_rextents, (NBBY / XR_BB)),
                               sizeof(uint64_t));
 
@@ -226,8 +228,9 @@ free_rt_bmap(xfs_mount_t *mp)
 {
        free(rt_bmap);
        rt_bmap = NULL;
-}
+       pthread_mutex_destroy(&rt_lock);
 
+}
 
 void
 reset_bmaps(xfs_mount_t *mp)
@@ -290,7 +293,6 @@ init_bmaps(xfs_mount_t *mp)
                btree_init(&ag_bmap[i]);
                pthread_mutex_init(&ag_locks[i].lock, NULL);
        }
-       pthread_mutex_init(&rt_lock.lock, NULL);
 
        init_rt_bmap(mp);
        reset_bmaps(mp);
@@ -301,8 +303,6 @@ free_bmaps(xfs_mount_t *mp)
 {
        xfs_agnumber_t i;
 
-       pthread_mutex_destroy(&rt_lock.lock);
-
        for (i = 0; i < mp->m_sb.sb_agcount; i++)
                pthread_mutex_destroy(&ag_locks[i].lock);