Skip to content

Commit ac5cffe

Browse files
yangyun50Miklos Szeredi
authored andcommitted
fuse: add fast path for fuse_range_is_writeback
In some cases, the fi->writepages may be empty. And there is no need to check fi->writepages with spin_lock, which may have an impact on performance due to lock contention. For example, in scenarios where multiple readers read the same file without any writers, or where the page cache is not enabled. Also remove the outdated comment since commit 6b2fb79 ("fuse: optimize writepages search") has optimize the situation by replacing list with rb-tree. Signed-off-by: yangyun <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 5de8acb commit ac5cffe

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/fuse/file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,16 +448,16 @@ static struct fuse_writepage_args *fuse_find_writeback(struct fuse_inode *fi,
448448

449449
/*
450450
* Check if any page in a range is under writeback
451-
*
452-
* This is currently done by walking the list of writepage requests
453-
* for the inode, which can be pretty inefficient.
454451
*/
455452
static bool fuse_range_is_writeback(struct inode *inode, pgoff_t idx_from,
456453
pgoff_t idx_to)
457454
{
458455
struct fuse_inode *fi = get_fuse_inode(inode);
459456
bool found;
460457

458+
if (RB_EMPTY_ROOT(&fi->writepages))
459+
return false;
460+
461461
spin_lock(&fi->lock);
462462
found = fuse_find_writeback(fi, idx_from, idx_to);
463463
spin_unlock(&fi->lock);

0 commit comments

Comments
 (0)