diff options
Diffstat (limited to 'fs/f2fs/node.h')
| -rw-r--r-- | fs/f2fs/node.h | 44 | 
1 files changed, 34 insertions, 10 deletions
diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h index 3496bb3e15d..7281112cd1c 100644 --- a/fs/f2fs/node.h +++ b/fs/f2fs/node.h @@ -17,14 +17,11 @@  /* # of pages to perform readahead before building free nids */  #define FREE_NID_PAGES 4 -/* maximum # of free node ids to produce during build_free_nids */ -#define MAX_FREE_NIDS (NAT_ENTRY_PER_BLOCK * FREE_NID_PAGES) -  /* maximum readahead size for node during getting data blocks */  #define MAX_RA_NODE		128 -/* maximum cached nat entries to manage memory footprint */ -#define NM_WOUT_THRESHOLD	(64 * NAT_ENTRY_PER_BLOCK) +/* control the memory footprint threshold (10MB per 1GB ram) */ +#define DEF_RAM_THRESHOLD	10  /* vector size for gang look-up from nat cache that consists of radix tree */  #define NATVEC_SIZE	64 @@ -45,6 +42,7 @@ struct node_info {  struct nat_entry {  	struct list_head list;	/* for clean or dirty nat list */  	bool checkpointed;	/* whether it is checkpointed or not */ +	bool fsync_done;	/* whether the latest node has fsync mark */  	struct node_info ni;	/* in-memory node information */  }; @@ -58,9 +56,15 @@ struct nat_entry {  #define nat_set_version(nat, v)		(nat->ni.version = v)  #define __set_nat_cache_dirty(nm_i, ne)					\ -	list_move_tail(&ne->list, &nm_i->dirty_nat_entries); +	do {								\ +		ne->checkpointed = false;				\ +		list_move_tail(&ne->list, &nm_i->dirty_nat_entries);	\ +	} while (0)  #define __clear_nat_cache_dirty(nm_i, ne)				\ -	list_move_tail(&ne->list, &nm_i->nat_entries); +	do {								\ +		ne->checkpointed = true;				\ +		list_move_tail(&ne->list, &nm_i->nat_entries);		\ +	} while (0)  #define inc_node_version(version)	(++version)  static inline void node_info_from_raw_nat(struct node_info *ni, @@ -71,6 +75,20 @@ static inline void node_info_from_raw_nat(struct node_info *ni,  	ni->version = raw_ne->version;  } +static inline void raw_nat_from_node_info(struct f2fs_nat_entry *raw_ne, +						struct node_info *ni) +{ +	raw_ne->ino = cpu_to_le32(ni->ino); +	raw_ne->block_addr = cpu_to_le32(ni->blk_addr); +	raw_ne->version = ni->version; +} + +enum mem_type { +	FREE_NIDS,	/* indicates the free nid list */ +	NAT_ENTRIES,	/* indicates the cached nat entry */ +	DIRTY_DENTS	/* indicates dirty dentry pages */ +}; +  /*   * For free nid mangement   */ @@ -224,13 +242,19 @@ static inline block_t next_blkaddr_of_node(struct page *node_page)   *    |            `- direct node (5 + N => 5 + 2N - 1)   *    `- double indirect node (5 + 2N)   *                 `- indirect node (6 + 2N) - *                       `- direct node (x(N + 1)) + *                       `- direct node + *                 ...... + *                 `- indirect node ((6 + 2N) + x(N + 1)) + *                       `- direct node + *                 ...... + *                 `- indirect node ((6 + 2N) + (N - 1)(N + 1)) + *                       `- direct node   */  static inline bool IS_DNODE(struct page *node_page)  {  	unsigned int ofs = ofs_of_node(node_page); -	if (ofs == XATTR_NODE_OFFSET) +	if (f2fs_has_xattr_block(ofs))  		return false;  	if (ofs == 3 || ofs == 4 + NIDS_PER_BLOCK || @@ -248,7 +272,7 @@ static inline void set_nid(struct page *p, int off, nid_t nid, bool i)  {  	struct f2fs_node *rn = F2FS_NODE(p); -	wait_on_page_writeback(p); +	f2fs_wait_on_page_writeback(p, NODE);  	if (i)  		rn->i.i_nid[off - NODE_DIR1_BLOCK] = cpu_to_le32(nid);  | 
