Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 233003
b: refs/heads/master
c: b1953bc
h: refs/heads/master
i:
  233001: e59597f
  232999: 4afaf34
v: v3
  • Loading branch information
Josef Bacik authored and Chris Mason committed Jan 31, 2011
1 parent 153a4ec commit c084404
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7adf5dfbb3af65a00e20b3ead224c3a1b40e4ec4
refs/heads/master: b1953bcec95c189b1eea690a08e89646d7750bda
17 changes: 14 additions & 3 deletions trunk/fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -3345,8 +3345,10 @@ static int shrink_delalloc(struct btrfs_trans_handle *trans,
u64 reserved;
u64 max_reclaim;
u64 reclaimed = 0;
long time_left;
int pause = 1;
int nr_pages = (2 * 1024 * 1024) >> PAGE_CACHE_SHIFT;
int loops = 0;

block_rsv = &root->fs_info->delalloc_block_rsv;
space_info = block_rsv->space_info;
Expand All @@ -3359,16 +3361,20 @@ static int shrink_delalloc(struct btrfs_trans_handle *trans,

max_reclaim = min(reserved, to_reclaim);

while (1) {
while (loops < 1024) {
/* have the flusher threads jump in and do some IO */
smp_mb();
nr_pages = min_t(unsigned long, nr_pages,
root->fs_info->delalloc_bytes >> PAGE_CACHE_SHIFT);
writeback_inodes_sb_nr_if_idle(root->fs_info->sb, nr_pages);

spin_lock(&space_info->lock);
if (reserved > space_info->bytes_reserved)
if (reserved > space_info->bytes_reserved) {
loops = 0;
reclaimed += reserved - space_info->bytes_reserved;
} else {
loops++;
}
reserved = space_info->bytes_reserved;
spin_unlock(&space_info->lock);

Expand All @@ -3379,7 +3385,12 @@ static int shrink_delalloc(struct btrfs_trans_handle *trans,
return -EAGAIN;

__set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(pause);
time_left = schedule_timeout(pause);

/* We were interrupted, exit */
if (time_left)
break;

pause <<= 1;
if (pause > HZ / 10)
pause = HZ / 10;
Expand Down

0 comments on commit c084404

Please sign in to comment.