xfs_db: widen block type mask to 64 bits
authorDarrick J. Wong <djwong@kernel.org>
Wed, 3 Jul 2024 21:22:33 +0000 (14:22 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 16 Jul 2024 22:49:24 +0000 (15:49 -0700)
We're about to enlarge enum dbm beyond 32 items, so we need to widen the
block type mask to 64 bits to avoid problems.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
db/check.c

index d5c2b54a21985a184c31066a3bd2aefdcf7ddd26..ce15177ff0213bc1bfbb66543cdb8fdd0ebabbd9 100644 (file)
@@ -282,9 +282,9 @@ static void         check_set_rdbmap(xfs_rfsblock_t bno, xfs_extlen_t len,
                                         dbm_t type1, dbm_t type2);
 static void            check_summary(void);
 static void            checknot_dbmap(xfs_agnumber_t agno, xfs_agblock_t agbno,
-                                      xfs_extlen_t len, int typemask);
+                                      xfs_extlen_t len, uint64_t typemask);
 static void            checknot_rdbmap(xfs_rfsblock_t bno, xfs_extlen_t len,
-                                       int typemask);
+                                       uint64_t typemask);
 static void            dir_hash_add(xfs_dahash_t hash,
                                     xfs_dir2_dataptr_t addr);
 static void            dir_hash_check(inodata_t *id, int v);
@@ -895,7 +895,7 @@ blockget_f(
        if (!tflag) {   /* are we in test mode, faking out freespace? */
                for (agno = 0; agno < mp->m_sb.sb_agcount; agno++)
                        checknot_dbmap(agno, 0, mp->m_sb.sb_agblocks,
-                               (1 << DBM_UNKNOWN) | (1 << DBM_FREE1));
+                               (1ULL << DBM_UNKNOWN) | (1ULL << DBM_FREE1));
        }
        for (agno = 0; agno < mp->m_sb.sb_agcount; agno++)
                check_linkcounts(agno);
