]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: remove xfs_rmap_ag_owner and friends
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 27 Feb 2019 23:13:44 +0000 (17:13 -0600)
committerEric Sandeen <sandeen@redhat.com>
Wed, 27 Feb 2019 23:13:44 +0000 (17:13 -0600)
Source kernel commit: 7280fedaf3a0f9097c0621c7d5b35849954d7f54

Owner information for static fs metadata can be defined readonly at
build time because it never changes across filesystems.  This enables us
to reduce stack usage (particularly in scrub) because we can use the
statically defined oinfo structures.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/libxfs_api_defs.h
libxfs/xfs_ag.c
libxfs/xfs_alloc.c
libxfs/xfs_bmap.c
libxfs/xfs_ialloc.c
libxfs/xfs_ialloc_btree.c
libxfs/xfs_refcount_btree.c
libxfs/xfs_rmap.c
libxfs/xfs_rmap.h
repair/phase5.c
repair/rmap.c

index c3792e120e2474504e5df792ce2b5f4868fda279..e10d78cd2849f04d5a53171ffad610932f415bf4 100644 (file)
@@ -97,7 +97,6 @@
 #define xfs_inode_validate_extsize     libxfs_inode_validate_extsize
 #define xfs_inode_validate_cowextsize  libxfs_inode_validate_cowextsize
 
-#define xfs_rmap_ag_owner              libxfs_rmap_ag_owner
 #define xfs_rmap_alloc                 libxfs_rmap_alloc
 #define xfs_rmap_query_range           libxfs_rmap_query_range
 #define xfs_rmap_lookup_le             libxfs_rmap_lookup_le
index 76e660d730dca9c62da4544f37a28eb753bbb15e..a7d1a0d9b4bde0d411c51829526597c15183ec27 100644 (file)
@@ -415,7 +415,6 @@ xfs_ag_extend_space(
        struct aghdr_init_data  *id,
        xfs_extlen_t            len)
 {
-       struct xfs_owner_info   oinfo;
        struct xfs_buf          *bp;
        struct xfs_agi          *agi;
        struct xfs_agf          *agf;
@@ -449,17 +448,17 @@ xfs_ag_extend_space(
        /*
         * Free the new space.
         *
-        * XFS_RMAP_OWN_NULL is used here to tell the rmap btree that
+        * XFS_RMAP_OINFO_SKIP_UPDATE is used here to tell the rmap btree that
         * this doesn't actually exist in the rmap btree.
         */
-       xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_NULL);
        error = xfs_rmap_free(tp, bp, id->agno,
                                be32_to_cpu(agf->agf_length) - len,
-                               len, &oinfo);
+                               len, &XFS_RMAP_OINFO_SKIP_UPDATE);
        if (error)
                return error;
 
        return  xfs_free_extent(tp, XFS_AGB_TO_FSB(mp, id->agno,
                                        be32_to_cpu(agf->agf_length) - len),
-                               len, &oinfo, XFS_AG_RESV_NONE);
+                               len, &XFS_RMAP_OINFO_SKIP_UPDATE,
+                               XFS_AG_RESV_NONE);
 }
index 5628e3c2d9802dc61ebb6b26c56ac918d8d6e937..2639e2f69fff936318d2a303dee4f2e8ad2567d8 100644 (file)
@@ -1590,7 +1590,6 @@ xfs_alloc_ag_vextent_small(
        xfs_extlen_t    *flenp, /* result length */
        int             *stat)  /* status: 0-freelist, 1-normal/none */
 {
-       struct xfs_owner_info   oinfo;
        int             error;
        xfs_agblock_t   fbno;
        xfs_extlen_t    flen;
@@ -1644,9 +1643,8 @@ xfs_alloc_ag_vextent_small(
                         * doesn't live in the free space, we need to clear
                         * out the OWN_AG rmap.
                         */
-                       xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_AG);
                        error = xfs_rmap_free(args->tp, args->agbp, args->agno,
-                                       fbno, 1, &oinfo);
+                                       fbno, 1, &XFS_RMAP_OINFO_AG);
                        if (error)
                                goto error0;
 
