]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: remove the agfl_bno member from struct xfs_agfl
authorChristoph Hellwig <hch@lst.de>
Fri, 1 May 2020 21:37:08 +0000 (17:37 -0400)
committerEric Sandeen <sandeen@redhat.com>
Fri, 1 May 2020 21:37:08 +0000 (17:37 -0400)
Source kernel commit: 183606d82446110e23987d4b693f3d3fc300bd82

struct xfs_agfl is a header in front of the AGFL entries that exists
for CRC enabled file systems.  For not CRC enabled file systems the AGFL
is simply a list of agbno.  Make the CRC case similar to that by just
using the list behind the new header.  This indirectly solves a problem
with modern gcc versions that warn about taking addresses of packed
structures (and we have to pack the AGFL given that gcc rounds up
structure sizes).  Also replace the helper macro to get from a buffer
with an inline function in xfs_alloc.h to make the code easier to
read.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
db/agfl.c
db/metadump.c
libxfs/xfs_ag.c
libxfs/xfs_alloc.c
libxfs/xfs_alloc.h
libxfs/xfs_format.h
repair/phase5.c
repair/rmap.c

index 4fb0d4607699dce8aa4b6354315325cba0f1844c..9848493704bba73175cc30e52ee909ff252b4689 100644 (file)
--- a/db/agfl.c
+++ b/db/agfl.c
@@ -47,8 +47,8 @@ const field_t agfl_crc_flds[] = {
        { "uuid", FLDT_UUID, OI(OFF(uuid)), C1, 0, TYP_NONE },
        { "lsn", FLDT_UINT64X, OI(OFF(lsn)), C1, 0, TYP_NONE },
        { "crc", FLDT_CRC, OI(OFF(crc)), C1, 0, TYP_NONE },
-       { "bno", FLDT_AGBLOCKNZ, OI(OFF(bno)), agfl_bno_size,
-         FLD_ARRAY|FLD_COUNT, TYP_DATA },
+       { "bno", FLDT_AGBLOCKNZ, OI(bitize(sizeof(struct xfs_agfl))),
+         agfl_bno_size, FLD_ARRAY|FLD_COUNT, TYP_DATA },
        { NULL }
 };
 
