diff options
author | Yan, Zheng <zheng.yan@oracle.com> | 2010-05-16 10:48:46 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2010-05-25 10:34:50 -0400 |
commit | a22285a6a32390195235171b89d157ed1a1fe932 (patch) | |
tree | 3fabc88a029e1af4f2fdcc708e7b62ef3cf3703a /fs/btrfs/file.c | |
parent | f0486c68e4bd9a06a5904d3eeb3a0d73a83befb8 (diff) |
Btrfs: Integrate metadata reservation with start_transaction
Besides simplify the code, this change makes sure all metadata
reservation for normal metadata operations are released after
committing transaction.
Changes since V1:
Add code that check if unlink and rmdir will free space.
Add ENOSPC handling for clone ioctl.
Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r-- | fs/btrfs/file.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 29ff749ff4ca..41e09e24e295 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -126,8 +126,7 @@ static noinline int dirty_and_release_pages(struct btrfs_trans_handle *trans, | |||
126 | end_of_last_block = start_pos + num_bytes - 1; | 126 | end_of_last_block = start_pos + num_bytes - 1; |
127 | err = btrfs_set_extent_delalloc(inode, start_pos, end_of_last_block, | 127 | err = btrfs_set_extent_delalloc(inode, start_pos, end_of_last_block, |
128 | NULL); | 128 | NULL); |
129 | if (err) | 129 | BUG_ON(err); |
130 | return err; | ||
131 | 130 | ||
132 | for (i = 0; i < num_pages; i++) { | 131 | for (i = 0; i < num_pages; i++) { |
133 | struct page *p = pages[i]; | 132 | struct page *p = pages[i]; |
@@ -142,7 +141,7 @@ static noinline int dirty_and_release_pages(struct btrfs_trans_handle *trans, | |||
142 | * at this time. | 141 | * at this time. |
143 | */ | 142 | */ |
144 | } | 143 | } |
145 | return err; | 144 | return 0; |
146 | } | 145 | } |
147 | 146 | ||
148 | /* | 147 | /* |
@@ -1008,7 +1007,7 @@ out_nolock: | |||
1008 | num_written = err; | 1007 | num_written = err; |
1009 | 1008 | ||
1010 | if ((file->f_flags & O_DSYNC) || IS_SYNC(inode)) { | 1009 | if ((file->f_flags & O_DSYNC) || IS_SYNC(inode)) { |
1011 | trans = btrfs_start_transaction(root, 1); | 1010 | trans = btrfs_start_transaction(root, 0); |
1012 | ret = btrfs_log_dentry_safe(trans, root, | 1011 | ret = btrfs_log_dentry_safe(trans, root, |
1013 | file->f_dentry); | 1012 | file->f_dentry); |
1014 | if (ret == 0) { | 1013 | if (ret == 0) { |
@@ -1104,9 +1103,9 @@ int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync) | |||
1104 | if (file && file->private_data) | 1103 | if (file && file->private_data) |
1105 | btrfs_ioctl_trans_end(file); | 1104 | btrfs_ioctl_trans_end(file); |
1106 | 1105 | ||
1107 | trans = btrfs_start_transaction(root, 1); | 1106 | trans = btrfs_start_transaction(root, 0); |
1108 | if (!trans) { | 1107 | if (IS_ERR(trans)) { |
1109 | ret = -ENOMEM; | 1108 | ret = PTR_ERR(trans); |
1110 | goto out; | 1109 | goto out; |
1111 | } | 1110 | } |
1112 | 1111 | ||