Skip to content

Commit 980faec

Browse files
author
Darrick J. Wong
committed
xfs: convert "skip_discard" to a proper flags bitset
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 <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent 4e0e2c0 commit 980faec

File tree

12 files changed

+39
-28
lines changed

12 files changed

+39
-28
lines changed

fs/xfs/libxfs/xfs_ag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ xfs_ag_shrink_space(
10081008
goto resv_err;
10091009

10101010
err2 = xfs_free_extent_later(*tpp, args.fsbno, delta, NULL,
1011-
XFS_AG_RESV_NONE, true);
1011+
XFS_AG_RESV_NONE, XFS_FREE_EXTENT_SKIP_DISCARD);
10121012
if (err2)
10131013
goto resv_err;
10141014

fs/xfs/libxfs/xfs_alloc.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,7 +2562,7 @@ xfs_defer_extent_free(
25622562
xfs_filblks_t len,
25632563
const struct xfs_owner_info *oinfo,
25642564
enum xfs_ag_resv_type type,
2565-
bool skip_discard,
2565+
unsigned int free_flags,
25662566
struct xfs_defer_pending **dfpp)
25672567
{
25682568
struct xfs_extent_free_item *xefi;
@@ -2582,6 +2582,7 @@ xfs_defer_extent_free(
25822582
ASSERT(len < mp->m_sb.sb_agblocks);
25832583
ASSERT(agbno + len <= mp->m_sb.sb_agblocks);
25842584
#endif
2585+
ASSERT(!(free_flags & ~XFS_FREE_EXTENT_ALL_FLAGS));
25852586
ASSERT(xfs_extfree_item_cache != NULL);
25862587
ASSERT(type != XFS_AG_RESV_AGFL);
25872588

@@ -2593,7 +2594,7 @@ xfs_defer_extent_free(
25932594
xefi->xefi_startblock = bno;
25942595
xefi->xefi_blockcount = (xfs_extlen_t)len;
25952596
xefi->xefi_agresv = type;
2596-
if (skip_discard)
2597+
if (free_flags & XFS_FREE_EXTENT_SKIP_DISCARD)
25972598
xefi->xefi_flags |= XFS_EFI_SKIP_DISCARD;
25982599
if (oinfo) {
25992600
ASSERT(oinfo->oi_offset == 0);
@@ -2621,11 +2622,11 @@ xfs_free_extent_later(
26212622
xfs_filblks_t len,
26222623
const struct xfs_owner_info *oinfo,
26232624
enum xfs_ag_resv_type type,
2624-
bool skip_discard)
2625+
unsigned int free_flags)
26252626
{
26262627
struct xfs_defer_pending *dontcare = NULL;
26272628

2628-
return xfs_defer_extent_free(tp, bno, len, oinfo, type, skip_discard,
2629+
return xfs_defer_extent_free(tp, bno, len, oinfo, type, free_flags,
26292630
&dontcare);
26302631
}
26312632

@@ -2650,13 +2651,13 @@ xfs_free_extent_later(
26502651
int
26512652
xfs_alloc_schedule_autoreap(
26522653
const struct xfs_alloc_arg *args,
2653-
bool skip_discard,
2654+
unsigned int free_flags,
26542655
struct xfs_alloc_autoreap *aarp)
26552656
{
26562657
int error;
26572658

26582659
error = xfs_defer_extent_free(args->tp, args->fsbno, args->len,
2659-
&args->oinfo, args->resv, skip_discard, &aarp->dfp);
2660+
&args->oinfo, args->resv, free_flags, &aarp->dfp);
26602661
if (error)
26612662
return error;
26622663

fs/xfs/libxfs/xfs_alloc.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,12 @@ xfs_buf_to_agfl_bno(
235235

236236
int xfs_free_extent_later(struct xfs_trans *tp, xfs_fsblock_t bno,
237237
xfs_filblks_t len, const struct xfs_owner_info *oinfo,
238-
enum xfs_ag_resv_type type, bool skip_discard);
238+
enum xfs_ag_resv_type type, unsigned int free_flags);
239+
240+
/* Don't issue a discard for the blocks freed. */
241+
#define XFS_FREE_EXTENT_SKIP_DISCARD (1U << 0)
242+
243+
#define XFS_FREE_EXTENT_ALL_FLAGS (XFS_FREE_EXTENT_SKIP_DISCARD)
239244

240245
/*
241246
* List of extents to be free "later".
@@ -264,7 +269,7 @@ struct xfs_alloc_autoreap {
264269
};
265270

266271
int xfs_alloc_schedule_autoreap(const struct xfs_alloc_arg *args,
267-
bool skip_discard, struct xfs_alloc_autoreap *aarp);
272+
unsigned int free_flags, struct xfs_alloc_autoreap *aarp);
268273
void xfs_alloc_cancel_autoreap(struct xfs_trans *tp,
269274
struct xfs_alloc_autoreap *aarp);
270275
void xfs_alloc_commit_autoreap(struct xfs_trans *tp,

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ xfs_bmap_btree_to_extents(
605605

606606
xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, whichfork);
607607
error = xfs_free_extent_later(cur->bc_tp, cbno, 1, &oinfo,
608-
XFS_AG_RESV_NONE, false);
608+
XFS_AG_RESV_NONE, 0);
609609
if (error)
610610
return error;
611611

@@ -5381,11 +5381,15 @@ xfs_bmap_del_extent_real(
53815381
error = xfs_rtfree_blocks(tp, del->br_startblock,
53825382
del->br_blockcount);
53835383
} else {
5384+
unsigned int efi_flags = 0;
5385+
5386+
if ((bflags & XFS_BMAPI_NODISCARD) ||
5387+
del->br_state == XFS_EXT_UNWRITTEN)
5388+
efi_flags |= XFS_FREE_EXTENT_SKIP_DISCARD;
5389+
53845390
error = xfs_free_extent_later(tp, del->br_startblock,
53855391
del->br_blockcount, NULL,
5386-
XFS_AG_RESV_NONE,
5387-
((bflags & XFS_BMAPI_NODISCARD) ||
5388-
del->br_state == XFS_EXT_UNWRITTEN));
5392+
XFS_AG_RESV_NONE, efi_flags);
53895393
}
53905394
if (error)
53915395
return error;

fs/xfs/libxfs/xfs_bmap_btree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ xfs_bmbt_free_block(
282282

283283
xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, cur->bc_ino.whichfork);
284284
error = xfs_free_extent_later(cur->bc_tp, fsbno, 1, &oinfo,
285-
XFS_AG_RESV_NONE, false);
285+
XFS_AG_RESV_NONE, 0);
286286
if (error)
287287
return error;
288288

fs/xfs/libxfs/xfs_ialloc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,7 +1990,7 @@ xfs_difree_inode_chunk(
19901990
return xfs_free_extent_later(tp,
19911991
XFS_AGB_TO_FSB(mp, agno, sagbno),
19921992
M_IGEO(mp)->ialloc_blks, &XFS_RMAP_OINFO_INODES,
1993-
XFS_AG_RESV_NONE, false);
1993+
XFS_AG_RESV_NONE, 0);
19941994
}
19951995

19961996
/* holemask is only 16-bits (fits in an unsigned long) */
@@ -2036,8 +2036,7 @@ xfs_difree_inode_chunk(
20362036
ASSERT(contigblk % mp->m_sb.sb_spino_align == 0);
20372037
error = xfs_free_extent_later(tp,
20382038
XFS_AGB_TO_FSB(mp, agno, agbno), contigblk,
2039-
&XFS_RMAP_OINFO_INODES, XFS_AG_RESV_NONE,
2040-
false);
2039+
&XFS_RMAP_OINFO_INODES, XFS_AG_RESV_NONE, 0);
20412040
if (error)
20422041
return error;
20432042

fs/xfs/libxfs/xfs_ialloc_btree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ __xfs_inobt_free_block(
170170
xfs_inobt_mod_blockcount(cur, -1);
171171
fsbno = XFS_DADDR_TO_FSB(cur->bc_mp, xfs_buf_daddr(bp));
172172
return xfs_free_extent_later(cur->bc_tp, fsbno, 1,
173-
&XFS_RMAP_OINFO_INOBT, resv, false);
173+
&XFS_RMAP_OINFO_INOBT, resv, 0);
174174
}
175175

176176
STATIC int

fs/xfs/libxfs/xfs_refcount.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,7 @@ xfs_refcount_adjust_extents(
11731173
tmp.rc_startblock);
11741174
error = xfs_free_extent_later(cur->bc_tp, fsbno,
11751175
tmp.rc_blockcount, NULL,
1176-
XFS_AG_RESV_NONE, false);
1176+
XFS_AG_RESV_NONE, 0);
11771177
if (error)
11781178
goto out_error;
11791179
}
@@ -1237,7 +1237,7 @@ xfs_refcount_adjust_extents(
12371237
ext.rc_startblock);
12381238
error = xfs_free_extent_later(cur->bc_tp, fsbno,
12391239
ext.rc_blockcount, NULL,
1240-
XFS_AG_RESV_NONE, false);
1240+
XFS_AG_RESV_NONE, 0);
12411241
if (error)
12421242
goto out_error;
12431243
}
@@ -2022,7 +2022,7 @@ xfs_refcount_recover_cow_leftovers(
20222022
/* Free the block. */
20232023
error = xfs_free_extent_later(tp, fsb,
20242024
rr->rr_rrec.rc_blockcount, NULL,
2025-
XFS_AG_RESV_NONE, false);
2025+
XFS_AG_RESV_NONE, 0);
20262026
if (error)
20272027
goto out_trans;
20282028

fs/xfs/libxfs/xfs_refcount_btree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ xfs_refcountbt_free_block(
109109
be32_add_cpu(&agf->agf_refcount_blocks, -1);
110110
xfs_alloc_log_agf(cur->bc_tp, agbp, XFS_AGF_REFCOUNT_BLOCKS);
111111
return xfs_free_extent_later(cur->bc_tp, fsbno, 1,
112-
&XFS_RMAP_OINFO_REFC, XFS_AG_RESV_METADATA, false);
112+
&XFS_RMAP_OINFO_REFC, XFS_AG_RESV_METADATA, 0);
113113
}
114114

115115
STATIC int

fs/xfs/scrub/newbt.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ xrep_newbt_add_blocks(
160160
if (args->tp) {
161161
ASSERT(xnr->oinfo.oi_offset == 0);
162162

163-
error = xfs_alloc_schedule_autoreap(args, true, &resv->autoreap);
163+
error = xfs_alloc_schedule_autoreap(args,
164+
XFS_FREE_EXTENT_SKIP_DISCARD, &resv->autoreap);
164165
if (error)
165166
goto out_pag;
166167
}
@@ -414,7 +415,7 @@ xrep_newbt_free_extent(
414415
*/
415416
fsbno = XFS_AGB_TO_FSB(sc->mp, resv->pag->pag_agno, free_agbno);
416417
error = xfs_free_extent_later(sc->tp, fsbno, free_aglen, &xnr->oinfo,
417-
xnr->resv, true);
418+
xnr->resv, XFS_FREE_EXTENT_SKIP_DISCARD);
418419
if (error)
419420
return error;
420421

0 commit comments

Comments
 (0)