From: Theodore Ts'o <tytso@mit.edu>
To: Dmitry Monakhov <dmonakhov@openvz.org>
Cc: linux-ext4@vger.kernel.org
Subject: Re: [PATCH] ext4: refactor ext4_move_extents code base v2
Date: Tue, 29 Jul 2014 10:25:56 -0400 [thread overview]
Message-ID: <20140729142556.GB2256@thunk.org> (raw)
In-Reply-To: <1406062822-2883-1-git-send-email-dmonakhov@openvz.org>
On Wed, Jul 23, 2014 at 01:00:22AM +0400, Dmitry Monakhov wrote:
> ext4_move_extents is too complex for review. It has duplicate almost each funciton
> available in the rest of other codebase. It has useless artifical restriction
> orig_offset == donor_offset. But in fact logic of ext4_move_extents
> is very simple:
Thanks for working to clean this up. ext4_move_extents() is a
complicated hot mess.
> +
> +int
> +ext4_swap_extents(handle_t *handle, struct inode *o_inode,
> + struct inode *d_inode, ext4_lblk_t o_off, ext4_lblk_t d_off,
> + ext4_lblk_t count, int *erp)
> +{
> + struct ext4_ext_path *o_path = NULL;
> + struct ext4_ext_path *d_path = NULL;
> + int replaced_count = 0;
We should document when the locking requirements are for
ext4_swap_extents. Better yet, there should an assertion here so we
BUG if the appropriate locks (i_data_sem, i_mutex, etc.) aren't taken.
Why are you using the parameter names o_off and d_off? "off" can make
someone think of byte offsets (which is where my mind went at first).
Maybe o_lblk and d_lblk instead?
> + /* ext4_split_extent_at() may retult in leaf extent split,
> + * path must to be revalidated. */
> + if (split)
> + goto repeat;
^^^
Whitespace?
> + /* If extents has different length we have to update i_blocks */
Why would the extents ever have different lengths? Should this
(already) be disallowed above?
> + repeat:
> + if (o_path) {
> + ext4_ext_drop_refs(o_path);
> + kfree(o_path);
> + o_path = NULL;
> + }
> + if (d_path) {
> + ext4_ext_drop_refs(d_path);
> + kfree(d_path);
> + d_path = NULL;
> + }
> + o_off += len;
> + d_off += len;
> + replaced_count += len;
> + count -= len;
> + }
Why not swap things so this reads:
o_off += len;
d_off += len;
replaced_count += len;
count -= len;
repeat:
if (o_path) {
ext4_ext_drop_refs(o_path);
kfree(o_path);
o_path = NULL;
}
if (d_path) {
ext4_ext_drop_refs(d_path);
kfree(d_path);
d_path = NULL;
}
}
This way we don't have to rely on len == 0, and in one of the places
where the code currently reads "{ len = 0; goto repeat; }", the len=0;
assignment can be dropped.
Cheers,
- Ted
prev parent reply other threads:[~2014-07-29 14:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-22 21:00 [PATCH] ext4: refactor ext4_move_extents code base v2 Dmitry Monakhov
2014-07-29 14:25 ` Theodore Ts'o [this message]
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=20140729142556.GB2256@thunk.org \
--to=tytso@mit.edu \
--cc=dmonakhov@openvz.org \
--cc=linux-ext4@vger.kernel.org \
/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).