index d542762e857fc98ce6bf5198aa29b9a2b83c06e0..ac0e28b2521d987a6f33cd02a680f79190a7e742 100644 (file)
@@ -2750,7 +2750,7 @@ scan_ag(
                        int i;
                         __be32  *agfl_bno;
 
-                       agfl_bno = XFS_BUF_TO_AGFL_BNO(mp, iocur_top->bp);
+                       agfl_bno = xfs_buf_to_agfl_bno(iocur_top->bp);
                        i = be32_to_cpu(agf->agf_fllast);
 
                        for (;;) {
index 73fb30cbcfac8817926e9e0abdef6ee67e25890b..57f31e2f8d30c0a28c625108a9c08159bcfffb87 100644 (file)
@@ -301,7 +301,7 @@ xfs_agflblock_init(
                uuid_copy(&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid);
        }
 
-       agfl_bno = XFS_BUF_TO_AGFL_BNO(mp, bp);
+       agfl_bno = xfs_buf_to_agfl_bno(bp);
        for (bucket = 0; bucket < xfs_agfl_size(mp); bucket++)
                agfl_bno[bucket] = cpu_to_be32(NULLAGBLOCK);
 }
index 09db66936f6e1db809ae8b036144f96ec0548b27..268776f2dd316b00948d52fca679b03a4b7a26f9 100644 (file)
@@ -585,6 +585,7 @@ xfs_agfl_verify(
 {
        struct xfs_mount *mp = bp->b_mount;
        struct xfs_agfl *agfl = XFS_BUF_TO_AGFL(bp);
+       __be32          *agfl_bno = xfs_buf_to_agfl_bno(bp);
        int             i;
 
        /*
@@ -610,8 +611,8 @@ xfs_agfl_verify(
                return __this_address;
 
        for (i = 0; i < xfs_agfl_size(mp); i++) {
-               if (be32_to_cpu(agfl->agfl_bno[i]) != NULLAGBLOCK &&
-                   be32_to_cpu(agfl->agfl_bno[i]) >= mp->m_sb.sb_agblocks)
+               if (be32_to_cpu(agfl_bno[i]) != NULLAGBLOCK &&
+                   be32_to_cpu(agfl_bno[i]) >= mp->m_sb.sb_agblocks)
                        return __this_address;
        }
 
@@ -2680,7 +2681,7 @@ xfs_alloc_get_freelist(
        /*
         * Get the block number and update the data structures.
         */
-       agfl_bno = XFS_BUF_TO_AGFL_BNO(mp, agflbp);
+       agfl_bno = xfs_buf_to_agfl_bno(agflbp);
        bno = be32_to_cpu(agfl_bno[be32_to_cpu(agf->agf_flfirst)]);
        be32_add_cpu(&agf->agf_flfirst, 1);
        xfs_trans_brelse(tp, agflbp);
@@ -2816,7 +2817,7 @@ xfs_alloc_put_freelist(
 
        ASSERT(be32_to_cpu(agf->agf_flcount) <= xfs_agfl_size(mp));
 
-       agfl_bno = XFS_BUF_TO_AGFL_BNO(mp, agflbp);
+       agfl_bno = xfs_buf_to_agfl_bno(agflbp);
        blockp = &agfl_bno[be32_to_cpu(agf->agf_fllast)];
        *blockp = cpu_to_be32(bno);
        startoff = (char *)blockp - (char *)agflbp->b_addr;
@@ -3420,7 +3421,7 @@ xfs_agfl_walk(
        unsigned int            i;
        int                     error;
 
-       agfl_bno = XFS_BUF_TO_AGFL_BNO(mp, agflbp);
+       agfl_bno = xfs_buf_to_agfl_bno(agflbp);
        i = be32_to_cpu(agf->agf_flfirst);
 
        /* Nothing to walk in an empty AGFL. */
index 7380fbe4a3fffd68e382ccd31c149a3cfd0880cb..a851bf77f17bfa91027be5e0c01740fd21a2e66e 100644 (file)
@@ -236,4 +236,13 @@ typedef int (*xfs_agfl_walk_fn)(struct xfs_mount *mp, xfs_agblock_t bno,
 int xfs_agfl_walk(struct xfs_mount *mp, struct xfs_agf *agf,
                struct xfs_buf *agflbp, xfs_agfl_walk_fn walk_fn, void *priv);
 
+static inline __be32 *
+xfs_buf_to_agfl_bno(
+       struct xfs_buf          *bp)
+{
+       if (xfs_sb_version_hascrc(&bp->b_mount->m_sb))
+               return bp->b_addr + sizeof(struct xfs_agfl);
+       return bp->b_addr;
+}
+
 #endif /* __XFS_ALLOC_H__ */
index 3dcc1ed5cdfb6b4531721f895a7736aa489ab249..c1c69a4c8519435bdc6ce3070974da0222971253 100644 (file)
@@ -785,18 +785,12 @@ typedef struct xfs_agi {
 #define        XFS_AGFL_BLOCK(mp)      XFS_HDR_BLOCK(mp, XFS_AGFL_DADDR(mp))
 #define        XFS_BUF_TO_AGFL(bp)     ((xfs_agfl_t *)((bp)->b_addr))
 
-#define XFS_BUF_TO_AGFL_BNO(mp, bp) \
-       (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \
-               &(XFS_BUF_TO_AGFL(bp)->agfl_bno[0]) : \
-               (__be32 *)(bp)->b_addr)
-
 typedef struct xfs_agfl {
        __be32          agfl_magicnum;
        __be32          agfl_seqno;
        uuid_t          agfl_uuid;
        __be64          agfl_lsn;
        __be32          agfl_crc;
-       __be32          agfl_bno[];     /* actually xfs_agfl_size(mp) */
 } __attribute__((packed)) xfs_agfl_t;
 
 #define XFS_AGFL_CRC_OFF       offsetof(struct xfs_agfl, agfl_crc)
index abae8a086a1be4b2f173c0604d9b6deedb9c75e4..a07dfbf38cf0ecd1f520a9724a99bab9215b12fd 100644 (file)
@@ -2150,13 +2150,16 @@ build_agf_agfl(
        /* setting to 0xff results in initialisation to NULLAGBLOCK */
        memset(agfl, 0xff, mp->m_sb.sb_sectsize);
        if (xfs_sb_version_hascrc(&mp->m_sb)) {
+               __be32 *agfl_bno = xfs_buf_to_agfl_bno(agfl_buf);
+
                agfl->agfl_magicnum = cpu_to_be32(XFS_AGFL_MAGIC);
                agfl->agfl_seqno = cpu_to_be32(agno);
                platform_uuid_copy(&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid);
                for (i = 0; i < libxfs_agfl_size(mp); i++)
-                       agfl->agfl_bno[i] = cpu_to_be32(NULLAGBLOCK);
+                       agfl_bno[i] = cpu_to_be32(NULLAGBLOCK);
        }
-       freelist = XFS_BUF_TO_AGFL_BNO(mp, agfl_buf);
+
+       freelist = xfs_buf_to_agfl_bno(agfl_buf);
 
        /*
         * do we have left-over blocks in the btree cursors that should
index a37efbe7c0ed3f617e5ecf3f99abde9a62a78dd3..a4cc6a4937c926b208fe894709555fab3aadab14 100644 (file)
@@ -512,7 +512,7 @@ rmap_store_ag_btree_rec(
        free_slab_cursor(&rm_cur);
 
        /* Create rmaps for any AGFL blocks that aren't already rmapped. */
-       agfl_bno = XFS_BUF_TO_AGFL_BNO(mp, agflbp);
+       agfl_bno = xfs_buf_to_agfl_bno(agflbp);
        b = agfl_bno + ag_rmap->ar_flcount;
        while (*b != cpu_to_be32(NULLAGBLOCK) &&
               b - agfl_bno < libxfs_agfl_size(mp)) {