Unless it's going to read inline extents from btree leaf to page,
btrfs_get_extent won't sleep during the period of holding path lock.
This sets leave_spinning at first and sets path to blocking mode right
before reading inline extent if that's the case. The benefit is that a
path in spinning mode typically has less impact (faster) on waiters
rather than that in blocking mode.
Also fixes the misalignment of the prototype, which is too trivial for
a single patch.
Signed-off-by: Liu Bo
---
v3: separate alignment fix out of this patch.
fs/btrfs/inode.c | 8
1 file changed, 8 insertions(+)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 10e86f7b5398..1e0af0cc56fc 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6843,6 +6843,12 @@ struct extent_map *btrfs_get_extent(struct btrfs_inode
*inode,
*/
path->reada = READA_FORWARD;
+ /*
+* Unless we're going to uncompress inline extent, no sleep would
+* happen.
+*/
+ path->leave_spinning = 1;
+
ret = btrfs_lookup_file_extent(NULL, root, path, objectid, start, 0);
if (ret < 0) {
err = ret;
@@ -6945,6 +6951,8 @@ struct extent_map *btrfs_get_extent(struct btrfs_inode
*inode,
em->orig_block_len = em->len;
em->orig_start = em->start;
ptr = btrfs_file_extent_inline_start(item) + extent_offset;
+
+ btrfs_set_path_blocking(path);
if (!PageUptodate(page)) {
if (btrfs_file_extent_compression(leaf, item) !=
BTRFS_COMPRESS_NONE) {
--
1.8.3.1