btrfs: remove unnecessary @nr_written parameters
authorQu Wenruo <wqu@suse.com>
Fri, 12 Nov 2021 05:33:14 +0000 (13:33 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 3 Jan 2022 14:09:45 +0000 (15:09 +0100)
commit83f1b68002c208329412cf9f998c90b3326828d2
tree3618c0d00e9f73598e8fc90917ef5c9f06914b66
parent9270501c163b67f48fd5fb2f98b1b48d6530f460
btrfs: remove unnecessary @nr_written parameters

We use @nr_written to record how many pages have been started by
btrfs_run_delalloc_range().

Currently there are only two cases that would populate @nr_written:

- Inline extent creation
- Compressed write

But both cases will also set @page_started to one.

In fact, in writepage_delalloc() we have the following code, showing
that @nr_written is really only utilized for above two cases:

/* did the fill delalloc function already unlock and start
 * the IO?
 */
if (page_started) {
/*
 * we've unlocked the page, so we can't update
 * the mapping's writeback index, just update
 * nr_to_write.
 */
wbc->nr_to_write -= nr_written;
return 1;
}

But for such cases, writepage_delalloc() will return 1, and exit
__extent_writepage() without going through __extent_writepage_io().

Thus this means, inside __extent_writepage_io(), we always get
@nr_written as 0.

So this patch is going to remove the unnecessary parameter from the
following functions:

- writepage_delalloc()

  As @nr_written passed in is always the initial value 0.

  Although inside that function, we still need a local @nr_written
  to update wbc->nr_to_write.

- __extent_writepage_io()

  As explained above, @nr_written passed in can only be 0.

  This also means we can remove one update_nr_written() call.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent_io.c