diff options
author | Josef Bacik <jbacik@fusionio.com> | 2012-06-21 14:05:49 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2012-07-23 15:41:40 -0400 |
commit | 96c3f4331a8c1cd0a58307e4ac7e73e09d7dab23 (patch) | |
tree | 9791f09825d0a03b66a2c2b41a40ef5d3bd79b71 /fs/btrfs/delayed-inode.c | |
parent | b27f7c0c150f74564b5d4c6c24a03c5226bf6327 (diff) |
Btrfs: flush delayed inodes if we're short on space
Those crazy gentoo guys have been complaining about ENOSPC errors on their
portage volumes. This is because doing things like untar tends to create
lots of new files which will soak up all the reservation space in the
delayed inodes. Usually this gets papered over by the fact that we will try
and commit the transaction, however if this happens in the wrong spot or we
choose not to commit the transaction you will be screwed. So add the
ability to expclitly flush delayed inodes to free up space. Please test
this out guys to make sure it works since as usual I cannot reproduce.
Thanks,
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/delayed-inode.c')
-rw-r--r-- | fs/btrfs/delayed-inode.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c index 2399f4086915..21d91a8073ee 100644 --- a/fs/btrfs/delayed-inode.c +++ b/fs/btrfs/delayed-inode.c | |||
@@ -1113,8 +1113,8 @@ static int btrfs_update_delayed_inode(struct btrfs_trans_handle *trans, | |||
1113 | * Returns < 0 on error and returns with an aborted transaction with any | 1113 | * Returns < 0 on error and returns with an aborted transaction with any |
1114 | * outstanding delayed items cleaned up. | 1114 | * outstanding delayed items cleaned up. |
1115 | */ | 1115 | */ |
1116 | int btrfs_run_delayed_items(struct btrfs_trans_handle *trans, | 1116 | static int __btrfs_run_delayed_items(struct btrfs_trans_handle *trans, |
1117 | struct btrfs_root *root) | 1117 | struct btrfs_root *root, int nr) |
1118 | { | 1118 | { |
1119 | struct btrfs_root *curr_root = root; | 1119 | struct btrfs_root *curr_root = root; |
1120 | struct btrfs_delayed_root *delayed_root; | 1120 | struct btrfs_delayed_root *delayed_root; |
@@ -1122,6 +1122,7 @@ int btrfs_run_delayed_items(struct btrfs_trans_handle *trans, | |||
1122 | struct btrfs_path *path; | 1122 | struct btrfs_path *path; |
1123 | struct btrfs_block_rsv *block_rsv; | 1123 | struct btrfs_block_rsv *block_rsv; |
1124 | int ret = 0; | 1124 | int ret = 0; |
1125 | bool count = (nr > 0); | ||
1125 | 1126 | ||
1126 | if (trans->aborted) | 1127 | if (trans->aborted) |
1127 | return -EIO; | 1128 | return -EIO; |
@@ -1137,7 +1138,7 @@ int btrfs_run_delayed_items(struct btrfs_trans_handle *trans, | |||
1137 | delayed_root = btrfs_get_delayed_root(root); | 1138 | delayed_root = btrfs_get_delayed_root(root); |
1138 | 1139 | ||
1139 | curr_node = btrfs_first_delayed_node(delayed_root); | 1140 | curr_node = btrfs_first_delayed_node(delayed_root); |
1140 | while (curr_node) { | 1141 | while (curr_node && (!count || (count && nr--))) { |
1141 | curr_root = curr_node->root; | 1142 | curr_root = curr_node->root; |
1142 | ret = btrfs_insert_delayed_items(trans, path, curr_root, | 1143 | ret = btrfs_insert_delayed_items(trans, path, curr_root, |
1143 | curr_node); | 1144 | curr_node); |
@@ -1149,6 +1150,7 @@ int btrfs_run_delayed_items(struct btrfs_trans_handle *trans, | |||
1149 | path, curr_node); | 1150 | path, curr_node); |
1150 | if (ret) { | 1151 | if (ret) { |
1151 | btrfs_release_delayed_node(curr_node); | 1152 | btrfs_release_delayed_node(curr_node); |
1153 | curr_node = NULL; | ||
1152 | btrfs_abort_transaction(trans, root, ret); | 1154 | btrfs_abort_transaction(trans, root, ret); |
1153 | break; | 1155 | break; |
1154 | } | 1156 | } |
@@ -1158,12 +1160,26 @@ int btrfs_run_delayed_items(struct btrfs_trans_handle *trans, | |||
1158 | btrfs_release_delayed_node(prev_node); | 1160 | btrfs_release_delayed_node(prev_node); |
1159 | } | 1161 | } |
1160 | 1162 | ||
1163 | if (curr_node) | ||
1164 | btrfs_release_delayed_node(curr_node); | ||
1161 | btrfs_free_path(path); | 1165 | btrfs_free_path(path); |
1162 | trans->block_rsv = block_rsv; | 1166 | trans->block_rsv = block_rsv; |
1163 | 1167 | ||
1164 | return ret; | 1168 | return ret; |
1165 | } | 1169 | } |
1166 | 1170 | ||
1171 | int btrfs_run_delayed_items(struct btrfs_trans_handle *trans, | ||
1172 | struct btrfs_root *root) | ||
1173 | { | ||
1174 | return __btrfs_run_delayed_items(trans, root, -1); | ||
1175 | } | ||
1176 | |||
1177 | int btrfs_run_delayed_items_nr(struct btrfs_trans_handle *trans, | ||
1178 | struct btrfs_root *root, int nr) | ||
1179 | { | ||
1180 | return __btrfs_run_delayed_items(trans, root, nr); | ||
1181 | } | ||
1182 | |||
1167 | static int __btrfs_commit_inode_delayed_items(struct btrfs_trans_handle *trans, | 1183 | static int __btrfs_commit_inode_delayed_items(struct btrfs_trans_handle *trans, |
1168 | struct btrfs_delayed_node *node) | 1184 | struct btrfs_delayed_node *node) |
1169 | { | 1185 | { |