From: Nikolay Borisov <nborisov@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: Nikolay Borisov <nborisov@suse.com>
Subject: [PATCH 2/3] btrfs: Perform data management operations outside of inode lock
Date: Wed, 17 Jun 2020 12:10:43 +0300 [thread overview]
Message-ID: <20200617091044.27846-3-nborisov@suse.com> (raw)
In-Reply-To: <20200617091044.27846-1-nborisov@suse.com>
btrfs_alloc_data_chunk_ondemand and btrfs_free_reserved_data_space_noquota
don't really use the guts of the inodes being passed to them. This
implies it's not required to call them under extent lock. Move code
around in prealloc_file_extent_cluster to do the heavy, data
alloc/free operations outside of the lock. This also makes the 'out'
label unnecessary, so remove it.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/relocation.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 348985c8a559..020d04035be1 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2584,17 +2584,15 @@ int prealloc_file_extent_cluster(struct inode *inode,
int ret = 0;
u64 prealloc_start = cluster->start - offset;
u64 prealloc_end = cluster->end - offset;
- u64 cur_offset;
+ u64 cur_offset = prealloc_start;
BUG_ON(cluster->start != cluster->boundary[0]);
- inode_lock(inode);
-
ret = btrfs_alloc_data_chunk_ondemand(BTRFS_I(inode),
prealloc_end + 1 - prealloc_start);
if (ret)
- goto out;
+ return ret;
- cur_offset = prealloc_start;
+ inode_lock(inode);
while (nr < cluster->nr) {
start = cluster->boundary[nr] - offset;
if (nr + 1 < cluster->nr)
@@ -2613,11 +2611,11 @@ int prealloc_file_extent_cluster(struct inode *inode,
break;
nr++;
}
+ inode_unlock(inode);
+
if (cur_offset < prealloc_end)
btrfs_free_reserved_data_space_noquota(inode,
prealloc_end + 1 - cur_offset);
-out:
- inode_unlock(inode);
return ret;
}
--
2.17.1
next prev parent reply other threads:[~2020-06-17 9:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-17 9:10 [PATCH 0/3] Refactor prealloc_file_extent_cluster Nikolay Borisov
2020-06-17 9:10 ` [PATCH 1/3] btrfs: Remove hole check in prealloc_file_extent_cluster Nikolay Borisov
2020-06-17 12:57 ` Johannes Thumshirn
2020-06-17 16:22 ` David Sterba
2020-06-17 9:10 ` Nikolay Borisov [this message]
2020-06-17 12:54 ` [PATCH 2/3] btrfs: Perform data management operations outside of inode lock Johannes Thumshirn
2020-06-17 9:10 ` [PATCH 3/3] btrfs: Use for loop in prealloc_file_extent_cluster Nikolay Borisov
2020-06-17 13:02 ` Johannes Thumshirn
2020-06-17 13:18 ` Nikolay Borisov
2020-06-17 16:38 ` [PATCH 0/3] Refactor prealloc_file_extent_cluster David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200617091044.27846-3-nborisov@suse.com \
--to=nborisov@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox