diff options
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 32 |
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) | |||
601 | { | 601 | { |
602 | struct btrfs_root *root; | 602 | struct btrfs_root *root; |
603 | struct btrfs_trans_handle *trans; | 603 | struct btrfs_trans_handle *trans; |
604 | struct inode *inode = dentry->d_inode; | ||
604 | int ret; | 605 | int ret; |
605 | unsigned long nr = 0; | 606 | unsigned long nr = 0; |
606 | 607 | ||
@@ -617,6 +618,18 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry) | |||
617 | ret = btrfs_unlink_trans(trans, root, dir, dentry); | 618 | ret = btrfs_unlink_trans(trans, root, dir, dentry); |
618 | nr = trans->blocks_used; | 619 | nr = trans->blocks_used; |
619 | 620 | ||
621 | if (inode->i_nlink == 0) { | ||
622 | int found; | ||
623 | /* if the inode isn't linked anywhere, | ||
624 | * we don't need to worry about | ||
625 | * data=ordered | ||
626 | */ | ||
627 | found = btrfs_del_ordered_inode(inode); | ||
628 | if (found == 1) { | ||
629 | atomic_dec(&inode->i_count); | ||
630 | } | ||
631 | } | ||
632 | |||
620 | btrfs_end_transaction(trans, root); | 633 | btrfs_end_transaction(trans, root); |
621 | fail: | 634 | fail: |
622 | mutex_unlock(&root->fs_info->fs_mutex); | 635 | mutex_unlock(&root->fs_info->fs_mutex); |
@@ -993,15 +1006,22 @@ fail: | |||
993 | return err; | 1006 | return err; |
994 | } | 1007 | } |
995 | 1008 | ||
996 | void btrfs_drop_inode(struct inode *inode) | 1009 | void btrfs_put_inode(struct inode *inode) |
997 | { | 1010 | { |
998 | if (!BTRFS_I(inode)->ordered_trans || inode->i_nlink) { | 1011 | int ret; |
999 | generic_drop_inode(inode); | 1012 | |
1013 | if (!BTRFS_I(inode)->ordered_trans) { | ||
1014 | return; | ||
1015 | } | ||
1016 | |||
1017 | if (mapping_tagged(inode->i_mapping, PAGECACHE_TAG_DIRTY) || | ||
1018 | mapping_tagged(inode->i_mapping, PAGECACHE_TAG_WRITEBACK)) | ||
1000 | return; | 1019 | return; |
1020 | |||
1021 | ret = btrfs_del_ordered_inode(inode); | ||
1022 | if (ret == 1) { | ||
1023 | atomic_dec(&inode->i_count); | ||
1001 | } | 1024 | } |
1002 | /* FIXME, make sure this delete actually ends up in the transaction */ | ||
1003 | btrfs_del_ordered_inode(inode); | ||
1004 | generic_drop_inode(inode); | ||
1005 | } | 1025 | } |
1006 | 1026 | ||
1007 | void btrfs_delete_inode(struct inode *inode) | 1027 | void btrfs_delete_inode(struct inode *inode) |