提交 10d2a9ff 编写于 作者: J Joe Thornber 提交者: Alasdair G Kergon

dm thin metadata: move dm_commit_pool_metadata into __write_initial_superblock

Move dm_commit_pool_metadata inline into __write_initial_superblock in dm-thin-metadata.
Signed-off-by: NJoe Thornber <ejt@redhat.com>
Signed-off-by: NMike Snitzer <snitzer@redhat.com>
Signed-off-by: NAlasdair G Kergon <agk@redhat.com>
上级 9cb6653f
...@@ -422,38 +422,70 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd) ...@@ -422,38 +422,70 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
pmd->details_info.value_type.equal = NULL; pmd->details_info.value_type.equal = NULL;
} }
static int __begin_transaction(struct dm_pool_metadata *pmd);
static int __write_initial_superblock(struct dm_pool_metadata *pmd) static int __write_initial_superblock(struct dm_pool_metadata *pmd)
{ {
int r; int r;
struct dm_block *sblock; struct dm_block *sblock;
size_t metadata_len, data_len;
struct thin_disk_superblock *disk_super; struct thin_disk_superblock *disk_super;
sector_t bdev_size = i_size_read(pmd->bdev->bd_inode) >> SECTOR_SHIFT; sector_t bdev_size = i_size_read(pmd->bdev->bd_inode) >> SECTOR_SHIFT;
if (bdev_size > THIN_METADATA_MAX_SECTORS) if (bdev_size > THIN_METADATA_MAX_SECTORS)
bdev_size = THIN_METADATA_MAX_SECTORS; bdev_size = THIN_METADATA_MAX_SECTORS;
r = dm_sm_root_size(pmd->metadata_sm, &metadata_len);
if (r < 0)
return r;
r = dm_sm_root_size(pmd->data_sm, &data_len);
if (r < 0)
return r;
r = dm_sm_commit(pmd->data_sm);
if (r < 0)
return r;
r = dm_tm_pre_commit(pmd->tm);
if (r < 0)
return r;
r = superblock_lock_zero(pmd, &sblock); r = superblock_lock_zero(pmd, &sblock);
if (r) if (r)
return r; return r;
disk_super = dm_block_data(sblock); disk_super = dm_block_data(sblock);
disk_super->flags = 0;
disk_super->magic = cpu_to_le64(THIN_SUPERBLOCK_MAGIC); disk_super->magic = cpu_to_le64(THIN_SUPERBLOCK_MAGIC);
disk_super->version = cpu_to_le32(THIN_VERSION); disk_super->version = cpu_to_le32(THIN_VERSION);
disk_super->time = 0; disk_super->time = 0;
disk_super->trans_id = 0;
disk_super->held_root = 0;
r = dm_sm_copy_root(pmd->metadata_sm, &disk_super->metadata_space_map_root,
metadata_len);
if (r < 0)
goto bad_locked;
r = dm_sm_copy_root(pmd->data_sm, &disk_super->data_space_map_root,
data_len);
if (r < 0)
goto bad_locked;
disk_super->data_mapping_root = cpu_to_le64(pmd->root);
disk_super->device_details_root = cpu_to_le64(pmd->details_root);
disk_super->metadata_block_size = cpu_to_le32(THIN_METADATA_BLOCK_SIZE >> SECTOR_SHIFT); disk_super->metadata_block_size = cpu_to_le32(THIN_METADATA_BLOCK_SIZE >> SECTOR_SHIFT);
disk_super->metadata_nr_blocks = cpu_to_le64(bdev_size >> SECTOR_TO_BLOCK_SHIFT); disk_super->metadata_nr_blocks = cpu_to_le64(bdev_size >> SECTOR_TO_BLOCK_SHIFT);
disk_super->data_block_size = cpu_to_le32(pmd->data_block_size); disk_super->data_block_size = cpu_to_le32(pmd->data_block_size);
r = dm_bm_unlock(sblock); r = dm_tm_commit(pmd->tm, sblock);
if (r) if (r)
return r; return r;
pmd->flags = 0; return __begin_transaction(pmd);
r = dm_pool_commit_metadata(pmd);
if (r < 0)
DMERR("%s: dm_pool_commit_metadata() failed, error = %d",
__func__, r);
bad_locked:
dm_bm_unlock(sblock);
return r; return r;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册