summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ordered-data.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-01-16 22:09:22 +0100
committerChris Mason <chris.mason@oracle.com>2008-09-25 17:03:59 +0200
commit4d5e74bc0aec3f54b7e429d77b7c35de042c507d (patch)
treebba22e2a9cfbe5663a2489c5404fff72639b5277 /fs/btrfs/ordered-data.c
parentBtrfs: Run igrab on data=ordered inodes to prevent deadlocks during writeout (diff)
downloadlinux-4d5e74bc0aec3f54b7e429d77b7c35de042c507d.tar.xz
linux-4d5e74bc0aec3f54b7e429d77b7c35de042c507d.zip
Btrfs: Fix data=ordered vs wait_on_inode deadlock on older kernels
Using ilookup5 during data=ordered writeback could deadlock on I_LOCK. This saves a pointer to the inode instead. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ordered-data.c')
-rw-r--r--fs/btrfs/ordered-data.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index cba2b623d02e..3ee51e10c187 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -25,6 +25,7 @@
struct tree_entry {
u64 root_objectid;
u64 objectid;
+ struct inode *inode;
struct rb_node rb_node;
};
@@ -144,6 +145,7 @@ int btrfs_add_ordered_inode(struct inode *inode)
write_lock(&tree->lock);
entry->objectid = inode->i_ino;
entry->root_objectid = root_objectid;
+ entry->inode = inode;
node = tree_insert(&tree->tree, root_objectid,
inode->i_ino, &entry->rb_node);
@@ -159,7 +161,8 @@ int btrfs_add_ordered_inode(struct inode *inode)
}
int btrfs_find_first_ordered_inode(struct btrfs_ordered_inode_tree *tree,
- u64 *root_objectid, u64 *objectid)
+ u64 *root_objectid, u64 *objectid,
+ struct inode **inode)
{
struct tree_entry *entry;
struct rb_node *node;
@@ -184,13 +187,16 @@ int btrfs_find_first_ordered_inode(struct btrfs_ordered_inode_tree *tree,
}
*root_objectid = entry->root_objectid;
+ *inode = entry->inode;
+ atomic_inc(&entry->inode->i_count);
*objectid = entry->objectid;
write_unlock(&tree->lock);
return 1;
}
int btrfs_find_del_first_ordered_inode(struct btrfs_ordered_inode_tree *tree,
- u64 *root_objectid, u64 *objectid)
+ u64 *root_objectid, u64 *objectid,
+ struct inode **inode)
{
struct tree_entry *entry;
struct rb_node *node;
@@ -216,6 +222,8 @@ int btrfs_find_del_first_ordered_inode(struct btrfs_ordered_inode_tree *tree,
*root_objectid = entry->root_objectid;
*objectid = entry->objectid;
+ *inode = entry->inode;
+ atomic_inc(&entry->inode->i_count);
rb_erase(node, &tree->tree);
write_unlock(&tree->lock);
kfree(entry);