OSDN Git Service

btrfs: improve the delalloc_to_write calculation in writepage_delalloc
authorChristoph Hellwig <hch@lst.de>
Wed, 28 Jun 2023 15:31:30 +0000 (17:31 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Aug 2023 12:52:14 +0000 (14:52 +0200)
commit2c73162d649670045415537dc746f7524cda1405
tree5ff4e80739d5f009f2aa18ba2249ddc91cf7f4e9
parent0835d1e66e7f22428bbc2ea56cb488a7759b51e2
btrfs: improve the delalloc_to_write calculation in writepage_delalloc

Currently writepage_delalloc adds to delalloc_to_write in every loop
operation.  That is not only more work than doing it once after the
loop, but can also over-increment the counter due to rounding errors
when a new loop iteration starts with an offset into a page.

Add a new page_start variable instead of recaculation that value over
and over, move the delalloc_to_write calculation out of the loop, use
the DIV_ROUND_UP helper instead of open coding it and remove the pointless
found local variable.

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