summaryrefslogtreecommitdiff
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-01-16 11:44:43 -0500
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:03:59 -0400
commit2da98f003f4788b0a72c5f87bc55b061f65f30fa (patch)
treee94832937031f347168aaec4e50ab2ced8331ccb /fs/btrfs/inode.c
parent9cce6c3bfca85bf92e8c9358542a18dfa6c232be (diff)
downloadlwn-2da98f003f4788b0a72c5f87bc55b061f65f30fa.tar.gz
lwn-2da98f003f4788b0a72c5f87bc55b061f65f30fa.zip
Btrfs: Run igrab on data=ordered inodes to prevent deadlocks during writeout
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index f83f88ca8ac7..c1ac0bcbb462 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -601,6 +601,7 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry)
{
struct btrfs_root *root;
struct btrfs_trans_handle *trans;
+ struct inode *inode = dentry->d_inode;
int ret;
unsigned long nr = 0;
@@ -617,6 +618,18 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry)
ret = btrfs_unlink_trans(trans, root, dir, dentry);
nr = trans->blocks_used;
+ if (inode->i_nlink == 0) {
+ int found;
+ /* if the inode isn't linked anywhere,
+ * we don't need to worry about
+ * data=ordered
+ */
+ found = btrfs_del_ordered_inode(inode);
+ if (found == 1) {
+ atomic_dec(&inode->i_count);
+ }
+ }
+
btrfs_end_transaction(trans, root);
fail:
mutex_unlock(&root->fs_info->fs_mutex);
@@ -993,15 +1006,22 @@ fail:
return err;
}
-void btrfs_drop_inode(struct inode *inode)
+void btrfs_put_inode(struct inode *inode)
{
- if (!BTRFS_I(inode)->ordered_trans || inode->i_nlink) {
- generic_drop_inode(inode);
+ int ret;
+
+ if (!BTRFS_I(inode)->ordered_trans) {
+ return;
+ }
+
+ if (mapping_tagged(inode->i_mapping, PAGECACHE_TAG_DIRTY) ||
+ mapping_tagged(inode->i_mapping, PAGECACHE_TAG_WRITEBACK))
return;
+
+ ret = btrfs_del_ordered_inode(inode);
+ if (ret == 1) {
+ atomic_dec(&inode->i_count);
}
- /* FIXME, make sure this delete actually ends up in the transaction */
- btrfs_del_ordered_inode(inode);
- generic_drop_inode(inode);
}
void btrfs_delete_inode(struct inode *inode)