xfs: create new metadata UUID field and incompat flag
authorEric Sandeen <sandeen@sandeen.net>
Wed, 29 Jul 2015 01:53:31 +0000 (11:53 +1000)
committerDave Chinner <david@fromorbit.com>
Wed, 29 Jul 2015 01:53:31 +0000 (11:53 +1000)
This adds a new superblock field, sb_meta_uuid.  If set, along with
a new incompat flag, the code will use that field on a V5 filesystem
to compare to metadata UUIDs, which allows us to change the user-
visible UUID at will.  Userspace handles the setting and clearing
of the incompat flag as appropriate, as the UUID gets changed; i.e.
setting the user-visible UUID back to the original UUID (as stored in
the new field) will remove the incompatible feature flag.

If the incompat flag is not set, this copies the user-visible UUID into
into the meta_uuid slot in memory when the superblock is read from disk;
the meta_uuid field is not written back to disk in this case.

The remainder of this patch simply switches verifiers, initializers,
etc to use the new sb_meta_uuid field.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
18 files changed:
fs/xfs/libxfs/xfs_alloc.c
fs/xfs/libxfs/xfs_alloc_btree.c
fs/xfs/libxfs/xfs_attr_leaf.c
fs/xfs/libxfs/xfs_attr_remote.c
fs/xfs/libxfs/xfs_bmap_btree.c
fs/xfs/libxfs/xfs_btree.c
fs/xfs/libxfs/xfs_da_btree.c
fs/xfs/libxfs/xfs_dir2_block.c
fs/xfs/libxfs/xfs_dir2_data.c
fs/xfs/libxfs/xfs_dir2_leaf.c
fs/xfs/libxfs/xfs_dir2_node.c
fs/xfs/libxfs/xfs_dquot_buf.c
fs/xfs/libxfs/xfs_format.h
fs/xfs/libxfs/xfs_ialloc.c
fs/xfs/libxfs/xfs_ialloc_btree.c
fs/xfs/libxfs/xfs_inode_buf.c
fs/xfs/libxfs/xfs_sb.c
fs/xfs/libxfs/xfs_symlink_remote.c

index f9e9ffe6fb46f88691e337d56d73928bc3d6f5cb..b7fc17ce8233a21c61e4a0f7dddd7c664e06fa43 100644 (file)
@@ -464,7 +464,7 @@ xfs_agfl_verify(
        struct xfs_agfl *agfl = XFS_BUF_TO_AGFL(bp);
        int             i;
 
-       if (!uuid_equal(&agfl->agfl_uuid, &mp->m_sb.sb_uuid))
+       if (!uuid_equal(&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid))
                return false;
        if (be32_to_cpu(agfl->agfl_magicnum) != XFS_AGFL_MAGIC)
                return false;
@@ -2260,7 +2260,7 @@ xfs_agf_verify(
        struct xfs_agf  *agf = XFS_BUF_TO_AGF(bp);
 
        if (xfs_sb_version_hascrc(&mp->m_sb) &&
-           !uuid_equal(&agf->agf_uuid, &mp->m_sb.sb_uuid))
+           !uuid_equal(&agf->agf_uuid, &mp->m_sb.sb_meta_uuid))
                        return false;
 
        if (!(agf->agf_magicnum == cpu_to_be32(XFS_AGF_MAGIC) &&
index 59d521c09a17b2310a5908324a9291cb247d95b1..90de071dd4c2cf2afbd7a7bde5658f1367b21bd1 100644 (file)
@@ -295,7 +295,7 @@ xfs_allocbt_verify(
        case cpu_to_be32(XFS_ABTB_CRC_MAGIC):
                if (!xfs_sb_version_hascrc(&mp->m_sb))
                        return false;
-               if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_uuid))
+               if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid))
                        return false;
                if (block->bb_u.s.bb_blkno != cpu_to_be64(bp->b_bn))
                        return false;
@@ -313,7 +313,7 @@ xfs_allocbt_verify(
        case cpu_to_be32(XFS_ABTC_CRC_MAGIC):
                if (!xfs_sb_version_hascrc(&mp->m_sb))
                        return false;
-               if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_uuid))
+               if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid))
                        return false;
                if (block->bb_u.s.bb_blkno != cpu_to_be64(bp->b_bn))
                        return false;
index e9d401ce93bb19d822a2ec9b475dae7ad5d279c1..33df52d97ec77bfeb07e4eb8bf45c33d7033a15c 100644 (file)
@@ -262,7 +262,7 @@ xfs_attr3_leaf_verify(
                if (ichdr.magic != XFS_ATTR3_LEAF_MAGIC)
                        return false;
 
-               if (!uuid_equal(&hdr3->info.uuid, &mp->m_sb.sb_uuid))
+               if (!uuid_equal(&hdr3->info.uuid, &mp->m_sb.sb_meta_uuid))
                        return false;
                if (be64_to_cpu(hdr3->info.blkno) != bp->b_bn)
                        return false;
@@ -1056,7 +1056,7 @@ xfs_attr3_leaf_create(
 
                hdr3->blkno = cpu_to_be64(bp->b_bn);
                hdr3->owner = cpu_to_be64(dp->i_ino);
-               uuid_copy(&hdr3->uuid, &mp->m_sb.sb_uuid);
+               uuid_copy(&hdr3->uuid, &mp->m_sb.sb_meta_uuid);
 
                ichdr.freemap[0].base = sizeof(struct xfs_attr3_leaf_hdr);
        } else {
index 20de88d1bf86205d126d5e27b43298af9b836a79..eba0d1e91a93eeb31185489b4c9862092b5096c4 100644 (file)
@@ -100,7 +100,7 @@ xfs_attr3_rmt_verify(
                return false;
        if (rmt->rm_magic != cpu_to_be32(XFS_ATTR3_RMT_MAGIC))
                return false;
-       if (!uuid_equal(&rmt->rm_uuid, &mp->m_sb.sb_uuid))
+       if (!uuid_equal(&rmt->rm_uuid, &mp->m_sb.sb_meta_uuid))
                return false;
        if (be64_to_cpu(rmt->rm_blkno) != bno)
                return false;
@@ -217,7 +217,7 @@ xfs_attr3_rmt_hdr_set(
        rmt->rm_magic = cpu_to_be32(XFS_ATTR3_RMT_MAGIC);
        rmt->rm_offset = cpu_to_be32(offset);
        rmt->rm_bytes = cpu_to_be32(size);
-       uuid_copy(&rmt->rm_uuid, &mp->m_sb.sb_uuid);
+       uuid_copy(&rmt->rm_uuid, &mp->m_sb.sb_meta_uuid);
        rmt->rm_owner = cpu_to_be64(ino);
        rmt->rm_blkno = cpu_to_be64(bno);
 
index 2c44c8e507827cba31851e1bb8248b6293da5bc6..6b0cf6546a82f7752bc8a7121d8741f3257269c7 100644 (file)
@@ -349,7 +349,8 @@ xfs_bmbt_to_bmdr(
 
        if (xfs_sb_version_hascrc(&mp->m_sb)) {
                ASSERT(rblock->bb_magic == cpu_to_be32(XFS_BMAP_CRC_MAGIC));
-               ASSERT(uuid_equal(&rblock->bb_u.l.bb_uuid, &mp->m_sb.sb_uuid));
+               ASSERT(uuid_equal(&rblock->bb_u.l.bb_uuid,
+                      &mp->m_sb.sb_meta_uuid));
                ASSERT(rblock->bb_u.l.bb_blkno ==
                       cpu_to_be64(XFS_BUF_DADDR_NULL));
        } else
@@ -647,7 +648,7 @@ xfs_bmbt_verify(
        case cpu_to_be32(XFS_BMAP_CRC_MAGIC):
                if (!xfs_sb_version_hascrc(&mp->m_sb))
                        return false;
-               if (!uuid_equal(&block->bb_u.l.bb_uuid, &mp->m_sb.sb_uuid))
+               if (!uuid_equal(&block->bb_u.l.bb_uuid, &mp->m_sb.sb_meta_uuid))
                        return false;
                if (be64_to_cpu(block->bb_u.l.bb_blkno) != bp->b_bn)
                        return false;
index c72283dd8d44b6327e420355864ea8571068c9f4..f7d7ee7a26072587262dfd27509ba8f502214cc7 100644 (file)
@@ -65,7 +65,8 @@ xfs_btree_check_lblock(
 
        if (xfs_sb_version_hascrc(&mp->m_sb)) {
                lblock_ok = lblock_ok &&
-                       uuid_equal(&block->bb_u.l.bb_uuid, &mp->m_sb.sb_uuid) &&
+                       uuid_equal(&block->bb_u.l.bb_uuid,
+                                  &mp->m_sb.sb_meta_uuid) &&
                        block->bb_u.l.bb_blkno == cpu_to_be64(
                                bp ? bp->b_bn : XFS_BUF_DADDR_NULL);
        }
@@ -115,7 +116,8 @@ xfs_btree_check_sblock(
 
        if (xfs_sb_version_hascrc(&mp->m_sb)) {
                sblock_ok = sblock_ok &&
-                       uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_uuid) &&
+                       uuid_equal(&block->bb_u.s.bb_uuid,
+                                  &mp->m_sb.sb_meta_uuid) &&
                        block->bb_u.s.bb_blkno == cpu_to_be64(
                                bp ? bp->b_bn : XFS_BUF_DADDR_NULL);
        }
@@ -1000,7 +1002,7 @@ xfs_btree_init_block_int(
                if (flags & XFS_BTREE_CRC_BLOCKS) {
                        buf->bb_u.l.bb_blkno = cpu_to_be64(blkno);
                        buf->bb_u.l.bb_owner = cpu_to_be64(owner);
-                       uuid_copy(&buf->bb_u.l.bb_uuid, &mp->m_sb.sb_uuid);
+                       uuid_copy(&buf->bb_u.l.bb_uuid, &mp->m_sb.sb_meta_uuid);
                        buf->bb_u.l.bb_pad = 0;
                        buf->bb_u.l.bb_lsn = 0;
                }
@@ -1013,7 +1015,7 @@ xfs_btree_init_block_int(
                if (flags & XFS_BTREE_CRC_BLOCKS) {
                        buf->bb_u.s.bb_blkno = cpu_to_be64(blkno);
                        buf->bb_u.s.bb_owner = cpu_to_be32(__owner);
-                       uuid_copy(&buf->bb_u.s.bb_uuid, &mp->m_sb.sb_uuid);
+                       uuid_copy(&buf->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid);
                        buf->bb_u.s.bb_lsn = 0;
                }
        }
index 2385f8cd08ab9f1cdf19ad3a9a8473a5e4e34eb3..e9f6709a3846e093f95eb23c70b21e4dd97ac9c5 100644 (file)
@@ -146,7 +146,7 @@ xfs_da3_node_verify(
                if (ichdr.magic != XFS_DA3_NODE_MAGIC)
                        return false;
 
-               if (!uuid_equal(&hdr3->info.uuid, &mp->m_sb.sb_uuid))
+               if (!uuid_equal(&hdr3->info.uuid, &mp->m_sb.sb_meta_uuid))
                        return false;
                if (be64_to_cpu(hdr3->info.blkno) != bp->b_bn)
                        return false;
@@ -324,7 +324,7 @@ xfs_da3_node_create(
                ichdr.magic = XFS_DA3_NODE_MAGIC;
                hdr3->info.blkno = cpu_to_be64(bp->b_bn);
                hdr3->info.owner = cpu_to_be64(args->dp->i_ino);
-               uuid_copy(&hdr3->info.uuid, &mp->m_sb.sb_uuid);
+               uuid_copy(&hdr3->info.uuid, &mp->m_sb.sb_meta_uuid);
        } else {
                ichdr.magic = XFS_DA_NODE_MAGIC;
        }
index 9354e190b82e9e9e4f33a38e2254309159622a97..4778d1dd511afae50eee4c6a7b5d0a7220fc4c4d 100644 (file)
@@ -67,7 +67,7 @@ xfs_dir3_block_verify(
        if (xfs_sb_version_hascrc(&mp->m_sb)) {
                if (hdr3->magic != cpu_to_be32(XFS_DIR3_BLOCK_MAGIC))
                        return false;
-               if (!uuid_equal(&hdr3->uuid, &mp->m_sb.sb_uuid))
+               if (!uuid_equal(&hdr3->uuid, &mp->m_sb.sb_meta_uuid))
                        return false;
                if (be64_to_cpu(hdr3->blkno) != bp->b_bn)
                        return false;
@@ -157,7 +157,7 @@ xfs_dir3_block_init(
                hdr3->magic = cpu_to_be32(XFS_DIR3_BLOCK_MAGIC);
                hdr3->blkno = cpu_to_be64(bp->b_bn);
                hdr3->owner = cpu_to_be64(dp->i_ino);
-               uuid_copy(&hdr3->uuid, &mp->m_sb.sb_uuid);
+               uuid_copy(&hdr3->uuid, &mp->m_sb.sb_meta_uuid);
                return;
 
        }
index de1ea16f57485ccc03143196eb2aced9147aed5b..6a57fdbc63ef4b67edb916afa2668c6a837425fc 100644 (file)
@@ -220,7 +220,7 @@ xfs_dir3_data_verify(
        if (xfs_sb_version_hascrc(&mp->m_sb)) {
                if (hdr3->magic != cpu_to_be32(XFS_DIR3_DATA_MAGIC))
                        return false;
-               if (!uuid_equal(&hdr3->uuid, &mp->m_sb.sb_uuid))
+               if (!uuid_equal(&hdr3->uuid, &mp->m_sb.sb_meta_uuid))
                        return false;
                if (be64_to_cpu(hdr3->blkno) != bp->b_bn)
                        return false;
@@ -604,7 +604,7 @@ xfs_dir3_data_init(
                hdr3->magic = cpu_to_be32(XFS_DIR3_DATA_MAGIC);
                hdr3->blkno = cpu_to_be64(bp->b_bn);
                hdr3->owner = cpu_to_be64(dp->i_ino);
-               uuid_copy(&hdr3->uuid, &mp->m_sb.sb_uuid);
+               uuid_copy(&hdr3->uuid, &mp->m_sb.sb_meta_uuid);
 
        } else
                hdr->magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC);
index 106119955400a6d06cc73ff93cad2055a8e4bc1e..f300240ebb8d1575191379978ba5ed722c009718 100644 (file)
@@ -160,7 +160,7 @@ xfs_dir3_leaf_verify(
 
                if (leaf3->info.hdr.magic != cpu_to_be16(magic3))
                        return false;
-               if (!uuid_equal(&leaf3->info.uuid, &mp->m_sb.sb_uuid))
+               if (!uuid_equal(&leaf3->info.uuid, &mp->m_sb.sb_meta_uuid))
                        return false;
                if (be64_to_cpu(leaf3->info.blkno) != bp->b_bn)
                        return false;
@@ -310,7 +310,7 @@ xfs_dir3_leaf_init(
                                         : cpu_to_be16(XFS_DIR3_LEAFN_MAGIC);
                leaf3->info.blkno = cpu_to_be64(bp->b_bn);
                leaf3->info.owner = cpu_to_be64(owner);
-               uuid_copy(&leaf3->info.uuid, &mp->m_sb.sb_uuid);
+               uuid_copy(&leaf3->info.uuid, &mp->m_sb.sb_meta_uuid);
        } else {
                memset(leaf, 0, sizeof(*leaf));
                leaf->hdr.info.magic = cpu_to_be16(type);
index 41b80d3d38772b100903bdcf7c604adad6417fd4..527b7337a43be4e9d43a1509c6c848dea49925ae 100644 (file)
@@ -93,7 +93,7 @@ xfs_dir3_free_verify(
 
                if (hdr3->magic != cpu_to_be32(XFS_DIR3_FREE_MAGIC))
                        return false;
-               if (!uuid_equal(&hdr3->uuid, &mp->m_sb.sb_uuid))
+               if (!uuid_equal(&hdr3->uuid, &mp->m_sb.sb_meta_uuid))
                        return false;
                if (be64_to_cpu(hdr3->blkno) != bp->b_bn)
                        return false;
@@ -226,7 +226,7 @@ xfs_dir3_free_get_buf(
 
                hdr3->hdr.blkno = cpu_to_be64(bp->b_bn);
                hdr3->hdr.owner = cpu_to_be64(dp->i_ino);
-               uuid_copy(&hdr3->hdr.uuid, &mp->m_sb.sb_uuid);
+               uuid_copy(&hdr3->hdr.uuid, &mp->m_sb.sb_meta_uuid);
        } else
                hdr.magic = XFS_DIR2_FREE_MAGIC;
        dp->d_ops->free_hdr_to_disk(bp->b_addr, &hdr);
index 6fbf2d853a54e178d0699fa90cb03ad8647a349e..5331b7f0460c7e16a72aab1b7b96f727a606a10c 100644 (file)
@@ -163,7 +163,7 @@ xfs_dqcheck(
        d->dd_diskdq.d_id = cpu_to_be32(id);
 
        if (xfs_sb_version_hascrc(&mp->m_sb)) {
-               uuid_copy(&d->dd_uuid, &mp->m_sb.sb_uuid);
+               uuid_copy(&d->dd_uuid, &mp->m_sb.sb_meta_uuid);
                xfs_update_cksum((char *)d, sizeof(struct xfs_dqblk),
                                 XFS_DQUOT_CRC_OFF);
        }
@@ -198,7 +198,7 @@ xfs_dquot_buf_verify_crc(
                if (!xfs_verify_cksum((char *)d, sizeof(struct xfs_dqblk),
                                 XFS_DQUOT_CRC_OFF))
                        return false;
-               if (!uuid_equal(&d->dd_uuid, &mp->m_sb.sb_uuid))
+               if (!uuid_equal(&d->dd_uuid, &mp->m_sb.sb_meta_uuid))
                        return false;
        }
        return true;
index a0ae572051de78b4169d5f363ba749f4030c170d..9590a069e5569a88942e4726382db7819d7884f7 100644 (file)
@@ -100,7 +100,7 @@ typedef struct xfs_sb {
        xfs_rfsblock_t  sb_dblocks;     /* number of data blocks */
        xfs_rfsblock_t  sb_rblocks;     /* number of realtime blocks */
        xfs_rtblock_t   sb_rextents;    /* number of realtime extents */
-       uuid_t          sb_uuid;        /* file system unique id */
+       uuid_t          sb_uuid;        /* user-visible file system unique id */
        xfs_fsblock_t   sb_logstart;    /* starting block of log if internal */
        xfs_ino_t       sb_rootino;     /* root inode number */
        xfs_ino_t       sb_rbmino;      /* bitmap inode for realtime extents */
@@ -174,6 +174,7 @@ typedef struct xfs_sb {
 
        xfs_ino_t       sb_pquotino;    /* project quota inode */
        xfs_lsn_t       sb_lsn;         /* last write sequence */
+       uuid_t          sb_meta_uuid;   /* metadata file system unique id */
 
        /* must be padded to 64 bit alignment */
 } xfs_sb_t;
@@ -190,7 +191,7 @@ typedef struct xfs_dsb {
        __be64          sb_dblocks;     /* number of data blocks */
        __be64          sb_rblocks;     /* number of realtime blocks */
        __be64          sb_rextents;    /* number of realtime extents */
-       uuid_t          sb_uuid;        /* file system unique id */
+       uuid_t          sb_uuid;        /* user-visible file system unique id */
        __be64          sb_logstart;    /* starting block of log if internal */
        __be64          sb_rootino;     /* root inode number */
        __be64          sb_rbmino;      /* bitmap inode for realtime extents */
@@ -260,6 +261,7 @@ typedef struct xfs_dsb {
 
        __be64          sb_pquotino;    /* project quota inode */
        __be64          sb_lsn;         /* last write sequence */
+       uuid_t          sb_meta_uuid;   /* metadata file system unique id */
 
        /* must be padded to 64 bit alignment */
 } xfs_dsb_t;
@@ -458,9 +460,11 @@ xfs_sb_has_ro_compat_feature(
 
 #define XFS_SB_FEAT_INCOMPAT_FTYPE     (1 << 0)        /* filetype in dirent */
 #define XFS_SB_FEAT_INCOMPAT_SPINODES  (1 << 1)        /* sparse inode chunks */
+#define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 2)        /* metadata UUID */
 #define XFS_SB_FEAT_INCOMPAT_ALL \
                (XFS_SB_FEAT_INCOMPAT_FTYPE|    \
-                XFS_SB_FEAT_INCOMPAT_SPINODES)
+                XFS_SB_FEAT_INCOMPAT_SPINODES| \
+                XFS_SB_FEAT_INCOMPAT_META_UUID)
 
 #define XFS_SB_FEAT_INCOMPAT_UNKNOWN   ~XFS_SB_FEAT_INCOMPAT_ALL
 static inline bool
@@ -514,6 +518,18 @@ static inline bool xfs_sb_version_hassparseinodes(struct xfs_sb *sbp)
                xfs_sb_has_incompat_feature(sbp, XFS_SB_FEAT_INCOMPAT_SPINODES);
 }
 
+/*
+ * XFS_SB_FEAT_INCOMPAT_META_UUID indicates that the metadata UUID
+ * is stored separately from the user-visible UUID; this allows the
+ * user-visible UUID to be changed on V5 filesystems which have a
+ * filesystem UUID stamped into every piece of metadata.
+ */
+static inline bool xfs_sb_version_hasmetauuid(struct xfs_sb *sbp)
+{
+       return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) &&
+               (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_META_UUID);
+}
+
 /*
  * end of superblock version macros
  */
index 66efc702452a0cd45920ce3fd021c689d7bdd40b..ce63e0431f3e5fe624c63f98a6daa064f5d6ad10 100644 (file)
@@ -338,7 +338,8 @@ xfs_ialloc_inode_init(
                        if (version == 3) {
                                free->di_ino = cpu_to_be64(ino);
                                ino++;
-                               uuid_copy(&free->di_uuid, &mp->m_sb.sb_uuid);
+                               uuid_copy(&free->di_uuid,
+                                         &mp->m_sb.sb_meta_uuid);
                                xfs_dinode_calc_crc(mp, free);
                        } else if (tp) {
                                /* just log the inode core */
@@ -2500,7 +2501,7 @@ xfs_agi_verify(
        struct xfs_agi  *agi = XFS_BUF_TO_AGI(bp);
 
        if (xfs_sb_version_hascrc(&mp->m_sb) &&
-           !uuid_equal(&agi->agi_uuid, &mp->m_sb.sb_uuid))
+           !uuid_equal(&agi->agi_uuid, &mp->m_sb.sb_meta_uuid))
                        return false;
        /*
         * Validate the magic number of the agi block.
index 674ad8f760be25ea8fd969b182eee8cee0af7900..f39b285beb19f659ab5a6f0774c966134c0fdf58 100644 (file)
@@ -239,7 +239,7 @@ xfs_inobt_verify(
        case cpu_to_be32(XFS_FIBT_CRC_MAGIC):
                if (!xfs_sb_version_hascrc(&mp->m_sb))
                        return false;
-               if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_uuid))
+               if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid))
                        return false;
                if (block->bb_u.s.bb_blkno != cpu_to_be64(bp->b_bn))
                        return false;
index 6526e7696184b75fd3206ba4d6c48e354a85721d..268c00f4f83af9b5eb3fe492322323c7be2f5b42 100644 (file)
@@ -304,7 +304,7 @@ xfs_dinode_verify(
                return false;
        if (be64_to_cpu(dip->di_ino) != ip->i_ino)
                return false;
-       if (!uuid_equal(&dip->di_uuid, &mp->m_sb.sb_uuid))
+       if (!uuid_equal(&dip->di_uuid, &mp->m_sb.sb_meta_uuid))
                return false;
        return true;
 }
@@ -366,7 +366,7 @@ xfs_iread(
                if (xfs_sb_version_hascrc(&mp->m_sb)) {
                        ip->i_d.di_version = 3;
                        ip->i_d.di_ino = ip->i_ino;
-                       uuid_copy(&ip->i_d.di_uuid, &mp->m_sb.sb_uuid);
+                       uuid_copy(&ip->i_d.di_uuid, &mp->m_sb.sb_meta_uuid);
                } else
                        ip->i_d.di_version = 2;
                return 0;
index df9851c46b5c2e053926b9f223a318ba04ee6489..0f5e08fe64a2c93b4d0298cdb201a6f2e9ee8c14 100644 (file)
@@ -398,6 +398,14 @@ __xfs_sb_from_disk(
        to->sb_spino_align = be32_to_cpu(from->sb_spino_align);
        to->sb_pquotino = be64_to_cpu(from->sb_pquotino);
        to->sb_lsn = be64_to_cpu(from->sb_lsn);
+       /*
+        * sb_meta_uuid is only on disk if it differs from sb_uuid and the
+        * feature flag is set; if not set we keep it only in memory.
+        */
+       if (xfs_sb_version_hasmetauuid(to))
+               uuid_copy(&to->sb_meta_uuid, &from->sb_meta_uuid);
+       else
+               uuid_copy(&to->sb_meta_uuid, &from->sb_uuid);
        /* Convert on-disk flags to in-memory flags? */
        if (convert_xquota)
                xfs_sb_quota_from_disk(to);
@@ -539,6 +547,8 @@ xfs_sb_to_disk(
                                cpu_to_be32(from->sb_features_log_incompat);
                to->sb_spino_align = cpu_to_be32(from->sb_spino_align);
                to->sb_lsn = cpu_to_be64(from->sb_lsn);
+               if (xfs_sb_version_hasmetauuid(from))
+                       uuid_copy(&to->sb_meta_uuid, &from->sb_meta_uuid);
        }
 }
 
index e7e26bd6468fdd218e3390a9913487f52e9576a2..8f8af05b3f13da7acadc9ebfbc64f0e7debaf655 100644 (file)
@@ -63,7 +63,7 @@ xfs_symlink_hdr_set(
        dsl->sl_magic = cpu_to_be32(XFS_SYMLINK_MAGIC);
        dsl->sl_offset = cpu_to_be32(offset);
        dsl->sl_bytes = cpu_to_be32(size);
-       uuid_copy(&dsl->sl_uuid, &mp->m_sb.sb_uuid);
+       uuid_copy(&dsl->sl_uuid, &mp->m_sb.sb_meta_uuid);
        dsl->sl_owner = cpu_to_be64(ino);
        dsl->sl_blkno = cpu_to_be64(bp->b_bn);
        bp->b_ops = &xfs_symlink_buf_ops;
@@ -107,7 +107,7 @@ xfs_symlink_verify(
                return false;
        if (dsl->sl_magic != cpu_to_be32(XFS_SYMLINK_MAGIC))
                return false;
-       if (!uuid_equal(&dsl->sl_uuid, &mp->m_sb.sb_uuid))
+       if (!uuid_equal(&dsl->sl_uuid, &mp->m_sb.sb_meta_uuid))
                return false;
        if (bp->b_bn != be64_to_cpu(dsl->sl_blkno))
                return false;