]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: const-ify xfs_owner_info arguments
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: 66e3237e724c6650dca03627b40bb00a812d3f7a

Only certain functions actually change the contents of an
xfs_owner_info; the rest can accept a const struct pointer.  This will
enable us to save stack space by hoisting static owner info types to
be const global variables.

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/xfs_alloc.c
libxfs/xfs_alloc.h
libxfs/xfs_bmap.c
libxfs/xfs_bmap.h
libxfs/xfs_rmap.c
libxfs/xfs_rmap.h

index 02694cde635180c5ca60341628d49867dc710743..5628e3c2d9802dc61ebb6b26c56ac918d8d6e937 100644 (file)
@@ -1690,28 +1690,28 @@ error0:
  */
 STATIC int
 xfs_free_ag_extent(
-       xfs_trans_t             *tp,
-       xfs_buf_t               *agbp,
-       xfs_agnumber_t          agno,
-       xfs_agblock_t           bno,
-       xfs_extlen_t            len,
-       struct xfs_owner_info   *oinfo,
-       enum xfs_ag_resv_type   type)
+       struct xfs_trans                *tp,
+       struct xfs_buf                  *agbp,
+       xfs_agnumber_t                  agno,
+       xfs_agblock_t                   bno,
+       xfs_extlen_t                    len,
+       const struct xfs_owner_info     *oinfo,
+       enum xfs_ag_resv_type           type)
 {
-       xfs_btree_cur_t *bno_cur;       /* cursor for by-block btree */
-       xfs_btree_cur_t *cnt_cur;       /* cursor for by-size btree */
-       int             error;          /* error return value */
-       xfs_agblock_t   gtbno;          /* start of right neighbor block */
-       xfs_extlen_t    gtlen;          /* length of right neighbor block */
-       int             haveleft;       /* have a left neighbor block */
-       int             haveright;      /* have a right neighbor block */
-       int             i;              /* temp, result code */
-       xfs_agblock_t   ltbno;          /* start of left neighbor block */
-       xfs_extlen_t    ltlen;          /* length of left neighbor block */
-       xfs_mount_t     *mp;            /* mount point struct for filesystem */
-       xfs_agblock_t   nbno;           /* new starting block of freespace */
-       xfs_extlen_t    nlen;           /* new length of freespace */
-       xfs_perag_t     *pag;           /* per allocation group data */
+       struct xfs_mount                *mp;
+       struct xfs_perag                *pag;
+       struct xfs_btree_cur            *bno_cur;
+       struct xfs_btree_cur            *cnt_cur;
+       xfs_agblock_t                   gtbno; /* start of right neighbor */
+       xfs_extlen_t                    gtlen; /* length of right neighbor */
+       xfs_agblock_t                   ltbno; /* start of left neighbor */
+       xfs_extlen_t                    ltlen; /* length of left neighbor */
+       xfs_agblock_t                   nbno; /* new starting block of freesp */
+       xfs_extlen_t                    nlen; /* new length of freespace */
+       int                             haveleft; /* have a left neighbor */
+       int                             haveright; /* have a right neighbor */
+       int                             i;
+       int                             error;
 
        bno_cur = cnt_cur = NULL;
        mp = tp->t_mountp;
@@ -3004,21 +3004,21 @@ out:
  * Just break up the extent address and hand off to xfs_free_ag_extent
  * after fixing up the freelist.
  */
-int                            /* error */
+int
 __xfs_free_extent(
-       struct xfs_trans        *tp,    /* transaction pointer */
-       xfs_fsblock_t           bno,    /* starting block number of extent */
-       xfs_extlen_t            len,    /* length of extent */
-       struct xfs_owner_info   *oinfo, /* extent owner */
-       enum xfs_ag_resv_type   type,   /* block reservation type */
-       bool                    skip_discard)
+       struct xfs_trans                *tp,
+       xfs_fsblock_t                   bno,
+       xfs_extlen_t                    len,
+       const struct xfs_owner_info     *oinfo,
+       enum xfs_ag_resv_type           type,
+       bool                            skip_discard)
 {
-       struct xfs_mount        *mp = tp->t_mountp;
-       struct xfs_buf          *agbp;
-       xfs_agnumber_t          agno = XFS_FSB_TO_AGNO(mp, bno);
-       xfs_agblock_t           agbno = XFS_FSB_TO_AGBNO(mp, bno);
-       int                     error;
-       unsigned int            busy_flags = 0;
+       struct xfs_mount                *mp = tp->t_mountp;
+       struct xfs_buf                  *agbp;
+       xfs_agnumber_t                  agno = XFS_FSB_TO_AGNO(mp, bno);
+       xfs_agblock_t                   agbno = XFS_FSB_TO_AGBNO(mp, bno);
+       int                             error;
+       unsigned int                    busy_flags = 0;
 
        ASSERT(len != 0);
        ASSERT(type != XFS_AG_RESV_AGFL);
index 00cd5ec4cb6b0424c23205b00e21539fb156c777..d6ed5d2c07c210446e999f9a99bfd2984abfffc1 100644 (file)
@@ -182,7 +182,7 @@ __xfs_free_extent(
        struct xfs_trans        *tp,    /* transaction pointer */
        xfs_fsblock_t           bno,    /* starting block number of extent */
        xfs_extlen_t            len,    /* length of extent */
-       struct xfs_owner_info   *oinfo, /* extent owner */
+       const struct xfs_owner_info     *oinfo, /* extent owner */
        enum xfs_ag_resv_type   type,   /* block reservation type */
        bool                    skip_discard);
 
@@ -191,7 +191,7 @@ xfs_free_extent(
        struct xfs_trans        *tp,
        xfs_fsblock_t           bno,
        xfs_extlen_t            len,
-       struct xfs_owner_info   *oinfo,
+       const struct xfs_owner_info     *oinfo,
        enum xfs_ag_resv_type   type)
 {
        return __xfs_free_extent(tp, bno, len, oinfo, type, false);
index 9c8c9107bb95beb0b5f557999cd33a162d25aca4..f2210d31deb9312078df80c9d6b1d8a3b20e41e5 100644 (file)
@@ -527,7 +527,7 @@ __xfs_bmap_add_free(
        struct xfs_trans                *tp,
        xfs_fsblock_t                   bno,
        xfs_filblks_t                   len,
-       struct xfs_owner_info           *oinfo,
+       const struct xfs_owner_info     *oinfo,
        bool                            skip_discard)
 {
        struct xfs_extent_free_item     *new;           /* new element */
index 488dc8860fd7c551b02e21eeae3462b96e268eb8..09d3ea97cc15a207cd9b6445ddab1372fc012146 100644 (file)
@@ -186,7 +186,7 @@ int xfs_bmap_add_attrfork(struct xfs_inode *ip, int size, int rsvd);
 int    xfs_bmap_set_attrforkoff(struct xfs_inode *ip, int size, int *version);
 void   xfs_bmap_local_to_extents_empty(struct xfs_inode *ip, int whichfork);
 void   __xfs_bmap_add_free(struct xfs_trans *tp, xfs_fsblock_t bno,
-               xfs_filblks_t len, struct xfs_owner_info *oinfo,
+               xfs_filblks_t len, const struct xfs_owner_info *oinfo,
                bool skip_discard);
 void   xfs_bmap_compute_maxlevels(struct xfs_mount *mp, int whichfork);
 int    xfs_bmap_first_unused(struct xfs_trans *tp, struct xfs_inode *ip,
@@ -234,7 +234,7 @@ xfs_bmap_add_free(
        struct xfs_trans                *tp,
        xfs_fsblock_t                   bno,
        xfs_filblks_t                   len,
-       struct xfs_owner_info           *oinfo)
+       const struct xfs_owner_info     *oinfo)
 {
        __xfs_bmap_add_free(tp, bno, len, oinfo, false);
 }
index 76f039d1ae88a0cf8e7d9150495c8ec65a39e1a5..ed5c7302c8cae6118229f7a7d31db6238740d28c 100644 (file)
@@ -456,21 +456,21 @@ out:
  */
 STATIC int
 xfs_rmap_unmap(
-       struct xfs_btree_cur    *cur,
-       xfs_agblock_t           bno,
-       xfs_extlen_t            len,
-       bool                    unwritten,
-       struct xfs_owner_info   *oinfo)
+       struct xfs_btree_cur            *cur,
+       xfs_agblock_t                   bno,
+       xfs_extlen_t                    len,
+       bool                            unwritten,
+       const struct xfs_owner_info     *oinfo)
 {
-       struct xfs_mount        *mp = cur->bc_mp;
-       struct xfs_rmap_irec    ltrec;
-       uint64_t                ltoff;
-       int                     error = 0;
-       int                     i;
-       uint64_t                owner;
-       uint64_t                offset;
-       unsigned int            flags;
-       bool                    ignore_off;
+       struct xfs_mount                *mp = cur->bc_mp;
+       struct xfs_rmap_irec            ltrec;
+       uint64_t                        ltoff;
+       int                             error = 0;
+       int                             i;
+       uint64_t                        owner;
+       uint64_t                        offset;
+       unsigned int                    flags;
+       bool                            ignore_off;
 
        xfs_owner_info_unpack(oinfo, &owner, &offset, &flags);
        ignore_off = XFS_RMAP_NON_INODE_OWNER(owner) ||
@@ -651,16 +651,16 @@ out_error:
  */
 int
 xfs_rmap_free(
-       struct xfs_trans        *tp,
-       struct xfs_buf          *agbp,
-       xfs_agnumber_t          agno,
-       xfs_agblock_t           bno,
-       xfs_extlen_t            len,
-       struct xfs_owner_info   *oinfo)
+       struct xfs_trans                *tp,
+       struct xfs_buf                  *agbp,
+       xfs_agnumber_t                  agno,
+       xfs_agblock_t                   bno,
+       xfs_extlen_t                    len,
+       const struct xfs_owner_info     *oinfo)
 {
-       struct xfs_mount        *mp = tp->t_mountp;
-       struct xfs_btree_cur    *cur;
-       int                     error;
+       struct xfs_mount                *mp = tp->t_mountp;
+       struct xfs_btree_cur            *cur;
+       int                             error;
 
        if (!xfs_sb_version_hasrmapbt(&mp->m_sb))
                return 0;
@@ -708,23 +708,23 @@ xfs_rmap_is_mergeable(
  */
 STATIC int
 xfs_rmap_map(
-       struct xfs_btree_cur    *cur,
-       xfs_agblock_t           bno,
-       xfs_extlen_t            len,
-       bool                    unwritten,
-       struct xfs_owner_info   *oinfo)
+       struct xfs_btree_cur            *cur,
+       xfs_agblock_t                   bno,
+       xfs_extlen_t                    len,
+       bool                            unwritten,
+       const struct xfs_owner_info     *oinfo)
 {
-       struct xfs_mount        *mp = cur->bc_mp;
-       struct xfs_rmap_irec    ltrec;
-       struct xfs_rmap_irec    gtrec;
-       int                     have_gt;
-       int                     have_lt;
-       int                     error = 0;
-       int                     i;
-       uint64_t                owner;
-       uint64_t                offset;
-       unsigned int            flags = 0;
-       bool                    ignore_off;
+       struct xfs_mount                *mp = cur->bc_mp;
+       struct xfs_rmap_irec            ltrec;
+       struct xfs_rmap_irec            gtrec;
+       int                             have_gt;
+       int                             have_lt;
+       int                             error = 0;
+       int                             i;
+       uint64_t                        owner;
+       uint64_t                        offset;
+       unsigned int                    flags = 0;
+       bool                            ignore_off;
 
        xfs_owner_info_unpack(oinfo, &owner, &offset, &flags);
        ASSERT(owner != 0);
@@ -888,16 +888,16 @@ out_error:
  */
 int
 xfs_rmap_alloc(
-       struct xfs_trans        *tp,
-       struct xfs_buf          *agbp,
-       xfs_agnumber_t          agno,
-       xfs_agblock_t           bno,
-       xfs_extlen_t            len,
-       struct xfs_owner_info   *oinfo)
+       struct xfs_trans                *tp,
+       struct xfs_buf                  *agbp,
+       xfs_agnumber_t                  agno,
+       xfs_agblock_t                   bno,
+       xfs_extlen_t                    len,
+       const struct xfs_owner_info     *oinfo)
 {
-       struct xfs_mount        *mp = tp->t_mountp;
-       struct xfs_btree_cur    *cur;
-       int                     error;
+       struct xfs_mount                *mp = tp->t_mountp;
+       struct xfs_btree_cur            *cur;
+       int                             error;
 
        if (!xfs_sb_version_hasrmapbt(&mp->m_sb))
                return 0;
@@ -927,16 +927,16 @@ xfs_rmap_alloc(
  */
 STATIC int
 xfs_rmap_convert(
-       struct xfs_btree_cur    *cur,
-       xfs_agblock_t           bno,
-       xfs_extlen_t            len,
-       bool                    unwritten,
-       struct xfs_owner_info   *oinfo)
+       struct xfs_btree_cur            *cur,
+       xfs_agblock_t                   bno,
+       xfs_extlen_t                    len,
+       bool                            unwritten,
+       const struct xfs_owner_info     *oinfo)
 {
-       struct xfs_mount        *mp = cur->bc_mp;
-       struct xfs_rmap_irec    r[4];   /* neighbor extent entries */
-                                       /* left is 0, right is 1, prev is 2 */
-                                       /* new is 3 */
+       struct xfs_mount                *mp = cur->bc_mp;
+       struct xfs_rmap_irec            r[4];   /* neighbor extent entries */
+                                               /* left is 0, right is 1, */
+                                               /* prev is 2, new is 3 */
        uint64_t                owner;
        uint64_t                offset;
        uint64_t                new_endoff;
@@ -1352,16 +1352,16 @@ done:
  */
 STATIC int
 xfs_rmap_convert_shared(
-       struct xfs_btree_cur    *cur,
-       xfs_agblock_t           bno,
-       xfs_extlen_t            len,
-       bool                    unwritten,
-       struct xfs_owner_info   *oinfo)
+       struct xfs_btree_cur            *cur,
+       xfs_agblock_t                   bno,
+       xfs_extlen_t                    len,
+       bool                            unwritten,
+       const struct xfs_owner_info     *oinfo)
 {
-       struct xfs_mount        *mp = cur->bc_mp;
-       struct xfs_rmap_irec    r[4];   /* neighbor extent entries */
-                                       /* left is 0, right is 1, prev is 2 */
-                                       /* new is 3 */
+       struct xfs_mount                *mp = cur->bc_mp;
+       struct xfs_rmap_irec            r[4];   /* neighbor extent entries */
+                                               /* left is 0, right is 1, */
+                                               /* prev is 2, new is 3 */
        uint64_t                owner;
        uint64_t                offset;
        uint64_t                new_endoff;
@@ -1741,20 +1741,20 @@ done:
  */
 STATIC int
 xfs_rmap_unmap_shared(
-       struct xfs_btree_cur    *cur,
-       xfs_agblock_t           bno,
-       xfs_extlen_t            len,
-       bool                    unwritten,
-       struct xfs_owner_info   *oinfo)
+       struct xfs_btree_cur            *cur,
+       xfs_agblock_t                   bno,
+       xfs_extlen_t                    len,
+       bool                            unwritten,
+       const struct xfs_owner_info     *oinfo)
 {
-       struct xfs_mount        *mp = cur->bc_mp;
-       struct xfs_rmap_irec    ltrec;
-       uint64_t                ltoff;
-       int                     error = 0;
-       int                     i;
-       uint64_t                owner;
-       uint64_t                offset;
-       unsigned int            flags;
+       struct xfs_mount                *mp = cur->bc_mp;
+       struct xfs_rmap_irec            ltrec;
+       uint64_t                        ltoff;
+       int                             error = 0;
+       int                             i;
+       uint64_t                        owner;
+       uint64_t                        offset;
+       unsigned int                    flags;
 
        xfs_owner_info_unpack(oinfo, &owner, &offset, &flags);
        if (unwritten)
@@ -1903,22 +1903,22 @@ out_error:
  */
 STATIC int
 xfs_rmap_map_shared(
-       struct xfs_btree_cur    *cur,
-       xfs_agblock_t           bno,
-       xfs_extlen_t            len,
-       bool                    unwritten,
-       struct xfs_owner_info   *oinfo)
+       struct xfs_btree_cur            *cur,
+       xfs_agblock_t                   bno,
+       xfs_extlen_t                    len,
+       bool                            unwritten,
+       const struct xfs_owner_info     *oinfo)
 {
-       struct xfs_mount        *mp = cur->bc_mp;
-       struct xfs_rmap_irec    ltrec;
-       struct xfs_rmap_irec    gtrec;
-       int                     have_gt;
-       int                     have_lt;
-       int                     error = 0;
-       int                     i;
-       uint64_t                owner;
-       uint64_t                offset;
-       unsigned int            flags = 0;
+       struct xfs_mount                *mp = cur->bc_mp;
+       struct xfs_rmap_irec            ltrec;
+       struct xfs_rmap_irec            gtrec;
+       int                             have_gt;
+       int                             have_lt;
+       int                             error = 0;
+       int                             i;
+       uint64_t                        owner;
+       uint64_t                        offset;
+       unsigned int                    flags = 0;
 
        xfs_owner_info_unpack(oinfo, &owner, &offset, &flags);
        if (unwritten)
@@ -2457,18 +2457,18 @@ xfs_rmap_has_record(
  */
 int
 xfs_rmap_record_exists(
-       struct xfs_btree_cur    *cur,
-       xfs_agblock_t           bno,
-       xfs_extlen_t            len,
-       struct xfs_owner_info   *oinfo,
-       bool                    *has_rmap)
+       struct xfs_btree_cur            *cur,
+       xfs_agblock_t                   bno,
+       xfs_extlen_t                    len,
+       const struct xfs_owner_info     *oinfo,
+       bool                            *has_rmap)
 {
-       uint64_t                owner;
-       uint64_t                offset;
-       unsigned int            flags;
-       int                     has_record;
-       struct xfs_rmap_irec    irec;
-       int                     error;
+       uint64_t                        owner;
+       uint64_t                        offset;
+       unsigned int                    flags;
+       int                             has_record;
+       struct xfs_rmap_irec            irec;
+       int                             error;
 
        xfs_owner_info_unpack(oinfo, &owner, &offset, &flags);
        ASSERT(XFS_RMAP_NON_INODE_OWNER(owner) ||
@@ -2528,7 +2528,7 @@ xfs_rmap_has_other_keys(
        struct xfs_btree_cur            *cur,
        xfs_agblock_t                   bno,
        xfs_extlen_t                    len,
-       struct xfs_owner_info           *oinfo,
+       const struct xfs_owner_info     *oinfo,
        bool                            *has_rmap)
 {
        struct xfs_rmap_irec            low = {0};
index 157dc722ad3513ac171d444c8154bbfa0254e616..6d32838aa184f0a9aae6be5b9c5d5ff1fe641dd5 100644 (file)
@@ -52,7 +52,7 @@ xfs_rmap_skip_owner_update(
 
 static inline bool
 xfs_rmap_should_skip_owner_update(
-       struct xfs_owner_info   *oi)
+       const struct xfs_owner_info     *oi)
 {
        return oi->oi_owner == XFS_RMAP_OWN_NULL;
 }
@@ -103,12 +103,12 @@ xfs_rmap_irec_offset_unpack(
 
 static inline void
 xfs_owner_info_unpack(
-       struct xfs_owner_info   *oinfo,
-       uint64_t                *owner,
-       uint64_t                *offset,
-       unsigned int            *flags)
+       const struct xfs_owner_info     *oinfo,
+       uint64_t                        *owner,
+       uint64_t                        *offset,
+       unsigned int                    *flags)
 {
-       unsigned int            r = 0;
+       unsigned int                    r = 0;
 
        *owner = oinfo->oi_owner;
        *offset = oinfo->oi_offset;
@@ -137,10 +137,10 @@ xfs_owner_info_pack(
 
 int xfs_rmap_alloc(struct xfs_trans *tp, struct xfs_buf *agbp,
                   xfs_agnumber_t agno, xfs_agblock_t bno, xfs_extlen_t len,
-                  struct xfs_owner_info *oinfo);
+                  const struct xfs_owner_info *oinfo);
 int xfs_rmap_free(struct xfs_trans *tp, struct xfs_buf *agbp,
                  xfs_agnumber_t agno, xfs_agblock_t bno, xfs_extlen_t len,
-                 struct xfs_owner_info *oinfo);
+                 const struct xfs_owner_info *oinfo);
 
 int xfs_rmap_lookup_le(struct xfs_btree_cur *cur, xfs_agblock_t bno,
                xfs_extlen_t len, uint64_t owner, uint64_t offset,
@@ -218,10 +218,10 @@ int xfs_rmap_btrec_to_irec(union xfs_btree_rec *rec,
 int xfs_rmap_has_record(struct xfs_btree_cur *cur, xfs_agblock_t bno,
                xfs_extlen_t len, bool *exists);
 int xfs_rmap_record_exists(struct xfs_btree_cur *cur, xfs_agblock_t bno,
-               xfs_extlen_t len, struct xfs_owner_info *oinfo,
+               xfs_extlen_t len, const struct xfs_owner_info *oinfo,
                bool *has_rmap);
 int xfs_rmap_has_other_keys(struct xfs_btree_cur *cur, xfs_agblock_t bno,
-               xfs_extlen_t len, struct xfs_owner_info *oinfo,
+               xfs_extlen_t len, const struct xfs_owner_info *oinfo,
                bool *has_rmap);
 int xfs_rmap_map_raw(struct xfs_btree_cur *cur, struct xfs_rmap_irec *rmap);