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 <[email protected]> > --- > 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 [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
