diff options
author | Yan, Zheng <zheng.yan@oracle.com> | 2010-05-16 10:46:25 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2010-05-25 10:34:48 -0400 |
commit | 5da9d01b66458b180a6bee0e637a1d0a3effc622 (patch) | |
tree | 47eca61c0ad07ddc791cb7677c548d663fbac818 /fs/btrfs/inode.c | |
parent | 424499dbd0c4d88742bf581b5714b27fb44b9fef (diff) |
Btrfs: Shrink delay allocated space in a synchronized
Shrink delayed allocation space in a synchronized manner is more
controllable than flushing all delay allocated space in an async
thread.
Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 2bfdc641d4e3..d53cad1afe26 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -5611,6 +5611,38 @@ int btrfs_start_delalloc_inodes(struct btrfs_root *root, int delay_iput) | |||
5611 | return 0; | 5611 | return 0; |
5612 | } | 5612 | } |
5613 | 5613 | ||
5614 | int btrfs_start_one_delalloc_inode(struct btrfs_root *root, int delay_iput) | ||
5615 | { | ||
5616 | struct btrfs_inode *binode; | ||
5617 | struct inode *inode = NULL; | ||
5618 | |||
5619 | spin_lock(&root->fs_info->delalloc_lock); | ||
5620 | while (!list_empty(&root->fs_info->delalloc_inodes)) { | ||
5621 | binode = list_entry(root->fs_info->delalloc_inodes.next, | ||
5622 | struct btrfs_inode, delalloc_inodes); | ||
5623 | inode = igrab(&binode->vfs_inode); | ||
5624 | if (inode) { | ||
5625 | list_move_tail(&binode->delalloc_inodes, | ||
5626 | &root->fs_info->delalloc_inodes); | ||
5627 | break; | ||
5628 | } | ||
5629 | |||
5630 | list_del_init(&binode->delalloc_inodes); | ||
5631 | cond_resched_lock(&root->fs_info->delalloc_lock); | ||
5632 | } | ||
5633 | spin_unlock(&root->fs_info->delalloc_lock); | ||
5634 | |||
5635 | if (inode) { | ||
5636 | write_inode_now(inode, 0); | ||
5637 | if (delay_iput) | ||
5638 | btrfs_add_delayed_iput(inode); | ||
5639 | else | ||
5640 | iput(inode); | ||
5641 | return 1; | ||
5642 | } | ||
5643 | return 0; | ||
5644 | } | ||
5645 | |||
5614 | static int btrfs_symlink(struct inode *dir, struct dentry *dentry, | 5646 | static int btrfs_symlink(struct inode *dir, struct dentry *dentry, |
5615 | const char *symname) | 5647 | const char *symname) |
5616 | { | 5648 | { |