linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH RFC] btrfs: extent-tree: refactor find_free_extent()
Date: Mon, 20 Aug 2018 16:17:05 +0200	[thread overview]
Message-ID: <20180820141704.GZ24025@twin.jikos.cz> (raw)
In-Reply-To: <20180725081242.8327-1-wqu@suse.com>

On Wed, Jul 25, 2018 at 04:12:42PM +0800, Qu Wenruo wrote:
> extent-tree.c::find_free_extent() could be one of the most
> ill-structured function, it has at least 4 non-exit tags and jumps
> between them.
> 
> To make it a little easier to understand, extract that big functions
> into 4 parts:
> 
> 1) find_free_extent()
>    Do the block group iterations, still the main function.
> 
> 2) find_free_extent_clustered()
>    Do the clustered allocation and cluster refill if needed.
> 
> 3) find_free_extent_unclustered()
>    Do the unclustered allocation and free space cache update if needed.
> 
> 4) find_free_extent_update_loop()
>    Do the corner-case black magic handling, like allocating new chunk
>    and update loop condition.
> 
> Also, for internal communication, created a new internal structure
> find_free_extent_ctrl, to make the parameter list shorter for function
> 2~4.
> 
> Please note that this patch will try to avoid any functional/logical
> modification during the refactor, so still a lot of bad practice like in
> find_free_extent() we still use search/have_block_group/loop tags to
> implement a custom loop.
> 
> But at least, this should provide the basis for later cleanup.

I'd prefer to do the cleanup in smaller pieces, this patch is too big
for review.

> ---
> I know such large patch is not a good practice, and there is choice to
> split the patch into 4 patches (one patch for each helper function), but
> that will make later rebase more error prone since new function will never
> conflict with newer changes.

Small patches can be refreshed and updated easily, also each refresh
reviewed that the change is still correct.

The big blob patches are the worst thing one can find in git history,
hunting a clustered allocation bug and ending up in a cleanup patch. No
amount of written assurance or "it worked on my machine" can change
that.

Finding the right way to split the patch and isolate nice and reviewable
changes requires more thinking which is not a bad thing on itself.

I know everybody hates that because it's more work for them, but
consider the work on both sides.

  reply	other threads:[~2018-08-20 17:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-25  8:12 [PATCH RFC] btrfs: extent-tree: refactor find_free_extent() Qu Wenruo
2018-08-20 14:17 ` David Sterba [this message]
2018-08-20 14:22   ` Qu Wenruo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180820141704.GZ24025@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).