aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChao Yu <chao2.yu@samsung.com>2014-04-26 07:59:52 -0400
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2014-05-06 21:21:56 -0400
commit6403eb1f646a49cc92f25c08f8716f8870a4a865 (patch)
tree31bb16630a67a086d0ff271cea88b9c9bc3e301b
parent2aea39eca6b68d6ae7eb545332df0695f56a3d3f (diff)
f2fs: introduce help macro ADDRS_PER_PAGE()
Introduce help macro ADDRS_PER_PAGE() to get the number of address pointers in direct node or inode. Signed-off-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
-rw-r--r--fs/f2fs/data.c6
-rw-r--r--fs/f2fs/file.c5
-rw-r--r--fs/f2fs/recovery.c5
-rw-r--r--include/linux/f2fs_fs.h3
4 files changed, 7 insertions, 12 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 0147de7e3973..273fe1631af9 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -652,8 +652,7 @@ static int get_data_block(struct inode *inode, sector_t iblock,
652 goto put_out; 652 goto put_out;
653 } 653 }
654 654
655 end_offset = IS_INODE(dn.node_page) ? 655 end_offset = ADDRS_PER_PAGE(dn.node_page, F2FS_I(inode));
656 ADDRS_PER_INODE(F2FS_I(inode)) : ADDRS_PER_BLOCK;
657 bh_result->b_size = (((size_t)1) << blkbits); 656 bh_result->b_size = (((size_t)1) << blkbits);
658 dn.ofs_in_node++; 657 dn.ofs_in_node++;
659 pgofs++; 658 pgofs++;
@@ -675,8 +674,7 @@ get_next:
675 if (dn.data_blkaddr == NEW_ADDR) 674 if (dn.data_blkaddr == NEW_ADDR)
676 goto put_out; 675 goto put_out;
677 676
678 end_offset = IS_INODE(dn.node_page) ? 677 end_offset = ADDRS_PER_PAGE(dn.node_page, F2FS_I(inode));
679 ADDRS_PER_INODE(F2FS_I(inode)) : ADDRS_PER_BLOCK;
680 } 678 }
681 679
682 if (maxblocks > (bh_result->b_size >> blkbits)) { 680 if (maxblocks > (bh_result->b_size >> blkbits)) {
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 60e7d5448a1d..bb365c932555 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -288,10 +288,7 @@ int truncate_blocks(struct inode *inode, u64 from)
288 return err; 288 return err;
289 } 289 }
290 290
291 if (IS_INODE(dn.node_page)) 291 count = ADDRS_PER_PAGE(dn.node_page, F2FS_I(inode));
292 count = ADDRS_PER_INODE(F2FS_I(inode));
293 else
294 count = ADDRS_PER_BLOCK;
295 292
296 count -= dn.ofs_in_node; 293 count -= dn.ofs_in_node;
297 f2fs_bug_on(count < 0); 294 f2fs_bug_on(count < 0);
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index 9eb6487f383d..be1e3e881725 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -301,10 +301,7 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,
301 goto out; 301 goto out;
302 302
303 start = start_bidx_of_node(ofs_of_node(page), fi); 303 start = start_bidx_of_node(ofs_of_node(page), fi);
304 if (IS_INODE(page)) 304 end = start + ADDRS_PER_PAGE(page, fi);
305 end = start + ADDRS_PER_INODE(fi);
306 else
307 end = start + ADDRS_PER_BLOCK;
308 305
309 f2fs_lock_op(sbi); 306 f2fs_lock_op(sbi);
310 307
diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h
index df53e1753a76..8c03f71307c6 100644
--- a/include/linux/f2fs_fs.h
+++ b/include/linux/f2fs_fs.h
@@ -146,6 +146,9 @@ struct f2fs_extent {
146#define ADDRS_PER_BLOCK 1018 /* Address Pointers in a Direct Block */ 146#define ADDRS_PER_BLOCK 1018 /* Address Pointers in a Direct Block */
147#define NIDS_PER_BLOCK 1018 /* Node IDs in an Indirect Block */ 147#define NIDS_PER_BLOCK 1018 /* Node IDs in an Indirect Block */
148 148
149#define ADDRS_PER_PAGE(page, fi) \
150 (IS_INODE(page) ? ADDRS_PER_INODE(fi) : ADDRS_PER_BLOCK)
151
149#define NODE_DIR1_BLOCK (DEF_ADDRS_PER_INODE + 1) 152#define NODE_DIR1_BLOCK (DEF_ADDRS_PER_INODE + 1)
150#define NODE_DIR2_BLOCK (DEF_ADDRS_PER_INODE + 2) 153#define NODE_DIR2_BLOCK (DEF_ADDRS_PER_INODE + 2)
151#define NODE_IND1_BLOCK (DEF_ADDRS_PER_INODE + 3) 154#define NODE_IND1_BLOCK (DEF_ADDRS_PER_INODE + 3)