* [PATCH] Btrfs: do not check inode's runtime flags under root->orphan_lock
@ 2018-01-25 18:02 Liu Bo
2018-01-26 14:22 ` Josef Bacik
0 siblings, 1 reply; 2+ messages in thread
From: Liu Bo @ 2018-01-25 18:02 UTC (permalink / raw)
To: linux-btrfs
It's not necessary to hold ->orphan_lock when checking inode's runtime
flags.
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
---
fs/btrfs/inode.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index b3fe0a8..1511db2 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3354,14 +3354,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
@@ -3376,12 +3368,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 */
--
2.9.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Btrfs: do not check inode's runtime flags under root->orphan_lock
2018-01-25 18:02 [PATCH] Btrfs: do not check inode's runtime flags under root->orphan_lock Liu Bo
@ 2018-01-26 14:22 ` Josef Bacik
0 siblings, 0 replies; 2+ messages in thread
From: Josef Bacik @ 2018-01-26 14:22 UTC (permalink / raw)
To: Liu Bo; +Cc: linux-btrfs
On Thu, Jan 25, 2018 at 11:02:55AM -0700, Liu Bo wrote:
> 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>
Thanks,
Josef
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-01-26 14:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-25 18:02 [PATCH] Btrfs: do not check inode's runtime flags under root->orphan_lock Liu Bo
2018-01-26 14:22 ` Josef Bacik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).