free(node_blk);
}
+unsigned int start_bidx_of_node(unsigned int node_ofs,
+ struct f2fs_node *node_blk)
+{
+ unsigned int indirect_blks = 2 * NIDS_PER_BLOCK + 4;
+ unsigned int bidx;
+
+ if (node_ofs == 0)
+ return 0;
+
+ if (node_ofs <= 2) {
+ bidx = node_ofs - 1;
+ } else if (node_ofs <= indirect_blks) {
+ int dec = (node_ofs - 4) / (NIDS_PER_BLOCK + 1);
+ bidx = node_ofs - 2 - dec;
+ } else {
+ int dec = (node_ofs - indirect_blks - 3) / (NIDS_PER_BLOCK + 1);
+ bidx = node_ofs - 5 - dec;
+ }
+ return bidx * ADDRS_PER_BLOCK + ADDRS_PER_INODE(&node_blk->i);
+}
+
static void dump_data_offset(u32 blk_addr, int ofs_in_node)
{
struct f2fs_node *node_blk;
- unsigned int indirect_blks = 2 * NIDS_PER_BLOCK + 4;
- unsigned int bidx = 0;
+ unsigned int bidx;
unsigned int node_ofs;
int ret;
node_ofs = ofs_of_node(node_blk);
- if (node_ofs == 0)
- goto got_it;
-
- if (node_ofs > 0 && node_ofs <= 2) {
- bidx = node_ofs - 1;
- } else if (node_ofs <= indirect_blks) {
- int dec = (node_ofs - 4) / (NIDS_PER_BLOCK + 1);
- bidx = node_ofs - 2 - dec;
- } else {
- int dec = (node_ofs - indirect_blks - 3) / (NIDS_PER_BLOCK + 1);
- bidx = node_ofs - 5 - dec;
- }
- bidx = bidx * ADDRS_PER_BLOCK + ADDRS_PER_INODE(&node_blk->i);
-got_it:
+ bidx = start_bidx_of_node(node_ofs, node_blk);
bidx += ofs_in_node;
setlocale(LC_ALL, "");