diff mbox series

[18/21] btrfs: check if writeback pages exist before starting writeback

Message ID 3499da06f72955091f63c15bfe454f77b72e4300.1677793433.git.rgoldwyn@suse.com (mailing list archive)
State New, archived
Headers show
Series Lock extents before pages | expand

Commit Message

Goldwyn Rodrigues March 2, 2023, 10:25 p.m. UTC
From: Goldwyn Rodrigues <rgoldwyn@suse.com>

Check if there are still pages to writeback after locking. This avoids
calls to check for extents.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 fs/btrfs/inode.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 70cf852a3efd..c4e5eb5d9ee4 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7773,6 +7773,11 @@  static int btrfs_writepages_async(struct btrfs_inode *inode, struct writeback_co
 
 	lock_extent(&inode->io_tree, start, end, NULL);
 
+	if (!filemap_range_has_writeback(inode->vfs_inode.i_mapping, start, end)) {
+		unlock_extent(&inode->io_tree, start, end, NULL);
+		return 0;
+	}
+
 	while (cur_start < end) {
 		bool found;
 		last_start = cur_start;