Skip to content

RFC use cleanup.h in btrfs

Gladyshev Ilya linux-btrfs lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest8 patches 12 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8btrfs: remove redundant label in __del_qgroup_relationfs/btrfs/qgroup.c+4 -70 replies
2/8btrfs: move kfree out of btrfs_create_qgroup's cleanup pathfs/btrfs/qgroup.c+4 -41 reply
3/8btrfs: simplify control flow in scrub_simple_mirrorfs/btrfs/scrub.c+8 -110 replies
4/8btrfs: simplify function protections with guardsfs/btrfs/discard.c fs/btrfs/disk-io.c fs/btrfs/extent-io-tree.c +8 more+29 -704 replies
5/8btrfs: use cleanup.h guard()s to simplify unlocks on returnfs/btrfs/block-group.c fs/btrfs/discard.c fs/btrfs/disk-io.c +12 more+73 -1530 replies
6/8btrfs: simplify cleanup via scoped_guard()fs/btrfs/block-group.c fs/btrfs/compression.c fs/btrfs/extent-tree.c +5 more+97 -1281 reply
7/8btrfs: simplify return path via cleanup.hfs/btrfs/extent-io-tree.c fs/btrfs/extent-tree.c fs/btrfs/ordered-data.c+68 -953 replies
8/8btrfs: simplify cleanup in btrfs_add_qgroup_relationfs/btrfs/qgroup.c+16 -261 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/8] use cleanup.h in btrfs

This series represents my experimentation with refactoring with cleanup guards. In my opinion, RAII-style locking improves readability in most cases and also improves code robustness for future code changes, so I tried to refactor simple cases that really benefits from lock guards.

However readability is a subjective concept, so you can freely disagree and reject any of those changes, I won't insist on any. Please note that patches 1-3 can be useful even without lock guards.

I didn't know how to split this series, mostly because it's just a lot of small changes... so I tried to split it by types of transformation:

1. Patches 1-3 include some preparation work and simple fixes I noticed.
2. Patches 4-6 gradually increase the complexity of the refactored situations, from simple lock/unlock pairs to scoped guards.
3. Patch 7 refactors functions which control flow can really benefit from removed cleanups on exit. E.g. we can get rid of obscure if statements in exit paths.
4. Patch 8 is kinda an example of overdone code refactoring and I predict that it will be dropped anyway.

There is no TODOs for this series, but it's junk enough to be marked as RFC.

Gladyshev Ilya (8):
btrfs: remove redundant label in __del_qgroup_relation
btrfs: move kfree out of btrfs_create_qgroup's cleanup path
btrfs: simplify control flow in scrub_simple_mirror
btrfs: simplify function protections with guards
btrfs: use cleanup.h guard()s to simplify unlocks on return
btrfs: simplify cleanup via scoped_guard()
btrfs: simplify return path via cleanup.h
btrfs: simplify cleanup in btrfs_add_qgroup_relation

 fs/btrfs/block-group.c      |  24 ++----
 fs/btrfs/compression.c      |  13 ++-
 fs/btrfs/discard.c          |  20 ++---
 fs/btrfs/disk-io.c          |   9 +-
 fs/btrfs/extent-io-tree.c   |  72 ++++++----------
 fs/btrfs/extent-tree.c      | 104 ++++++++++-------------
 fs/btrfs/extent_io.c        |  33 ++++----
 fs/btrfs/file-item.c        |   6 +-
 fs/btrfs/free-space-cache.c |  87 +++++++------------
 fs/btrfs/fs.c               |   9 +-
 fs/btrfs/inode.c            |   3 +-
 fs/btrfs/ordered-data.c     |  67 ++++++---------
 fs/btrfs/qgroup.c           | 165 ++++++++++++++----------------------
 fs/btrfs/raid56.c           |  20 ++---
 fs/btrfs/scrub.c            |  19 ++---
 fs/btrfs/send.c             |  40 ++++-----
 fs/btrfs/space-info.c       |   4 +-
 fs/btrfs/subpage.c          |  41 +++------
 fs/btrfs/tree-log.c         |  28 +++---
 fs/btrfs/volumes.c          |   3 +-
 fs/btrfs/zoned.c            |  13 +--
 fs/btrfs/zstd.c             |  13 +--
 22 files changed, 299 insertions(+), 494 deletions(-)

base-commit: 24172e0d79900908cf5ebf366600616d29c9b417

Signature · 1 line
2.51.1.dirty