aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs/data.c
diff options
context:
space:
mode:
authorChao Yu <chao2.yu@samsung.com>2015-02-05 04:57:31 -0500
committerJaegeuk Kim <jaegeuk@kernel.org>2015-03-03 12:58:47 -0500
commit1dcc336b02bff3d38f173feac55a2b6c25a5fb54 (patch)
tree65224e862473f315da2817ca8f1c08202a8d5fdb /fs/f2fs/data.c
parent8967215954a50947fbd9c2996232548bf6dd9062 (diff)
f2fs: enable rb-tree extent cache
This patch enables rb-tree based extent cache in f2fs. When we mount with "-o extent_cache", f2fs will try to add recently accessed page-block mappings into rb-tree based extent cache as much as possible, instead of original one extent info cache. By this way, f2fs can support more effective cache between dnode page cache and disk. It will supply high hit ratio in the cache with fewer memory when dnode page cache are reclaimed in environment of low memory. Storage: Sandisk sd card 64g 1.append write file (offset: 0, size: 128M); 2.override write file (offset: 2M, size: 1M); 3.override write file (offset: 4M, size: 1M); ... 4.override write file (offset: 48M, size: 1M); ... 5.override write file (offset: 112M, size: 1M); 6.sync 7.echo 3 > /proc/sys/vm/drop_caches 8.read file (size:128M, unit: 4k, count: 32768) (time dd if=/mnt/f2fs/128m bs=4k count=32768) Extent Hit Ratio: before patched Hit Ratio 121 / 1071 1071 / 1071 Performance: before patched real 0m37.051s 0m35.556s user 0m0.040s 0m0.026s sys 0m2.990s 0m2.251s Memory Cost: before patched Tree Count: 0 1 (size: 24 bytes) Node Count: 0 45 (size: 1440 bytes) v3: o retest and given more details of test result. Signed-off-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/data.c')
-rw-r--r--fs/f2fs/data.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index f52745346205..acdc0767f77c 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -666,6 +666,9 @@ void f2fs_shrink_extent_tree(struct f2fs_sb_info *sbi, int nr_shrink)
666 void **slot; 666 void **slot;
667 unsigned int found; 667 unsigned int found;
668 668
669 if (!test_opt(sbi, EXTENT_CACHE))
670 return;
671
669 if (available_free_memory(sbi, EXTENT_CACHE)) 672 if (available_free_memory(sbi, EXTENT_CACHE))
670 return; 673 return;
671 674
@@ -714,6 +717,9 @@ void f2fs_destroy_extent_tree(struct inode *inode)
714 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); 717 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
715 struct extent_tree *et; 718 struct extent_tree *et;
716 719
720 if (!test_opt(sbi, EXTENT_CACHE))
721 return;
722
717 down_read(&sbi->extent_tree_lock); 723 down_read(&sbi->extent_tree_lock);
718 et = radix_tree_lookup(&sbi->extent_tree_root, inode->i_ino); 724 et = radix_tree_lookup(&sbi->extent_tree_root, inode->i_ino);
719 if (!et) { 725 if (!et) {
@@ -749,6 +755,9 @@ out:
749static bool f2fs_lookup_extent_cache(struct inode *inode, pgoff_t pgofs, 755static bool f2fs_lookup_extent_cache(struct inode *inode, pgoff_t pgofs,
750 struct extent_info *ei) 756 struct extent_info *ei)
751{ 757{
758 if (test_opt(F2FS_I_SB(inode), EXTENT_CACHE))
759 return f2fs_lookup_extent_tree(inode, pgofs, ei);
760
752 return lookup_extent_info(inode, pgofs, ei); 761 return lookup_extent_info(inode, pgofs, ei);
753} 762}
754 763
@@ -765,6 +774,10 @@ void f2fs_update_extent_cache(struct dnode_of_data *dn)
765 fofs = start_bidx_of_node(ofs_of_node(dn->node_page), fi) + 774 fofs = start_bidx_of_node(ofs_of_node(dn->node_page), fi) +
766 dn->ofs_in_node; 775 dn->ofs_in_node;
767 776
777 if (test_opt(F2FS_I_SB(dn->inode), EXTENT_CACHE))
778 return f2fs_update_extent_tree(dn->inode, fofs,
779 dn->data_blkaddr);
780
768 if (update_extent_info(dn->inode, fofs, dn->data_blkaddr)) 781 if (update_extent_info(dn->inode, fofs, dn->data_blkaddr))
769 sync_inode_page(dn); 782 sync_inode_page(dn);
770} 783}