diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2016-08-02 21:30:32 -0400 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2016-08-02 21:30:32 -0400 |
commit | b87049444ac4a6515ba0427d16a73438b646435b (patch) | |
tree | 7751a4e8fbcdea52eb87852cc2e96aa93cf9abeb | |
parent | df3954ff72590fd20b68261a0c939e40fa3579ea (diff) |
xfs: introduce rmap btree definitions
Originally-From: Dave Chinner <dchinner@redhat.com>
Add new per-ag rmap btree definitions to the per-ag structures. The
rmap btree will sit in the empty slots on disk after the free space
btrees, and hence form a part of the array of space management
btrees. This requires the definition of the btree to be contiguous
with the free space btrees.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
-rw-r--r-- | fs/xfs/libxfs/xfs_alloc.c | 6 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_btree.c | 4 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_btree.h | 3 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_format.h | 22 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_types.h | 4 |
5 files changed, 30 insertions, 9 deletions
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c index 22ac3f136f21..c02d8e8419ce 100644 --- a/fs/xfs/libxfs/xfs_alloc.c +++ b/fs/xfs/libxfs/xfs_alloc.c | |||
@@ -2272,6 +2272,10 @@ xfs_agf_verify( | |||
2272 | be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]) > XFS_BTREE_MAXLEVELS) | 2272 | be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]) > XFS_BTREE_MAXLEVELS) |
2273 | return false; | 2273 | return false; |
2274 | 2274 | ||
2275 | if (xfs_sb_version_hasrmapbt(&mp->m_sb) && | ||
2276 | be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]) > XFS_BTREE_MAXLEVELS) | ||
2277 | return false; | ||
2278 | |||
2275 | /* | 2279 | /* |
2276 | * during growfs operations, the perag is not fully initialised, | 2280 | * during growfs operations, the perag is not fully initialised, |
2277 | * so we can't use it for any useful checking. growfs ensures we can't | 2281 | * so we can't use it for any useful checking. growfs ensures we can't |
@@ -2403,6 +2407,8 @@ xfs_alloc_read_agf( | |||
2403 | be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNOi]); | 2407 | be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNOi]); |
2404 | pag->pagf_levels[XFS_BTNUM_CNTi] = | 2408 | pag->pagf_levels[XFS_BTNUM_CNTi] = |
2405 | be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNTi]); | 2409 | be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNTi]); |
2410 | pag->pagf_levels[XFS_BTNUM_RMAPi] = | ||
2411 | be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAPi]); | ||
2406 | spin_lock_init(&pag->pagb_lock); | 2412 | spin_lock_init(&pag->pagb_lock); |
2407 | pag->pagb_count = 0; | 2413 | pag->pagb_count = 0; |
2408 | pag->pagb_tree = RB_ROOT; | 2414 | pag->pagb_tree = RB_ROOT; |
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c index 4fc46529753d..4066b01a1807 100644 --- a/fs/xfs/libxfs/xfs_btree.c +++ b/fs/xfs/libxfs/xfs_btree.c | |||
@@ -44,9 +44,9 @@ kmem_zone_t *xfs_btree_cur_zone; | |||
44 | * Btree magic numbers. | 44 | * Btree magic numbers. |
45 | */ | 45 | */ |
46 | static const __uint32_t xfs_magics[2][XFS_BTNUM_MAX] = { | 46 | static const __uint32_t xfs_magics[2][XFS_BTNUM_MAX] = { |
47 | { XFS_ABTB_MAGIC, XFS_ABTC_MAGIC, XFS_BMAP_MAGIC, XFS_IBT_MAGIC, | 47 | { XFS_ABTB_MAGIC, XFS_ABTC_MAGIC, 0, XFS_BMAP_MAGIC, XFS_IBT_MAGIC, |
48 | XFS_FIBT_MAGIC }, | 48 | XFS_FIBT_MAGIC }, |
49 | { XFS_ABTB_CRC_MAGIC, XFS_ABTC_CRC_MAGIC, | 49 | { XFS_ABTB_CRC_MAGIC, XFS_ABTC_CRC_MAGIC, XFS_RMAP_CRC_MAGIC, |
50 | XFS_BMAP_CRC_MAGIC, XFS_IBT_CRC_MAGIC, XFS_FIBT_CRC_MAGIC } | 50 | XFS_BMAP_CRC_MAGIC, XFS_IBT_CRC_MAGIC, XFS_FIBT_CRC_MAGIC } |
51 | }; | 51 | }; |
52 | #define xfs_btree_magic(cur) \ | 52 | #define xfs_btree_magic(cur) \ |
diff --git a/fs/xfs/libxfs/xfs_btree.h b/fs/xfs/libxfs/xfs_btree.h index ac5cd6ef6859..25f1b69e7515 100644 --- a/fs/xfs/libxfs/xfs_btree.h +++ b/fs/xfs/libxfs/xfs_btree.h | |||
@@ -77,6 +77,7 @@ union xfs_btree_rec { | |||
77 | #define XFS_BTNUM_BMAP ((xfs_btnum_t)XFS_BTNUM_BMAPi) | 77 | #define XFS_BTNUM_BMAP ((xfs_btnum_t)XFS_BTNUM_BMAPi) |
78 | #define XFS_BTNUM_INO ((xfs_btnum_t)XFS_BTNUM_INOi) | 78 | #define XFS_BTNUM_INO ((xfs_btnum_t)XFS_BTNUM_INOi) |
79 | #define XFS_BTNUM_FINO ((xfs_btnum_t)XFS_BTNUM_FINOi) | 79 | #define XFS_BTNUM_FINO ((xfs_btnum_t)XFS_BTNUM_FINOi) |
80 | #define XFS_BTNUM_RMAP ((xfs_btnum_t)XFS_BTNUM_RMAPi) | ||
80 | 81 | ||
81 | /* | 82 | /* |
82 | * For logging record fields. | 83 | * For logging record fields. |
@@ -109,6 +110,7 @@ do { \ | |||
109 | case XFS_BTNUM_BMAP: __XFS_BTREE_STATS_INC(__mp, bmbt, stat); break; \ | 110 | case XFS_BTNUM_BMAP: __XFS_BTREE_STATS_INC(__mp, bmbt, stat); break; \ |
110 | case XFS_BTNUM_INO: __XFS_BTREE_STATS_INC(__mp, ibt, stat); break; \ | 111 | case XFS_BTNUM_INO: __XFS_BTREE_STATS_INC(__mp, ibt, stat); break; \ |
111 | case XFS_BTNUM_FINO: __XFS_BTREE_STATS_INC(__mp, fibt, stat); break; \ | 112 | case XFS_BTNUM_FINO: __XFS_BTREE_STATS_INC(__mp, fibt, stat); break; \ |
113 | case XFS_BTNUM_RMAP: break; \ | ||
112 | case XFS_BTNUM_MAX: ASSERT(0); /* fucking gcc */ ; break; \ | 114 | case XFS_BTNUM_MAX: ASSERT(0); /* fucking gcc */ ; break; \ |
113 | } \ | 115 | } \ |
114 | } while (0) | 116 | } while (0) |
@@ -129,6 +131,7 @@ do { \ | |||
129 | __XFS_BTREE_STATS_ADD(__mp, ibt, stat, val); break; \ | 131 | __XFS_BTREE_STATS_ADD(__mp, ibt, stat, val); break; \ |
130 | case XFS_BTNUM_FINO: \ | 132 | case XFS_BTNUM_FINO: \ |
131 | __XFS_BTREE_STATS_ADD(__mp, fibt, stat, val); break; \ | 133 | __XFS_BTREE_STATS_ADD(__mp, fibt, stat, val); break; \ |
134 | case XFS_BTNUM_RMAP: break; \ | ||
132 | case XFS_BTNUM_MAX: ASSERT(0); /* fucking gcc */ ; break; \ | 135 | case XFS_BTNUM_MAX: ASSERT(0); /* fucking gcc */ ; break; \ |
133 | } \ | 136 | } \ |
134 | } while (0) | 137 | } while (0) |
diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index adb204d40f22..74f4d3da598c 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h | |||
@@ -455,6 +455,7 @@ xfs_sb_has_compat_feature( | |||
455 | } | 455 | } |
456 | 456 | ||
457 | #define XFS_SB_FEAT_RO_COMPAT_FINOBT (1 << 0) /* free inode btree */ | 457 | #define XFS_SB_FEAT_RO_COMPAT_FINOBT (1 << 0) /* free inode btree */ |
458 | #define XFS_SB_FEAT_RO_COMPAT_RMAPBT (1 << 1) /* reverse map btree */ | ||
458 | #define XFS_SB_FEAT_RO_COMPAT_ALL \ | 459 | #define XFS_SB_FEAT_RO_COMPAT_ALL \ |
459 | (XFS_SB_FEAT_RO_COMPAT_FINOBT) | 460 | (XFS_SB_FEAT_RO_COMPAT_FINOBT) |
460 | #define XFS_SB_FEAT_RO_COMPAT_UNKNOWN ~XFS_SB_FEAT_RO_COMPAT_ALL | 461 | #define XFS_SB_FEAT_RO_COMPAT_UNKNOWN ~XFS_SB_FEAT_RO_COMPAT_ALL |
@@ -538,6 +539,12 @@ static inline bool xfs_sb_version_hasmetauuid(struct xfs_sb *sbp) | |||
538 | (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_META_UUID); | 539 | (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_META_UUID); |
539 | } | 540 | } |
540 | 541 | ||
542 | static inline bool xfs_sb_version_hasrmapbt(struct xfs_sb *sbp) | ||
543 | { | ||
544 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) && | ||
545 | (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_RMAPBT); | ||
546 | } | ||
547 | |||
541 | /* | 548 | /* |
542 | * end of superblock version macros | 549 | * end of superblock version macros |
543 | */ | 550 | */ |
@@ -598,10 +605,10 @@ xfs_is_quota_inode(struct xfs_sb *sbp, xfs_ino_t ino) | |||
598 | #define XFS_AGI_GOOD_VERSION(v) ((v) == XFS_AGI_VERSION) | 605 | #define XFS_AGI_GOOD_VERSION(v) ((v) == XFS_AGI_VERSION) |
599 | 606 | ||
600 | /* | 607 | /* |
601 | * Btree number 0 is bno, 1 is cnt. This value gives the size of the | 608 | * Btree number 0 is bno, 1 is cnt, 2 is rmap. This value gives the size of the |
602 | * arrays below. | 609 | * arrays below. |
603 | */ | 610 | */ |
604 | #define XFS_BTNUM_AGF ((int)XFS_BTNUM_CNTi + 1) | 611 | #define XFS_BTNUM_AGF ((int)XFS_BTNUM_RMAPi + 1) |
605 | 612 | ||
606 | /* | 613 | /* |
607 | * The second word of agf_levels in the first a.g. overlaps the EFS | 614 | * The second word of agf_levels in the first a.g. overlaps the EFS |
@@ -618,12 +625,10 @@ typedef struct xfs_agf { | |||
618 | __be32 agf_seqno; /* sequence # starting from 0 */ | 625 | __be32 agf_seqno; /* sequence # starting from 0 */ |
619 | __be32 agf_length; /* size in blocks of a.g. */ | 626 | __be32 agf_length; /* size in blocks of a.g. */ |
620 | /* | 627 | /* |
621 | * Freespace information | 628 | * Freespace and rmap information |
622 | */ | 629 | */ |
623 | __be32 agf_roots[XFS_BTNUM_AGF]; /* root blocks */ | 630 | __be32 agf_roots[XFS_BTNUM_AGF]; /* root blocks */ |
624 | __be32 agf_spare0; /* spare field */ | ||
625 | __be32 agf_levels[XFS_BTNUM_AGF]; /* btree levels */ | 631 | __be32 agf_levels[XFS_BTNUM_AGF]; /* btree levels */ |
626 | __be32 agf_spare1; /* spare field */ | ||
627 | 632 | ||
628 | __be32 agf_flfirst; /* first freelist block's index */ | 633 | __be32 agf_flfirst; /* first freelist block's index */ |
629 | __be32 agf_fllast; /* last freelist block's index */ | 634 | __be32 agf_fllast; /* last freelist block's index */ |
@@ -1308,6 +1313,13 @@ typedef __be32 xfs_inobt_ptr_t; | |||
1308 | #define XFS_FIBT_BLOCK(mp) ((xfs_agblock_t)(XFS_IBT_BLOCK(mp) + 1)) | 1313 | #define XFS_FIBT_BLOCK(mp) ((xfs_agblock_t)(XFS_IBT_BLOCK(mp) + 1)) |
1309 | 1314 | ||
1310 | /* | 1315 | /* |
1316 | * Reverse mapping btree format definitions | ||
1317 | * | ||
1318 | * There is a btree for the reverse map per allocation group | ||
1319 | */ | ||
1320 | #define XFS_RMAP_CRC_MAGIC 0x524d4233 /* 'RMB3' */ | ||
1321 | |||
1322 | /* | ||
1311 | * The first data block of an AG depends on whether the filesystem was formatted | 1323 | * The first data block of an AG depends on whether the filesystem was formatted |
1312 | * with the finobt feature. If so, account for the finobt reserved root btree | 1324 | * with the finobt feature. If so, account for the finobt reserved root btree |
1313 | * block. | 1325 | * block. |
diff --git a/fs/xfs/libxfs/xfs_types.h b/fs/xfs/libxfs/xfs_types.h index b79dc66b2ecd..3d503647f26b 100644 --- a/fs/xfs/libxfs/xfs_types.h +++ b/fs/xfs/libxfs/xfs_types.h | |||
@@ -108,8 +108,8 @@ typedef enum { | |||
108 | } xfs_lookup_t; | 108 | } xfs_lookup_t; |
109 | 109 | ||
110 | typedef enum { | 110 | typedef enum { |
111 | XFS_BTNUM_BNOi, XFS_BTNUM_CNTi, XFS_BTNUM_BMAPi, XFS_BTNUM_INOi, | 111 | XFS_BTNUM_BNOi, XFS_BTNUM_CNTi, XFS_BTNUM_RMAPi, XFS_BTNUM_BMAPi, |
112 | XFS_BTNUM_FINOi, XFS_BTNUM_MAX | 112 | XFS_BTNUM_INOi, XFS_BTNUM_FINOi, XFS_BTNUM_MAX |
113 | } xfs_btnum_t; | 113 | } xfs_btnum_t; |
114 | 114 | ||
115 | struct xfs_name { | 115 | struct xfs_name { |