• Chao Yu's avatar
    f2fs: update extent tree in batches · 19b2c30d
    Chao Yu authored
    This patch introduce a new helper f2fs_update_extent_tree_range which can
    do extent mapping update at a specified range.
    
    The main idea is:
    1) punch all mapping info in extent node(s) which are at a specified range;
    2) try to merge new extent mapping with adjacent node, or failing that,
       insert the mapping into extent tree as a new node.
    
    In order to see the benefit, I add a function for stating time stamping
    count as below:
    
    uint64_t rdtsc(void)
    {
    	uint32_t lo, hi;
    	__asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));
    	return (uint64_t)hi << 32 | lo;
    }
    
    My test environment is: ubuntu, intel i7-3770, 16G memory, 256g micron ssd.
    
    truncation path:	update extent cache from truncate_data_blocks_range
    non-truncataion path:	update extent cache from other paths
    total:			all update paths
    
    a) Removing 128MB file which has one extent node mapping whole range of
    file:
    1. dd if=/dev/zero of=/mnt/f2fs/128M bs=1M count=128
    2. sync
    3. rm /mnt/f2fs/128M
    
    Before:
    		total		count		average
    truncation:	7651022		32768		233.49
    
    Patched:
    		total		count		average
    truncation:	3321		33		100.64
    
    b) fsstress:
    fsstress -d /mnt/f2fs -l 5 -n 100 -p 20
    Test times:		5 times.
    
    Before:
    		total		count		average
    truncation:	5812480.6	20911.6		277.95
    non-truncation:	7783845.6	13440.8		579.12
    total:		13596326.2	34352.4		395.79
    
    Patched:
    		total		count		average
    truncation:	1281283.0	3041.6		421.25
    non-truncation:	7355844.4	13662.8		538.38
    total:		8637127.4	16704.4		517.06
    
    1) For the updates in truncation path:
     - we can see updating in batches leads total tsc and update count reducing
       explicitly;
     - besides, for a single batched updating, punching multiple extent nodes
       in a loop, result in executing more operations, so our average tsc
       increase intensively.
    2) For the updates in non-truncation path:
     - there is a little improvement, that is because for the scenario that we
       just need to update in the head or tail of extent node, new interface
       optimize to update info in extent node directly, rather than removing
       original extent node for updating and then inserting that updated one
       into cache as new node.
    Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
    Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
    19b2c30d
f2fs.h 65.3 KB