Commit 3d5addaf authored by Liu Bo's avatar Liu Bo Committed by David Sterba

Btrfs: do not check inode's runtime flags under root->orphan_lock

It's not necessary to hold ->orphan_lock when checking inode's runtime
flags.
Signed-off-by: default avatarLiu Bo <bo.li.liu@oracle.com>
Reviewed-by: default avatarJosef Bacik <jbacik@fb.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent bc5511d0
...@@ -3355,14 +3355,6 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, ...@@ -3355,14 +3355,6 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans,
return -ENOMEM; return -ENOMEM;
} }
spin_lock(&root->orphan_lock);
if (!root->orphan_block_rsv) {
root->orphan_block_rsv = block_rsv;
} else if (block_rsv) {
btrfs_free_block_rsv(fs_info, block_rsv);
block_rsv = NULL;
}
if (!test_and_set_bit(BTRFS_INODE_HAS_ORPHAN_ITEM, if (!test_and_set_bit(BTRFS_INODE_HAS_ORPHAN_ITEM,
&inode->runtime_flags)) { &inode->runtime_flags)) {
#if 0 #if 0
...@@ -3377,12 +3369,23 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, ...@@ -3377,12 +3369,23 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans,
insert = 1; insert = 1;
#endif #endif
insert = 1; insert = 1;
atomic_inc(&root->orphan_inodes);
} }
if (!test_and_set_bit(BTRFS_INODE_ORPHAN_META_RESERVED, if (!test_and_set_bit(BTRFS_INODE_ORPHAN_META_RESERVED,
&inode->runtime_flags)) &inode->runtime_flags))
reserve = 1; reserve = 1;
spin_lock(&root->orphan_lock);
/* If someone has created ->orphan_block_rsv, be happy to use it. */
if (!root->orphan_block_rsv) {
root->orphan_block_rsv = block_rsv;
} else if (block_rsv) {
btrfs_free_block_rsv(fs_info, block_rsv);
block_rsv = NULL;
}
if (insert)
atomic_inc(&root->orphan_inodes);
spin_unlock(&root->orphan_lock); spin_unlock(&root->orphan_lock);
/* grab metadata reservation from transaction handle */ /* grab metadata reservation from transaction handle */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment