Loading fs/btrfs/ctree.h +1 −0 Original line number Diff line number Diff line Loading @@ -345,6 +345,7 @@ struct btrfs_fs_info { struct completion kobj_unregister; int do_barriers; int closing; unsigned long throttles; u64 total_pinned; spinlock_t delalloc_lock; Loading fs/btrfs/disk-io.c +7 −0 Original line number Diff line number Diff line Loading @@ -631,6 +631,7 @@ struct btrfs_root *open_ctree(struct super_block *sb) fs_info->tree_root = tree_root; fs_info->extent_root = extent_root; fs_info->sb = sb; fs_info->throttles = 0; fs_info->mount_opt = 0; fs_info->max_extent = (u64)-1; fs_info->delalloc_bytes = 0; Loading Loading @@ -889,6 +890,12 @@ void btrfs_mark_buffer_dirty(struct extent_buffer *buf) set_extent_buffer_dirty(&BTRFS_I(btree_inode)->extent_tree, buf); } void btrfs_throttle(struct btrfs_root *root) { if (root->fs_info->throttles) congestion_wait(WRITE, HZ/10); } void btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr) { balance_dirty_pages_ratelimited_nr( Loading fs/btrfs/disk-io.h +1 −0 Original line number Diff line number Diff line Loading @@ -64,4 +64,5 @@ int btrfs_clear_buffer_defrag_done(struct extent_buffer *buf); int btrfs_read_buffer(struct extent_buffer *buf); u32 btrfs_csum_data(struct btrfs_root *root, char *data, u32 seed, size_t len); void btrfs_csum_final(u32 crc, char *result); void btrfs_throttle(struct btrfs_root *root); #endif fs/btrfs/file.c +1 −0 Original line number Diff line number Diff line Loading @@ -800,6 +800,7 @@ static ssize_t btrfs_file_write(struct file *file, const char __user *buf, balance_dirty_pages_ratelimited_nr(inode->i_mapping, num_pages); if (num_pages < (root->leafsize >> PAGE_CACHE_SHIFT) + 1) btrfs_btree_balance_dirty(root, 1); btrfs_throttle(root); cond_resched(); } out: Loading fs/btrfs/inode.c +12 −0 Original line number Diff line number Diff line Loading @@ -610,6 +610,7 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry) fail: mutex_unlock(&root->fs_info->fs_mutex); btrfs_btree_balance_dirty(root, nr); btrfs_throttle(root); return ret; } Loading Loading @@ -644,6 +645,7 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry) fail: mutex_unlock(&root->fs_info->fs_mutex); btrfs_btree_balance_dirty(root, nr); btrfs_throttle(root); if (ret && !err) err = ret; Loading Loading @@ -1010,6 +1012,7 @@ void btrfs_delete_inode(struct inode *inode) btrfs_end_transaction(trans, root); mutex_unlock(&root->fs_info->fs_mutex); btrfs_btree_balance_dirty(root, nr); btrfs_throttle(root); return; no_delete_lock: Loading @@ -1017,6 +1020,7 @@ void btrfs_delete_inode(struct inode *inode) btrfs_end_transaction(trans, root); mutex_unlock(&root->fs_info->fs_mutex); btrfs_btree_balance_dirty(root, nr); btrfs_throttle(root); no_delete: clear_inode(inode); } Loading Loading @@ -1574,6 +1578,7 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry, iput(inode); } btrfs_btree_balance_dirty(root, nr); btrfs_throttle(root); return err; } Loading Loading @@ -1633,6 +1638,7 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry, iput(inode); } btrfs_btree_balance_dirty(root, nr); btrfs_throttle(root); return err; } Loading Loading @@ -1684,6 +1690,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir, iput(inode); } btrfs_btree_balance_dirty(root, nr); btrfs_throttle(root); return err; } Loading Loading @@ -1752,6 +1759,7 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) if (drop_on_err) iput(inode); btrfs_btree_balance_dirty(root, nr); btrfs_throttle(root); return err; } Loading Loading @@ -2117,6 +2125,7 @@ static void btrfs_truncate(struct inode *inode) BUG_ON(ret); mutex_unlock(&root->fs_info->fs_mutex); btrfs_btree_balance_dirty(root, nr); btrfs_throttle(root); } static int noinline create_subvol(struct btrfs_root *root, char *name, Loading Loading @@ -2245,6 +2254,7 @@ static int noinline create_subvol(struct btrfs_root *root, char *name, fail_commit: mutex_unlock(&root->fs_info->fs_mutex); btrfs_btree_balance_dirty(root, nr); btrfs_throttle(root); return ret; } Loading Loading @@ -2287,6 +2297,7 @@ static int create_snapshot(struct btrfs_root *root, char *name, int namelen) fail_unlock: mutex_unlock(&root->fs_info->fs_mutex); btrfs_btree_balance_dirty(root, nr); btrfs_throttle(root); return ret; } Loading Loading @@ -2827,6 +2838,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, iput(inode); } btrfs_btree_balance_dirty(root, nr); btrfs_throttle(root); return err; } Loading Loading
fs/btrfs/ctree.h +1 −0 Original line number Diff line number Diff line Loading @@ -345,6 +345,7 @@ struct btrfs_fs_info { struct completion kobj_unregister; int do_barriers; int closing; unsigned long throttles; u64 total_pinned; spinlock_t delalloc_lock; Loading
fs/btrfs/disk-io.c +7 −0 Original line number Diff line number Diff line Loading @@ -631,6 +631,7 @@ struct btrfs_root *open_ctree(struct super_block *sb) fs_info->tree_root = tree_root; fs_info->extent_root = extent_root; fs_info->sb = sb; fs_info->throttles = 0; fs_info->mount_opt = 0; fs_info->max_extent = (u64)-1; fs_info->delalloc_bytes = 0; Loading Loading @@ -889,6 +890,12 @@ void btrfs_mark_buffer_dirty(struct extent_buffer *buf) set_extent_buffer_dirty(&BTRFS_I(btree_inode)->extent_tree, buf); } void btrfs_throttle(struct btrfs_root *root) { if (root->fs_info->throttles) congestion_wait(WRITE, HZ/10); } void btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr) { balance_dirty_pages_ratelimited_nr( Loading
fs/btrfs/disk-io.h +1 −0 Original line number Diff line number Diff line Loading @@ -64,4 +64,5 @@ int btrfs_clear_buffer_defrag_done(struct extent_buffer *buf); int btrfs_read_buffer(struct extent_buffer *buf); u32 btrfs_csum_data(struct btrfs_root *root, char *data, u32 seed, size_t len); void btrfs_csum_final(u32 crc, char *result); void btrfs_throttle(struct btrfs_root *root); #endif
fs/btrfs/file.c +1 −0 Original line number Diff line number Diff line Loading @@ -800,6 +800,7 @@ static ssize_t btrfs_file_write(struct file *file, const char __user *buf, balance_dirty_pages_ratelimited_nr(inode->i_mapping, num_pages); if (num_pages < (root->leafsize >> PAGE_CACHE_SHIFT) + 1) btrfs_btree_balance_dirty(root, 1); btrfs_throttle(root); cond_resched(); } out: Loading
fs/btrfs/inode.c +12 −0 Original line number Diff line number Diff line Loading @@ -610,6 +610,7 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry) fail: mutex_unlock(&root->fs_info->fs_mutex); btrfs_btree_balance_dirty(root, nr); btrfs_throttle(root); return ret; } Loading Loading @@ -644,6 +645,7 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry) fail: mutex_unlock(&root->fs_info->fs_mutex); btrfs_btree_balance_dirty(root, nr); btrfs_throttle(root); if (ret && !err) err = ret; Loading Loading @@ -1010,6 +1012,7 @@ void btrfs_delete_inode(struct inode *inode) btrfs_end_transaction(trans, root); mutex_unlock(&root->fs_info->fs_mutex); btrfs_btree_balance_dirty(root, nr); btrfs_throttle(root); return; no_delete_lock: Loading @@ -1017,6 +1020,7 @@ void btrfs_delete_inode(struct inode *inode) btrfs_end_transaction(trans, root); mutex_unlock(&root->fs_info->fs_mutex); btrfs_btree_balance_dirty(root, nr); btrfs_throttle(root); no_delete: clear_inode(inode); } Loading Loading @@ -1574,6 +1578,7 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry, iput(inode); } btrfs_btree_balance_dirty(root, nr); btrfs_throttle(root); return err; } Loading Loading @@ -1633,6 +1638,7 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry, iput(inode); } btrfs_btree_balance_dirty(root, nr); btrfs_throttle(root); return err; } Loading Loading @@ -1684,6 +1690,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir, iput(inode); } btrfs_btree_balance_dirty(root, nr); btrfs_throttle(root); return err; } Loading Loading @@ -1752,6 +1759,7 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) if (drop_on_err) iput(inode); btrfs_btree_balance_dirty(root, nr); btrfs_throttle(root); return err; } Loading Loading @@ -2117,6 +2125,7 @@ static void btrfs_truncate(struct inode *inode) BUG_ON(ret); mutex_unlock(&root->fs_info->fs_mutex); btrfs_btree_balance_dirty(root, nr); btrfs_throttle(root); } static int noinline create_subvol(struct btrfs_root *root, char *name, Loading Loading @@ -2245,6 +2254,7 @@ static int noinline create_subvol(struct btrfs_root *root, char *name, fail_commit: mutex_unlock(&root->fs_info->fs_mutex); btrfs_btree_balance_dirty(root, nr); btrfs_throttle(root); return ret; } Loading Loading @@ -2287,6 +2297,7 @@ static int create_snapshot(struct btrfs_root *root, char *name, int namelen) fail_unlock: mutex_unlock(&root->fs_info->fs_mutex); btrfs_btree_balance_dirty(root, nr); btrfs_throttle(root); return ret; } Loading Loading @@ -2827,6 +2838,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, iput(inode); } btrfs_btree_balance_dirty(root, nr); btrfs_throttle(root); return err; } Loading