Skip to content

Commit

Permalink
f2fs: avoid extra ++ while returning from get_node_path
Browse files Browse the repository at this point in the history
In all the breaking conditions in get_node_path, 'n' is used to
track index in offset[] array, but while breaking out also, in all
paths n++ is done.
So, remove the ++ from breaking paths. Also, avoid
reset of 'level=0' in first case.

Signed-off-by: Namjae Jeon <[email protected]>
Signed-off-by: Amit Sahrawat <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>
  • Loading branch information
namjaejeon authored and Jaegeuk Kim committed Mar 18, 2013
1 parent 5a20d33 commit 25c0a6e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions fs/f2fs/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,23 +320,22 @@ static int get_node_path(long block, int offset[4], unsigned int noffset[4])
noffset[0] = 0;

if (block < direct_index) {
offset[n++] = block;
level = 0;
offset[n] = block;
goto got;
}
block -= direct_index;
if (block < direct_blks) {
offset[n++] = NODE_DIR1_BLOCK;
noffset[n] = 1;
offset[n++] = block;
offset[n] = block;
level = 1;
goto got;
}
block -= direct_blks;
if (block < direct_blks) {
offset[n++] = NODE_DIR2_BLOCK;
noffset[n] = 2;
offset[n++] = block;
offset[n] = block;
level = 1;
goto got;
}
Expand All @@ -346,7 +345,7 @@ static int get_node_path(long block, int offset[4], unsigned int noffset[4])
noffset[n] = 3;
offset[n++] = block / direct_blks;
noffset[n] = 4 + offset[n - 1];
offset[n++] = block % direct_blks;
offset[n] = block % direct_blks;
level = 2;
goto got;
}
Expand All @@ -356,7 +355,7 @@ static int get_node_path(long block, int offset[4], unsigned int noffset[4])
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;
offset[n] = block % direct_blks;
level = 2;
goto got;
}
Expand All @@ -371,7 +370,7 @@ static int get_node_path(long block, int offset[4], unsigned int noffset[4])
noffset[n] = 7 + (dptrs_per_blk * 2) +
offset[n - 2] * (dptrs_per_blk + 1) +
offset[n - 1];
offset[n++] = block % direct_blks;
offset[n] = block % direct_blks;
level = 3;
goto got;
} else {
Expand Down

0 comments on commit 25c0a6e

Please sign in to comment.