Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 360391
b: refs/heads/master
c: da633a4
h: refs/heads/master
i:
  360389: a79c372
  360387: 79b64c5
  360383: aa94030
v: v3
  • Loading branch information
Miao Xie authored and Josef Bacik committed Feb 20, 2013
1 parent 3e2e6ad commit be6d46c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 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: 093486c453a55230ccdad4b48863b872fe68c46e
refs/heads/master: da633a42170165cbf20a2d3886c7480ccc832ec3
40 changes: 31 additions & 9 deletions trunk/fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -3695,12 +3695,15 @@ static int can_overcommit(struct btrfs_root *root,
return 0;
}

static int writeback_inodes_sb_nr_if_idle_safe(struct super_block *sb,
unsigned long nr_pages,
enum wb_reason reason)
static inline int writeback_inodes_sb_nr_if_idle_safe(struct super_block *sb,
unsigned long nr_pages,
enum wb_reason reason)
{
if (!writeback_in_progress(sb->s_bdi) &&
down_read_trylock(&sb->s_umount)) {
/* the flusher is dealing with the dirty inodes now. */
if (writeback_in_progress(sb->s_bdi))
return 1;

if (down_read_trylock(&sb->s_umount)) {
writeback_inodes_sb_nr(sb, nr_pages, reason);
up_read(&sb->s_umount);
return 1;
Expand All @@ -3709,6 +3712,28 @@ static int writeback_inodes_sb_nr_if_idle_safe(struct super_block *sb,
return 0;
}

void btrfs_writeback_inodes_sb_nr(struct btrfs_root *root,
unsigned long nr_pages)
{
struct super_block *sb = root->fs_info->sb;
int started;

/* If we can not start writeback, just sync all the delalloc file. */
started = writeback_inodes_sb_nr_if_idle_safe(sb, nr_pages,
WB_REASON_FS_FREE_SPACE);
if (!started) {
/*
* We needn't worry the filesystem going from r/w to r/o though
* we don't acquire ->s_umount mutex, because the filesystem
* should guarantee the delalloc inodes list be empty after
* the filesystem is readonly(all dirty pages are written to
* the disk).
*/
btrfs_start_delalloc_inodes(root, 0);
btrfs_wait_ordered_extents(root, 0);
}
}

/*
* shrink metadata reservation for delalloc
*/
Expand Down Expand Up @@ -3741,10 +3766,7 @@ static void shrink_delalloc(struct btrfs_root *root, u64 to_reclaim, u64 orig,
while (delalloc_bytes && loops < 3) {
max_reclaim = min(delalloc_bytes, to_reclaim);
nr_pages = max_reclaim >> PAGE_CACHE_SHIFT;
writeback_inodes_sb_nr_if_idle_safe(root->fs_info->sb,
nr_pages,
WB_REASON_FS_FREE_SPACE);

btrfs_writeback_inodes_sb_nr(root, nr_pages);
/*
* We need to wait for the async pages to actually start before
* we do anything.
Expand Down

0 comments on commit be6d46c

Please sign in to comment.