@@ -2310,10 +2308,11 @@ xfs_alloc_fix_freelist(
         * repair/rmap.c in xfsprogs for details.
         */
        memset(&targs, 0, sizeof(targs));
+       /* struct copy below */
        if (flags & XFS_ALLOC_FLAG_NORMAP)
-               xfs_rmap_skip_owner_update(&targs.oinfo);
+               targs.oinfo = XFS_RMAP_OINFO_SKIP_UPDATE;
        else
-               xfs_rmap_ag_owner(&targs.oinfo, XFS_RMAP_OWN_AG);
+               targs.oinfo = XFS_RMAP_OINFO_AG;
        while (!(flags & XFS_ALLOC_FLAG_NOSHRINK) && pag->pagf_flcount > need) {
                error = xfs_alloc_get_freelist(tp, agbp, &bno, 0);
                if (error)
index f2210d31deb9312078df80c9d6b1d8a3b20e41e5..dc853b1f90d68c8bdc0051246887158cf642bca0 100644 (file)
@@ -555,7 +555,7 @@ __xfs_bmap_add_free(
        if (oinfo)
                new->xefi_oinfo = *oinfo;
        else
-               xfs_rmap_skip_owner_update(&new->xefi_oinfo);
+               new->xefi_oinfo = XFS_RMAP_OINFO_SKIP_UPDATE;
        new->xefi_skip_discard = skip_discard;
        trace_xfs_bmap_free_defer(tp->t_mountp,
                        XFS_FSB_TO_AGNO(tp->t_mountp, bno), 0,
@@ -3444,7 +3444,7 @@ xfs_bmap_btalloc(
        args.tp = ap->tp;
        args.mp = mp;
        args.fsbno = ap->blkno;
-       xfs_rmap_skip_owner_update(&args.oinfo);
+       args.oinfo = XFS_RMAP_OINFO_SKIP_UPDATE;
 
        /* Trim the allocation back to the maximum an AG can fit. */
        args.maxlen = min(ap->length, mp->m_ag_max_usable);
index 9640a872daeeb7cb5e23949ef9cb756f1011dc28..cccfb363ab7160c81af46a3e4c1b4fecc226fb8f 100644 (file)
@@ -635,7 +635,7 @@ xfs_ialloc_ag_alloc(
        args.tp = tp;
        args.mp = tp->t_mountp;
        args.fsbno = NULLFSBLOCK;
-       xfs_rmap_ag_owner(&args.oinfo, XFS_RMAP_OWN_INODES);
+       args.oinfo = XFS_RMAP_OINFO_INODES;
 
 #ifdef DEBUG
        /* randomly do sparse inode allocations */
@@ -1843,14 +1843,12 @@ xfs_difree_inode_chunk(
        int                             nextbit;
        xfs_agblock_t                   agbno;
        int                             contigblk;
-       struct xfs_owner_info           oinfo;
        DECLARE_BITMAP(holemask, XFS_INOBT_HOLEMASK_BITS);
-       xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_INODES);
 
        if (!xfs_inobt_issparse(rec->ir_holemask)) {
                /* not sparse, calculate extent info directly */
                xfs_bmap_add_free(tp, XFS_AGB_TO_FSB(mp, agno, sagbno),
-                                 mp->m_ialloc_blks, &oinfo);
+                                 mp->m_ialloc_blks, &XFS_RMAP_OINFO_INODES);
                return;
        }
 
@@ -1894,7 +1892,7 @@ xfs_difree_inode_chunk(
                ASSERT(agbno % mp->m_sb.sb_spino_align == 0);
                ASSERT(contigblk % mp->m_sb.sb_spino_align == 0);
                xfs_bmap_add_free(tp, XFS_AGB_TO_FSB(mp, agno, agbno),
-                                 contigblk, &oinfo);
+                                 contigblk, &XFS_RMAP_OINFO_INODES);
 
                /* reset range to current bit and carry on... */
                startidx = endidx = nextbit;
index 5e0ef91e28a6dfbcefd22a1d4ddb5ab808698c25..716a81f90593501dcf3057f7a189ae176eceff63 100644 (file)
@@ -83,7 +83,7 @@ __xfs_inobt_alloc_block(
        memset(&args, 0, sizeof(args));
        args.tp = cur->bc_tp;
        args.mp = cur->bc_mp;
-       xfs_rmap_ag_owner(&args.oinfo, XFS_RMAP_OWN_INOBT);
+       args.oinfo = XFS_RMAP_OINFO_INOBT;
        args.fsbno = XFS_AGB_TO_FSB(args.mp, cur->bc_private.a.agno, sbno);
        args.minlen = 1;
        args.maxlen = 1;
@@ -135,12 +135,9 @@ __xfs_inobt_free_block(
        struct xfs_buf          *bp,
        enum xfs_ag_resv_type   resv)
 {
-       struct xfs_owner_info   oinfo;
-
-       xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_INOBT);
        return xfs_free_extent(cur->bc_tp,
                        XFS_DADDR_TO_FSB(cur->bc_mp, XFS_BUF_ADDR(bp)), 1,
-                       &oinfo, resv);
+                       &XFS_RMAP_OINFO_INOBT, resv);
 }
 
 STATIC int
index 864b70cf17865a0b5e7da1df83524f107150e13c..09f3045cff78df81951e1090e3d1b51fdd0ede59 100644 (file)
@@ -69,7 +69,7 @@ xfs_refcountbt_alloc_block(
        args.type = XFS_ALLOCTYPE_NEAR_BNO;
        args.fsbno = XFS_AGB_TO_FSB(cur->bc_mp, cur->bc_private.a.agno,
                        xfs_refc_block(args.mp));
-       xfs_rmap_ag_owner(&args.oinfo, XFS_RMAP_OWN_REFC);
+       args.oinfo = XFS_RMAP_OINFO_REFC;
        args.minlen = args.maxlen = args.prod = 1;
        args.resv = XFS_AG_RESV_METADATA;
 
@@ -105,15 +105,13 @@ xfs_refcountbt_free_block(
        struct xfs_buf          *agbp = cur->bc_private.a.agbp;
        struct xfs_agf          *agf = XFS_BUF_TO_AGF(agbp);
        xfs_fsblock_t           fsbno = XFS_DADDR_TO_FSB(mp, XFS_BUF_ADDR(bp));
-       struct xfs_owner_info   oinfo;
        int                     error;
 
        trace_xfs_refcountbt_free_block(cur->bc_mp, cur->bc_private.a.agno,
                        XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno), 1);
-       xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_REFC);
        be32_add_cpu(&agf->agf_refcount_blocks, -1);
        xfs_alloc_log_agf(cur->bc_tp, agbp, XFS_AGF_REFCOUNT_BLOCKS);
-       error = xfs_free_extent(cur->bc_tp, fsbno, 1, &oinfo,
+       error = xfs_free_extent(cur->bc_tp, fsbno, 1, &XFS_RMAP_OINFO_REFC,
                        XFS_AG_RESV_METADATA);
        if (error)
                return error;
index ed5c7302c8cae6118229f7a7d31db6238740d28c..42938e668ee26c95048730c45d6dc8cef881dc9b 100644 (file)
@@ -2548,3 +2548,31 @@ xfs_rmap_has_other_keys(
        *has_rmap = rks.has_rmap;
        return error;
 }
+
+const struct xfs_owner_info XFS_RMAP_OINFO_SKIP_UPDATE = {
+       .oi_owner = XFS_RMAP_OWN_NULL,
+};
+const struct xfs_owner_info XFS_RMAP_OINFO_ANY_OWNER = {
+       .oi_owner = XFS_RMAP_OWN_UNKNOWN,
+};
+const struct xfs_owner_info XFS_RMAP_OINFO_FS = {
+       .oi_owner = XFS_RMAP_OWN_FS,
+};
+const struct xfs_owner_info XFS_RMAP_OINFO_LOG = {
+       .oi_owner = XFS_RMAP_OWN_LOG,
+};
+const struct xfs_owner_info XFS_RMAP_OINFO_AG = {
+       .oi_owner = XFS_RMAP_OWN_AG,
+};
+const struct xfs_owner_info XFS_RMAP_OINFO_INOBT = {
+       .oi_owner = XFS_RMAP_OWN_INOBT,
+};
+const struct xfs_owner_info XFS_RMAP_OINFO_INODES = {
+       .oi_owner = XFS_RMAP_OWN_INODES,
+};
+const struct xfs_owner_info XFS_RMAP_OINFO_REFC = {
+       .oi_owner = XFS_RMAP_OWN_REFC,
+};
+const struct xfs_owner_info XFS_RMAP_OINFO_COW = {
+       .oi_owner = XFS_RMAP_OWN_COW,
+};
index 6d32838aa184f0a9aae6be5b9c5d5ff1fe641dd5..e21ed0294e5c9898584eb688b700692273718706 100644 (file)
@@ -6,16 +6,6 @@
 #ifndef __XFS_RMAP_H__
 #define __XFS_RMAP_H__
 
-static inline void
-xfs_rmap_ag_owner(
-       struct xfs_owner_info   *oi,
-       uint64_t                owner)
-{
-       oi->oi_owner = owner;
-       oi->oi_offset = 0;
-       oi->oi_flags = 0;
-}
-
 static inline void
 xfs_rmap_ino_bmbt_owner(
        struct xfs_owner_info   *oi,
@@ -43,13 +33,6 @@ xfs_rmap_ino_owner(
                oi->oi_flags |= XFS_OWNER_INFO_ATTR_FORK;
 }
 
-static inline void
-xfs_rmap_skip_owner_update(
-       struct xfs_owner_info   *oi)
-{
-       xfs_rmap_ag_owner(oi, XFS_RMAP_OWN_NULL);
-}
-
 static inline bool
 xfs_rmap_should_skip_owner_update(
        const struct xfs_owner_info     *oi)
@@ -57,13 +40,6 @@ xfs_rmap_should_skip_owner_update(
        return oi->oi_owner == XFS_RMAP_OWN_NULL;
 }
 
-static inline void
-xfs_rmap_any_owner_update(
-       struct xfs_owner_info   *oi)
-{
-       xfs_rmap_ag_owner(oi, XFS_RMAP_OWN_UNKNOWN);
-}
-
 /* Reverse mapping functions. */
 
 struct xfs_buf;
@@ -225,4 +201,14 @@ int xfs_rmap_has_other_keys(struct xfs_btree_cur *cur, xfs_agblock_t bno,
                bool *has_rmap);
 int xfs_rmap_map_raw(struct xfs_btree_cur *cur, struct xfs_rmap_irec *rmap);
 
+extern const struct xfs_owner_info XFS_RMAP_OINFO_SKIP_UPDATE;
+extern const struct xfs_owner_info XFS_RMAP_OINFO_ANY_OWNER;
+extern const struct xfs_owner_info XFS_RMAP_OINFO_FS;
+extern const struct xfs_owner_info XFS_RMAP_OINFO_LOG;
+extern const struct xfs_owner_info XFS_RMAP_OINFO_AG;
+extern const struct xfs_owner_info XFS_RMAP_OINFO_INOBT;
+extern const struct xfs_owner_info XFS_RMAP_OINFO_INODES;
+extern const struct xfs_owner_info XFS_RMAP_OINFO_REFC;
+extern const struct xfs_owner_info XFS_RMAP_OINFO_COW;
+
 #endif /* __XFS_RMAP_H__ */
index e8f9f46822a0d94ce674f0ae4f47a1b203b92a0b..367c3ab9eb9e9e3d93006a6c322204500272fc11 100644 (file)
@@ -2421,10 +2421,8 @@ inject_lost_blocks(
        struct xfs_trans        *tp = NULL;
        struct xfs_slab_cursor  *cur = NULL;
        xfs_fsblock_t           *fsb;
-       struct xfs_owner_info   oinfo;
        int                     error;
 
-       libxfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_AG);
        error = init_slab_cursor(lost_fsbs, NULL, &cur);
        if (error)
                return error;
@@ -2434,7 +2432,7 @@ inject_lost_blocks(
                if (error)
                        goto out_cancel;
 
-               error = -libxfs_free_extent(tp, *fsb, 1, &oinfo,
+               error = -libxfs_free_extent(tp, *fsb, 1, &XFS_RMAP_OINFO_AG,
                                            XFS_AG_RESV_NONE);
                if (error)
                        goto out_cancel;
index c5a866468e59dbbd9a475e47a34b4555f8782178..d0156f9dbb480f4d6d5321b60da1e4ea8e990a90 100644 (file)
@@ -451,7 +451,6 @@ rmap_store_ag_btree_rec(
        struct xfs_trans        *tp;
        __be32                  *agfl_bno, *b;
        int                     error = 0;
-       struct xfs_owner_info   oinfo;
 
        if (!xfs_sb_version_hasrmapbt(&mp->m_sb))
                return 0;
@@ -507,6 +506,8 @@ rmap_store_ag_btree_rec(
        /* Insert rmaps into the btree one at a time */
        rm_rec = pop_slab_cursor(rm_cur);
        while (rm_rec) {
+               struct xfs_owner_info   oinfo = {};
+
                error = -libxfs_trans_alloc_rollable(mp, 16, &tp);
                if (error)
                        goto err_slab;
@@ -516,7 +517,7 @@ rmap_store_ag_btree_rec(
                        goto err_trans;
 
                ASSERT(XFS_RMAP_NON_INODE_OWNER(rm_rec->rm_owner));
-               libxfs_rmap_ag_owner(&oinfo, rm_rec->rm_owner);
+               oinfo.oi_owner = rm_rec->rm_owner;
                error = -libxfs_rmap_alloc(tp, agbp, agno, rm_rec->rm_startblock,
                                rm_rec->rm_blockcount, &oinfo);
                if (error)