Btrfs: fix wrong reserved space in qgroup during snap/subv creation
PATCH 2/3 Btrfs: fix wrong reserved space in qgroup during snap/subv creation
There are two problems in the space reservation of the snapshot/ subvolume creation.
- don't reserve the space for the root item insertion
- the space which is reserved in the qgroup is different with the free space reservation. we need reserve free space for 7 items, but in qgroup reservation, we need reserve space only for 3 items.
So we implement new metadata reservation functions for the snapshot/subvolume creation.
Signed-off-by Miao Xie <[email protected]>
--- fs/btrfs/ctree.h | 9 +++++- fs/btrfs/extent-tree.c | 65 +++++++++++++++++++++++++++++++++++++++--------- fs/btrfs/ioctl.c | 62 +++++++++++++++++++++++++++++++-------------- fs/btrfs/transaction.c | 4 +-- fs/btrfs/transaction.h | 1 + 5 files changed, 105 insertions(+), 36 deletions(-)
fs/btrfs/ctree.h +7 -2
@@ -3068,8 +3068,13 @@ void btrfs_trans_release_metadata(struct btrfs_trans_handle *trans,int btrfs_orphan_reserve_metadata (struct btrfs_trans_handle *trans,struct inode *inode);void btrfs_orphan_release_metadata (struct inode *inode); -int btrfs_snap_reserve_metadata (struct btrfs_trans_handle *trans, -struct btrfs_pending_snapshot *pending); +int btrfs_subvolume_reserve_metadata (struct btrfs_root *root, +struct btrfs_block_rsv *rsv, +int nitems, +u64 *qgroup_reserved); +void btrfs_subvolume_release_metadata (struct btrfs_root *root, +struct btrfs_block_rsv *rsv, +u64 qgroup_reserved);int btrfs_delalloc_reserve_metadata (struct inode *inode,u64 num_bytes);void btrfs_delalloc_release_metadata (struct inode *inode,u64 num_bytes);int btrfs_delalloc_reserve_space (struct inode *inode,u64 num_bytes);
fs/btrfs/extent-tree.c +53 -12
72 lines not on this page · raw message
fs/btrfs/ioctl.c +43 -19
130 lines not on this page · raw message
fs/btrfs/transaction.c +1 -3
@@ -1075,7 +1075,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, path =btrfs_alloc_path ();if (!path) { ret = pending->error = -ENOMEM ; - goto path_alloc_fail; +return ret; } new_root_item =kmalloc (sizeof (*new_root_item),GFP_NOFS );
@@ -1270,8 +1270,6 @@ no_free_objectid:kfree (new_root_item); root_item_alloc_fail:btrfs_free_path (path); -path_alloc_fail: -btrfs_block_rsv_release (root, &pending->block_rsv, (u64)-1 );return ret; }
fs/btrfs/transaction.h +1 -0
@@ -90,6 +90,7 @@ struct btrfs_pending_snapshot {struct btrfs_qgroup_inherit *inherit;/* block reservation for the operation */ struct btrfs_block_rsv block_rsv; +u64 qgroup_reserved;/* extra metadata reseration for relocation */ int error;bool readonly;
Signature · 1 line
1.6.5.2