]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs: convert "skip_discard" to a proper flags bitset
authorDarrick J. Wong <djwong@kernel.org>
Tue, 7 Mar 2023 03:55:41 +0000 (19:55 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 22 Nov 2023 23:03:36 +0000 (15:03 -0800)
Convert the boolean to skip discard on free into a proper flags field so
that we can add more flags in the next patch.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
libxfs/xfs_ag.c
libxfs/xfs_alloc.c
libxfs/xfs_alloc.h
libxfs/xfs_bmap.c
libxfs/xfs_bmap_btree.c
libxfs/xfs_ialloc.c
libxfs/xfs_ialloc_btree.c
libxfs/xfs_refcount.c
libxfs/xfs_refcount_btree.c
repair/bulkload.c

index f22d58ad04063e31f9ba610b1d0d773843050995..ac6b0090825739e57339e813578a78b39021d320 100644 (file)
@@ -978,7 +978,7 @@ xfs_ag_shrink_space(
                        goto resv_err;
 
                err2 = xfs_free_extent_later(*tpp, args.fsbno, delta, NULL,
-                               XFS_AG_RESV_NONE, true);
+                               XFS_AG_RESV_NONE, XFS_FREE_EXTENT_SKIP_DISCARD);
                if (err2)
                        goto resv_err;
 
index 9ae30c8f1e6278733d507110c28ae3eb1ec2eb4a..ea026936bebffe27451875d8d431e5ffae1981ca 100644 (file)
@@ -2595,7 +2595,7 @@ xfs_defer_extent_free(
        xfs_filblks_t                   len,
        const struct xfs_owner_info     *oinfo,
        enum xfs_ag_resv_type           type,
-       bool                            skip_discard,
+       unsigned int                    free_flags,
        struct xfs_defer_pending        **dfpp)
 {
        struct xfs_extent_free_item     *xefi;
@@ -2615,6 +2615,7 @@ xfs_defer_extent_free(
        ASSERT(len < mp->m_sb.sb_agblocks);
        ASSERT(agbno + len <= mp->m_sb.sb_agblocks);
 #endif
+       ASSERT(!(free_flags & ~XFS_FREE_EXTENT_ALL_FLAGS));
        ASSERT(xfs_extfree_item_cache != NULL);
        ASSERT(type != XFS_AG_RESV_AGFL);
 
@@ -2626,7 +2627,7 @@ xfs_defer_extent_free(
        xefi->xefi_startblock = bno;
        xefi->xefi_blockcount = (xfs_extlen_t)len;
        xefi->xefi_agresv = type;
-       if (skip_discard)
+       if (free_flags & XFS_FREE_EXTENT_SKIP_DISCARD)
                xefi->xefi_flags |= XFS_EFI_SKIP_DISCARD;
        if (oinfo) {
                ASSERT(oinfo->oi_offset == 0);
@@ -2654,11 +2655,11 @@ xfs_free_extent_later(
        xfs_filblks_t                   len,
        const struct xfs_owner_info     *oinfo,
        enum xfs_ag_resv_type           type,
-       bool                            skip_discard)
+       unsigned int                    free_flags)
 {
        struct xfs_defer_pending        *dontcare = NULL;
 
-       return xfs_defer_extent_free(tp, bno, len, oinfo, type, skip_discard,
+       return xfs_defer_extent_free(tp, bno, len, oinfo, type, free_flags,
                        &dontcare);
 }
 
@@ -2683,13 +2684,13 @@ xfs_free_extent_later(
 int
 xfs_alloc_schedule_autoreap(
        const struct xfs_alloc_arg      *args,
-       bool                            skip_discard,
+       unsigned int                    free_flags,
        struct xfs_alloc_autoreap       *aarp)
 {
        int                             error;
 
        error = xfs_defer_extent_free(args->tp, args->fsbno, args->len,
-                       &args->oinfo, args->resv, skip_discard, &aarp->dfp);
+                       &args->oinfo, args->resv, free_flags, &aarp->dfp);
        if (error)
                return error;
 
index 68ffe058a420f1e5a3385fe6cdf9e0ecd6afab93..59914e78ae50889983d46c7fe08c8325c7e66de3 100644 (file)
@@ -235,7 +235,12 @@ xfs_buf_to_agfl_bno(
 
 int xfs_free_extent_later(struct xfs_trans *tp, xfs_fsblock_t bno,
                xfs_filblks_t len, const struct xfs_owner_info *oinfo,
-               enum xfs_ag_resv_type type, bool skip_discard);
+               enum xfs_ag_resv_type type, unsigned int free_flags);
+
+/* Don't issue a discard for the blocks freed. */
+#define XFS_FREE_EXTENT_SKIP_DISCARD   (1U << 0)
+
+#define XFS_FREE_EXTENT_ALL_FLAGS      (XFS_FREE_EXTENT_SKIP_DISCARD)
 
 /*
  * List of extents to be free "later".
@@ -264,7 +269,7 @@ struct xfs_alloc_autoreap {
 };
 
 int xfs_alloc_schedule_autoreap(const struct xfs_alloc_arg *args,
-               bool skip_discard, struct xfs_alloc_autoreap *aarp);
+               unsigned int free_flags, struct xfs_alloc_autoreap *aarp);
 void xfs_alloc_cancel_autoreap(struct xfs_trans *tp,
                struct xfs_alloc_autoreap *aarp);
 void xfs_alloc_commit_autoreap(struct xfs_trans *tp,
index 6b4e9ae62c0f4f45711e7aaebb2b7d4f64531453..0f365723774b80df43a0b496a9c1ae321e2af008 100644 (file)
@@ -582,7 +582,7 @@ xfs_bmap_btree_to_extents(
 
        xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, whichfork);
        error = xfs_free_extent_later(cur->bc_tp, cbno, 1, &oinfo,
-                       XFS_AG_RESV_NONE, false);
+                       XFS_AG_RESV_NONE, 0);
        if (error)
                return error;
 
@@ -5265,11 +5265,15 @@ xfs_bmap_del_extent_real(
                if (xfs_is_reflink_inode(ip) && whichfork == XFS_DATA_FORK) {
                        xfs_refcount_decrease_extent(tp, del);
                } else {
+                       unsigned int    efi_flags = 0;
+
+                       if ((bflags & XFS_BMAPI_NODISCARD) ||
+                           del->br_state == XFS_EXT_UNWRITTEN)
+                               efi_flags |= XFS_FREE_EXTENT_SKIP_DISCARD;
+
                        error = xfs_free_extent_later(tp, del->br_startblock,
                                        del->br_blockcount, NULL,
-                                       XFS_AG_RESV_NONE,
-                                       ((bflags & XFS_BMAPI_NODISCARD) ||
-                                       del->br_state == XFS_EXT_UNWRITTEN));
+                                       XFS_AG_RESV_NONE, efi_flags);
                        if (error)
                                goto done;
                }
index f2ba117d9374c1969037122be716b0cdbaabe532..8cdbb97f92240d530c70ebb5579d85e856f4bf0b 100644 (file)
@@ -269,7 +269,7 @@ xfs_bmbt_free_block(
 
        xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, cur->bc_ino.whichfork);
        error = xfs_free_extent_later(cur->bc_tp, fsbno, 1, &oinfo,
-                       XFS_AG_RESV_NONE, false);
+                       XFS_AG_RESV_NONE, 0);
        if (error)
                return error;
 
index ae272393b05f1c9e7a28f824449387295a0f5ba8..49c13dd4c6b970af0f6b7424e7105dbc32db30d9 100644 (file)
@@ -1970,7 +1970,7 @@ xfs_difree_inode_chunk(
                return xfs_free_extent_later(tp,
                                XFS_AGB_TO_FSB(mp, agno, sagbno),
                                M_IGEO(mp)->ialloc_blks, &XFS_RMAP_OINFO_INODES,
-                               XFS_AG_RESV_NONE, false);
+                               XFS_AG_RESV_NONE, 0);
        }
 
        /* holemask is only 16-bits (fits in an unsigned long) */
@@ -2016,8 +2016,7 @@ xfs_difree_inode_chunk(
                ASSERT(contigblk % mp->m_sb.sb_spino_align == 0);
                error = xfs_free_extent_later(tp,
                                XFS_AGB_TO_FSB(mp, agno, agbno), contigblk,
-                               &XFS_RMAP_OINFO_INODES, XFS_AG_RESV_NONE,
-                               false);
+                               &XFS_RMAP_OINFO_INODES, XFS_AG_RESV_NONE, 0);
                if (error)
                        return error;
 
index 80d28d3fea5214df42ab28ba66edbf796c9a1a6d..a5f2ccec2e99e5b135734a195925d2d209217ae7 100644 (file)
@@ -160,7 +160,7 @@ __xfs_inobt_free_block(
        xfs_inobt_mod_blockcount(cur, -1);
        fsbno = XFS_DADDR_TO_FSB(cur->bc_mp, xfs_buf_daddr(bp));
        return xfs_free_extent_later(cur->bc_tp, fsbno, 1,
-                       &XFS_RMAP_OINFO_INOBT, resv, false);
+                       &XFS_RMAP_OINFO_INOBT, resv, 0);
 }
 
 STATIC int
index e739dc870facda53965e9c58d51d2f616d3bdbc2..b4f0179e1a40ba972939ad5521cb7a10c78d7726 100644 (file)
@@ -1180,7 +1180,7 @@ xfs_refcount_adjust_extents(
                                                tmp.rc_startblock);
                                error = xfs_free_extent_later(cur->bc_tp, fsbno,
                                                  tmp.rc_blockcount, NULL,
-                                                 XFS_AG_RESV_NONE, false);
+                                                 XFS_AG_RESV_NONE, 0);
                                if (error)
                                        goto out_error;
                        }
@@ -1244,7 +1244,7 @@ xfs_refcount_adjust_extents(
                                        ext.rc_startblock);
                        error = xfs_free_extent_later(cur->bc_tp, fsbno,
                                        ext.rc_blockcount, NULL,
-                                       XFS_AG_RESV_NONE, false);
+                                       XFS_AG_RESV_NONE, 0);
                        if (error)
                                goto out_error;
                }
@@ -2029,7 +2029,7 @@ xfs_refcount_recover_cow_leftovers(
                /* Free the block. */
                error = xfs_free_extent_later(tp, fsb,
                                rr->rr_rrec.rc_blockcount, NULL,
-                               XFS_AG_RESV_NONE, false);
+                               XFS_AG_RESV_NONE, 0);
                if (error)
                        goto out_trans;
 
index 70cf92324692a22adbb09190f60fdc942094528b..d2452932b3f1adb9fcdc6104f15b923091f33d18 100644 (file)
@@ -107,7 +107,7 @@ xfs_refcountbt_free_block(
        be32_add_cpu(&agf->agf_refcount_blocks, -1);
        xfs_alloc_log_agf(cur->bc_tp, agbp, XFS_AGF_REFCOUNT_BLOCKS);
        return xfs_free_extent_later(cur->bc_tp, fsbno, 1,
-                       &XFS_RMAP_OINFO_REFC, XFS_AG_RESV_METADATA, false);
+                       &XFS_RMAP_OINFO_REFC, XFS_AG_RESV_METADATA, 0);
 }
 
 STATIC int
index e82747d8cfdbbf4494dd27b23a6868b191f2837d..a3c0a2ae71e845eb6218f0e0057385ada7cab535 100644 (file)
@@ -197,7 +197,8 @@ free:
         */
        fsbno = XFS_AGB_TO_FSB(sc->mp, resv->pag->pag_agno, free_agbno);
        error = -libxfs_free_extent_later(sc->tp, fsbno, free_aglen,
-                       &bkl->oinfo, XFS_AG_RESV_NONE, true);
+                       &bkl->oinfo, XFS_AG_RESV_NONE,
+                       XFS_FREE_EXTENT_SKIP_DISCARD);
        if (error)
                return error;