@@ -903,7 +903,7 @@ blockget_f(
                checknot_rdbmap(0,
                        (xfs_extlen_t)(mp->m_sb.sb_rextents *
                                       mp->m_sb.sb_rextsize),
-                       1 << DBM_UNKNOWN);
+                       1ULL << DBM_UNKNOWN);
                check_summary();
        }
        if (mp->m_sb.sb_icount != icount) {
@@ -1074,7 +1074,7 @@ blocktrash_f(
        int             c;
        int             count;
        int             done;
-       int             goodmask;
+       uint64_t        goodmask;
        int             i;
        ltab_t          *lentab;
        int             lentablen;
@@ -1086,7 +1086,7 @@ blocktrash_f(
        xfs_rfsblock_t  randb;
        uint            seed;
        int             sopt;
-       int             tmask;
+       uint64_t        tmask;
        bool            this_block = false;
        int             bit_offset = -1;
 
@@ -1099,27 +1099,27 @@ blocktrash_f(
        seed = (unsigned int)(now.tv_sec ^ now.tv_usec);
        sopt = 0;
        tmask = 0;
-       goodmask = (1 << DBM_AGF) |
-                  (1 << DBM_AGFL) |
-                  (1 << DBM_AGI) |
-                  (1 << DBM_ATTR) |
-                  (1 << DBM_BTBMAPA) |
-                  (1 << DBM_BTBMAPD) |
-                  (1 << DBM_BTBNO) |
-                  (1 << DBM_BTCNT) |
-                  (1 << DBM_BTINO) |
-                  (1 << DBM_DIR) |
-                  (1 << DBM_INODE) |
-                  (1 << DBM_LOG) |
-                  (1 << DBM_QUOTA) |
-                  (1 << DBM_RTBITMAP) |
-                  (1 << DBM_RTSUM) |
-                  (1 << DBM_BTRTRMAP) |
-                  (1 << DBM_SYMLINK) |
-                  (1 << DBM_BTFINO) |
-                  (1 << DBM_BTRMAP) |
-                  (1 << DBM_BTREFC) |
-                  (1 << DBM_SB);
+       goodmask = (1ULL << DBM_AGF) |
+                  (1ULL << DBM_AGFL) |
+                  (1ULL << DBM_AGI) |
+                  (1ULL << DBM_ATTR) |
+                  (1ULL << DBM_BTBMAPA) |
+                  (1ULL << DBM_BTBMAPD) |
+                  (1ULL << DBM_BTBNO) |
+                  (1ULL << DBM_BTCNT) |
+                  (1ULL << DBM_BTINO) |
+                  (1ULL << DBM_DIR) |
+                  (1ULL << DBM_INODE) |
+                  (1ULL << DBM_LOG) |
+                  (1ULL << DBM_QUOTA) |
+                  (1ULL << DBM_RTBITMAP) |
+                  (1ULL << DBM_RTSUM) |
+                  (1ULL << DBM_BTRTRMAP) |
+                  (1ULL << DBM_SYMLINK) |
+                  (1ULL << DBM_BTFINO) |
+                  (1ULL << DBM_BTRMAP) |
+                  (1ULL << DBM_BTREFC) |
+                  (1ULL << DBM_SB);
        while ((c = getopt(argc, argv, "0123n:o:s:t:x:y:z")) != EOF) {
                switch (c) {
                case '0':
@@ -1165,11 +1165,11 @@ blocktrash_f(
                                if (strcmp(typename[i], optarg) == 0)
                                        break;
                        }
-                       if (!typename[i] || (((1 << i) & goodmask) == 0)) {
+                       if (!typename[i] || (((1ULL << i) & goodmask) == 0)) {
                                dbprintf(_("bad blocktrash type %s\n"), optarg);
                                return 0;
                        }
-                       tmask |= 1 << i;
+                       tmask |= 1ULL << i;
                        break;
                case 'x':
                        min = (int)strtol(optarg, &p, 0);
@@ -1208,7 +1208,7 @@ blocktrash_f(
                return 0;
        }
        if (tmask == 0)
-               tmask = goodmask & ~((1 << DBM_LOG) | (1 << DBM_SB));
+               tmask = goodmask & ~((1ULL << DBM_LOG) | (1ULL << DBM_SB));
        lentab = xmalloc(sizeof(ltab_t));
        lentab->min = lentab->max = min;
        lentablen = 1;
@@ -1233,7 +1233,7 @@ blocktrash_f(
                for (agbno = 0, p = dbmap[agno];
                     agbno < mp->m_sb.sb_agblocks;
                     agbno++, p++) {
-                       if ((1 << *p) & tmask)
+                       if ((1ULL << *p) & tmask)
                                blocks++;
                }
        }
@@ -1250,7 +1250,7 @@ blocktrash_f(
                        for (agbno = 0, p = dbmap[agno];
                             agbno < mp->m_sb.sb_agblocks;
                             agbno++, p++) {
-                               if (!((1 << *p) & tmask))
+                               if (!((1ULL << *p) & tmask))
                                        continue;
                                if (bi++ < randb)
                                        continue;
@@ -1803,7 +1803,7 @@ checknot_dbmap(
        xfs_agnumber_t  agno,
        xfs_agblock_t   agbno,
        xfs_extlen_t    len,
-       int             typemask)
+       uint64_t        typemask)
 {
        xfs_extlen_t    i;
        char            *p;
@@ -1811,7 +1811,7 @@ checknot_dbmap(
        if (!check_range(agno, agbno, len))
                return;
        for (i = 0, p = &dbmap[agno][agbno]; i < len; i++, p++) {
-               if ((1 << *p) & typemask) {
+               if ((1ULL << *p) & typemask) {
                        if (!sflag || CHECK_BLISTA(agno, agbno + i))
                                dbprintf(_("block %u/%u type %s not expected\n"),
                                        agno, agbno + i, typename[(dbm_t)*p]);
@@ -1824,7 +1824,7 @@ static void
 checknot_rdbmap(
        xfs_rfsblock_t  bno,
        xfs_extlen_t    len,
-       int             typemask)
+       uint64_t        typemask)
 {
        xfs_extlen_t    i;
        char            *p;
@@ -1832,7 +1832,7 @@ checknot_rdbmap(
        if (!check_rrange(bno, len))
                return;
        for (i = 0, p = &dbmap[mp->m_sb.sb_agcount][bno]; i < len; i++, p++) {
-               if ((1 << *p) & typemask) {
+               if ((1ULL << *p) & typemask) {
                        if (!sflag || CHECK_BLIST(bno + i))
                                dbprintf(_("rtblock %llu type %s not expected\n"),
                                        bno + i, typename[(dbm_t)*p]);