aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2010-09-16 14:29:55 -0400
committerJosef Bacik <josef@redhat.com>2010-10-22 15:54:51 -0400
commita1f765061e1491d5ec467429d0d6adfd9df2f6d9 (patch)
tree0263688d261b69aedf2dad690ac1d93f875eec78 /fs/btrfs
parent9fe6206f400646a2322096b56c59891d530e8d51 (diff)
Btrfs: stop trying to shrink delalloc if there are no inodes to reclaim
In very severe ENOSPC cases we can run out of inodes to do delalloc on, which means we'll just keep looping trying to shrink delalloc. Instead, if we fail to shrink delalloc 3 times in a row break out since we're not likely to make any progress. Tested this with a 100mb fs an xfstests test 13. Before the patch it would hang the box, with the patch we get -ENOSPC like we should. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/extent-tree.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 32d094002a5..c6a5d9095d5 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3115,6 +3115,7 @@ static int shrink_delalloc(struct btrfs_trans_handle *trans,
3115 u64 reserved; 3115 u64 reserved;
3116 u64 max_reclaim; 3116 u64 max_reclaim;
3117 u64 reclaimed = 0; 3117 u64 reclaimed = 0;
3118 int no_reclaim = 0;
3118 int pause = 1; 3119 int pause = 1;
3119 int ret; 3120 int ret;
3120 3121
@@ -3131,12 +3132,16 @@ static int shrink_delalloc(struct btrfs_trans_handle *trans,
3131 while (1) { 3132 while (1) {
3132 ret = btrfs_start_one_delalloc_inode(root, trans ? 1 : 0); 3133 ret = btrfs_start_one_delalloc_inode(root, trans ? 1 : 0);
3133 if (!ret) { 3134 if (!ret) {
3135 if (no_reclaim > 2)
3136 break;
3137 no_reclaim++;
3134 __set_current_state(TASK_INTERRUPTIBLE); 3138 __set_current_state(TASK_INTERRUPTIBLE);
3135 schedule_timeout(pause); 3139 schedule_timeout(pause);
3136 pause <<= 1; 3140 pause <<= 1;
3137 if (pause > HZ / 10) 3141 if (pause > HZ / 10)
3138 pause = HZ / 10; 3142 pause = HZ / 10;
3139 } else { 3143 } else {
3144 no_reclaim = 0;
3140 pause = 1; 3145 pause = 1;
3141 } 3146 }
3142 3147