summaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-04-25 08:51:48 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:02 -0400
commit81d7ed29ff6bdec903c36c26b386e16c014993b2 (patch)
tree561f6d5b85c9af14acc97ec45b6ce6622c3ec3f4 /fs/btrfs
parentbce4eae9864e6b6ebde5d7f05576ff0a6c3724d0 (diff)
downloadop-kernel-dev-81d7ed29ff6bdec903c36c26b386e16c014993b2.zip
op-kernel-dev-81d7ed29ff6bdec903c36c26b386e16c014993b2.tar.gz
Btrfs: Throttle file_write when data=ordered is flushing the inode
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/btrfs_inode.h1
-rw-r--r--fs/btrfs/file.c1
-rw-r--r--fs/btrfs/inode.c4
-rw-r--r--fs/btrfs/ordered-data.c13
-rw-r--r--fs/btrfs/ordered-data.h1
-rw-r--r--fs/btrfs/transaction.c10
6 files changed, 28 insertions, 2 deletions
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index fe6ef8e..5ba8389 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -31,6 +31,7 @@ struct btrfs_inode {
struct extent_io_tree io_tree;
struct extent_io_tree io_failure_tree;
struct inode vfs_inode;
+ atomic_t ordered_writeback;
u64 ordered_trans;
/*
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 5d537f2..8effdf4 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -977,6 +977,7 @@ out_nolock:
(start_pos + num_written - 1) >> PAGE_CACHE_SHIFT);
}
current->backing_dev_info = NULL;
+ btrfs_ordered_throttle(root, inode);
return num_written ? num_written : err;
}
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index d58b4d5..b31f52d 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1419,6 +1419,7 @@ static int btrfs_init_locked_inode(struct inode *inode, void *p)
inode->i_mapping, GFP_NOFS);
extent_io_tree_init(&BTRFS_I(inode)->io_failure_tree,
inode->i_mapping, GFP_NOFS);
+ atomic_set(&BTRFS_I(inode)->ordered_writeback, 0);
return 0;
}
@@ -1728,6 +1729,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
inode->i_mapping, GFP_NOFS);
extent_io_tree_init(&BTRFS_I(inode)->io_failure_tree,
inode->i_mapping, GFP_NOFS);
+ atomic_set(&BTRFS_I(inode)->ordered_writeback, 0);
BTRFS_I(inode)->delalloc_bytes = 0;
BTRFS_I(inode)->root = root;
@@ -1956,6 +1958,7 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
extent_io_tree_init(&BTRFS_I(inode)->io_failure_tree,
inode->i_mapping, GFP_NOFS);
BTRFS_I(inode)->delalloc_bytes = 0;
+ atomic_set(&BTRFS_I(inode)->ordered_writeback, 0);
BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops;
}
dir->i_sb->s_dirt = 1;
@@ -3292,6 +3295,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry,
extent_io_tree_init(&BTRFS_I(inode)->io_failure_tree,
inode->i_mapping, GFP_NOFS);
BTRFS_I(inode)->delalloc_bytes = 0;
+ atomic_set(&BTRFS_I(inode)->ordered_writeback, 0);
BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops;
}
dir->i_sb->s_dirt = 1;
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 3ee51e1..b474902 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -269,3 +269,16 @@ int btrfs_del_ordered_inode(struct inode *inode)
return ret;
}
+int btrfs_ordered_throttle(struct btrfs_root *root, struct inode *inode)
+{
+ struct btrfs_transaction *cur = root->fs_info->running_transaction;
+ while(cur == root->fs_info->running_transaction &&
+ atomic_read(&BTRFS_I(inode)->ordered_writeback)) {
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18)
+ congestion_wait(WRITE, HZ/20);
+#else
+ blk_congestion_wait(WRITE, HZ/20);
+#endif
+ }
+ return 0;
+}
diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h
index f25c677..29047e0 100644
--- a/fs/btrfs/ordered-data.h
+++ b/fs/btrfs/ordered-data.h
@@ -39,4 +39,5 @@ int btrfs_find_first_ordered_inode(struct btrfs_ordered_inode_tree *tree,
u64 *root_objectid, u64 *objectid,
struct inode **inode);
int btrfs_del_ordered_inode(struct inode *inode);
+int btrfs_ordered_throttle(struct btrfs_root *root, struct inode *inode);
#endif
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 1ed179c..c85cb48 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -512,8 +512,11 @@ int btrfs_write_ordered_inodes(struct btrfs_trans_handle *trans,
mutex_unlock(&root->fs_info->trans_mutex);
mutex_unlock(&root->fs_info->fs_mutex);
- if (S_ISREG(inode->i_mode))
+ if (S_ISREG(inode->i_mode)) {
+ atomic_inc(&BTRFS_I(inode)->ordered_writeback);
filemap_fdatawrite(inode->i_mapping);
+ atomic_dec(&BTRFS_I(inode)->ordered_writeback);
+ }
iput(inode);
mutex_lock(&root->fs_info->fs_mutex);
@@ -530,8 +533,11 @@ int btrfs_write_ordered_inodes(struct btrfs_trans_handle *trans,
mutex_unlock(&root->fs_info->trans_mutex);
mutex_unlock(&root->fs_info->fs_mutex);
- if (S_ISREG(inode->i_mode))
+ if (S_ISREG(inode->i_mode)) {
+ atomic_inc(&BTRFS_I(inode)->ordered_writeback);
filemap_write_and_wait(inode->i_mapping);
+ atomic_dec(&BTRFS_I(inode)->ordered_writeback);
+ }
atomic_dec(&inode->i_count);
iput(inode);
OpenPOWER on IntegriCloud