Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757089AbbBEJx5 (ORCPT ); Thu, 5 Feb 2015 04:53:57 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:36123 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750823AbbBEJxz (ORCPT ); Thu, 5 Feb 2015 04:53:55 -0500 X-AuditID: cbfee61b-f79d76d0000024d6-55-54d33da7a3c3 From: Chao Yu To: Jaegeuk Kim , Changman Lee Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH v3 05/10] f2fs: introduce infra macro and data structure of rb-tree extent cache Date: Thu, 05 Feb 2015 17:52:58 +0800 Message-id: <000201d04129$9fcf9370$df6eba50$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: AdA/j6sp2VRDF8f1QRGvOpSJC31M7g== Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrILMWRmVeSWpSXmKPExsVy+t9jQd3ltpdDDK491LK4tq+RyeLJ+lnM FpcWuVtc3jWHzYHFY9OqTjaP3Qs+M3n0bVnF6PF5k1wASxSXTUpqTmZZapG+XQJXxpOpD1gL nktVNPbHNDDuFe1i5OSQEDCRONXYyw5hi0lcuLeerYuRi0NIYDqjxJTrJ5kgnB+MEvtaV7CA VLEJqEgs7/jPBGKLCHhJTNp/AizOLOAh0djxnbWLkYNDWCBJYveaGJAwi4CqxOvDXWDlvAKW Ev9uLGeEsAUlfky+B9WqJbF+53EmCFteYvOat8wQBylI7Dj7mhFilZ7Eq7bLzBA14hIbj9xi mcAoMAvJqFlIRs1CMmoWkpYFjCyrGEVTC5ILipPSc430ihNzi0vz0vWS83M3MYID+pn0DsZV DRaHGAU4GJV4eC32XQoRYk0sK67MPcQowcGsJMKryXE5RIg3JbGyKrUoP76oNCe1+BCjNAeL kjivkn1biJBAemJJanZqakFqEUyWiYNTqoGRU8d3+4KgLWsDgpZdeeTB4/w95gbLfumICv5S jwd/T654cftuc7f32nn8sxy2s/7i8TFgWnyw5Oqupg8vN0x6p/K904xDaXrqj/sVJVkCoYs4 1oduPn1bS3fxquy1zTxbRANWHQg+Ne/enTrRTp7Hju5K+cu+nyl/4xVavfqP+k8LtW3KAXvb lFiKMxINtZiLihMB5JBqA2QCAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3582 Lines: 99 Introduce infra macro and data structure for rb-tree based extent cache: Macros: * EXT_TREE_VEC_SIZE: indicate vector size for gang lookup in extent tree. * F2FS_MIN_EXTENT_LEN: indicate minimum length of extent managed in cache. * EXTENT_CACHE_SHRINK_NUMBER: indicate number of extent in cache will be shrunk. Basic data structures for extent cache: * struct extent_tree: extent tree entry per inode. * struct extent_node: extent info node linked in extent tree. Besides, adding new extent cache related fields in f2fs_sb_info. Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Changman Lee --- fs/f2fs/f2fs.h | 36 ++++++++++++++++++++++++++++++++---- fs/f2fs/node.h | 1 + 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 78bd6d4..7c6c192 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -271,13 +271,33 @@ enum { #define MAX_DIR_RA_PAGES 4 /* maximum ra pages of dir */ +/* vector size for gang look-up from extent cache that consists of radix tree */ +#define EXT_TREE_VEC_SIZE 64 + /* for in-memory extent cache entry */ -#define F2FS_MIN_EXTENT_LEN 16 /* minimum extent length */ +#define F2FS_MIN_EXTENT_LEN 64 /* minimum extent length */ + +/* number of extent info in extent cache we try to shrink */ +#define EXTENT_CACHE_SHRINK_NUMBER 128 struct extent_info { - unsigned int fofs; /* start offset in a file */ - u32 blk; /* start block address of the extent */ - unsigned int len; /* length of the extent */ + unsigned int fofs; /* start offset in a file */ + u32 blk; /* start block address of the extent */ + unsigned int len; /* length of the extent */ +}; + +struct extent_node { + struct rb_node rb_node; /* rb node located in rb-tree */ + struct list_head list; /* node in global extent list of sbi */ + struct extent_info ei; /* extent info */ +}; + +struct extent_tree { + nid_t ino; /* inode number */ + struct rb_root root; /* root of extent info rb-tree */ + rwlock_t lock; /* protect extent info rb-tree */ + atomic_t refcount; /* reference count of rb-tree */ + unsigned int count; /* # of extent node in rb-tree*/ }; /* @@ -562,6 +582,14 @@ struct f2fs_sb_info { struct list_head dir_inode_list; /* dir inode list */ spinlock_t dir_inode_lock; /* for dir inode list lock */ + /* for extent tree cache */ + struct radix_tree_root extent_tree_root;/* cache extent cache entries */ + struct rw_semaphore extent_tree_lock; /* locking extent radix tree */ + struct list_head extent_list; /* lru list for shrinker */ + spinlock_t extent_lock; /* locking extent lru list */ + int total_ext_tree; /* extent tree count */ + atomic_t total_ext_node; /* extent info count */ + /* basic filesystem units */ unsigned int log_sectors_per_block; /* log2 sectors per block */ unsigned int log_blocksize; /* log2 block size */ diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h index f405bbf..c56026f 100644 --- a/fs/f2fs/node.h +++ b/fs/f2fs/node.h @@ -120,6 +120,7 @@ enum mem_type { NAT_ENTRIES, /* indicates the cached nat entry */ DIRTY_DENTS, /* indicates dirty dentry pages */ INO_ENTRIES, /* indicates inode entries */ + EXTENT_CACHE, /* indicates extent cache */ BASE_CHECK, /* check kernel status */ }; -- 2.2.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/