node.h (e19b9137142988bec5a76c5f8bdf12a77ea802b0) node.h (cdfc41c134d48c1923066bcfa6630b94588ad6bc)
1/*
2 * fs/f2fs/node.h
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11/* start node id of a node block dedicated to the given node id */
12#define START_NID(nid) ((nid / NAT_ENTRY_PER_BLOCK) * NAT_ENTRY_PER_BLOCK)
13
14/* node block offset on the NAT area dedicated to the given start node id */
15#define NAT_BLOCK_OFFSET(start_nid) (start_nid / NAT_ENTRY_PER_BLOCK)
16
17/* # of pages to perform readahead before building free nids */
18#define FREE_NID_PAGES 4
19
1/*
2 * fs/f2fs/node.h
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11/* start node id of a node block dedicated to the given node id */
12#define START_NID(nid) ((nid / NAT_ENTRY_PER_BLOCK) * NAT_ENTRY_PER_BLOCK)
13
14/* node block offset on the NAT area dedicated to the given start node id */
15#define NAT_BLOCK_OFFSET(start_nid) (start_nid / NAT_ENTRY_PER_BLOCK)
16
17/* # of pages to perform readahead before building free nids */
18#define FREE_NID_PAGES 4
19
20/* maximum # of free node ids to produce during build_free_nids */
21#define MAX_FREE_NIDS (NAT_ENTRY_PER_BLOCK * FREE_NID_PAGES)
22
23/* maximum readahead size for node during getting data blocks */
24#define MAX_RA_NODE 128
25
26/* maximum cached nat entries to manage memory footprint */
27#define NM_WOUT_THRESHOLD (64 * NAT_ENTRY_PER_BLOCK)
28
20/* maximum readahead size for node during getting data blocks */
21#define MAX_RA_NODE 128
22
23/* maximum cached nat entries to manage memory footprint */
24#define NM_WOUT_THRESHOLD (64 * NAT_ENTRY_PER_BLOCK)
25
26/* control the memory footprint threshold (10MB per 1GB ram) */
27#define DEF_RAM_THRESHOLD 10
28
29/* vector size for gang look-up from nat cache that consists of radix tree */
30#define NATVEC_SIZE 64
31
32/* return value for read_node_page */
33#define LOCKED_PAGE 1
34
35/*
36 * For node information

--- 16 unchanged lines hidden (view full) ---

53#define nat_get_blkaddr(nat) (nat->ni.blk_addr)
54#define nat_set_blkaddr(nat, b) (nat->ni.blk_addr = b)
55#define nat_get_ino(nat) (nat->ni.ino)
56#define nat_set_ino(nat, i) (nat->ni.ino = i)
57#define nat_get_version(nat) (nat->ni.version)
58#define nat_set_version(nat, v) (nat->ni.version = v)
59
60#define __set_nat_cache_dirty(nm_i, ne) \
29/* vector size for gang look-up from nat cache that consists of radix tree */
30#define NATVEC_SIZE 64
31
32/* return value for read_node_page */
33#define LOCKED_PAGE 1
34
35/*
36 * For node information

--- 16 unchanged lines hidden (view full) ---

53#define nat_get_blkaddr(nat) (nat->ni.blk_addr)
54#define nat_set_blkaddr(nat, b) (nat->ni.blk_addr = b)
55#define nat_get_ino(nat) (nat->ni.ino)
56#define nat_set_ino(nat, i) (nat->ni.ino = i)
57#define nat_get_version(nat) (nat->ni.version)
58#define nat_set_version(nat, v) (nat->ni.version = v)
59
60#define __set_nat_cache_dirty(nm_i, ne) \
61 list_move_tail(&ne->list, &nm_i->dirty_nat_entries);
61 do { \
62 ne->checkpointed = false; \
63 list_move_tail(&ne->list, &nm_i->dirty_nat_entries); \
64 } while (0);
62#define __clear_nat_cache_dirty(nm_i, ne) \
65#define __clear_nat_cache_dirty(nm_i, ne) \
63 list_move_tail(&ne->list, &nm_i->nat_entries);
66 do { \
67 ne->checkpointed = true; \
68 list_move_tail(&ne->list, &nm_i->nat_entries); \
69 } while (0);
64#define inc_node_version(version) (++version)
65
66static inline void node_info_from_raw_nat(struct node_info *ni,
67 struct f2fs_nat_entry *raw_ne)
68{
69 ni->ino = le32_to_cpu(raw_ne->ino);
70 ni->blk_addr = le32_to_cpu(raw_ne->block_addr);
71 ni->version = raw_ne->version;
72}
73
70#define inc_node_version(version) (++version)
71
72static inline void node_info_from_raw_nat(struct node_info *ni,
73 struct f2fs_nat_entry *raw_ne)
74{
75 ni->ino = le32_to_cpu(raw_ne->ino);
76 ni->blk_addr = le32_to_cpu(raw_ne->block_addr);
77 ni->version = raw_ne->version;
78}
79
80enum nid_type {
81 FREE_NIDS, /* indicates the free nid list */
82 NAT_ENTRIES /* indicates the cached nat entry */
83};
84
74/*
75 * For free nid mangement
76 */
77enum nid_state {
78 NID_NEW, /* newly added to free nid list */
79 NID_ALLOC /* it is allocated */
80};
81

--- 149 unchanged lines hidden (view full) ---

231 * ......
232 * `- indirect node ((6 + 2N) + (N - 1)(N + 1))
233 * `- direct node
234 */
235static inline bool IS_DNODE(struct page *node_page)
236{
237 unsigned int ofs = ofs_of_node(node_page);
238
85/*
86 * For free nid mangement
87 */
88enum nid_state {
89 NID_NEW, /* newly added to free nid list */
90 NID_ALLOC /* it is allocated */
91};
92

--- 149 unchanged lines hidden (view full) ---

242 * ......
243 * `- indirect node ((6 + 2N) + (N - 1)(N + 1))
244 * `- direct node
245 */
246static inline bool IS_DNODE(struct page *node_page)
247{
248 unsigned int ofs = ofs_of_node(node_page);
249
239 if (ofs == XATTR_NODE_OFFSET)
250 if (f2fs_has_xattr_block(ofs))
240 return false;
241
242 if (ofs == 3 || ofs == 4 + NIDS_PER_BLOCK ||
243 ofs == 5 + 2 * NIDS_PER_BLOCK)
244 return false;
245 if (ofs >= 6 + 2 * NIDS_PER_BLOCK) {
246 ofs -= 6 + 2 * NIDS_PER_BLOCK;
247 if (!((long int)ofs % (NIDS_PER_BLOCK + 1)))

--- 104 unchanged lines hidden ---
251 return false;
252
253 if (ofs == 3 || ofs == 4 + NIDS_PER_BLOCK ||
254 ofs == 5 + 2 * NIDS_PER_BLOCK)
255 return false;
256 if (ofs >= 6 + 2 * NIDS_PER_BLOCK) {
257 ofs -= 6 + 2 * NIDS_PER_BLOCK;
258 if (!((long int)ofs % (NIDS_PER_BLOCK + 1)))

--- 104 unchanged lines hidden ---