On 2018/3/28 9:46, heyunlei wrote: > > >> -----Original Message----- >> From: Yuchao (T) >> Sent: Wednesday, March 28, 2018 9:41 AM >> To: heyunlei; jaeg...@kernel.org; linux-f2fs-devel@lists.sourceforge.net >> Cc: Wangbintian >> Subject: Re: [f2fs-dev][PATCH v2] f2fs: rebuild get_node_path function >> >> 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. >> > > Here I just refer to code in function ext2_block_to_path
Got it, for better readability, let's just keep current code style. Thanks, > > Thanks, > >> Thanks, >> >>> >>> Signed-off-by: Yunlei He <heyun...@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 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel