aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/libxfs
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2018-12-12 11:46:23 -0500
committerDarrick J. Wong <darrick.wong@oracle.com>2018-12-12 11:47:16 -0500
commit7280fedaf3a0f9097c0621c7d5b35849954d7f54 (patch)
treea454c99dfb864a35505fed5744a09a0048db9493 /fs/xfs/libxfs
parent66e3237e724c6650dca03627b40bb00a812d3f7a (diff)
xfs: remove xfs_rmap_ag_owner and friends
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>
Diffstat (limited to 'fs/xfs/libxfs')
-rw-r--r--fs/xfs/libxfs/xfs_ag.c9
-rw-r--r--fs/xfs/libxfs/xfs_alloc.c9
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c4
-rw-r--r--fs/xfs/libxfs/xfs_ialloc.c8
-rw-r--r--fs/xfs/libxfs/xfs_ialloc_btree.c7
-rw-r--r--fs/xfs/libxfs/xfs_refcount_btree.c6
-rw-r--r--fs/xfs/libxfs/xfs_rmap.c28
-rw-r--r--fs/xfs/libxfs/xfs_rmap.h34
8 files changed, 55 insertions, 50 deletions
diff --git a/fs/xfs/libxfs/xfs_ag.c b/fs/xfs/libxfs/xfs_ag.c
index 9345802c99f7..999ad8d00d43 100644
--- a/fs/xfs/libxfs/xfs_ag.c
+++ b/fs/xfs/libxfs/xfs_ag.c
@@ -414,7 +414,6 @@ xfs_ag_extend_space(
414 struct aghdr_init_data *id, 414 struct aghdr_init_data *id,
415 xfs_extlen_t len) 415 xfs_extlen_t len)
416{ 416{
417 struct xfs_owner_info oinfo;
418 struct xfs_buf *bp; 417 struct xfs_buf *bp;
419 struct xfs_agi *agi; 418 struct xfs_agi *agi;
420 struct xfs_agf *agf; 419 struct xfs_agf *agf;
@@ -448,17 +447,17 @@ xfs_ag_extend_space(
448 /* 447 /*
449 * Free the new space. 448 * Free the new space.
450 * 449 *
451 * XFS_RMAP_OWN_NULL is used here to tell the rmap btree that 450 * XFS_RMAP_OINFO_SKIP_UPDATE is used here to tell the rmap btree that
452 * this doesn't actually exist in the rmap btree. 451 * this doesn't actually exist in the rmap btree.
453 */ 452 */
454 xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_NULL);
455 error = xfs_rmap_free(tp, bp, id->agno, 453 error = xfs_rmap_free(tp, bp, id->agno,
456 be32_to_cpu(agf->agf_length) - len, 454 be32_to_cpu(agf->agf_length) - len,
457 len, &oinfo); 455 len, &XFS_RMAP_OINFO_SKIP_UPDATE);
458 if (error) 456 if (error)
459 return error; 457 return error;
460 458
461 return xfs_free_extent(tp, XFS_AGB_TO_FSB(mp, id->agno, 459 return xfs_free_extent(tp, XFS_AGB_TO_FSB(mp, id->agno,
462 be32_to_cpu(agf->agf_length) - len), 460 be32_to_cpu(agf->agf_length) - len),
463 len, &oinfo, XFS_AG_RESV_NONE); 461 len, &XFS_RMAP_OINFO_SKIP_UPDATE,
462 XFS_AG_RESV_NONE);
464} 463}
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index e9eb4b2768f2..b715668886a4 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -1594,7 +1594,6 @@ xfs_alloc_ag_vextent_small(
1594 xfs_extlen_t *flenp, /* result length */ 1594 xfs_extlen_t *flenp, /* result length */
1595 int *stat) /* status: 0-freelist, 1-normal/none */ 1595 int *stat) /* status: 0-freelist, 1-normal/none */
1596{ 1596{
1597 struct xfs_owner_info oinfo;
1598 int error; 1597 int error;
1599 xfs_agblock_t fbno; 1598 xfs_agblock_t fbno;
1600 xfs_extlen_t flen; 1599 xfs_extlen_t flen;
@@ -1648,9 +1647,8 @@ xfs_alloc_ag_vextent_small(
1648 * doesn't live in the free space, we need to clear 1647 * doesn't live in the free space, we need to clear
1649 * out the OWN_AG rmap. 1648 * out the OWN_AG rmap.
1650 */ 1649 */
1651 xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_AG);
1652 error = xfs_rmap_free(args->tp, args->agbp, args->agno, 1650 error = xfs_rmap_free(args->tp, args->agbp, args->agno,
1653 fbno, 1, &oinfo); 1651 fbno, 1, &XFS_RMAP_OINFO_AG);
1654 if (error) 1652 if (error)
1655 goto error0; 1653 goto error0;
1656 1654
@@ -2314,10 +2312,11 @@ xfs_alloc_fix_freelist(
2314 * repair/rmap.c in xfsprogs for details. 2312 * repair/rmap.c in xfsprogs for details.
2315 */ 2313 */
2316 memset(&targs, 0, sizeof(targs)); 2314 memset(&targs, 0, sizeof(targs));
2315 /* struct copy below */
2317 if (flags & XFS_ALLOC_FLAG_NORMAP) 2316 if (flags & XFS_ALLOC_FLAG_NORMAP)
2318 xfs_rmap_skip_owner_update(&targs.oinfo); 2317 targs.oinfo = XFS_RMAP_OINFO_SKIP_UPDATE;
2319 else 2318 else
2320 xfs_rmap_ag_owner(&targs.oinfo, XFS_RMAP_OWN_AG); 2319 targs.oinfo = XFS_RMAP_OINFO_AG;
2321 while (!(flags & XFS_ALLOC_FLAG_NOSHRINK) && pag->pagf_flcount > need) { 2320 while (!(flags & XFS_ALLOC_FLAG_NOSHRINK) && pag->pagf_flcount > need) {
2322 error = xfs_alloc_get_freelist(tp, agbp, &bno, 0); 2321 error = xfs_alloc_get_freelist(tp, agbp, &bno, 0);
2323 if (error) 2322 if (error)
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index d5672ab58b1f..332eefa2700b 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -564,7 +564,7 @@ __xfs_bmap_add_free(
564 if (oinfo) 564 if (oinfo)
565 new->xefi_oinfo = *oinfo; 565 new->xefi_oinfo = *oinfo;
566 else 566 else
567 xfs_rmap_skip_owner_update(&new->xefi_oinfo); 567 new->xefi_oinfo = XFS_RMAP_OINFO_SKIP_UPDATE;
568 new->xefi_skip_discard = skip_discard; 568 new->xefi_skip_discard = skip_discard;
569 trace_xfs_bmap_free_defer(tp->t_mountp, 569 trace_xfs_bmap_free_defer(tp->t_mountp,
570 XFS_FSB_TO_AGNO(tp->t_mountp, bno), 0, 570 XFS_FSB_TO_AGNO(tp->t_mountp, bno), 0,
@@ -3453,7 +3453,7 @@ xfs_bmap_btalloc(
3453 args.tp = ap->tp; 3453 args.tp = ap->tp;
3454 args.mp = mp; 3454 args.mp = mp;
3455 args.fsbno = ap->blkno; 3455 args.fsbno = ap->blkno;
3456 xfs_rmap_skip_owner_update(&args.oinfo); 3456 args.oinfo = XFS_RMAP_OINFO_SKIP_UPDATE;
3457 3457
3458 /* Trim the allocation back to the maximum an AG can fit. */ 3458 /* Trim the allocation back to the maximum an AG can fit. */
3459 args.maxlen = min(ap->length, mp->m_ag_max_usable); 3459 args.maxlen = min(ap->length, mp->m_ag_max_usable);
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index a8f6db735d5d..fcf0d17405d8 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -641,7 +641,7 @@ xfs_ialloc_ag_alloc(
641 args.tp = tp; 641 args.tp = tp;
642 args.mp = tp->t_mountp; 642 args.mp = tp->t_mountp;
643 args.fsbno = NULLFSBLOCK; 643 args.fsbno = NULLFSBLOCK;
644 xfs_rmap_ag_owner(&args.oinfo, XFS_RMAP_OWN_INODES); 644 args.oinfo = XFS_RMAP_OINFO_INODES;
645 645
646#ifdef DEBUG 646#ifdef DEBUG
647 /* randomly do sparse inode allocations */ 647 /* randomly do sparse inode allocations */
@@ -1849,14 +1849,12 @@ xfs_difree_inode_chunk(
1849 int nextbit; 1849 int nextbit;
1850 xfs_agblock_t agbno; 1850 xfs_agblock_t agbno;
1851 int contigblk; 1851 int contigblk;
1852 struct xfs_owner_info oinfo;
1853 DECLARE_BITMAP(holemask, XFS_INOBT_HOLEMASK_BITS); 1852 DECLARE_BITMAP(holemask, XFS_INOBT_HOLEMASK_BITS);
1854 xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_INODES);
1855 1853
1856 if (!xfs_inobt_issparse(rec->ir_holemask)) { 1854 if (!xfs_inobt_issparse(rec->ir_holemask)) {
1857 /* not sparse, calculate extent info directly */ 1855 /* not sparse, calculate extent info directly */
1858 xfs_bmap_add_free(tp, XFS_AGB_TO_FSB(mp, agno, sagbno), 1856 xfs_bmap_add_free(tp, XFS_AGB_TO_FSB(mp, agno, sagbno),
1859 mp->m_ialloc_blks, &oinfo); 1857 mp->m_ialloc_blks, &XFS_RMAP_OINFO_INODES);
1860 return; 1858 return;
1861 } 1859 }
1862 1860
@@ -1900,7 +1898,7 @@ xfs_difree_inode_chunk(
1900 ASSERT(agbno % mp->m_sb.sb_spino_align == 0); 1898 ASSERT(agbno % mp->m_sb.sb_spino_align == 0);
1901 ASSERT(contigblk % mp->m_sb.sb_spino_align == 0); 1899 ASSERT(contigblk % mp->m_sb.sb_spino_align == 0);
1902 xfs_bmap_add_free(tp, XFS_AGB_TO_FSB(mp, agno, agbno), 1900 xfs_bmap_add_free(tp, XFS_AGB_TO_FSB(mp, agno, agbno),
1903 contigblk, &oinfo); 1901 contigblk, &XFS_RMAP_OINFO_INODES);
1904 1902
1905 /* reset range to current bit and carry on... */ 1903 /* reset range to current bit and carry on... */
1906 startidx = endidx = nextbit; 1904 startidx = endidx = nextbit;
diff --git a/fs/xfs/libxfs/xfs_ialloc_btree.c b/fs/xfs/libxfs/xfs_ialloc_btree.c
index 7fbf8af0b159..9b25e7a0df47 100644
--- a/fs/xfs/libxfs/xfs_ialloc_btree.c
+++ b/fs/xfs/libxfs/xfs_ialloc_btree.c
@@ -84,7 +84,7 @@ __xfs_inobt_alloc_block(
84 memset(&args, 0, sizeof(args)); 84 memset(&args, 0, sizeof(args));
85 args.tp = cur->bc_tp; 85 args.tp = cur->bc_tp;
86 args.mp = cur->bc_mp; 86 args.mp = cur->bc_mp;
87 xfs_rmap_ag_owner(&args.oinfo, XFS_RMAP_OWN_INOBT); 87 args.oinfo = XFS_RMAP_OINFO_INOBT;
88 args.fsbno = XFS_AGB_TO_FSB(args.mp, cur->bc_private.a.agno, sbno); 88 args.fsbno = XFS_AGB_TO_FSB(args.mp, cur->bc_private.a.agno, sbno);
89 args.minlen = 1; 89 args.minlen = 1;
90 args.maxlen = 1; 90 args.maxlen = 1;
@@ -136,12 +136,9 @@ __xfs_inobt_free_block(
136 struct xfs_buf *bp, 136 struct xfs_buf *bp,
137 enum xfs_ag_resv_type resv) 137 enum xfs_ag_resv_type resv)
138{ 138{
139 struct xfs_owner_info oinfo;
140
141 xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_INOBT);
142 return xfs_free_extent(cur->bc_tp, 139 return xfs_free_extent(cur->bc_tp,
143 XFS_DADDR_TO_FSB(cur->bc_mp, XFS_BUF_ADDR(bp)), 1, 140 XFS_DADDR_TO_FSB(cur->bc_mp, XFS_BUF_ADDR(bp)), 1,
144 &oinfo, resv); 141 &XFS_RMAP_OINFO_INOBT, resv);
145} 142}
146 143
147STATIC int 144STATIC int
diff --git a/fs/xfs/libxfs/xfs_refcount_btree.c b/fs/xfs/libxfs/xfs_refcount_btree.c
index 1aaa01c97517..d9eab657b63e 100644
--- a/fs/xfs/libxfs/xfs_refcount_btree.c
+++ b/fs/xfs/libxfs/xfs_refcount_btree.c
@@ -70,7 +70,7 @@ xfs_refcountbt_alloc_block(
70 args.type = XFS_ALLOCTYPE_NEAR_BNO; 70 args.type = XFS_ALLOCTYPE_NEAR_BNO;
71 args.fsbno = XFS_AGB_TO_FSB(cur->bc_mp, cur->bc_private.a.agno, 71 args.fsbno = XFS_AGB_TO_FSB(cur->bc_mp, cur->bc_private.a.agno,
72 xfs_refc_block(args.mp)); 72 xfs_refc_block(args.mp));
73 xfs_rmap_ag_owner(&args.oinfo, XFS_RMAP_OWN_REFC); 73 args.oinfo = XFS_RMAP_OINFO_REFC;
74 args.minlen = args.maxlen = args.prod = 1; 74 args.minlen = args.maxlen = args.prod = 1;
75 args.resv = XFS_AG_RESV_METADATA; 75 args.resv = XFS_AG_RESV_METADATA;
76 76
@@ -106,15 +106,13 @@ xfs_refcountbt_free_block(
106 struct xfs_buf *agbp = cur->bc_private.a.agbp; 106 struct xfs_buf *agbp = cur->bc_private.a.agbp;
107 struct xfs_agf *agf = XFS_BUF_TO_AGF(agbp); 107 struct xfs_agf *agf = XFS_BUF_TO_AGF(agbp);
108 xfs_fsblock_t fsbno = XFS_DADDR_TO_FSB(mp, XFS_BUF_ADDR(bp)); 108 xfs_fsblock_t fsbno = XFS_DADDR_TO_FSB(mp, XFS_BUF_ADDR(bp));
109 struct xfs_owner_info oinfo;
110 int error; 109 int error;
111 110
112 trace_xfs_refcountbt_free_block(cur->bc_mp, cur->bc_private.a.agno, 111 trace_xfs_refcountbt_free_block(cur->bc_mp, cur->bc_private.a.agno,
113 XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno), 1); 112 XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno), 1);
114 xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_REFC);
115 be32_add_cpu(&agf->agf_refcount_blocks, -1); 113 be32_add_cpu(&agf->agf_refcount_blocks, -1);
116 xfs_alloc_log_agf(cur->bc_tp, agbp, XFS_AGF_REFCOUNT_BLOCKS); 114 xfs_alloc_log_agf(cur->bc_tp, agbp, XFS_AGF_REFCOUNT_BLOCKS);
117 error = xfs_free_extent(cur->bc_tp, fsbno, 1, &oinfo, 115 error = xfs_free_extent(cur->bc_tp, fsbno, 1, &XFS_RMAP_OINFO_REFC,
118 XFS_AG_RESV_METADATA); 116 XFS_AG_RESV_METADATA);
119 if (error) 117 if (error)
120 return error; 118 return error;
diff --git a/fs/xfs/libxfs/xfs_rmap.c b/fs/xfs/libxfs/xfs_rmap.c
index e7d06295338d..8ed885507dd8 100644
--- a/fs/xfs/libxfs/xfs_rmap.c
+++ b/fs/xfs/libxfs/xfs_rmap.c
@@ -2550,3 +2550,31 @@ xfs_rmap_has_other_keys(
2550 *has_rmap = rks.has_rmap; 2550 *has_rmap = rks.has_rmap;
2551 return error; 2551 return error;
2552} 2552}
2553
2554const struct xfs_owner_info XFS_RMAP_OINFO_SKIP_UPDATE = {
2555 .oi_owner = XFS_RMAP_OWN_NULL,
2556};
2557const struct xfs_owner_info XFS_RMAP_OINFO_ANY_OWNER = {
2558 .oi_owner = XFS_RMAP_OWN_UNKNOWN,
2559};
2560const struct xfs_owner_info XFS_RMAP_OINFO_FS = {
2561 .oi_owner = XFS_RMAP_OWN_FS,
2562};
2563const struct xfs_owner_info XFS_RMAP_OINFO_LOG = {
2564 .oi_owner = XFS_RMAP_OWN_LOG,
2565};
2566const struct xfs_owner_info XFS_RMAP_OINFO_AG = {
2567 .oi_owner = XFS_RMAP_OWN_AG,
2568};
2569const struct xfs_owner_info XFS_RMAP_OINFO_INOBT = {
2570 .oi_owner = XFS_RMAP_OWN_INOBT,
2571};
2572const struct xfs_owner_info XFS_RMAP_OINFO_INODES = {
2573 .oi_owner = XFS_RMAP_OWN_INODES,
2574};
2575const struct xfs_owner_info XFS_RMAP_OINFO_REFC = {
2576 .oi_owner = XFS_RMAP_OWN_REFC,
2577};
2578const struct xfs_owner_info XFS_RMAP_OINFO_COW = {
2579 .oi_owner = XFS_RMAP_OWN_COW,
2580};
diff --git a/fs/xfs/libxfs/xfs_rmap.h b/fs/xfs/libxfs/xfs_rmap.h
index 6d32838aa184..e21ed0294e5c 100644
--- a/fs/xfs/libxfs/xfs_rmap.h
+++ b/fs/xfs/libxfs/xfs_rmap.h
@@ -7,16 +7,6 @@
7#define __XFS_RMAP_H__ 7#define __XFS_RMAP_H__
8 8
9static inline void 9static inline void
10xfs_rmap_ag_owner(
11 struct xfs_owner_info *oi,
12 uint64_t owner)
13{
14 oi->oi_owner = owner;
15 oi->oi_offset = 0;
16 oi->oi_flags = 0;
17}
18
19static inline void
20xfs_rmap_ino_bmbt_owner( 10xfs_rmap_ino_bmbt_owner(
21 struct xfs_owner_info *oi, 11 struct xfs_owner_info *oi,
22 xfs_ino_t ino, 12 xfs_ino_t ino,
@@ -43,13 +33,6 @@ xfs_rmap_ino_owner(
43 oi->oi_flags |= XFS_OWNER_INFO_ATTR_FORK; 33 oi->oi_flags |= XFS_OWNER_INFO_ATTR_FORK;
44} 34}
45 35
46static inline void
47xfs_rmap_skip_owner_update(
48 struct xfs_owner_info *oi)
49{
50 xfs_rmap_ag_owner(oi, XFS_RMAP_OWN_NULL);
51}
52
53static inline bool 36static inline bool
54xfs_rmap_should_skip_owner_update( 37xfs_rmap_should_skip_owner_update(
55 const struct xfs_owner_info *oi) 38 const struct xfs_owner_info *oi)
@@ -57,13 +40,6 @@ xfs_rmap_should_skip_owner_update(
57 return oi->oi_owner == XFS_RMAP_OWN_NULL; 40 return oi->oi_owner == XFS_RMAP_OWN_NULL;
58} 41}
59 42
60static inline void
61xfs_rmap_any_owner_update(
62 struct xfs_owner_info *oi)
63{
64 xfs_rmap_ag_owner(oi, XFS_RMAP_OWN_UNKNOWN);
65}
66
67/* Reverse mapping functions. */ 43/* Reverse mapping functions. */
68 44
69struct xfs_buf; 45struct xfs_buf;
@@ -225,4 +201,14 @@ int xfs_rmap_has_other_keys(struct xfs_btree_cur *cur, xfs_agblock_t bno,
225 bool *has_rmap); 201 bool *has_rmap);
226int xfs_rmap_map_raw(struct xfs_btree_cur *cur, struct xfs_rmap_irec *rmap); 202int xfs_rmap_map_raw(struct xfs_btree_cur *cur, struct xfs_rmap_irec *rmap);
227 203
204extern const struct xfs_owner_info XFS_RMAP_OINFO_SKIP_UPDATE;
205extern const struct xfs_owner_info XFS_RMAP_OINFO_ANY_OWNER;
206extern const struct xfs_owner_info XFS_RMAP_OINFO_FS;
207extern const struct xfs_owner_info XFS_RMAP_OINFO_LOG;
208extern const struct xfs_owner_info XFS_RMAP_OINFO_AG;
209extern const struct xfs_owner_info XFS_RMAP_OINFO_INOBT;
210extern const struct xfs_owner_info XFS_RMAP_OINFO_INODES;
211extern const struct xfs_owner_info XFS_RMAP_OINFO_REFC;
212extern const struct xfs_owner_info XFS_RMAP_OINFO_COW;
213
228#endif /* __XFS_RMAP_H__ */ 214#endif /* __XFS_RMAP_H__ */