diff options
author | Filipe David Borba Manana <fdmanana@gmail.com> | 2013-09-22 16:54:55 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2013-11-11 21:53:01 -0500 |
commit | 703c88e035242202e3ab48fcbbbe0a7bc62fb7bb (patch) | |
tree | 06ea46ed4a0492754e8b0be82f43b60b2322c1f8 /fs/btrfs/inode.c | |
parent | fe09e16cc8d444ecc52f6f9a651946f16fffa4e1 (diff) |
Btrfs: fix tracking of orphan inode count
In inode.c:btrfs_orphan_add() if we failed to insert the orphan
item, we would return without decrementing the orphan count that
we just incremented before attempting the insertion, leaving the
orphan inode count wrong.
In inode.c:btrfs_orphan_del(), we were decrementing the inode
orphan count if the bit BTRFS_INODE_ORPHAN_META_RESERVED was set,
which is logically wrong because it should be decremented if the
bit BTRFS_INODE_HAS_ORPHAN_ITEM was set - after all we increment
the count when we set the bit BTRFS_INODE_HAS_ORPHAN_ITEM elsewhere.
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 57b27012d43a..939dd1ff34a7 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -2969,6 +2969,7 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode) | |||
2969 | if (insert >= 1) { | 2969 | if (insert >= 1) { |
2970 | ret = btrfs_insert_orphan_item(trans, root, btrfs_ino(inode)); | 2970 | ret = btrfs_insert_orphan_item(trans, root, btrfs_ino(inode)); |
2971 | if (ret) { | 2971 | if (ret) { |
2972 | atomic_dec(&root->orphan_inodes); | ||
2972 | if (reserve) { | 2973 | if (reserve) { |
2973 | clear_bit(BTRFS_INODE_ORPHAN_META_RESERVED, | 2974 | clear_bit(BTRFS_INODE_ORPHAN_META_RESERVED, |
2974 | &BTRFS_I(inode)->runtime_flags); | 2975 | &BTRFS_I(inode)->runtime_flags); |
@@ -3018,14 +3019,16 @@ static int btrfs_orphan_del(struct btrfs_trans_handle *trans, | |||
3018 | release_rsv = 1; | 3019 | release_rsv = 1; |
3019 | spin_unlock(&root->orphan_lock); | 3020 | spin_unlock(&root->orphan_lock); |
3020 | 3021 | ||
3021 | if (trans && delete_item) | 3022 | if (delete_item) { |
3022 | ret = btrfs_del_orphan_item(trans, root, btrfs_ino(inode)); | ||
3023 | |||
3024 | if (release_rsv) { | ||
3025 | btrfs_orphan_release_metadata(inode); | ||
3026 | atomic_dec(&root->orphan_inodes); | 3023 | atomic_dec(&root->orphan_inodes); |
3024 | if (trans) | ||
3025 | ret = btrfs_del_orphan_item(trans, root, | ||
3026 | btrfs_ino(inode)); | ||
3027 | } | 3027 | } |
3028 | 3028 | ||
3029 | if (release_rsv) | ||
3030 | btrfs_orphan_release_metadata(inode); | ||
3031 | |||
3029 | return ret; | 3032 | return ret; |
3030 | } | 3033 | } |
3031 | 3034 | ||