Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
Btrfs: set leave_spinning in btrfs_get_extent
Browse files Browse the repository at this point in the history
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 lower impact (faster) on waiters
rather than that in the blocking mode.

Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
liubogithub authored and kdave committed Oct 15, 2018
1 parent de2c661 commit e49aabd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -6827,6 +6827,12 @@ struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
/* Chances are we'll be called again, so go ahead and do readahead */
path->reada = READA_FORWARD;

/*
* Unless we're going to uncompress the 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;
Expand Down Expand Up @@ -6929,6 +6935,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) {
Expand Down

0 comments on commit e49aabd

Please sign in to comment.