allow UUID changes on V5/CRC filesystems
cover allow UUID changes on V5/CRC filesystems
Ok, here's the next round. This has been through some degree of testing, though I still probably owe some xfstests testcases.
Dave, in the end I went ahead and kept the sb_uuid name and meaning in the same superblock location; this does mean we touch all verifiers etc, but it makes for more consistency, IMHO.
Thanks,
-Eric
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 1/2 xfs: create new metadata UUID field and incompat flag
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 or clearing of the incompat flag as appropriate, as the UUID gets written.
If the incompat flag is not set, copy the user-visible UUID into into the meta_uuid slot in memory; this 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.
---
fs/xfs/libxfs/xfs_format.h +19 -3
@@ -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;
@@ -457,8 +459,10 @@ xfs_sb_has_ro_compat_feature( }#define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0)/* filetype in dirent */ +#define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 1)/* metadata UUID */ #define XFS_SB_FEAT_INCOMPAT_ALL \ - (XFS_SB_FEAT_INCOMPAT_FTYPE) + (XFS_SB_FEAT_INCOMPAT_FTYPE | \ + XFS_SB_FEAT_INCOMPAT_META_UUID)#define XFS_SB_FEAT_INCOMPAT_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_ALL static inline bool
@@ -507,6 +511,18 @@ static inline int xfs_sb_version_hasfinobt(xfs_sb_t *sbp) }/* +* 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 int xfs_sb_version_hasmetauuid (xfs_sb_t *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 */
fs/xfs/libxfs/xfs_sb.c +11 -0
@@ -377,6 +377,13 @@ __xfs_sb_from_disk( to->sb_pad =0 ; to->sb_pquotino =be64_to_cpu (from->sb_pquotino); to->sb_lsn =be64_to_cpu (from->sb_lsn); +if (xfs_sb_version_hasmetauuid (to)) { +memcpy (&to->sb_meta_uuid, &from->sb_meta_uuid, +sizeof (to->sb_meta_uuid)); + }else { +memcpy (&to->sb_meta_uuid, &from->sb_uuid, +sizeof (to->sb_meta_uuid)); + }/* Convert on-disk flags to in-memory flags? */ if (convert_xquota)xfs_sb_quota_from_disk (to);
@@ -518,6 +525,10 @@ xfs_sb_to_disk(cpu_to_be32 (from->sb_features_log_incompat); to->sb_pad =0 ; to->sb_lsn =cpu_to_be64 (from->sb_lsn); +if (xfs_sb_version_hasmetauuid (from)) { +memcpy (&to->sb_meta_uuid, &from->sb_meta_uuid, +sizeof (to->sb_meta_uuid)); + } } }
fs/xfs/libxfs/xfs_alloc.c +2 -2
@@ -450,7 +450,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;
@@ -2203,7 +2203,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) &&
fs/xfs/libxfs/xfs_alloc_btree.c +2 -2
@@ -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;
fs/xfs/libxfs/xfs_attr_leaf.c +2 -2
@@ -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 {
fs/xfs/libxfs/xfs_attr_remote.c +2 -2
@@ -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);
fs/xfs/libxfs/xfs_bmap_btree.c +3 -2
@@ -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;
fs/xfs/libxfs/xfs_btree.c +6 -4
@@ -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 ; } }
fs/xfs/libxfs/xfs_da_btree.c +2 -2
@@ -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 ; }
fs/xfs/libxfs/xfs_dir2_block.c +2 -2
@@ -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 ; }
fs/xfs/libxfs/xfs_dir2_data.c +2 -2
@@ -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 );
fs/xfs/libxfs/xfs_dir2_leaf.c +2 -2
@@ -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);
fs/xfs/libxfs/xfs_dir2_node.c +2 -2
@@ -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);
fs/xfs/libxfs/xfs_dquot_buf.c +2 -2
@@ -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;
fs/xfs/libxfs/xfs_ialloc.c +3 -2
@@ -307,7 +307,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 */
@@ -2049,7 +2050,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.
fs/xfs/libxfs/xfs_ialloc_btree.c +1 -1
@@ -230,7 +230,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;
fs/xfs/libxfs/xfs_inode_buf.c +2 -2
@@ -306,7 +306,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; }
@@ -368,7 +368,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 ;
fs/xfs/libxfs/xfs_symlink_remote.c +2 -2
@@ -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;
fs/xfs/xfs_dquot.c +1 -1
@@ -251,7 +251,7 @@ xfs_qm_init_dquot_blk( d->dd_diskdq.d_id =cpu_to_be32 (curid); d->dd_diskdq.d_flags = type;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 ); }
fs/xfs/xfs_fsops.c +3 -3
@@ -248,7 +248,7 @@ xfs_growfs_data_private( agf->agf_freeblks =cpu_to_be32 (tmpsize); agf->agf_longest =cpu_to_be32 (tmpsize);if (xfs_sb_version_hascrc (&mp->m_sb)) -uuid_copy (&agf->agf_uuid, &mp->m_sb.sb_uuid); +uuid_copy (&agf->agf_uuid, &mp->m_sb.sb_meta_uuid); error =xfs_bwrite (bp);xfs_buf_relse (bp);
@@ -271,7 +271,7 @@ xfs_growfs_data_private(if (xfs_sb_version_hascrc (&mp->m_sb)) { agfl->agfl_magicnum =cpu_to_be32 (XFS_AGFL_MAGIC ); agfl->agfl_seqno =cpu_to_be32 (agno); -uuid_copy (&agfl->agfl_uuid, &mp->m_sb.sb_uuid); +uuid_copy (&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid); } agfl_bno =XFS_BUF_TO_AGFL_BNO (mp, bp);
@@ -307,7 +307,7 @@ xfs_growfs_data_private( agi->agi_newino =cpu_to_be32 (NULLAGINO ); agi->agi_dirino =cpu_to_be32 (NULLAGINO );if (xfs_sb_version_hascrc (&mp->m_sb)) -uuid_copy (&agi->agi_uuid, &mp->m_sb.sb_uuid); +uuid_copy (&agi->agi_uuid, &mp->m_sb.sb_meta_uuid);if (xfs_sb_version_hasfinobt (&mp->m_sb)) { agi->agi_free_root =cpu_to_be32 (XFS_FIBT_BLOCK (mp)); agi->agi_free_level =cpu_to_be32 (1 );
fs/xfs/xfs_inode.c +1 -1
@@ -787,7 +787,7 @@ xfs_ialloc(if (ip->i_d.di_version ==3 ) {ASSERT (ip->i_d.di_ino == ino); -ASSERT (uuid_equal (&ip->i_d.di_uuid, &mp->m_sb.sb_uuid)); +ASSERT (uuid_equal (&ip->i_d.di_uuid, &mp->m_sb.sb_meta_uuid)); ip->i_d.di_crc =0 ; ip->i_d.di_changecount =1 ; ip->i_d.di_lsn =0 ;
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 1/2] xfs: create new metadata UUID field and incompat flag
Quoted 10 lines · Eric Sandeen
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 or clearing of the incompat flag as appropriate, as the UUID gets written.If the incompat flag is not set, copy the user-visible UUID into into the
meta_uuidslot in memory; this is not written back to disk in this case.
Quoted 5 lines
The remainder of this patch simply switches verifiers, initializers, etc to use the new
sb_meta_uuidfield.Signed-off-by Eric Sandeen <[email protected]>---
This all looks fine to me. The only thing that confuses me is why we continue to use sb_uuid for the log. Eric points out on irc that we can't modify the uuid when the log is dirty, so we can't actually break anything in this manner. In other words, we effectively already handle a modified uuid with respect to the log.
That said, it seems inconsistent to me to create a metadata uuid field and not use it for all metadata. My expectation from such a change is to see sb_uuid now used only for user facing bits (e.g., mount and get geo related) and sb_meta_uuid used everywhere else. Instead, we use sb_uuid for the user facing bits, sb_meta_uuid for the internal bits that can't handle a uuid change and sb_uuid for the internal bits that can.
I suppose I could be convinced otherwise if there's context I'm missing, but otherwise this seems a bit confusing to me...
Brian
Quoted 522 lines
fs/xfs/libxfs/xfs_format.h +19
-3@@ -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;@@ -457,8 +459,10 @@ xfs_sb_has_ro_compat_feature( }#define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0)/* filetype in dirent */ +#define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 1)/* metadata UUID */ #define XFS_SB_FEAT_INCOMPAT_ALL \ - (XFS_SB_FEAT_INCOMPAT_FTYPE) + (XFS_SB_FEAT_INCOMPAT_FTYPE | \ + XFS_SB_FEAT_INCOMPAT_META_UUID)#define XFS_SB_FEAT_INCOMPAT_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_ALL static inline bool@@ -507,6 +511,18 @@ static inline int xfs_sb_version_hasfinobt(xfs_sb_t *sbp) }/* +* 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 int xfs_sb_version_hasmetauuid (xfs_sb_t *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 */ fs/xfs/libxfs/xfs_sb.c +11
-0@@ -377,6 +377,13 @@ __xfs_sb_from_disk( to->sb_pad =0 ; to->sb_pquotino =be64_to_cpu (from->sb_pquotino); to->sb_lsn =be64_to_cpu (from->sb_lsn); +if (xfs_sb_version_hasmetauuid (to)) { +memcpy (&to->sb_meta_uuid, &from->sb_meta_uuid, +sizeof (to->sb_meta_uuid)); + }else { +memcpy (&to->sb_meta_uuid, &from->sb_uuid, +sizeof (to->sb_meta_uuid)); + }/* Convert on-disk flags to in-memory flags? */ if (convert_xquota)xfs_sb_quota_from_disk (to);@@ -518,6 +525,10 @@ xfs_sb_to_disk(cpu_to_be32 (from->sb_features_log_incompat); to->sb_pad =0 ; to->sb_lsn =cpu_to_be64 (from->sb_lsn); +if (xfs_sb_version_hasmetauuid (from)) { +memcpy (&to->sb_meta_uuid, &from->sb_meta_uuid, +sizeof (to->sb_meta_uuid)); + } } }fs/xfs/libxfs/xfs_alloc.c +2
-2@@ -450,7 +450,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;@@ -2203,7 +2203,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) &&fs/xfs/libxfs/xfs_alloc_btree.c +2
-2@@ -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;fs/xfs/libxfs/xfs_attr_leaf.c +2
-2@@ -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 {fs/xfs/libxfs/xfs_attr_remote.c +2
-2@@ -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);fs/xfs/libxfs/xfs_bmap_btree.c +3
-2@@ -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;fs/xfs/libxfs/xfs_btree.c +6
-4@@ -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 ; } }fs/xfs/libxfs/xfs_da_btree.c +2
-2@@ -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 ; }fs/xfs/libxfs/xfs_dir2_block.c +2
-2@@ -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 ; }fs/xfs/libxfs/xfs_dir2_data.c +2
-2@@ -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 );fs/xfs/libxfs/xfs_dir2_leaf.c +2
-2@@ -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);fs/xfs/libxfs/xfs_dir2_node.c +2
-2@@ -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);fs/xfs/libxfs/xfs_dquot_buf.c +2
-2@@ -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;fs/xfs/libxfs/xfs_ialloc.c +3
-2@@ -307,7 +307,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 */ @@ -2049,7 +2050,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. fs/xfs/libxfs/xfs_ialloc_btree.c +1
-1@@ -230,7 +230,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;fs/xfs/libxfs/xfs_inode_buf.c +2
-2@@ -306,7 +306,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; }@@ -368,7 +368,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 ;fs/xfs/libxfs/xfs_symlink_remote.c +2
-2@@ -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;fs/xfs/xfs_dquot.c +1
-1@@ -251,7 +251,7 @@ xfs_qm_init_dquot_blk( d->dd_diskdq.d_id =cpu_to_be32 (curid); d->dd_diskdq.d_flags = type;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 ); }fs/xfs/xfs_fsops.c +3
-3@@ -248,7 +248,7 @@ xfs_growfs_data_private( agf->agf_freeblks =cpu_to_be32 (tmpsize); agf->agf_longest =cpu_to_be32 (tmpsize);if (xfs_sb_version_hascrc (&mp->m_sb)) -uuid_copy (&agf->agf_uuid, &mp->m_sb.sb_uuid); +uuid_copy (&agf->agf_uuid, &mp->m_sb.sb_meta_uuid); error =xfs_bwrite (bp);xfs_buf_relse (bp);@@ -271,7 +271,7 @@ xfs_growfs_data_private(if (xfs_sb_version_hascrc (&mp->m_sb)) { agfl->agfl_magicnum =cpu_to_be32 (XFS_AGFL_MAGIC ); agfl->agfl_seqno =cpu_to_be32 (agno); -uuid_copy (&agfl->agfl_uuid, &mp->m_sb.sb_uuid); +uuid_copy (&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid); } agfl_bno =XFS_BUF_TO_AGFL_BNO (mp, bp);@@ -307,7 +307,7 @@ xfs_growfs_data_private( agi->agi_newino =cpu_to_be32 (NULLAGINO ); agi->agi_dirino =cpu_to_be32 (NULLAGINO );if (xfs_sb_version_hascrc (&mp->m_sb)) -uuid_copy (&agi->agi_uuid, &mp->m_sb.sb_uuid); +uuid_copy (&agi->agi_uuid, &mp->m_sb.sb_meta_uuid);if (xfs_sb_version_hasfinobt (&mp->m_sb)) { agi->agi_free_root =cpu_to_be32 (XFS_FIBT_BLOCK (mp)); agi->agi_free_level =cpu_to_be32 (1 );fs/xfs/xfs_inode.c +1
-1@@ -787,7 +787,7 @@ xfs_ialloc(if (ip->i_d.di_version ==3 ) {ASSERT (ip->i_d.di_ino == ino); -ASSERT (uuid_equal (&ip->i_d.di_uuid, &mp->m_sb.sb_uuid)); +ASSERT (uuid_equal (&ip->i_d.di_uuid, &mp->m_sb.sb_meta_uuid)); ip->i_d.di_crc =0 ; ip->i_d.di_changecount =1 ; ip->i_d.di_lsn =0 ;
Quoted 4 lines
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 1/2] xfs: create new metadata UUID field and incompat flag
Quoted 29 lines · Brian Foster
Quoted 10 lines · Eric Sandeen
Quoted 10 lines
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 or clearing of the incompat flag as appropriate, as the UUID gets written.If the incompat flag is not set, copy the user-visible UUID into into the
meta_uuidslot in memory; this is not written back to disk in this case.Quoted 5 lines
Quoted 5 lines
The remainder of this patch simply switches verifiers, initializers, etc to use the new
sb_meta_uuidfield.Signed-off-by Eric Sandeen <[email protected]>---
This all looks fine to me. The only thing that confuses me is why we continue to use
sb_uuidfor the log. Eric points out on irc that we can't modify the uuid when the log is dirty, so we can't actually break anything in this manner. In other words, we effectively already handle a modified uuid with respect to the log.That said, it seems inconsistent to me to create a metadata uuid field and not use it for all metadata. My expectation from such a change is to see
sb_uuidnow used only for user facing bits (e.g., mount and get geo related) andsb_meta_uuidused everywhere else. Instead, we usesb_uuidfor the user facing bits,sb_meta_uuidfor the internal bits that can't handle a uuid change andsb_uuidfor the internal bits that can.
Quoted 4 lines
I suppose I could be convinced otherwise if there's context I'm missing, but otherwise this seems a bit confusing to me...
Brian
Yeah, I'm sympathetic to that argument. I can look into using sb_meta_uuid for the log too, if the incompat flag is set.
I had skipped it just because that use of the UUID predated the CRC changes.
-Eric
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 1/2] xfs: create new metadata UUID field and incompat flag
Quoted 30 lines · Eric Sandeen
Quoted 29 lines · Brian Foster
Quoted 10 lines · Eric Sandeen
Quoted 10 lines
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 or clearing of the incompat flag as appropriate, as the UUID gets written.If the incompat flag is not set, copy the user-visible UUID into into the
meta_uuidslot in memory; this is not written back to disk in this case.Quoted 5 lines
Quoted 5 lines
The remainder of this patch simply switches verifiers, initializers, etc to use the new
sb_meta_uuidfield.Signed-off-by Eric Sandeen <[email protected]>---
This all looks fine to me. The only thing that confuses me is why we continue to use
sb_uuidfor the log. Eric points out on irc that we can't modify the uuid when the log is dirty, so we can't actually break anything in this manner. In other words, we effectively already handle a modified uuid with respect to the log.That said, it seems inconsistent to me to create a metadata uuid field and not use it for all metadata. My expectation from such a change is to see
sb_uuidnow used only for user facing bits (e.g., mount and get geo related) andsb_meta_uuidused everywhere else. Instead, we usesb_uuidfor the user facing bits,sb_meta_uuidfor the internal bits that can't handle a uuid change andsb_uuidfor the internal bits that can.
Quoted 7 lines
Quoted 4 lines
I suppose I could be convinced otherwise if there's context I'm missing, but otherwise this seems a bit confusing to me...
Brian
Yeah, I'm sympathetic to that argument. I can look into using
sb_meta_uuidfor the log too, if the incompat flag is set.
The log uuid is user facing, like the superblock uuid. i.e. there are tools that identify external log devices by checking that the uuid in the log matches the user facing uuid in the superblock. Hence the log uuid needs to use the uuid that is reported to userspace.
Quoted 1 line
I had skipped it just because that use of the UUID predated the CRC changes.
Changing the uuid results in the log being zeroed, so the uuid in the log can be changed without issue, even if we are using CRCs.
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 1/2] xfs: create new metadata UUID field and incompat flag
Quoted 36 lines · Dave Chinner
Quoted 35 lines · Eric Sandeen
Quoted 33 lines · Brian Foster
Quoted 10 lines · Eric Sandeen
Quoted 10 lines
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 or clearing of the incompat flag as appropriate, as the UUID gets written.If the incompat flag is not set, copy the user-visible UUID into into the
meta_uuidslot in memory; this is not written back to disk in this case.Quoted 5 lines
Quoted 5 lines
The remainder of this patch simply switches verifiers, initializers, etc to use the new
sb_meta_uuidfield.Signed-off-by Eric Sandeen <[email protected]>---
This all looks fine to me. The only thing that confuses me is why we continue to use
sb_uuidfor the log. Eric points out on irc that we can't modify the uuid when the log is dirty, so we can't actually break anything in this manner. In other words, we effectively already handle a modified uuid with respect to the log.That said, it seems inconsistent to me to create a metadata uuid field and not use it for all metadata. My expectation from such a change is to see
sb_uuidnow used only for user facing bits (e.g., mount and get geo related) andsb_meta_uuidused everywhere else. Instead, we usesb_uuidfor the user facing bits,sb_meta_uuidfor the internal bits that can't handle a uuid change andsb_uuidfor the internal bits that can.I suppose I could be convinced otherwise if there's context I'm missing, but otherwise this seems a bit confusing to me...
Brian
Quoted 8 lines
Quoted 2 lines
Yeah, I'm sympathetic to that argument. I can look into using
sb_meta_uuidfor the log too, if the incompat flag is set.The log uuid is user facing, like the superblock uuid. i.e. there are tools that identify external log devices by checking that the uuid in the log matches the user facing uuid in the superblock. Hence the log uuid needs to use the uuid that is reported to userspace.
None that are external to xfsprogs, I think, are there? (1) - but still. I'm happy to leave it as it is ... I don't think it really matters either way.
-Eric
(1) at one point I wanted to teach blkid to find an external log by UUID, but there is no "log superblock" so I gave up on that idea.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 1/2] xfs: create new metadata UUID field and incompat flag
Quoted 19 lines · Eric Sandeen
Quoted 8 lines · Dave Chinner
Quoted 7 lines · Eric Sandeen
Quoted 5 lines · Brian Foster
On Fri, May 08, 2015 at 03:48:16PM -0500, Eric Sandeen wrote:
I suppose I could be convinced otherwise if there's context I'm missing, but otherwise this seems a bit confusing to me...Brian
Quoted 8 lines
Quoted 2 lines
Yeah, I'm sympathetic to that argument. I can look into using
sb_meta_uuidfor the log too, if the incompat flag is set.The log uuid is user facing, like the superblock uuid. i.e. there are tools that identify external log devices by checking that the uuid in the log matches the user facing uuid in the superblock. Hence the log uuid needs to use the uuid that is reported to userspace.
Quoted 7 lines
None that are external to xfsprogs, I think, are there? (1) - but still. I'm happy to leave it as it is ... I don't think it really matters either way.
-Eric
(1) at one point I wanted to teach blkid to find an external log by UUID, but there is no "log superblock" so I gave up on that idea.
Well, we don't know, really, do we? It's best to play it safe and keep it the same as the user visible filesytem uuid, as that is what is currently expected by anything poking at block dev UUIDs...
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 1/2] xfs: create new metadata UUID field and incompat flag
In reply to Dave ChinnerQuoted 36 lines · Dave Chinner
Quoted 35 lines · Eric Sandeen
Quoted 33 lines · Brian Foster
Quoted 10 lines · Eric Sandeen
Quoted 10 lines
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 or clearing of the incompat flag as appropriate, as the UUID gets written.If the incompat flag is not set, copy the user-visible UUID into into the
meta_uuidslot in memory; this is not written back to disk in this case.Quoted 5 lines
Quoted 5 lines
The remainder of this patch simply switches verifiers, initializers, etc to use the new
sb_meta_uuidfield.Signed-off-by Eric Sandeen <[email protected]>---
This all looks fine to me. The only thing that confuses me is why we continue to use
sb_uuidfor the log. Eric points out on irc that we can't modify the uuid when the log is dirty, so we can't actually break anything in this manner. In other words, we effectively already handle a modified uuid with respect to the log.That said, it seems inconsistent to me to create a metadata uuid field and not use it for all metadata. My expectation from such a change is to see
sb_uuidnow used only for user facing bits (e.g., mount and get geo related) andsb_meta_uuidused everywhere else. Instead, we usesb_uuidfor the user facing bits,sb_meta_uuidfor the internal bits that can't handle a uuid change andsb_uuidfor the internal bits that can.I suppose I could be convinced otherwise if there's context I'm missing, but otherwise this seems a bit confusing to me...
Brian
Quoted 9 lines
Quoted 2 lines
Yeah, I'm sympathetic to that argument. I can look into using
sb_meta_uuidfor the log too, if the incompat flag is set.The log uuid is user facing, like the superblock uuid. i.e. there are tools that identify external log devices by checking that the uuid in the log matches the user facing uuid in the superblock. Hence the log uuid needs to use the uuid that is reported to userspace.
Ok, sounds good. Thanks for the explanation.
Brian
Quoted 16 lines
Quoted 1 line
I had skipped it just because that use of the UUID predated the CRC changes.
Changing the uuid results in the log being zeroed, so the uuid in the log can be changed without issue, even if we are using CRCs.
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 2/2 xfsprogs: Add new sb_meta_uuid field, and userspace tools to manipulate it
In reply to Eric SandeenThis adds a new superblock field, sb_meta_uuid. This allows us to change the use-visible UUID on crc-enabled filesytems from userspace if desired, by copying the existing UUID to the new location for metadata comparisons. If this is done, an incompat flag must be set to prevent older filesystems from mounting the filesystem, but the original UUID can be restored, and the incompat flag removed, with a new xfs_db / xfs_admin UUID command, "restore."
Much of this patch mirrors the kernel patch in simply renaming the field used for metadata uuid comparison; other bits:
* Teach xfs_db to print the new meta_uuid field
* Allow xfs_db to generate a new UUID for CRC-enabled filesystems
* Allow xfs_db to revert to the original UUID and clear the flag
* Fix up xfs_copy to work with CRC-enabled filesystems
* Update the xfs_admin manpage to show the UUID "generate" command
---
I could break this into core libxfs & functional patches if you like; in retrospect that's probably a good idea.
Right now xfs_db "uuid restore" squawks if called on a filesystem that doesn't need it; perhaps that should be removed...
I'm not totally sold on the "restore" command name either; open to suggestions.
include/xfs_sb.h +22 -5
@@ -107,7 +107,7 @@ typedef struct xfs_sb {xfs_drfsbno_t sb_dblocks;/* number of data blocks */ xfs_drfsbno_t sb_rblocks;/* number of realtime blocks */ xfs_drtbno_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_dfsbno_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 */
@@ -178,6 +178,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;
@@ -194,7 +195,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 */
@@ -264,6 +265,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;
@@ -287,7 +289,7 @@ typedef enum {XFS_SBS_FEATURES2 ,XFS_SBS_BAD_FEATURES2 ,XFS_SBS_FEATURES_COMPAT ,XFS_SBS_FEATURES_RO_COMPAT ,XFS_SBS_FEATURES_INCOMPAT ,XFS_SBS_FEATURES_LOG_INCOMPAT ,XFS_SBS_CRC ,XFS_SBS_PAD , -XFS_SBS_PQUOTINO ,XFS_SBS_LSN , +XFS_SBS_PQUOTINO ,XFS_SBS_LSN ,XFS_SBS_META_UUID ,XFS_SBS_FIELDCOUNT } xfs_sb_field_t;
@@ -319,6 +321,7 @@ typedef enum {#define XFS_SB_FEATURES_LOG_INCOMPAT XFS_SB_MVAL(FEATURES_LOG_INCOMPAT)#define XFS_SB_CRC XFS_SB_MVAL(CRC)#define XFS_SB_PQUOTINO XFS_SB_MVAL(PQUOTINO) +#define XFS_SB_META_UUID XFS_SB_MVAL(META_UUID)#define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT)#define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1)#define XFS_SB_MOD_BITS \
@@ -328,7 +331,7 @@ typedef enum {XFS_SB_ICOUNT |XFS_SB_IFREE |XFS_SB_FDBLOCKS |XFS_SB_FEATURES2 | \XFS_SB_BAD_FEATURES2 |XFS_SB_FEATURES_COMPAT | \XFS_SB_FEATURES_RO_COMPAT |XFS_SB_FEATURES_INCOMPAT | \ - XFS_SB_FEATURES_LOG_INCOMPAT | XFS_SB_PQUOTINO) + XFS_SB_FEATURES_LOG_INCOMPAT | XFS_SB_PQUOTINO | XFS_SB_META_UUID)/*
@@ -600,8 +603,10 @@ xfs_sb_has_ro_compat_feature( }#define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0)/* filetype in dirent */ +#define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 1)/* metadata UUID */ #define XFS_SB_FEAT_INCOMPAT_ALL \ - (XFS_SB_FEAT_INCOMPAT_FTYPE) + (XFS_SB_FEAT_INCOMPAT_FTYPE | \ + XFS_SB_FEAT_INCOMPAT_META_UUID)#define XFS_SB_FEAT_INCOMPAT_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_ALL static inline bool
@@ -650,6 +655,18 @@ static inline int xfs_sb_version_hasfinobt(xfs_sb_t *sbp) }/* +* 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 int xfs_sb_version_hasmetauuid (xfs_sb_t *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 */
libxfs/xfs_sb.c +15 -0
@@ -81,6 +81,7 @@ static const struct { { offsetof(xfs_sb_t, sb_pad), 0 }, { offsetof(xfs_sb_t, sb_pquotino), 0 }, { offsetof(xfs_sb_t, sb_lsn), 0 }, + { offsetof(xfs_sb_t, sb_meta_uuid), 1 }, { sizeof(xfs_sb_t), 0 } };
@@ -413,6 +414,13 @@ xfs_sb_from_disk( to->sb_pad =0 ; to->sb_pquotino =be64_to_cpu (from->sb_pquotino); to->sb_lsn =be64_to_cpu (from->sb_lsn); +if (xfs_sb_version_hasmetauuid (to)) { +memcpy (&to->sb_meta_uuid, &from->sb_meta_uuid, +sizeof (to->sb_meta_uuid)); + }else { +memcpy (&to->sb_meta_uuid, &from->sb_uuid, +sizeof (to->sb_meta_uuid)); + } } static inline void
@@ -490,6 +498,13 @@ xfs_sb_to_disk(/* We should never write the crc here, it's updated in the IO path */ fields &= ~XFS_SB_CRC ; +/* +* If the metadata-specific UUID feature isn't set, it's only set +* in memory; don't write it out. +*/ +if (!xfs_sb_version_hasmetauuid (from)) + fields &= ~XFS_SB_UUID ; +xfs_sb_quota_to_disk (to, from, &fields);while (fields) { f = (xfs_sb_field_t )xfs_lowbit64 ((__uint64_t )fields);
copy/xfs_copy.c +29 -12
59 lines not on this page · raw message
db/sb.c +46 -13
103 lines not on this page · raw message
libxfs/util.c +1 -1
@@ -250,7 +250,7 @@ libxfs_ialloc(if (ip->i_d.di_version ==3 ) {ASSERT (ip->i_d.di_ino == ino); -ASSERT (uuid_equal (&ip->i_d.di_uuid, &mp->m_sb.sb_uuid)); +ASSERT (uuid_equal (&ip->i_d.di_uuid, &mp->m_sb.sb_meta_uuid)); ip->i_d.di_crc =0 ; ip->i_d.di_changecount =1 ; ip->i_d.di_lsn =0 ;
libxfs/xfs_alloc.c +2 -2
@@ -426,7 +426,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;
@@ -2181,7 +2181,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) &&
libxfs/xfs_alloc_btree.c +2 -2
@@ -279,7 +279,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;
@@ -297,7 +297,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;
libxfs/xfs_attr_leaf.c +2 -2
@@ -161,7 +161,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;
@@ -952,7 +952,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 {
libxfs/xfs_attr_remote.c +2 -2
@@ -78,7 +78,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;
@@ -194,7 +194,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);
libxfs/xfs_bmap_btree.c +3 -2
@@ -412,7 +412,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
@@ -712,7 +713,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;
libxfs/xfs_btree.c +6 -4
@@ -50,7 +50,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 ); }
@@ -100,7 +101,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 ); }
@@ -992,7 +994,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 ; }
@@ -1005,7 +1007,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 ; } }
libxfs/xfs_da_btree.c +2 -2
@@ -172,7 +172,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;
@@ -349,7 +349,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 ; }
libxfs/xfs_dir2_block.c +2 -2
@@ -51,7 +51,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;
@@ -141,7 +141,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 ; }
libxfs/xfs_dir2_data.c +2 -2
@@ -186,7 +186,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;
@@ -573,7 +573,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 );
libxfs/xfs_dir2_leaf.c +2 -2
@@ -186,7 +186,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;
@@ -337,7 +337,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);
libxfs/xfs_dir2_node.c +2 -2
@@ -78,7 +78,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;
@@ -257,7 +257,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 ;xfs_dir3_free_hdr_to_disk (bp->b_addr, &hdr);
libxfs/xfs_dquot_buf.c +2 -2
@@ -146,7 +146,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 ); }
@@ -181,7 +181,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;
libxfs/xfs_ialloc.c +3 -2
@@ -295,7 +295,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 */
@@ -1947,7 +1948,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.
libxfs/xfs_ialloc_btree.c +1 -1
@@ -214,7 +214,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;
libxfs/xfs_inode_buf.c +1 -1
@@ -295,7 +295,7 @@ xfs_dinode_verify(return false;if (be64_to_cpu (dip->di_ino) != 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; }
libxfs/xfs_symlink_remote.c +2 -2
@@ -48,7 +48,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;
@@ -93,7 +93,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;
libxlog/util.c +4 -2
@@ -28,8 +28,10 @@ header_check_uuid(xfs_mount_t *mp, xlog_rec_header_t *head) {char uu_log[64 ], uu_sb[64 ]; -if (print_skip_uuid)return 0 ; -if (!platform_uuid_compare (&mp->m_sb.sb_uuid, &head->h_fs_uuid))return 0 ; +if (print_skip_uuid) +return 0 ; +if (!platform_uuid_compare (&mp->m_sb.sb_uuid, &head->h_fs_uuid)) +return 0 ;platform_uuid_unparse (&mp->m_sb.sb_uuid, uu_sb);platform_uuid_unparse (&head->h_fs_uuid, uu_log);
man/man8/xfs_admin.8 +6 -1
@@ -98,7 +98,12 @@ The .I uuid may also be .BR generate , -which will generate a new UUID for the filesystem. +which will generate a new UUID for the filesystem. Note that on CRC-enabled +filesystems, this will set an incompatible flag such that older kernels will +not be able to mount the filesystem. To remove this incompatible flag, use +.BR restore , +which will match the UUID to the metadata UUID and remove the incompatible +feature flag. .TP .B \-V Prints the version number and exits.
man/man8/xfs_db.8 +7 -2
@@ -664,7 +664,7 @@ The possible data types are: .BR sb ", " symlink " and " text . See the TYPES section below for more information on these data types. .TP -.BI "uuid [" uuid " | " generate " | " rewrite ] +.BI "uuid [" uuid " | " generate " | " rewrite " | " restore ] Set the filesystem universally unique identifier (UUID). The filesystem UUID can be used by .BR mount (8)
@@ -675,7 +675,12 @@ can be set directly to the desired UUID, or it can be automatically generated using the .B generate option. These options will both write the UUID into every copy of the -superblock in the filesystem. +superblock in the filesystem. On a CRC-enabled filesystem, this will +set an incompatible superblock flag, and the filesystem will not be +mountable with older kernels. This can be reverted with the +.B restore +option, which will copy the original UUID back into place, and clear +the incompatible flag. .B rewrite copies the current UUID from the primary superblock to all secondary copies of the superblock.
mkfs/xfs_mkfs.c +6 -3
@@ -2755,7 +2755,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"), agf->agf_freeblks =cpu_to_be32 (nbmblocks); agf->agf_longest =cpu_to_be32 (nbmblocks);if (xfs_sb_version_hascrc (&mp->m_sb)) -platform_uuid_copy (&agf->agf_uuid, &mp->m_sb.sb_uuid); +platform_uuid_copy (&agf->agf_uuid, + &mp->m_sb.sb_meta_uuid);if (loginternal && agno == logagno) {be32_add_cpu (&agf->agf_freeblks, -logblocks);
@@ -2779,7 +2780,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),if (xfs_sb_version_hascrc (&mp->m_sb)) { agfl->agfl_magicnum =cpu_to_be32 (XFS_AGFL_MAGIC ); agfl->agfl_seqno =cpu_to_be32 (agno); -platform_uuid_copy (&agfl->agfl_uuid, &mp->m_sb.sb_uuid); +platform_uuid_copy (&agfl->agfl_uuid, + &mp->m_sb.sb_meta_uuid);for (bucket =0 ; bucket <XFS_AGFL_SIZE (mp); bucket++) agfl->agfl_bno[bucket] =cpu_to_be32 (NULLAGBLOCK ); }
@@ -2810,7 +2812,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"), agi->agi_newino =cpu_to_be32 (NULLAGINO ); agi->agi_dirino =cpu_to_be32 (NULLAGINO );if (xfs_sb_version_hascrc (&mp->m_sb)) -platform_uuid_copy (&agi->agi_uuid, &mp->m_sb.sb_uuid); +platform_uuid_copy (&agi->agi_uuid, + &mp->m_sb.sb_meta_uuid);for (c =0 ; c <XFS_AGI_UNLINKED_BUCKETS ; c++) agi->agi_unlinked[c] =cpu_to_be32 (NULLAGINO );libxfs_writebuf (buf,LIBXFS_EXIT_ON_FAILURE );
repair/agheader.c +12 -7
@@ -112,7 +112,7 @@ verify_set_agf(xfs_mount_t *mp, xfs_agf_t *agf, xfs_agnumber_t i)if (!xfs_sb_version_hascrc (&mp->m_sb))return retval; -if (platform_uuid_compare (&agf->agf_uuid, &mp->m_sb.sb_uuid)) { +if (platform_uuid_compare (&agf->agf_uuid, &mp->m_sb.sb_meta_uuid)) {char uu[64 ]; retval =XR_AG_AGF ;
@@ -120,7 +120,8 @@ verify_set_agf(xfs_mount_t *mp, xfs_agf_t *agf, xfs_agnumber_t i)do_warn (_ ("bad uuid %s for agf %d\n" ), uu, i);if (!no_modify) -platform_uuid_copy (&agf->agf_uuid, &mp->m_sb.sb_uuid); +platform_uuid_copy (&agf->agf_uuid, + &mp->m_sb.sb_meta_uuid); }return retval; }
@@ -190,7 +191,7 @@ verify_set_agi(xfs_mount_t *mp, xfs_agi_t *agi, xfs_agnumber_t agno)if (!xfs_sb_version_hascrc (&mp->m_sb))return retval; -if (platform_uuid_compare (&agi->agi_uuid, &mp->m_sb.sb_uuid)) { +if (platform_uuid_compare (&agi->agi_uuid, &mp->m_sb.sb_meta_uuid)) {char uu[64 ]; retval =XR_AG_AGI ;
@@ -198,7 +199,8 @@ verify_set_agi(xfs_mount_t *mp, xfs_agi_t *agi, xfs_agnumber_t agno)do_warn (_ ("bad uuid %s for agi %d\n" ), uu, agno);if (!no_modify) -platform_uuid_copy (&agi->agi_uuid, &mp->m_sb.sb_uuid); +platform_uuid_copy (&agi->agi_uuid, + &mp->m_sb.sb_meta_uuid); }return retval;
@@ -245,7 +247,7 @@ compare_sb(xfs_mount_t *mp, xfs_sb_t *sb)* superblocks, not just the secondary superblocks. */ static int -secondary_sb_wack( +secondary_sb_whack( struct xfs_mount *mp, struct xfs_buf *sbuf, struct xfs_sb *sb,
@@ -267,7 +269,10 @@ secondary_sb_wack(* * size is the size of data which is valid for this sb. */ -if (xfs_sb_version_hascrc (sb)) +if (xfs_sb_version_hasmetauuid (sb)) + size = offsetof(xfs_sb_t , sb_meta_uuid) + +sizeof (sb->sb_meta_uuid); +else if (xfs_sb_version_hascrc (sb)) size = offsetof(xfs_sb_t , sb_lsn) +sizeof (sb->sb_lsn);else if (xfs_sb_version_hasmorebits (sb))
@@ -526,7 +531,7 @@ verify_set_agheader(xfs_mount_t *mp, xfs_buf_t *sbuf, xfs_sb_t *sb, rval |=XR_AG_SB ; } - rval |=secondary_sb_wack (mp, sbuf, sb, i); + rval |=secondary_sb_whack (mp, sbuf, sb, i); rval |=verify_set_agf (mp, agf, i); rval |=verify_set_agi (mp, agi, i);
repair/agheader.h +0 -1
@@ -24,7 +24,6 @@ typedef struct fs_geometry {xfs_drfsbno_t sb_dblocks;/* # data blocks */ xfs_drfsbno_t sb_rblocks;/* # realtime blocks */ xfs_drtbno_t sb_rextents;/* # realtime extents */ -uuid_t sb_uuid;/* fs uuid */ xfs_dfsbno_t sb_logstart;/* starting log block # */ xfs_agblock_t sb_rextsize;/* realtime extent size (blocks )*/ xfs_agblock_t sb_agblocks;/* # of blocks per ag */
repair/dinode.c +4 -3
@@ -208,9 +208,9 @@ clear_dinode_core(struct xfs_mount *mp, xfs_dinode_t *dinoc, xfs_ino_t ino_num) dinoc->di_ino =cpu_to_be64 (ino_num); } -if (platform_uuid_compare (&dinoc->di_uuid, &mp->m_sb.sb_uuid)) { +if (platform_uuid_compare (&dinoc->di_uuid, &mp->m_sb.sb_meta_uuid)) {__dirty_no_modify_ret (dirty); -platform_uuid_copy (&dinoc->di_uuid, &mp->m_sb.sb_uuid); +platform_uuid_copy (&dinoc->di_uuid, &mp->m_sb.sb_meta_uuid); }for (i =0 ; i <sizeof (dinoc->di_pad2)/sizeof (dinoc->di_pad2[0 ]); i++) {
@@ -2366,7 +2366,8 @@ _("inode identifier %llu mismatch on inode %" PRIu64 "\n"),return 1 ; goto clear_bad_out; } -if (platform_uuid_compare (&dino->di_uuid, &mp->m_sb.sb_uuid)) { +if (platform_uuid_compare (&dino->di_uuid, + &mp->m_sb.sb_meta_uuid)) {if (!uncertain)do_warn (_ ("UUID mismatch on inode %" PRIu64"\n" ), lino);
repair/phase5.c +3 -3
@@ -1119,7 +1119,7 @@ build_agi(xfs_mount_t *mp, xfs_agnumber_t agno, bt_status_t *btree_curs, agi->agi_unlinked[i] =cpu_to_be32 (NULLAGINO );if (xfs_sb_version_hascrc (&mp->m_sb)) -platform_uuid_copy (&agi->agi_uuid, &mp->m_sb.sb_uuid); +platform_uuid_copy (&agi->agi_uuid, &mp->m_sb.sb_meta_uuid);if (xfs_sb_version_hasfinobt (&mp->m_sb)) { agi->agi_free_root =cpu_to_be32 (finobt_curs->root);
@@ -1360,7 +1360,7 @@ build_agf_agfl(xfs_mount_t *mp,#endif if (xfs_sb_version_hascrc (&mp->m_sb)) -platform_uuid_copy (&agf->agf_uuid, &mp->m_sb.sb_uuid); +platform_uuid_copy (&agf->agf_uuid, &mp->m_sb.sb_meta_uuid);/* initialise the AGFL, then fill it if there are blocks left over. */ agfl_buf = libxfs_getbuf(mp->m_dev,
@@ -1374,7 +1374,7 @@ build_agf_agfl(xfs_mount_t *mp,if (xfs_sb_version_hascrc (&mp->m_sb)) { agfl->agfl_magicnum =cpu_to_be32 (XFS_AGFL_MAGIC ); agfl->agfl_seqno =cpu_to_be32 (agno); -platform_uuid_copy (&agfl->agfl_uuid, &mp->m_sb.sb_uuid); +platform_uuid_copy (&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid);for (i =0 ; i <XFS_AGFL_SIZE (mp); i++) agfl->agfl_bno[i] =cpu_to_be32 (NULLAGBLOCK ); }
repair/phase6.c +3 -3
@@ -526,7 +526,7 @@ mk_rbmino(xfs_mount_t *mp) ip->i_d.di_flags2 =0 ; ip->i_d.di_ino = mp->m_sb.sb_rbmino;memset (&(ip->i_d.di_pad2[0 ]),0 ,sizeof (ip->i_d.di_pad2)); -platform_uuid_copy (&ip->i_d.di_uuid, &mp->m_sb.sb_uuid); +platform_uuid_copy (&ip->i_d.di_uuid, &mp->m_sb.sb_meta_uuid); times |=XFS_ICHGTIME_CREATE ; }libxfs_trans_ichgtime (tp, ip, times);
@@ -782,7 +782,7 @@ mk_rsumino(xfs_mount_t *mp) ip->i_d.di_flags2 =0 ; ip->i_d.di_ino = mp->m_sb.sb_rsumino;memset (&(ip->i_d.di_pad2[0 ]),0 ,sizeof (ip->i_d.di_pad2)); -platform_uuid_copy (&ip->i_d.di_uuid, &mp->m_sb.sb_uuid); +platform_uuid_copy (&ip->i_d.di_uuid, &mp->m_sb.sb_meta_uuid); times |=XFS_ICHGTIME_CREATE ; }libxfs_trans_ichgtime (tp, ip, times);
@@ -898,7 +898,7 @@ mk_root_dir(xfs_mount_t *mp) ip->i_d.di_flags2 =0 ; ip->i_d.di_ino = mp->m_sb.sb_rootino;memset (&(ip->i_d.di_pad2[0 ]),0 ,sizeof (ip->i_d.di_pad2)); -platform_uuid_copy (&ip->i_d.di_uuid, &mp->m_sb.sb_uuid); +platform_uuid_copy (&ip->i_d.di_uuid, &mp->m_sb.sb_meta_uuid); times |=XFS_ICHGTIME_CREATE ; }libxfs_trans_ichgtime (tp, ip, times);
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 2/2] xfsprogs: Add new sb_meta_uuid field, and userspace tools to manipulate it
Of course, just ran into a problem w/ mkfs not initializing stuff right, not sure why the first 25 xfstests were happy.
Will send V2 for userspace, split into libxfs & tools updates, and that fix.
-Eric
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 2/2 xfsprogs: Add new sb_meta_uuid field, and userspace tools to manipulate it
In reply to Eric SandeenThis adds a new superblock field, sb_meta_uuid. This allows us to change the use-visible UUID on crc-enabled filesytems from userspace if desired, by copying the existing UUID to the new location for metadata comparisons. If this is done, an incompat flag must be set to prevent older filesystems from mounting the filesystem, but the original UUID can be restored, and the incompat flag removed, with a new xfs_db / xfs_admin UUID command, "restore."
Much of this patch mirrors the kernel patch in simply renaming the field used for metadata uuid comparison; other bits:
* Teach xfs_db to print the new meta_uuid field
* Allow xfs_db to generate a new UUID for CRC-enabled filesystems
* Allow xfs_db to revert to the original UUID and clear the flag
* Fix up xfs_copy to work with CRC-enabled filesystems
* Update the xfs_admin manpage to show the UUID "generate" command
---
V2: initialize meta_uuid at mkfs time, libxfs expects this to be as if read from disk w/o the META_UUID incompat flag, and copied to the meta_uuid field.
Breaking it into libxfs & tools is actually more intricate than I thought, so skipping it unless really desired. ;)
Right now xfs_db "uuid restore" squawks if called on a filesystem that doesn't need it; perhaps that should be removed...
I'm not totally sold on the "restore" command name either; open to suggestions.
copy/xfs_copy.c +29 -12
@@ -466,6 +466,34 @@ write_wbuf(void)sighold (SIGCHLD ); } +void +sb_update_uuid ( +xfs_sb_t *sb, +ag_header_t *ag_hdr, +thread_args *tcarg) +{ +/* +* If this filesystem has CRCs, the original UUID is stamped into +* all metadata. We need to copy the original UUID into the meta_uuid +* slot and set the incompat flag if that hasn't already been done. +*/ +if (xfs_sb_version_hascrc (sb) && !xfs_sb_version_hasmetauuid (sb)) { +__be32 feat; + + feat =be32_to_cpu (ag_hdr->xfs_sb->sb_features_incompat); + feat |=XFS_SB_FEAT_INCOMPAT_META_UUID ; + ag_hdr->xfs_sb->sb_features_incompat =cpu_to_be32 (feat); +platform_uuid_copy (&ag_hdr->xfs_sb->sb_meta_uuid, + &ag_hdr->xfs_sb->sb_uuid); + } + +platform_uuid_copy (&ag_hdr->xfs_sb->sb_uuid, &tcarg->uuid); + +/* We changed the UUID, so update the superblock CRC if needed */ +if (xfs_sb_version_hascrc (sb)) +xfs_update_cksum ((char *)&ag_hdr->xfs_sb, sb->sb_sectsize, +XFS_SB_CRC_OFF ); +}int main (int argc,char **argv)
@@ -659,16 +687,6 @@ main(int argc, char **argv) sb = &mbuf.m_sb;libxfs_sb_from_disk (sb,XFS_BUF_TO_SBP (sbp)); -/* -* For now, V5 superblock filesystems are not supported without -d; -* we do not have the infrastructure yet to fix CRCs when a new UUID -* is generated. -*/ -if (xfs_sb_version_hascrc (sb) && !duplicate) { -do_log (_ ("%s: Cannot yet copy V5 fs without '-d'\n" ), progname); -exit (1 ); - } - mp =libxfs_mount (&mbuf, sb, xargs.ddev, xargs.logdev, xargs.rtdev,0 );if (mp ==NULL ) { do_log(_("%s: %s filesystem failed to initialize\n"
@@ -1127,8 +1145,7 @@ main(int argc, char **argv)/* do each thread in turn, each has its own UUID */ for (j =0 , tcarg = targ; j < num_targets; j++) { -platform_uuid_copy (&ag_hdr.xfs_sb->sb_uuid, - &tcarg->uuid); +sb_update_uuid (sb, &ag_hdr, tcarg);do_write (tcarg); tcarg++; }
db/sb.c +46 -13
103 lines not on this page · raw message
libxfs/xfs_sb.c +1 -1
@@ -503,7 +503,7 @@ xfs_sb_to_disk(* in memory; don't write it out. */ if (!xfs_sb_version_hasmetauuid (from)) - fields &= ~XFS_SB_UUID ; + fields &= ~XFS_SB_META_UUID ;xfs_sb_quota_to_disk (to, from, &fields);while (fields) {
libxlog/util.c +4 -2
@@ -28,8 +28,10 @@ header_check_uuid(xfs_mount_t *mp, xlog_rec_header_t *head) {char uu_log[64 ], uu_sb[64 ]; -if (print_skip_uuid)return 0 ; -if (!platform_uuid_compare (&mp->m_sb.sb_uuid, &head->h_fs_uuid))return 0 ; +if (print_skip_uuid) +return 0 ; +if (!platform_uuid_compare (&mp->m_sb.sb_uuid, &head->h_fs_uuid)) +return 0 ;platform_uuid_unparse (&mp->m_sb.sb_uuid, uu_sb);platform_uuid_unparse (&head->h_fs_uuid, uu_log);
man/man8/xfs_admin.8 +6 -1
@@ -98,7 +98,12 @@ The .I uuid may also be .BR generate , -which will generate a new UUID for the filesystem. +which will generate a new UUID for the filesystem. Note that on CRC-enabled +filesystems, this will set an incompatible flag such that older kernels will +not be able to mount the filesystem. To remove this incompatible flag, use +.BR restore , +which will match the UUID to the metadata UUID and remove the incompatible +feature flag. .TP .B \-V Prints the version number and exits.
man/man8/xfs_db.8 +7 -2
@@ -664,7 +664,7 @@ The possible data types are: .BR sb ", " symlink " and " text . See the TYPES section below for more information on these data types. .TP -.BI "uuid [" uuid " | " generate " | " rewrite ] +.BI "uuid [" uuid " | " generate " | " rewrite " | " restore ] Set the filesystem universally unique identifier (UUID). The filesystem UUID can be used by .BR mount (8)
@@ -675,7 +675,12 @@ can be set directly to the desired UUID, or it can be automatically generated using the .B generate option. These options will both write the UUID into every copy of the -superblock in the filesystem. +superblock in the filesystem. On a CRC-enabled filesystem, this will +set an incompatible superblock flag, and the filesystem will not be +mountable with older kernels. This can be reverted with the +.B restore +option, which will copy the original UUID back into place, and clear +the incompatible flag. .B rewrite copies the current UUID from the primary superblock to all secondary copies of the superblock.
mkfs/xfs_mkfs.c +2 -0
@@ -2598,6 +2598,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"), sbp->sb_rextents = rtextents;platform_uuid_generate (&uuid);platform_uuid_copy (&sbp->sb_uuid, &uuid); +/* Only in memory; libxfs expects this */ +platform_uuid_copy (&sbp->sb_meta_uuid, &uuid); sbp->sb_logstart = logstart; sbp->sb_rootino = sbp->sb_rbmino = sbp->sb_rsumino =NULLFSINO ; sbp->sb_rextsize = rtextblocks;
repair/agheader.c +12 -7
@@ -112,7 +112,7 @@ verify_set_agf(xfs_mount_t *mp, xfs_agf_t *agf, xfs_agnumber_t i)if (!xfs_sb_version_hascrc (&mp->m_sb))return retval; -if (platform_uuid_compare (&agf->agf_uuid, &mp->m_sb.sb_uuid)) { +if (platform_uuid_compare (&agf->agf_uuid, &mp->m_sb.sb_meta_uuid)) {char uu[64 ]; retval =XR_AG_AGF ;
@@ -120,7 +120,8 @@ verify_set_agf(xfs_mount_t *mp, xfs_agf_t *agf, xfs_agnumber_t i)do_warn (_ ("bad uuid %s for agf %d\n" ), uu, i);if (!no_modify) -platform_uuid_copy (&agf->agf_uuid, &mp->m_sb.sb_uuid); +platform_uuid_copy (&agf->agf_uuid, + &mp->m_sb.sb_meta_uuid); }return retval; }
@@ -190,7 +191,7 @@ verify_set_agi(xfs_mount_t *mp, xfs_agi_t *agi, xfs_agnumber_t agno)if (!xfs_sb_version_hascrc (&mp->m_sb))return retval; -if (platform_uuid_compare (&agi->agi_uuid, &mp->m_sb.sb_uuid)) { +if (platform_uuid_compare (&agi->agi_uuid, &mp->m_sb.sb_meta_uuid)) {char uu[64 ]; retval =XR_AG_AGI ;
@@ -198,7 +199,8 @@ verify_set_agi(xfs_mount_t *mp, xfs_agi_t *agi, xfs_agnumber_t agno)do_warn (_ ("bad uuid %s for agi %d\n" ), uu, agno);if (!no_modify) -platform_uuid_copy (&agi->agi_uuid, &mp->m_sb.sb_uuid); +platform_uuid_copy (&agi->agi_uuid, + &mp->m_sb.sb_meta_uuid); }return retval;
@@ -245,7 +247,7 @@ compare_sb(xfs_mount_t *mp, xfs_sb_t *sb)* superblocks, not just the secondary superblocks. */ static int -secondary_sb_wack( +secondary_sb_whack( struct xfs_mount *mp, struct xfs_buf *sbuf, struct xfs_sb *sb,
@@ -267,7 +269,10 @@ secondary_sb_wack(* * size is the size of data which is valid for this sb. */ -if (xfs_sb_version_hascrc (sb)) +if (xfs_sb_version_hasmetauuid (sb)) + size = offsetof(xfs_sb_t , sb_meta_uuid) + +sizeof (sb->sb_meta_uuid); +else if (xfs_sb_version_hascrc (sb)) size = offsetof(xfs_sb_t , sb_lsn) +sizeof (sb->sb_lsn);else if (xfs_sb_version_hasmorebits (sb))
@@ -526,7 +531,7 @@ verify_set_agheader(xfs_mount_t *mp, xfs_buf_t *sbuf, xfs_sb_t *sb, rval |=XR_AG_SB ; } - rval |=secondary_sb_wack (mp, sbuf, sb, i); + rval |=secondary_sb_whack (mp, sbuf, sb, i); rval |=verify_set_agf (mp, agf, i); rval |=verify_set_agi (mp, agi, i);
repair/agheader.h +0 -1
@@ -24,7 +24,6 @@ typedef struct fs_geometry {xfs_drfsbno_t sb_dblocks;/* # data blocks */ xfs_drfsbno_t sb_rblocks;/* # realtime blocks */ xfs_drtbno_t sb_rextents;/* # realtime extents */ -uuid_t sb_uuid;/* fs uuid */ xfs_dfsbno_t sb_logstart;/* starting log block # */ xfs_agblock_t sb_rextsize;/* realtime extent size (blocks )*/ xfs_agblock_t sb_agblocks;/* # of blocks per ag */
repair/dinode.c +4 -3
@@ -208,9 +208,9 @@ clear_dinode_core(struct xfs_mount *mp, xfs_dinode_t *dinoc, xfs_ino_t ino_num) dinoc->di_ino =cpu_to_be64 (ino_num); } -if (platform_uuid_compare (&dinoc->di_uuid, &mp->m_sb.sb_uuid)) { +if (platform_uuid_compare (&dinoc->di_uuid, &mp->m_sb.sb_meta_uuid)) {__dirty_no_modify_ret (dirty); -platform_uuid_copy (&dinoc->di_uuid, &mp->m_sb.sb_uuid); +platform_uuid_copy (&dinoc->di_uuid, &mp->m_sb.sb_meta_uuid); }for (i =0 ; i <sizeof (dinoc->di_pad2)/sizeof (dinoc->di_pad2[0 ]); i++) {
@@ -2366,7 +2366,8 @@ _("inode identifier %llu mismatch on inode %" PRIu64 "\n"),return 1 ; goto clear_bad_out; } -if (platform_uuid_compare (&dino->di_uuid, &mp->m_sb.sb_uuid)) { +if (platform_uuid_compare (&dino->di_uuid, + &mp->m_sb.sb_meta_uuid)) {if (!uncertain)do_warn (_ ("UUID mismatch on inode %" PRIu64"\n" ), lino);
repair/phase5.c +3 -3
@@ -1119,7 +1119,7 @@ build_agi(xfs_mount_t *mp, xfs_agnumber_t agno, bt_status_t *btree_curs, agi->agi_unlinked[i] =cpu_to_be32 (NULLAGINO );if (xfs_sb_version_hascrc (&mp->m_sb)) -platform_uuid_copy (&agi->agi_uuid, &mp->m_sb.sb_uuid); +platform_uuid_copy (&agi->agi_uuid, &mp->m_sb.sb_meta_uuid);if (xfs_sb_version_hasfinobt (&mp->m_sb)) { agi->agi_free_root =cpu_to_be32 (finobt_curs->root);
@@ -1360,7 +1360,7 @@ build_agf_agfl(xfs_mount_t *mp,#endif if (xfs_sb_version_hascrc (&mp->m_sb)) -platform_uuid_copy (&agf->agf_uuid, &mp->m_sb.sb_uuid); +platform_uuid_copy (&agf->agf_uuid, &mp->m_sb.sb_meta_uuid);/* initialise the AGFL, then fill it if there are blocks left over. */ agfl_buf = libxfs_getbuf(mp->m_dev,
@@ -1374,7 +1374,7 @@ build_agf_agfl(xfs_mount_t *mp,if (xfs_sb_version_hascrc (&mp->m_sb)) { agfl->agfl_magicnum =cpu_to_be32 (XFS_AGFL_MAGIC ); agfl->agfl_seqno =cpu_to_be32 (agno); -platform_uuid_copy (&agfl->agfl_uuid, &mp->m_sb.sb_uuid); +platform_uuid_copy (&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid);for (i =0 ; i <XFS_AGFL_SIZE (mp); i++) agfl->agfl_bno[i] =cpu_to_be32 (NULLAGBLOCK ); }
repair/phase6.c +3 -3
@@ -526,7 +526,7 @@ mk_rbmino(xfs_mount_t *mp) ip->i_d.di_flags2 =0 ; ip->i_d.di_ino = mp->m_sb.sb_rbmino;memset (&(ip->i_d.di_pad2[0 ]),0 ,sizeof (ip->i_d.di_pad2)); -platform_uuid_copy (&ip->i_d.di_uuid, &mp->m_sb.sb_uuid); +platform_uuid_copy (&ip->i_d.di_uuid, &mp->m_sb.sb_meta_uuid); times |=XFS_ICHGTIME_CREATE ; }libxfs_trans_ichgtime (tp, ip, times);
@@ -782,7 +782,7 @@ mk_rsumino(xfs_mount_t *mp) ip->i_d.di_flags2 =0 ; ip->i_d.di_ino = mp->m_sb.sb_rsumino;memset (&(ip->i_d.di_pad2[0 ]),0 ,sizeof (ip->i_d.di_pad2)); -platform_uuid_copy (&ip->i_d.di_uuid, &mp->m_sb.sb_uuid); +platform_uuid_copy (&ip->i_d.di_uuid, &mp->m_sb.sb_meta_uuid); times |=XFS_ICHGTIME_CREATE ; }libxfs_trans_ichgtime (tp, ip, times);
@@ -898,7 +898,7 @@ mk_root_dir(xfs_mount_t *mp) ip->i_d.di_flags2 =0 ; ip->i_d.di_ino = mp->m_sb.sb_rootino;memset (&(ip->i_d.di_pad2[0 ]),0 ,sizeof (ip->i_d.di_pad2)); -platform_uuid_copy (&ip->i_d.di_uuid, &mp->m_sb.sb_uuid); +platform_uuid_copy (&ip->i_d.di_uuid, &mp->m_sb.sb_meta_uuid); times |=XFS_ICHGTIME_CREATE ; }libxfs_trans_ichgtime (tp, ip, times);
include/xfs_sb.h +22 -5
@@ -107,7 +107,7 @@ typedef struct xfs_sb {xfs_drfsbno_t sb_dblocks;/* number of data blocks */ xfs_drfsbno_t sb_rblocks;/* number of realtime blocks */ xfs_drtbno_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_dfsbno_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 */
@@ -178,6 +178,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;
@@ -194,7 +195,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 */
@@ -264,6 +265,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;
@@ -287,7 +289,7 @@ typedef enum {XFS_SBS_FEATURES2 ,XFS_SBS_BAD_FEATURES2 ,XFS_SBS_FEATURES_COMPAT ,XFS_SBS_FEATURES_RO_COMPAT ,XFS_SBS_FEATURES_INCOMPAT ,XFS_SBS_FEATURES_LOG_INCOMPAT ,XFS_SBS_CRC ,XFS_SBS_PAD , -XFS_SBS_PQUOTINO ,XFS_SBS_LSN , +XFS_SBS_PQUOTINO ,XFS_SBS_LSN ,XFS_SBS_META_UUID ,XFS_SBS_FIELDCOUNT } xfs_sb_field_t;
@@ -319,6 +321,7 @@ typedef enum {#define XFS_SB_FEATURES_LOG_INCOMPAT XFS_SB_MVAL(FEATURES_LOG_INCOMPAT)#define XFS_SB_CRC XFS_SB_MVAL(CRC)#define XFS_SB_PQUOTINO XFS_SB_MVAL(PQUOTINO) +#define XFS_SB_META_UUID XFS_SB_MVAL(META_UUID)#define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT)#define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1)#define XFS_SB_MOD_BITS \
@@ -328,7 +331,7 @@ typedef enum {XFS_SB_ICOUNT |XFS_SB_IFREE |XFS_SB_FDBLOCKS |XFS_SB_FEATURES2 | \XFS_SB_BAD_FEATURES2 |XFS_SB_FEATURES_COMPAT | \XFS_SB_FEATURES_RO_COMPAT |XFS_SB_FEATURES_INCOMPAT | \ - XFS_SB_FEATURES_LOG_INCOMPAT | XFS_SB_PQUOTINO) + XFS_SB_FEATURES_LOG_INCOMPAT | XFS_SB_PQUOTINO | XFS_SB_META_UUID)/*
@@ -600,8 +603,10 @@ xfs_sb_has_ro_compat_feature( }#define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0)/* filetype in dirent */ +#define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 1)/* metadata UUID */ #define XFS_SB_FEAT_INCOMPAT_ALL \ - (XFS_SB_FEAT_INCOMPAT_FTYPE) + (XFS_SB_FEAT_INCOMPAT_FTYPE | \ + XFS_SB_FEAT_INCOMPAT_META_UUID)#define XFS_SB_FEAT_INCOMPAT_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_ALL static inline bool
@@ -650,6 +655,18 @@ static inline int xfs_sb_version_hasfinobt(xfs_sb_t *sbp) }/* +* 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 int xfs_sb_version_hasmetauuid (xfs_sb_t *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 */
libxfs/util.c +1 -1
@@ -250,7 +250,7 @@ libxfs_ialloc(if (ip->i_d.di_version ==3 ) {ASSERT (ip->i_d.di_ino == ino); -ASSERT (uuid_equal (&ip->i_d.di_uuid, &mp->m_sb.sb_uuid)); +ASSERT (uuid_equal (&ip->i_d.di_uuid, &mp->m_sb.sb_meta_uuid)); ip->i_d.di_crc =0 ; ip->i_d.di_changecount =1 ; ip->i_d.di_lsn =0 ;
libxfs/xfs_alloc.c +2 -2
@@ -426,7 +426,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;
@@ -2181,7 +2181,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) &&
libxfs/xfs_alloc_btree.c +2 -2
@@ -279,7 +279,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;
@@ -297,7 +297,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;
libxfs/xfs_attr_leaf.c +2 -2
@@ -161,7 +161,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;
@@ -952,7 +952,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 {
libxfs/xfs_attr_remote.c +2 -2
@@ -78,7 +78,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;
@@ -194,7 +194,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);
libxfs/xfs_bmap_btree.c +3 -2
@@ -412,7 +412,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
@@ -712,7 +713,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;
libxfs/xfs_btree.c +6 -4
@@ -50,7 +50,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 ); }
@@ -100,7 +101,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 ); }
@@ -992,7 +994,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 ; }
@@ -1005,7 +1007,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 ; } }
libxfs/xfs_da_btree.c +2 -2
@@ -172,7 +172,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;
@@ -349,7 +349,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 ; }
libxfs/xfs_dir2_block.c +2 -2
@@ -51,7 +51,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;
@@ -141,7 +141,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 ; }
libxfs/xfs_dir2_data.c +2 -2
@@ -186,7 +186,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;
@@ -573,7 +573,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 );
libxfs/xfs_dir2_leaf.c +2 -2
@@ -186,7 +186,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;
@@ -337,7 +337,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);
libxfs/xfs_dir2_node.c +2 -2
@@ -78,7 +78,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;
@@ -257,7 +257,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 ;xfs_dir3_free_hdr_to_disk (bp->b_addr, &hdr);
libxfs/xfs_dquot_buf.c +2 -2
@@ -146,7 +146,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 ); }
@@ -181,7 +181,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;
libxfs/xfs_ialloc.c +3 -2
@@ -295,7 +295,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 */
@@ -1947,7 +1948,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.
libxfs/xfs_ialloc_btree.c +1 -1
@@ -214,7 +214,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;
libxfs/xfs_inode_buf.c +1 -1
@@ -295,7 +295,7 @@ xfs_dinode_verify(return false;if (be64_to_cpu (dip->di_ino) != 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; }
libxfs/xfs_sb.c +15 -0
@@ -81,6 +81,7 @@ static const struct { { offsetof(xfs_sb_t, sb_pad), 0 }, { offsetof(xfs_sb_t, sb_pquotino), 0 }, { offsetof(xfs_sb_t, sb_lsn), 0 }, + { offsetof(xfs_sb_t, sb_meta_uuid), 1 }, { sizeof(xfs_sb_t), 0 } };
@@ -413,6 +414,13 @@ xfs_sb_from_disk( to->sb_pad =0 ; to->sb_pquotino =be64_to_cpu (from->sb_pquotino); to->sb_lsn =be64_to_cpu (from->sb_lsn); +if (xfs_sb_version_hasmetauuid (to)) { +memcpy (&to->sb_meta_uuid, &from->sb_meta_uuid, +sizeof (to->sb_meta_uuid)); + }else { +memcpy (&to->sb_meta_uuid, &from->sb_uuid, +sizeof (to->sb_meta_uuid)); + } } static inline void
@@ -490,6 +498,13 @@ xfs_sb_to_disk(/* We should never write the crc here, it's updated in the IO path */ fields &= ~XFS_SB_CRC ; +/* +* If the metadata-specific UUID feature isn't set, it's only set +* in memory; don't write it out. +*/ +if (!xfs_sb_version_hasmetauuid (from)) + fields &= ~XFS_SB_UUID ; +xfs_sb_quota_to_disk (to, from, &fields);while (fields) { f = (xfs_sb_field_t )xfs_lowbit64 ((__uint64_t )fields);
libxfs/xfs_symlink_remote.c +2 -2
@@ -48,7 +48,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;
@@ -93,7 +93,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;
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs