btrfs: fix range_end calculation in extent_write_locked_range
authorChristoph Hellwig <hch@lst.de>
Wed, 31 May 2023 06:04:50 +0000 (08:04 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 19 Jun 2023 11:59:34 +0000 (13:59 +0200)
The range_end field in struct writeback_control is inclusive, just like
the end parameter passed to extent_write_locked_range.  Not doing this
could cause extra writeout, which is harmless but suboptimal.

Fixes: 771ed689d2cd ("Btrfs: Optimize compressed writeback and reads")
CC: stable@vger.kernel.org # 5.9+
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent_io.c

index d5b3b15f7ab222cd52eebe982cdaa2d77d3fedf2..0726c82db309a29543ea08369e436a232b1302cc 100644 (file)
@@ -2310,7 +2310,7 @@ int extent_write_locked_range(struct inode *inode, u64 start, u64 end)
        struct writeback_control wbc_writepages = {
                .sync_mode      = WB_SYNC_ALL,
                .range_start    = start,
-               .range_end      = end + 1,
+               .range_end      = end,
                .no_cgroup_owner = 1,
        };
        struct btrfs_bio_ctrl bio_ctrl = {