mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
btrfs: switch to use new generic UUID API
There are new types and helpers that are supposed to be used in new code. As a preparation to get rid of legacy types and API functions do the conversion here. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
48a2e88f53
commit
807fc790aa
4 changed files with 8 additions and 13 deletions
|
@ -1223,7 +1223,6 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
|
||||||
struct btrfs_key key;
|
struct btrfs_key key;
|
||||||
unsigned int nofs_flag;
|
unsigned int nofs_flag;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
uuid_le uuid = NULL_UUID_LE;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We're holding a transaction handle, so use a NOFS memory allocation
|
* We're holding a transaction handle, so use a NOFS memory allocation
|
||||||
|
@ -1262,8 +1261,9 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
|
||||||
btrfs_set_root_last_snapshot(&root->root_item, 0);
|
btrfs_set_root_last_snapshot(&root->root_item, 0);
|
||||||
btrfs_set_root_dirid(&root->root_item, 0);
|
btrfs_set_root_dirid(&root->root_item, 0);
|
||||||
if (is_fstree(objectid))
|
if (is_fstree(objectid))
|
||||||
uuid_le_gen(&uuid);
|
generate_random_guid(root->root_item.uuid);
|
||||||
memcpy(root->root_item.uuid, uuid.b, BTRFS_UUID_SIZE);
|
else
|
||||||
|
export_guid(root->root_item.uuid, &guid_null);
|
||||||
root->root_item.drop_level = 0;
|
root->root_item.drop_level = 0;
|
||||||
|
|
||||||
key.objectid = objectid;
|
key.objectid = objectid;
|
||||||
|
|
|
@ -574,7 +574,6 @@ static noinline int create_subvol(struct inode *dir,
|
||||||
u64 objectid;
|
u64 objectid;
|
||||||
u64 new_dirid = BTRFS_FIRST_FREE_OBJECTID;
|
u64 new_dirid = BTRFS_FIRST_FREE_OBJECTID;
|
||||||
u64 index = 0;
|
u64 index = 0;
|
||||||
uuid_le new_uuid;
|
|
||||||
|
|
||||||
root_item = kzalloc(sizeof(*root_item), GFP_KERNEL);
|
root_item = kzalloc(sizeof(*root_item), GFP_KERNEL);
|
||||||
if (!root_item)
|
if (!root_item)
|
||||||
|
@ -644,8 +643,7 @@ static noinline int create_subvol(struct inode *dir,
|
||||||
|
|
||||||
btrfs_set_root_generation_v2(root_item,
|
btrfs_set_root_generation_v2(root_item,
|
||||||
btrfs_root_generation(root_item));
|
btrfs_root_generation(root_item));
|
||||||
uuid_le_gen(&new_uuid);
|
generate_random_guid(root_item->uuid);
|
||||||
memcpy(root_item->uuid, new_uuid.b, BTRFS_UUID_SIZE);
|
|
||||||
btrfs_set_stack_timespec_sec(&root_item->otime, cur_time.tv_sec);
|
btrfs_set_stack_timespec_sec(&root_item->otime, cur_time.tv_sec);
|
||||||
btrfs_set_stack_timespec_nsec(&root_item->otime, cur_time.tv_nsec);
|
btrfs_set_stack_timespec_nsec(&root_item->otime, cur_time.tv_nsec);
|
||||||
root_item->ctime = root_item->otime;
|
root_item->ctime = root_item->otime;
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
static void btrfs_read_root_item(struct extent_buffer *eb, int slot,
|
static void btrfs_read_root_item(struct extent_buffer *eb, int slot,
|
||||||
struct btrfs_root_item *item)
|
struct btrfs_root_item *item)
|
||||||
{
|
{
|
||||||
uuid_le uuid;
|
|
||||||
u32 len;
|
u32 len;
|
||||||
int need_reset = 0;
|
int need_reset = 0;
|
||||||
|
|
||||||
|
@ -44,8 +43,7 @@ static void btrfs_read_root_item(struct extent_buffer *eb, int slot,
|
||||||
sizeof(*item) - offsetof(struct btrfs_root_item,
|
sizeof(*item) - offsetof(struct btrfs_root_item,
|
||||||
generation_v2));
|
generation_v2));
|
||||||
|
|
||||||
uuid_le_gen(&uuid);
|
generate_random_guid(item->uuid);
|
||||||
memcpy(item->uuid, uuid.b, BTRFS_UUID_SIZE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1479,7 +1479,6 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
|
||||||
u64 index = 0;
|
u64 index = 0;
|
||||||
u64 objectid;
|
u64 objectid;
|
||||||
u64 root_flags;
|
u64 root_flags;
|
||||||
uuid_le new_uuid;
|
|
||||||
|
|
||||||
ASSERT(pending->path);
|
ASSERT(pending->path);
|
||||||
path = pending->path;
|
path = pending->path;
|
||||||
|
@ -1572,8 +1571,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
|
||||||
|
|
||||||
btrfs_set_root_generation_v2(new_root_item,
|
btrfs_set_root_generation_v2(new_root_item,
|
||||||
trans->transid);
|
trans->transid);
|
||||||
uuid_le_gen(&new_uuid);
|
generate_random_guid(new_root_item->uuid);
|
||||||
memcpy(new_root_item->uuid, new_uuid.b, BTRFS_UUID_SIZE);
|
|
||||||
memcpy(new_root_item->parent_uuid, root->root_item.uuid,
|
memcpy(new_root_item->parent_uuid, root->root_item.uuid,
|
||||||
BTRFS_UUID_SIZE);
|
BTRFS_UUID_SIZE);
|
||||||
if (!(root_flags & BTRFS_ROOT_SUBVOL_RDONLY)) {
|
if (!(root_flags & BTRFS_ROOT_SUBVOL_RDONLY)) {
|
||||||
|
@ -1684,7 +1682,8 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
|
||||||
btrfs_abort_transaction(trans, ret);
|
btrfs_abort_transaction(trans, ret);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
ret = btrfs_uuid_tree_add(trans, new_uuid.b, BTRFS_UUID_KEY_SUBVOL,
|
ret = btrfs_uuid_tree_add(trans, new_root_item->uuid,
|
||||||
|
BTRFS_UUID_KEY_SUBVOL,
|
||||||
objectid);
|
objectid);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
btrfs_abort_transaction(trans, ret);
|
btrfs_abort_transaction(trans, ret);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue