summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorLiu Bo <bo.li.liu@oracle.com>2018-01-25 19:02:55 +0100
committerDavid Sterba <dsterba@suse.com>2018-03-26 15:09:36 +0200
commit3d5addafd0c49d57afe867339ec1cc535d23715e (patch)
treeb5ace6fadaad888aa7b0d78eeedeb1dcd13a12d1 /fs/btrfs/inode.c
parentbtrfs: Use schedule_timeout_interruptible (diff)
downloadlinux-3d5addafd0c49d57afe867339ec1cc535d23715e.tar.xz
linux-3d5addafd0c49d57afe867339ec1cc535d23715e.zip
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: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 28491a82e645..4d3a4d1507a1 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3355,14 +3355,6 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans,
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,
&inode->runtime_flags)) {
#if 0
@@ -3377,12 +3369,23 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans,
insert = 1;
#endif
insert = 1;
- atomic_inc(&root->orphan_inodes);
}
if (!test_and_set_bit(BTRFS_INODE_ORPHAN_META_RESERVED,
&inode->runtime_flags))
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);
/* grab metadata reservation from transaction handle */