浏览代码

Btrfs: use reserved space for creating a snapshot

While inserting dir index and updating inode for a snapshot, we'd
add delayed items which consume trans->block_rsv, if we don't have
any space reserved in this trans handle, we either just return or
reserve space again.

But before creating pending snapshots during committing transaction,
we've done a release on this trans handle, so we don't have space reserved
in it at this stage.

What we're using is block_rsv of pending snapshots which has already
reserved well enough space for both inserting dir index and updating
inode, so we need to set trans handle to indicate that we have space
now.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Liu Bo 12 年之前
父节点
当前提交
2382c5cc7e
共有 1 个文件被更改,包括 2 次插入0 次删除
  1. 2 0
      fs/btrfs/transaction.c

+ 2 - 0
fs/btrfs/transaction.c

@@ -1123,6 +1123,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
 
 
 	rsv = trans->block_rsv;
 	rsv = trans->block_rsv;
 	trans->block_rsv = &pending->block_rsv;
 	trans->block_rsv = &pending->block_rsv;
+	trans->bytes_reserved = trans->block_rsv->reserved;
 
 
 	dentry = pending->dentry;
 	dentry = pending->dentry;
 	parent = dget_parent(dentry);
 	parent = dget_parent(dentry);
@@ -1276,6 +1277,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
 fail:
 fail:
 	dput(parent);
 	dput(parent);
 	trans->block_rsv = rsv;
 	trans->block_rsv = rsv;
+	trans->bytes_reserved = 0;
 no_free_objectid:
 no_free_objectid:
 	kfree(new_root_item);
 	kfree(new_root_item);
 root_item_alloc_fail:
 root_item_alloc_fail: