aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/btrfs/inode.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index ae74c740f3e1..6c476dc81b8e 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5292,8 +5292,7 @@ static void evict_inode_truncate_pages(struct inode *inode)
5292} 5292}
5293 5293
5294static struct btrfs_trans_handle *evict_refill_and_join(struct btrfs_root *root, 5294static struct btrfs_trans_handle *evict_refill_and_join(struct btrfs_root *root,
5295 struct btrfs_block_rsv *rsv, 5295 struct btrfs_block_rsv *rsv)
5296 u64 min_size)
5297{ 5296{
5298 struct btrfs_fs_info *fs_info = root->fs_info; 5297 struct btrfs_fs_info *fs_info = root->fs_info;
5299 struct btrfs_block_rsv *global_rsv = &fs_info->global_block_rsv; 5298 struct btrfs_block_rsv *global_rsv = &fs_info->global_block_rsv;
@@ -5303,7 +5302,7 @@ static struct btrfs_trans_handle *evict_refill_and_join(struct btrfs_root *root,
5303 struct btrfs_trans_handle *trans; 5302 struct btrfs_trans_handle *trans;
5304 int ret; 5303 int ret;
5305 5304
5306 ret = btrfs_block_rsv_refill(root, rsv, min_size, 5305 ret = btrfs_block_rsv_refill(root, rsv, rsv->size,
5307 BTRFS_RESERVE_FLUSH_LIMIT); 5306 BTRFS_RESERVE_FLUSH_LIMIT);
5308 5307
5309 if (ret && ++failures > 2) { 5308 if (ret && ++failures > 2) {
@@ -5321,7 +5320,7 @@ static struct btrfs_trans_handle *evict_refill_and_join(struct btrfs_root *root,
5321 * it. 5320 * it.
5322 */ 5321 */
5323 if (!btrfs_check_space_for_delayed_refs(trans, fs_info) && 5322 if (!btrfs_check_space_for_delayed_refs(trans, fs_info) &&
5324 !btrfs_block_rsv_migrate(global_rsv, rsv, min_size, false)) 5323 !btrfs_block_rsv_migrate(global_rsv, rsv, rsv->size, false))
5325 return trans; 5324 return trans;
5326 5325
5327 /* If not, commit and try again. */ 5326 /* If not, commit and try again. */
@@ -5337,7 +5336,6 @@ void btrfs_evict_inode(struct inode *inode)
5337 struct btrfs_trans_handle *trans; 5336 struct btrfs_trans_handle *trans;
5338 struct btrfs_root *root = BTRFS_I(inode)->root; 5337 struct btrfs_root *root = BTRFS_I(inode)->root;
5339 struct btrfs_block_rsv *rsv; 5338 struct btrfs_block_rsv *rsv;
5340 u64 min_size;
5341 int ret; 5339 int ret;
5342 5340
5343 trace_btrfs_inode_evict(inode); 5341 trace_btrfs_inode_evict(inode);
@@ -5347,8 +5345,6 @@ void btrfs_evict_inode(struct inode *inode)
5347 return; 5345 return;
5348 } 5346 }
5349 5347
5350 min_size = btrfs_calc_trunc_metadata_size(fs_info, 1);
5351
5352 evict_inode_truncate_pages(inode); 5348 evict_inode_truncate_pages(inode);
5353 5349
5354 if (inode->i_nlink && 5350 if (inode->i_nlink &&
@@ -5378,13 +5374,13 @@ void btrfs_evict_inode(struct inode *inode)
5378 rsv = btrfs_alloc_block_rsv(fs_info, BTRFS_BLOCK_RSV_TEMP); 5374 rsv = btrfs_alloc_block_rsv(fs_info, BTRFS_BLOCK_RSV_TEMP);
5379 if (!rsv) 5375 if (!rsv)
5380 goto no_delete; 5376 goto no_delete;
5381 rsv->size = min_size; 5377 rsv->size = btrfs_calc_trunc_metadata_size(fs_info, 1);
5382 rsv->failfast = 1; 5378 rsv->failfast = 1;
5383 5379
5384 btrfs_i_size_write(BTRFS_I(inode), 0); 5380 btrfs_i_size_write(BTRFS_I(inode), 0);
5385 5381
5386 while (1) { 5382 while (1) {
5387 trans = evict_refill_and_join(root, rsv, min_size); 5383 trans = evict_refill_and_join(root, rsv);
5388 if (IS_ERR(trans)) 5384 if (IS_ERR(trans))
5389 goto free_rsv; 5385 goto free_rsv;
5390 5386
@@ -5409,7 +5405,7 @@ void btrfs_evict_inode(struct inode *inode)
5409 * If it turns out that we are dropping too many of these, we might want 5405 * If it turns out that we are dropping too many of these, we might want
5410 * to add a mechanism for retrying these after a commit. 5406 * to add a mechanism for retrying these after a commit.
5411 */ 5407 */
5412 trans = evict_refill_and_join(root, rsv, min_size); 5408 trans = evict_refill_and_join(root, rsv);
5413 if (!IS_ERR(trans)) { 5409 if (!IS_ERR(trans)) {
5414 trans->block_rsv = rsv; 5410 trans->block_rsv = rsv;
5415 btrfs_orphan_del(trans, BTRFS_I(inode)); 5411 btrfs_orphan_del(trans, BTRFS_I(inode));