mbox series

[00/20] btrfs: remove plenty of redundant btrfs_mark_buffer_dirty() calls

Message ID cover.1734527445.git.fdmanana@suse.com (mailing list archive)
Headers show
Series btrfs: remove plenty of redundant btrfs_mark_buffer_dirty() calls | expand

Message

Filipe Manana Dec. 18, 2024, 5:06 p.m. UTC
From: Filipe Manana <fdmanana@suse.com>

There's quite a lot of places calling btrfs_mark_buffer_dirty() when it
is not necessary because we already have a path setup for writing, due
to calls to btrfs_search_slot() with a 'cow' argument having a value of 1
or anything that calls btrfs_search_slot() that way (and it's obvious
from the context). These make the code more verbose, add some overhead
and increase the module's text size unnecessarily. This patchset removes
such unnecessary calls. Often people keep adding them because they copy
the approach done from such places.

The changes are made on a per file basis to make it easier to review or
bisect.

Module size before this patchset:

  $ size fs/btrfs/btrfs.ko 
     text	   data	    bss	    dec	    hex	filename
  1781992	 161029	  16920	1959941	 1de805	fs/btrfs/btrfs.ko

After this patchet:

  $ size fs/btrfs/btrfs.ko 
     text	   data	    bss	    dec	    hex	filename
  1780646	 161021	  16920	1958587	 1de2bb	fs/btrfs/btrfs.ko

Filipe Manana (20):
  btrfs: tree-log: remove unnecessary calls to btrfs_mark_buffer_dirty()
  btrfs: free-space-tree: remove unnecessary calls to btrfs_mark_buffer_dirty()
  btrfs: extent-tree: remove unnecessary calls to btrfs_mark_buffer_dirty()
  btrfs: block-group: remove unnecessary calls to btrfs_mark_buffer_dirty()
  btrfs: delayed-inode: remove unnecessary call to btrfs_mark_buffer_dirty()
  btrfs: dev-replace: remove unnecessary call to btrfs_mark_buffer_dirty()
  btrfs: dir-item: remove unnecessary calls to btrfs_mark_buffer_dirty()
  btrfs: file: remove unnecessary calls to btrfs_mark_buffer_dirty()
  btrfs: file-item: remove unnecessary calls to btrfs_mark_buffer_dirty()
  btrfs: free-space-cache: remove unnecessary calls to btrfs_mark_buffer_dirty()
  btrfs: inode: remove unnecessary calls to btrfs_mark_buffer_dirty()
  btrfs: inode-item: remove unnecessary calls to btrfs_mark_buffer_dirty()
  btrfs: ioctl: remove unnecessary call to btrfs_mark_buffer_dirty()
  btrfs: qgroup: remove unnecessary calls to btrfs_mark_buffer_dirty()
  btrfs: raid-stripe-tree: remove unnecessary call to btrfs_mark_buffer_dirty()
  btrfs: relocation: remove unnecessary calls to btrfs_mark_buffer_dirty()
  btrfs: root-tree: remove unnecessary calls to btrfs_mark_buffer_dirty()
  btrfs: uuid-tree: remove unnecessary call to btrfs_mark_buffer_dirty()
  btrfs: volumes: remove unnecessary calls to btrfs_mark_buffer_dirty()
  btrfs: xattr: remove unnecessary call to btrfs_mark_buffer_dirty()

 fs/btrfs/block-group.c      |  2 --
 fs/btrfs/delayed-inode.c    |  1 -
 fs/btrfs/dev-replace.c      |  3 ---
 fs/btrfs/dir-item.c         |  2 --
 fs/btrfs/extent-tree.c      | 10 ----------
 fs/btrfs/file-item.c        |  3 ---
 fs/btrfs/file.c             | 11 -----------
 fs/btrfs/free-space-cache.c |  3 ---
 fs/btrfs/free-space-tree.c  |  5 -----
 fs/btrfs/inode-item.c       |  5 -----
 fs/btrfs/inode.c            |  5 -----
 fs/btrfs/ioctl.c            |  1 -
 fs/btrfs/qgroup.c           | 18 ------------------
 fs/btrfs/raid-stripe-tree.c |  1 -
 fs/btrfs/relocation.c       |  7 -------
 fs/btrfs/root-tree.c        |  2 --
 fs/btrfs/tree-log.c         |  4 ----
 fs/btrfs/uuid-tree.c        |  2 --
 fs/btrfs/volumes.c          | 12 +-----------
 fs/btrfs/xattr.c            |  1 -
 20 files changed, 1 insertion(+), 97 deletions(-)

Comments

Johannes Thumshirn Dec. 19, 2024, 7:43 a.m. UTC | #1
On 18.12.24 18:07, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> There's quite a lot of places calling btrfs_mark_buffer_dirty() when it
> is not necessary because we already have a path setup for writing, due
> to calls to btrfs_search_slot() with a 'cow' argument having a value of 1
> or anything that calls btrfs_search_slot() that way (and it's obvious
> from the context). These make the code more verbose, add some overhead
> and increase the module's text size unnecessarily. This patchset removes
> such unnecessary calls. Often people keep adding them because they copy
> the approach done from such places.
> 
> The changes are made on a per file basis to make it easier to review or
> bisect.
> 
> Module size before this patchset:
> 
>    $ size fs/btrfs/btrfs.ko
>       text	   data	    bss	    dec	    hex	filename
>    1781992	 161029	  16920	1959941	 1de805	fs/btrfs/btrfs.ko
> 
> After this patchet:
> 
>    $ size fs/btrfs/btrfs.ko
>       text	   data	    bss	    dec	    hex	filename
>    1780646	 161021	  16920	1958587	 1de2bb	fs/btrfs/btrfs.ko

For the series,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>