mirror of
https://github.com/kdave/btrfs-progs
synced 2025-04-01 22:48:06 +00:00
btrfs-progs: mkfs: introduce function to insert qgroup info and limit items
Introduce a new function, insert_qgroup_items(), to insert qgroup info item and qgroup limit item for later mkfs qgroup support. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
e0e047f292
commit
83ad692230
34
mkfs/main.c
34
mkfs/main.c
@ -797,6 +797,40 @@ out:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int insert_qgroup_items(struct btrfs_trans_handle *trans,
|
||||||
|
struct btrfs_fs_info *fs_info,
|
||||||
|
u64 qgroupid)
|
||||||
|
{
|
||||||
|
struct btrfs_path path;
|
||||||
|
struct btrfs_root *quota_root = fs_info->quota_root;
|
||||||
|
struct btrfs_key key;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (qgroupid >> BTRFS_QGROUP_LEVEL_SHIFT) {
|
||||||
|
error("qgroup level other than 0 is not supported yet");
|
||||||
|
return -ENOTTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
key.objectid = 0;
|
||||||
|
key.type = BTRFS_QGROUP_INFO_KEY;
|
||||||
|
key.offset = qgroupid;
|
||||||
|
|
||||||
|
btrfs_init_path(&path);
|
||||||
|
ret = btrfs_insert_empty_item(trans, quota_root, &path, &key,
|
||||||
|
sizeof(struct btrfs_qgroup_info_item));
|
||||||
|
btrfs_release_path(&path);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
key.objectid = 0;
|
||||||
|
key.type = BTRFS_QGROUP_LIMIT_KEY;
|
||||||
|
key.offset = qgroupid;
|
||||||
|
ret = btrfs_insert_empty_item(trans, quota_root, &path, &key,
|
||||||
|
sizeof(struct btrfs_qgroup_limit_item));
|
||||||
|
btrfs_release_path(&path);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int BOX_MAIN(mkfs)(int argc, char **argv)
|
int BOX_MAIN(mkfs)(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *file;
|
char *file;
|
||||||
|
Loading…
Reference in New Issue
Block a user