From: Chao Yu <yuchao0@huawei.com>
To: Yunlei He <heyunlei@huawei.com>,
jaegeuk@kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [PATCH v2] f2fs: rebuild get_node_path function
Date: Wed, 28 Mar 2018 09:41:26 +0800 [thread overview]
Message-ID: <be57d93a-93c3-4b13-58d1-ed348eb2bc28@huawei.com> (raw)
In-Reply-To: <1521689502-6040-1-git-send-email-heyunlei@huawei.com>
On 2018/3/22 11:31, Yunlei He wrote:
> This patch rebuild get_node_path function, no logic changes.
>
> v1->v2: '<' has higher priority than '-='
It looks that after the cleanup, the code logic would not be more understandable
than before, since we'd better to avoid doing calculation inside if condition.
Thanks,
>
> Signed-off-by: Yunlei He <heyunlei@huawei.com>
> ---
> fs/f2fs/node.c | 28 ++++++----------------------
> 1 file changed, 6 insertions(+), 22 deletions(-)
>
> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> index c511ef6..b8f2577 100644
> --- a/fs/f2fs/node.c
> +++ b/fs/f2fs/node.c
> @@ -526,46 +526,31 @@ static int get_node_path(struct inode *inode, long block,
>
> if (block < direct_index) {
> offset[n] = block;
> - goto got;
> - }
> - block -= direct_index;
> - if (block < direct_blks) {
> + } else if ((block -= direct_index) < direct_blks) {
> offset[n++] = NODE_DIR1_BLOCK;
> noffset[n] = 1;
> offset[n] = block;
> level = 1;
> - goto got;
> - }
> - block -= direct_blks;
> - if (block < direct_blks) {
> + } else if ((block -= direct_blks) < direct_blks) {
> offset[n++] = NODE_DIR2_BLOCK;
> noffset[n] = 2;
> offset[n] = block;
> level = 1;
> - goto got;
> - }
> - block -= direct_blks;
> - if (block < indirect_blks) {
> + } else if ((block -= direct_blks) < indirect_blks) {
> offset[n++] = NODE_IND1_BLOCK;
> noffset[n] = 3;
> offset[n++] = block / direct_blks;
> noffset[n] = 4 + offset[n - 1];
> offset[n] = block % direct_blks;
> level = 2;
> - goto got;
> - }
> - block -= indirect_blks;
> - if (block < indirect_blks) {
> + } else if ((block -= indirect_blks) < indirect_blks) {
> offset[n++] = NODE_IND2_BLOCK;
> noffset[n] = 4 + dptrs_per_blk;
> offset[n++] = block / direct_blks;
> noffset[n] = 5 + dptrs_per_blk + offset[n - 1];
> offset[n] = block % direct_blks;
> level = 2;
> - goto got;
> - }
> - block -= indirect_blks;
> - if (block < dindirect_blks) {
> + } else if ((block -= indirect_blks) < dindirect_blks) {
> offset[n++] = NODE_DIND_BLOCK;
> noffset[n] = 5 + (dptrs_per_blk * 2);
> offset[n++] = block / indirect_blks;
> @@ -577,11 +562,10 @@ static int get_node_path(struct inode *inode, long block,
> offset[n - 1];
> offset[n] = block % direct_blks;
> level = 3;
> - goto got;
> } else {
> return -E2BIG;
> }
> -got:
> +
> return level;
> }
>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
next prev parent reply other threads:[~2018-03-28 1:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-22 3:31 [PATCH v2] f2fs: rebuild get_node_path function Yunlei He
2018-03-28 1:41 ` Chao Yu [this message]
2018-03-28 1:46 ` heyunlei
2018-03-28 2:13 ` Chao Yu
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=be57d93a-93c3-4b13-58d1-ed348eb2bc28@huawei.com \
--to=yuchao0@huawei.com \
--cc=heyunlei@huawei.com \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
/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).