diff options
author | Gu Zheng <guz.fnst@cn.fujitsu.com> | 2013-07-15 05:57:38 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-07-30 02:17:02 -0400 |
commit | 4559071063270999d016c92a0b9241692cbbb522 (patch) | |
tree | 06e530ac8b0d5e80c4bd15011f019f666689279b /fs | |
parent | 963d4f7d7be6f9dba77362941921c33034fee91e (diff) |
f2fs: introduce help function F2FS_NODE()
Introduce help function F2FS_NODE() to simplify the conversion of node_page to
f2fs_node.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/f2fs/data.c | 2 | ||||
-rw-r--r-- | fs/f2fs/dir.c | 2 | ||||
-rw-r--r-- | fs/f2fs/f2fs.h | 9 | ||||
-rw-r--r-- | fs/f2fs/file.c | 2 | ||||
-rw-r--r-- | fs/f2fs/inode.c | 4 | ||||
-rw-r--r-- | fs/f2fs/node.c | 10 | ||||
-rw-r--r-- | fs/f2fs/node.h | 40 | ||||
-rw-r--r-- | fs/f2fs/recovery.c | 6 |
8 files changed, 35 insertions, 40 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 035f9a345cdf..c73c394c3d8c 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c | |||
@@ -39,7 +39,7 @@ static void __set_data_blkaddr(struct dnode_of_data *dn, block_t new_addr) | |||
39 | 39 | ||
40 | wait_on_page_writeback(node_page); | 40 | wait_on_page_writeback(node_page); |
41 | 41 | ||
42 | rn = (struct f2fs_node *)page_address(node_page); | 42 | rn = F2FS_NODE(node_page); |
43 | 43 | ||
44 | /* Get physical address of data block */ | 44 | /* Get physical address of data block */ |
45 | addr_array = blkaddr_in_node(rn); | 45 | addr_array = blkaddr_in_node(rn); |
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index 62f0d5977c64..89ecb3785321 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c | |||
@@ -270,7 +270,7 @@ static void init_dent_inode(const struct qstr *name, struct page *ipage) | |||
270 | struct f2fs_node *rn; | 270 | struct f2fs_node *rn; |
271 | 271 | ||
272 | /* copy name info. to this inode page */ | 272 | /* copy name info. to this inode page */ |
273 | rn = (struct f2fs_node *)page_address(ipage); | 273 | rn = F2FS_NODE(ipage); |
274 | rn->i.i_namelen = cpu_to_le32(name->len); | 274 | rn->i.i_namelen = cpu_to_le32(name->len); |
275 | memcpy(rn->i.i_name, name->name, name->len); | 275 | memcpy(rn->i.i_name, name->name, name->len); |
276 | set_page_dirty(ipage); | 276 | set_page_dirty(ipage); |
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 0a352b658ed8..2dfd584bf79f 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h | |||
@@ -455,6 +455,11 @@ static inline struct f2fs_checkpoint *F2FS_CKPT(struct f2fs_sb_info *sbi) | |||
455 | return (struct f2fs_checkpoint *)(sbi->ckpt); | 455 | return (struct f2fs_checkpoint *)(sbi->ckpt); |
456 | } | 456 | } |
457 | 457 | ||
458 | static inline struct f2fs_node *F2FS_NODE(struct page *page) | ||
459 | { | ||
460 | return (struct f2fs_node *)page_address(page); | ||
461 | } | ||
462 | |||
458 | static inline struct f2fs_nm_info *NM_I(struct f2fs_sb_info *sbi) | 463 | static inline struct f2fs_nm_info *NM_I(struct f2fs_sb_info *sbi) |
459 | { | 464 | { |
460 | return (struct f2fs_nm_info *)(sbi->nm_info); | 465 | return (struct f2fs_nm_info *)(sbi->nm_info); |
@@ -813,7 +818,7 @@ static inline struct kmem_cache *f2fs_kmem_cache_create(const char *name, | |||
813 | 818 | ||
814 | static inline bool IS_INODE(struct page *page) | 819 | static inline bool IS_INODE(struct page *page) |
815 | { | 820 | { |
816 | struct f2fs_node *p = (struct f2fs_node *)page_address(page); | 821 | struct f2fs_node *p = F2FS_NODE(page); |
817 | return RAW_IS_INODE(p); | 822 | return RAW_IS_INODE(p); |
818 | } | 823 | } |
819 | 824 | ||
@@ -827,7 +832,7 @@ static inline block_t datablock_addr(struct page *node_page, | |||
827 | { | 832 | { |
828 | struct f2fs_node *raw_node; | 833 | struct f2fs_node *raw_node; |
829 | __le32 *addr_array; | 834 | __le32 *addr_array; |
830 | raw_node = (struct f2fs_node *)page_address(node_page); | 835 | raw_node = F2FS_NODE(node_page); |
831 | addr_array = blkaddr_in_node(raw_node); | 836 | addr_array = blkaddr_in_node(raw_node); |
832 | return le32_to_cpu(addr_array[offset]); | 837 | return le32_to_cpu(addr_array[offset]); |
833 | } | 838 | } |
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 157a6357f14c..65ca3b3e5806 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c | |||
@@ -206,7 +206,7 @@ int truncate_data_blocks_range(struct dnode_of_data *dn, int count) | |||
206 | struct f2fs_node *raw_node; | 206 | struct f2fs_node *raw_node; |
207 | __le32 *addr; | 207 | __le32 *addr; |
208 | 208 | ||
209 | raw_node = page_address(dn->node_page); | 209 | raw_node = F2FS_NODE(dn->node_page); |
210 | addr = blkaddr_in_node(raw_node) + ofs; | 210 | addr = blkaddr_in_node(raw_node) + ofs; |
211 | 211 | ||
212 | for ( ; count > 0; count--, addr++, dn->ofs_in_node++) { | 212 | for ( ; count > 0; count--, addr++, dn->ofs_in_node++) { |
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index 2b2d45d19e3e..debf74308045 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c | |||
@@ -56,7 +56,7 @@ static int do_read_inode(struct inode *inode) | |||
56 | if (IS_ERR(node_page)) | 56 | if (IS_ERR(node_page)) |
57 | return PTR_ERR(node_page); | 57 | return PTR_ERR(node_page); |
58 | 58 | ||
59 | rn = page_address(node_page); | 59 | rn = F2FS_NODE(node_page); |
60 | ri = &(rn->i); | 60 | ri = &(rn->i); |
61 | 61 | ||
62 | inode->i_mode = le16_to_cpu(ri->i_mode); | 62 | inode->i_mode = le16_to_cpu(ri->i_mode); |
@@ -153,7 +153,7 @@ void update_inode(struct inode *inode, struct page *node_page) | |||
153 | 153 | ||
154 | wait_on_page_writeback(node_page); | 154 | wait_on_page_writeback(node_page); |
155 | 155 | ||
156 | rn = page_address(node_page); | 156 | rn = F2FS_NODE(node_page); |
157 | ri = &(rn->i); | 157 | ri = &(rn->i); |
158 | 158 | ||
159 | ri->i_mode = cpu_to_le16(inode->i_mode); | 159 | ri->i_mode = cpu_to_le16(inode->i_mode); |
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index b418aee09573..f5172e271d46 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c | |||
@@ -565,7 +565,7 @@ static int truncate_nodes(struct dnode_of_data *dn, unsigned int nofs, | |||
565 | return PTR_ERR(page); | 565 | return PTR_ERR(page); |
566 | } | 566 | } |
567 | 567 | ||
568 | rn = (struct f2fs_node *)page_address(page); | 568 | rn = F2FS_NODE(page); |
569 | if (depth < 3) { | 569 | if (depth < 3) { |
570 | for (i = ofs; i < NIDS_PER_BLOCK; i++, freed++) { | 570 | for (i = ofs; i < NIDS_PER_BLOCK; i++, freed++) { |
571 | child_nid = le32_to_cpu(rn->in.nid[i]); | 571 | child_nid = le32_to_cpu(rn->in.nid[i]); |
@@ -698,7 +698,7 @@ restart: | |||
698 | set_new_dnode(&dn, inode, page, NULL, 0); | 698 | set_new_dnode(&dn, inode, page, NULL, 0); |
699 | unlock_page(page); | 699 | unlock_page(page); |
700 | 700 | ||
701 | rn = page_address(page); | 701 | rn = F2FS_NODE(page); |
702 | switch (level) { | 702 | switch (level) { |
703 | case 0: | 703 | case 0: |
704 | case 1: | 704 | case 1: |
@@ -1484,8 +1484,8 @@ int recover_inode_page(struct f2fs_sb_info *sbi, struct page *page) | |||
1484 | SetPageUptodate(ipage); | 1484 | SetPageUptodate(ipage); |
1485 | fill_node_footer(ipage, ino, ino, 0, true); | 1485 | fill_node_footer(ipage, ino, ino, 0, true); |
1486 | 1486 | ||
1487 | src = (struct f2fs_node *)page_address(page); | 1487 | src = F2FS_NODE(page); |
1488 | dst = (struct f2fs_node *)page_address(ipage); | 1488 | dst = F2FS_NODE(ipage); |
1489 | 1489 | ||
1490 | memcpy(dst, src, (unsigned long)&src->i.i_ext - (unsigned long)&src->i); | 1490 | memcpy(dst, src, (unsigned long)&src->i.i_ext - (unsigned long)&src->i); |
1491 | dst->i.i_size = 0; | 1491 | dst->i.i_size = 0; |
@@ -1535,7 +1535,7 @@ int restore_node_summary(struct f2fs_sb_info *sbi, | |||
1535 | goto out; | 1535 | goto out; |
1536 | 1536 | ||
1537 | lock_page(page); | 1537 | lock_page(page); |
1538 | rn = (struct f2fs_node *)page_address(page); | 1538 | rn = F2FS_NODE(page); |
1539 | sum_entry->nid = rn->footer.nid; | 1539 | sum_entry->nid = rn->footer.nid; |
1540 | sum_entry->version = 0; | 1540 | sum_entry->version = 0; |
1541 | sum_entry->ofs_in_node = 0; | 1541 | sum_entry->ofs_in_node = 0; |
diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h index c65fb4f4230f..87349c4ea0ef 100644 --- a/fs/f2fs/node.h +++ b/fs/f2fs/node.h | |||
@@ -155,8 +155,7 @@ static inline void set_to_next_nat(struct f2fs_nm_info *nm_i, nid_t start_nid) | |||
155 | static inline void fill_node_footer(struct page *page, nid_t nid, | 155 | static inline void fill_node_footer(struct page *page, nid_t nid, |
156 | nid_t ino, unsigned int ofs, bool reset) | 156 | nid_t ino, unsigned int ofs, bool reset) |
157 | { | 157 | { |
158 | void *kaddr = page_address(page); | 158 | struct f2fs_node *rn = F2FS_NODE(page); |
159 | struct f2fs_node *rn = (struct f2fs_node *)kaddr; | ||
160 | if (reset) | 159 | if (reset) |
161 | memset(rn, 0, sizeof(*rn)); | 160 | memset(rn, 0, sizeof(*rn)); |
162 | rn->footer.nid = cpu_to_le32(nid); | 161 | rn->footer.nid = cpu_to_le32(nid); |
@@ -166,10 +165,8 @@ static inline void fill_node_footer(struct page *page, nid_t nid, | |||
166 | 165 | ||
167 | static inline void copy_node_footer(struct page *dst, struct page *src) | 166 | static inline void copy_node_footer(struct page *dst, struct page *src) |
168 | { | 167 | { |
169 | void *src_addr = page_address(src); | 168 | struct f2fs_node *src_rn = F2FS_NODE(src); |
170 | void *dst_addr = page_address(dst); | 169 | struct f2fs_node *dst_rn = F2FS_NODE(dst); |
171 | struct f2fs_node *src_rn = (struct f2fs_node *)src_addr; | ||
172 | struct f2fs_node *dst_rn = (struct f2fs_node *)dst_addr; | ||
173 | memcpy(&dst_rn->footer, &src_rn->footer, sizeof(struct node_footer)); | 170 | memcpy(&dst_rn->footer, &src_rn->footer, sizeof(struct node_footer)); |
174 | } | 171 | } |
175 | 172 | ||
@@ -177,45 +174,40 @@ static inline void fill_node_footer_blkaddr(struct page *page, block_t blkaddr) | |||
177 | { | 174 | { |
178 | struct f2fs_sb_info *sbi = F2FS_SB(page->mapping->host->i_sb); | 175 | struct f2fs_sb_info *sbi = F2FS_SB(page->mapping->host->i_sb); |
179 | struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); | 176 | struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); |
180 | void *kaddr = page_address(page); | 177 | struct f2fs_node *rn = F2FS_NODE(page); |
181 | struct f2fs_node *rn = (struct f2fs_node *)kaddr; | 178 | |
182 | rn->footer.cp_ver = ckpt->checkpoint_ver; | 179 | rn->footer.cp_ver = ckpt->checkpoint_ver; |
183 | rn->footer.next_blkaddr = cpu_to_le32(blkaddr); | 180 | rn->footer.next_blkaddr = cpu_to_le32(blkaddr); |
184 | } | 181 | } |
185 | 182 | ||
186 | static inline nid_t ino_of_node(struct page *node_page) | 183 | static inline nid_t ino_of_node(struct page *node_page) |
187 | { | 184 | { |
188 | void *kaddr = page_address(node_page); | 185 | struct f2fs_node *rn = F2FS_NODE(node_page); |
189 | struct f2fs_node *rn = (struct f2fs_node *)kaddr; | ||
190 | return le32_to_cpu(rn->footer.ino); | 186 | return le32_to_cpu(rn->footer.ino); |
191 | } | 187 | } |
192 | 188 | ||
193 | static inline nid_t nid_of_node(struct page *node_page) | 189 | static inline nid_t nid_of_node(struct page *node_page) |
194 | { | 190 | { |
195 | void *kaddr = page_address(node_page); | 191 | struct f2fs_node *rn = F2FS_NODE(node_page); |
196 | struct f2fs_node *rn = (struct f2fs_node *)kaddr; | ||
197 | return le32_to_cpu(rn->footer.nid); | 192 | return le32_to_cpu(rn->footer.nid); |
198 | } | 193 | } |
199 | 194 | ||
200 | static inline unsigned int ofs_of_node(struct page *node_page) | 195 | static inline unsigned int ofs_of_node(struct page *node_page) |
201 | { | 196 | { |
202 | void *kaddr = page_address(node_page); | 197 | struct f2fs_node *rn = F2FS_NODE(node_page); |
203 | struct f2fs_node *rn = (struct f2fs_node *)kaddr; | ||
204 | unsigned flag = le32_to_cpu(rn->footer.flag); | 198 | unsigned flag = le32_to_cpu(rn->footer.flag); |
205 | return flag >> OFFSET_BIT_SHIFT; | 199 | return flag >> OFFSET_BIT_SHIFT; |
206 | } | 200 | } |
207 | 201 | ||
208 | static inline unsigned long long cpver_of_node(struct page *node_page) | 202 | static inline unsigned long long cpver_of_node(struct page *node_page) |
209 | { | 203 | { |
210 | void *kaddr = page_address(node_page); | 204 | struct f2fs_node *rn = F2FS_NODE(node_page); |
211 | struct f2fs_node *rn = (struct f2fs_node *)kaddr; | ||
212 | return le64_to_cpu(rn->footer.cp_ver); | 205 | return le64_to_cpu(rn->footer.cp_ver); |
213 | } | 206 | } |
214 | 207 | ||
215 | static inline block_t next_blkaddr_of_node(struct page *node_page) | 208 | static inline block_t next_blkaddr_of_node(struct page *node_page) |
216 | { | 209 | { |
217 | void *kaddr = page_address(node_page); | 210 | struct f2fs_node *rn = F2FS_NODE(node_page); |
218 | struct f2fs_node *rn = (struct f2fs_node *)kaddr; | ||
219 | return le32_to_cpu(rn->footer.next_blkaddr); | 211 | return le32_to_cpu(rn->footer.next_blkaddr); |
220 | } | 212 | } |
221 | 213 | ||
@@ -250,7 +242,7 @@ static inline bool IS_DNODE(struct page *node_page) | |||
250 | 242 | ||
251 | static inline void set_nid(struct page *p, int off, nid_t nid, bool i) | 243 | static inline void set_nid(struct page *p, int off, nid_t nid, bool i) |
252 | { | 244 | { |
253 | struct f2fs_node *rn = (struct f2fs_node *)page_address(p); | 245 | struct f2fs_node *rn = F2FS_NODE(p); |
254 | 246 | ||
255 | wait_on_page_writeback(p); | 247 | wait_on_page_writeback(p); |
256 | 248 | ||
@@ -263,7 +255,8 @@ static inline void set_nid(struct page *p, int off, nid_t nid, bool i) | |||
263 | 255 | ||
264 | static inline nid_t get_nid(struct page *p, int off, bool i) | 256 | static inline nid_t get_nid(struct page *p, int off, bool i) |
265 | { | 257 | { |
266 | struct f2fs_node *rn = (struct f2fs_node *)page_address(p); | 258 | struct f2fs_node *rn = F2FS_NODE(p); |
259 | |||
267 | if (i) | 260 | if (i) |
268 | return le32_to_cpu(rn->i.i_nid[off - NODE_DIR1_BLOCK]); | 261 | return le32_to_cpu(rn->i.i_nid[off - NODE_DIR1_BLOCK]); |
269 | return le32_to_cpu(rn->in.nid[off]); | 262 | return le32_to_cpu(rn->in.nid[off]); |
@@ -314,8 +307,7 @@ static inline void clear_cold_data(struct page *page) | |||
314 | 307 | ||
315 | static inline int is_node(struct page *page, int type) | 308 | static inline int is_node(struct page *page, int type) |
316 | { | 309 | { |
317 | void *kaddr = page_address(page); | 310 | struct f2fs_node *rn = F2FS_NODE(page); |
318 | struct f2fs_node *rn = (struct f2fs_node *)kaddr; | ||
319 | return le32_to_cpu(rn->footer.flag) & (1 << type); | 311 | return le32_to_cpu(rn->footer.flag) & (1 << type); |
320 | } | 312 | } |
321 | 313 | ||
@@ -325,7 +317,7 @@ static inline int is_node(struct page *page, int type) | |||
325 | 317 | ||
326 | static inline void set_cold_node(struct inode *inode, struct page *page) | 318 | static inline void set_cold_node(struct inode *inode, struct page *page) |
327 | { | 319 | { |
328 | struct f2fs_node *rn = (struct f2fs_node *)page_address(page); | 320 | struct f2fs_node *rn = F2FS_NODE(page); |
329 | unsigned int flag = le32_to_cpu(rn->footer.flag); | 321 | unsigned int flag = le32_to_cpu(rn->footer.flag); |
330 | 322 | ||
331 | if (S_ISDIR(inode->i_mode)) | 323 | if (S_ISDIR(inode->i_mode)) |
@@ -337,7 +329,7 @@ static inline void set_cold_node(struct inode *inode, struct page *page) | |||
337 | 329 | ||
338 | static inline void set_mark(struct page *page, int mark, int type) | 330 | static inline void set_mark(struct page *page, int mark, int type) |
339 | { | 331 | { |
340 | struct f2fs_node *rn = (struct f2fs_node *)page_address(page); | 332 | struct f2fs_node *rn = F2FS_NODE(page); |
341 | unsigned int flag = le32_to_cpu(rn->footer.flag); | 333 | unsigned int flag = le32_to_cpu(rn->footer.flag); |
342 | if (mark) | 334 | if (mark) |
343 | flag |= (0x1 << type); | 335 | flag |= (0x1 << type); |
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c index d56d951c2253..639eb3465286 100644 --- a/fs/f2fs/recovery.c +++ b/fs/f2fs/recovery.c | |||
@@ -40,8 +40,7 @@ static struct fsync_inode_entry *get_fsync_inode(struct list_head *head, | |||
40 | 40 | ||
41 | static int recover_dentry(struct page *ipage, struct inode *inode) | 41 | static int recover_dentry(struct page *ipage, struct inode *inode) |
42 | { | 42 | { |
43 | void *kaddr = page_address(ipage); | 43 | struct f2fs_node *raw_node = F2FS_NODE(ipage); |
44 | struct f2fs_node *raw_node = (struct f2fs_node *)kaddr; | ||
45 | struct f2fs_inode *raw_inode = &(raw_node->i); | 44 | struct f2fs_inode *raw_inode = &(raw_node->i); |
46 | nid_t pino = le32_to_cpu(raw_inode->i_pino); | 45 | nid_t pino = le32_to_cpu(raw_inode->i_pino); |
47 | struct f2fs_dir_entry *de; | 46 | struct f2fs_dir_entry *de; |
@@ -93,8 +92,7 @@ out: | |||
93 | 92 | ||
94 | static int recover_inode(struct inode *inode, struct page *node_page) | 93 | static int recover_inode(struct inode *inode, struct page *node_page) |
95 | { | 94 | { |
96 | void *kaddr = page_address(node_page); | 95 | struct f2fs_node *raw_node = F2FS_NODE(node_page); |
97 | struct f2fs_node *raw_node = (struct f2fs_node *)kaddr; | ||
98 | struct f2fs_inode *raw_inode = &(raw_node->i); | 96 | struct f2fs_inode *raw_inode = &(raw_node->i); |
99 | 97 | ||
100 | if (!IS_INODE(node_page)) | 98 | if (!IS_INODE(node_page)) |