f2fs: add missing sysfs description
PATCH 1/5 f2fs: add missing sysfs description
There are some missing sysfs entries' description in document, add them.
--- Documentation/ABI/testing/sysfs-fs-f2fs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
Documentation/ABI/testing/sysfs-fs-f2fs +18 -0
@@ -51,6 +51,12 @@ Description: Controls the dirty page count condition for the in-place-update policies. +What: /sys/fs/f2fs/<disk>/min_hot_blocks +Date: March 2017 +Contact: "Jaegeuk Kim" <[email protected]> +Description: + Controls the dirty page count condition for redefining hot data. + What: /sys/fs/f2fs/<disk>/max_small_discards Date: November 2013 Contact: "Jaegeuk Kim" <[email protected]>
@@ -102,6 +108,12 @@ Contact: "Jaegeuk Kim" <[email protected]> Description: Controls the idle timing. +What: /sys/fs/f2fs/<disk>/iostat_enable +Date: August 2017 +Contact: "Chao Yu" <[email protected]> +Description: + Controls to enable/disable IO stat. + What: /sys/fs/f2fs/<disk>/ra_nid_pages Date: October 2015 Contact: "Chao Yu" <[email protected]>
@@ -122,6 +134,12 @@ Contact: "Shuoran Liu" <[email protected]> Description: Shows total written kbytes issued to disk. +What: /sys/fs/f2fs/<disk>/feature +Date: July 2017 +Contact: "Jaegeuk Kim" <[email protected]> +Description: + Shows all enabled features in current device. + What: /sys/fs/f2fs/<disk>/inject_rate Date: May 2016 Contact: "Sheng Yong" <[email protected]>
Signature · 1 line
2.13.1.388.g69e6b9b4f4a9
PATCH 2/5 f2fs: support get_page error injection
This patch adds to support get_page error injection to simulate out-of-memory test scenario.
--- fs/f2fs/data.c | 2 +- fs/f2fs/f2fs.h | 14 ++++++++++++++ fs/f2fs/gc.c | 4 ++-- fs/f2fs/node.c | 3 ++- fs/f2fs/super.c | 1 + 5 files changed, 20 insertions(+), 4 deletions(-)
fs/f2fs/data.c +1 -1
@@ -1958,7 +1958,7 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,* Do not use grab_cache_page_write_begin() to avoid deadlock due to * wait_for_stable_page. Will wait that below with our IO control. */ - page =pagecache_get_page (mapping, index, + page =f2fs_pagecache_get_page (mapping, index,FGP_LOCK |FGP_WRITE |FGP_CREAT ,GFP_NOFS );if (!page) { err = -ENOMEM ;
fs/f2fs/f2fs.h +14 -0
@@ -46,6 +46,7 @@enum {FAULT_KMALLOC ,FAULT_PAGE_ALLOC , +FAULT_PAGE_GET ,FAULT_ALLOC_NID ,FAULT_ORPHAN ,FAULT_BLOCK ,
@@ -1843,6 +1844,19 @@ static inline struct page *f2fs_grab_cache_page(struct address_space *mapping,return grab_cache_page_write_begin (mapping, index,AOP_FLAG_NOFS ); } +static inline struct page *f2fs_pagecache_get_page ( +struct address_space *mapping,pgoff_t index, +int fgp_flags,gfp_t gfp_mask) +{ +#ifdef CONFIG_F2FS_FAULT_INJECTION +if (time_to_inject (F2FS_M_SB (mapping),FAULT_PAGE_GET )) { +f2fs_show_injection_info (FAULT_PAGE_GET ); +return NULL ; + } +#endif +return pagecache_get_page (mapping, index, fgp_flags, gfp_mask); +} +static inline void f2fs_copy_page (struct page *src,struct page *dst) {char *src_kaddr =kmap (src);
fs/f2fs/gc.c +2 -2
@@ -650,8 +650,8 @@ static void move_data_block(struct inode *inode, block_t bidx,allocate_data_block (fio.sbi,NULL , fio.old_blkaddr, &newaddr, &sum,CURSEG_COLD_DATA ,NULL , false); - fio.encrypted_page =pagecache_get_page (META_MAPPING (fio.sbi), newaddr, -FGP_LOCK |FGP_CREAT ,GFP_NOFS ); + fio.encrypted_page =f2fs_pagecache_get_page (META_MAPPING (fio.sbi), + newaddr,FGP_LOCK |FGP_CREAT ,GFP_NOFS );if (!fio.encrypted_page) { err = -ENOMEM ; goto recover_block;
fs/f2fs/node.c +2 -1
@@ -1216,7 +1216,8 @@ static void flush_inline_data(struct f2fs_sb_info *sbi, nid_t ino)if (!inode)return ; - page =pagecache_get_page (inode->i_mapping,0 ,FGP_LOCK |FGP_NOWAIT ,0 ); + page =f2fs_pagecache_get_page (inode->i_mapping,0 , +FGP_LOCK |FGP_NOWAIT ,0 );if (!page) goto iput_out;
fs/f2fs/super.c +1 -0
@@ -44,6 +44,7 @@ static struct kmem_cache *f2fs_inode_cachep;char *fault_name[FAULT_MAX ] = { [FAULT_KMALLOC ] ="kmalloc" , [FAULT_PAGE_ALLOC ] ="page alloc" , + [FAULT_PAGE_GET ] ="page get" , [FAULT_ALLOC_NID ] ="alloc nid" , [FAULT_ORPHAN ] ="orphan" , [FAULT_BLOCK ] ="no more block" ,
Signature · 6 lines
2.13.1.388.g69e6b9b4f4a9 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
PATCH 3/5 f2fs: support bio allocation error injection
In reply to Chao YuThis patch adds to support bio allocation error injection to simulate out-of-memory test scenario.
--- fs/f2fs/data.c | 4 ++-- fs/f2fs/f2fs.h | 23 +++++++++++++++++------ fs/f2fs/segment.c | 2 +- fs/f2fs/super.c | 1 + 4 files changed, 21 insertions(+), 9 deletions(-)
fs/f2fs/data.c +2 -2
@@ -172,7 +172,7 @@ static struct bio *__bio_alloc(struct f2fs_sb_info *sbi, block_t blk_addr, {struct bio *bio; - bio =f2fs_bio_alloc (npages); + bio =f2fs_bio_alloc (sbi, npages, true);f2fs_target_device (sbi, blk_addr, bio); bio->bi_end_io = is_read ? f2fs_read_end_io : f2fs_write_end_io;
@@ -472,7 +472,7 @@ static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr,f2fs_wait_on_block_writeback (sbi, blkaddr); } - bio =bio_alloc (GFP_KERNEL ,min_t (int, nr_pages,BIO_MAX_PAGES )); + bio =f2fs_bio_alloc (sbi,min_t (int, nr_pages,BIO_MAX_PAGES ), false);if (!bio) {if (ctx)fscrypt_release_ctx (ctx);
fs/f2fs/f2fs.h +17 -6
@@ -47,6 +47,7 @@ enum {FAULT_KMALLOC ,FAULT_PAGE_ALLOC ,FAULT_PAGE_GET , +FAULT_ALLOC_BIO ,FAULT_ALLOC_NID ,FAULT_ORPHAN , FAULT_BLOCK,
@@ -1906,15 +1907,25 @@ static inline void *f2fs_kmem_cache_alloc(struct kmem_cache *cachep,return entry; } -static inline struct bio *f2fs_bio_alloc (int npages) +static inline struct bio *f2fs_bio_alloc (struct f2fs_sb_info *sbi, +int npages,bool no_fail) {struct bio *bio; -/* No failure on bio allocation */ - bio =bio_alloc (GFP_NOIO , npages); -if (!bio) - bio =bio_alloc (GFP_NOIO | __GFP_NOFAIL, npages); -return bio; +if (no_fail) { +/* No failure on bio allocation */ + bio =bio_alloc (GFP_NOIO , npages); +if (!bio) + bio =bio_alloc (GFP_NOIO | __GFP_NOFAIL, npages); +return bio; + } +#ifdef CONFIG_F2FS_FAULT_INJECTION +if (time_to_inject (sbi,FAULT_ALLOC_BIO )) { +f2fs_show_injection_info (FAULT_ALLOC_BIO ); +return NULL ; + } +#endif +return bio_alloc (GFP_KERNEL , npages); } static inline void f2fs_radix_tree_insert(struct radix_tree_root *root,
fs/f2fs/segment.c +1 -1
@@ -473,7 +473,7 @@ void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi)static int __submit_flush_wait (struct f2fs_sb_info *sbi,struct block_device *bdev) { -struct bio *bio =f2fs_bio_alloc (0 ); +struct bio *bio =f2fs_bio_alloc (sbi,0 , true);int ret; bio->bi_opf =REQ_OP_WRITE |REQ_SYNC |REQ_PREFLUSH ;
fs/f2fs/super.c +1 -0
@@ -45,6 +45,7 @@ char *fault_name[FAULT_MAX] = { [FAULT_KMALLOC] = "kmalloc", [FAULT_PAGE_ALLOC] = "page alloc", [FAULT_PAGE_GET] = "page get", + [FAULT_ALLOC_BIO] = "alloc bio", [FAULT_ALLOC_NID] = "alloc nid", [FAULT_ORPHAN] = "orphan", [FAULT_BLOCK] = "no more block",
Signature · 6 lines
2.13.1.388.g69e6b9b4f4a9 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
PATCH 4/5 f2fs: give correct trimmed blocks in fstrim
In reply to Chao YuWe have supported to issue discard in specified range during fstrim, it needs to return caller with successfully trimmed bytes in that range instead of bytes of invalid blocks which are scanned in checkpoint.
--- fs/f2fs/f2fs.h | 1 - fs/f2fs/segment.c | 27 +++++++++++++++++++-------- 2 files changed, 19 insertions(+), 9 deletions(-)
fs/f2fs/f2fs.h +0 -1
@@ -162,7 +162,6 @@ struct cp_control {__u64 trim_start;__u64 trim_end;__u64 trim_minlen; -__u64 trimmed; };/*
fs/f2fs/segment.c +19 -8
@@ -1218,21 +1218,27 @@ static bool __drop_discard_cmd(struct f2fs_sb_info *sbi)return dropped; } -static void __wait_one_discard_bio (struct f2fs_sb_info *sbi, +static unsigned int __wait_one_discard_bio (struct f2fs_sb_info *sbi,struct discard_cmd *dc) {struct discard_cmd_control *dcc =SM_I (sbi)->dcc_info; +unsigned int len =0 ;wait_for_completion_io (&dc->wait);mutex_lock (&dcc->cmd_lock);f2fs_bug_on (sbi, dc->state !=D_DONE ); dc->ref--; -if (!dc->ref) +if (!dc->ref) { +if (!dc->error) + len = dc->len;__remove_discard_cmd (sbi, dc); + }mutex_unlock (&dcc->cmd_lock); + +return len; } -static void __wait_discard_cmd_range (struct f2fs_sb_info *sbi, +static unsigned int __wait_discard_cmd_range (struct f2fs_sb_info *sbi,struct discard_policy *dpolicy,block_t start,block_t end) {
@@ -1241,6 +1247,7 @@ static void __wait_discard_cmd_range(struct f2fs_sb_info *sbi, &(dcc->fstrim_list) : &(dcc->wait_list);struct discard_cmd *dc, *tmp;bool need_wait; +unsigned int trimmed =0 ; next: need_wait = false;
@@ -1253,6 +1260,8 @@ static void __wait_discard_cmd_range(struct f2fs_sb_info *sbi,continue ;if (dc->state ==D_DONE && !dc->ref) {wait_for_completion_io (&dc->wait); +if (!dc->error) + trimmed += dc->len;__remove_discard_cmd (sbi, dc); }else { dc->ref++;
@@ -1263,9 +1272,11 @@ static void __wait_discard_cmd_range(struct f2fs_sb_info *sbi,mutex_unlock (&dcc->cmd_lock);if (need_wait) { -__wait_one_discard_bio (sbi, dc); + trimmed +=__wait_one_discard_bio (sbi, dc); goto next; } + +return trimmed; } static void __wait_all_discard_cmd(struct f2fs_sb_info *sbi,
@@ -1626,7 +1637,6 @@ void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc)f2fs_issue_discard (sbi, entry->start_blkaddr + cur_pos, len); - cpc->trimmed += len; total_len += len; }else { next_pos = find_next_bit_le(entry->discard_map,
@@ -2330,12 +2340,12 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)block_t start_block, end_block;struct cp_control cpc;struct discard_policy dpolicy; +unsigned long long trimmed =0 ;int err =0 ;if (start >=MAX_BLKADDR (sbi) || range->len < sbi->blocksize)return -EINVAL ; - cpc.trimmed =0 ;if (end <=MAIN_BLKADDR (sbi)) goto out;
@@ -2385,9 +2395,10 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)init_discard_policy (&dpolicy,DPOLICY_FSTRIM , cpc.trim_minlen);__issue_discard_cmd_range (sbi, &dpolicy, start_block, end_block); -__wait_discard_cmd_range (sbi, &dpolicy, start_block, end_block); + trimmed =__wait_discard_cmd_range (sbi, &dpolicy, + start_block, end_block); out: - range->len =F2FS_BLK_TO_BYTES (cpc.trimmed); + range->len =F2FS_BLK_TO_BYTES (trimmed);return err; }
Signature · 6 lines
2.13.1.388.g69e6b9b4f4a9 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
PATCH 5/5 f2fs: export SSR allocation threshold
In reply to Chao YuThis patch exports min_ssr_segments threshold in sysfs to let user control triggering SSR allocation flexibly.
--- Documentation/ABI/testing/sysfs-fs-f2fs | 6 ++++++ fs/f2fs/f2fs.h | 2 ++ fs/f2fs/segment.c | 3 ++- fs/f2fs/sysfs.c | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-fs-f2fs +6 -0
@@ -57,6 +57,12 @@ Contact: "Jaegeuk Kim" <[email protected]> Description: Controls the dirty page count condition for redefining hot data. +What: /sys/fs/f2fs/<disk>/min_ssr_sections +Date: October 2017 +Contact: "Chao Yu" <[email protected]> +Description: + Controls the fee section threshold to trigger SSR allocation. + What: /sys/fs/f2fs/<disk>/max_small_discards Date: November 2013 Contact: "Jaegeuk Kim" <[email protected]>
fs/f2fs/f2fs.h +2 -0
@@ -839,6 +839,7 @@ struct f2fs_sm_info {unsigned int min_ipu_util;/* in-place-update threshold */ unsigned int min_fsync_blocks;/* threshold for fsync */ unsigned int min_hot_blocks;/* threshold for hot block allocation */ +unsigned int min_ssr_sections;/* threshold to trigger SSR allocation */ /* for flush command control */ struct flush_cmd_control *fcc_info;
@@ -1088,6 +1089,7 @@ struct f2fs_sb_info {int active_logs;/* # of active logs */ int dir_level;/* directory level */ int inline_xattr_size;/* inline xattr size */ +unsigned int trigger_ssr_threshold;/* threshold to trigger ssr */ block_t user_block_count;/* # of user blocks */ block_t total_valid_block_count;/* # of valid blocks */
fs/f2fs/segment.c +2 -1
@@ -181,7 +181,7 @@ bool need_SSR(struct f2fs_sb_info *sbi)return true;return free_sections (sbi) <= (node_secs +2 * dent_secs + imeta_secs + -2 *reserved_sections (sbi)); +SM_I (sbi)->min_ssr_sections +reserved_sections (sbi)); }void register_inmem_page (struct inode *inode,struct page *page)
@@ -3637,6 +3637,7 @@ int build_segment_manager(struct f2fs_sb_info *sbi) sm_info->min_ipu_util =DEF_MIN_IPU_UTIL ; sm_info->min_fsync_blocks =DEF_MIN_FSYNC_BLOCKS ; sm_info->min_hot_blocks =DEF_MIN_HOT_BLOCKS ; + sm_info->min_ssr_sections =reserved_sections (sbi); sm_info->trim_sections =DEF_BATCHED_TRIM_SECTIONS ;
fs/f2fs/sysfs.c +2 -0
@@ -275,6 +275,7 @@ F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, ipu_policy, ipu_policy);F2FS_RW_ATTR (SM_INFO , f2fs_sm_info, min_ipu_util, min_ipu_util);F2FS_RW_ATTR (SM_INFO , f2fs_sm_info, min_fsync_blocks, min_fsync_blocks);F2FS_RW_ATTR (SM_INFO , f2fs_sm_info, min_hot_blocks, min_hot_blocks); +F2FS_RW_ATTR (SM_INFO , f2fs_sm_info, min_ssr_sections, min_ssr_sections);F2FS_RW_ATTR (NM_INFO , f2fs_nm_info, ram_thresh, ram_thresh);F2FS_RW_ATTR (NM_INFO , f2fs_nm_info, ra_nid_pages, ra_nid_pages);F2FS_RW_ATTR (NM_INFO , f2fs_nm_info, dirty_nats_ratio, dirty_nats_ratio);
@@ -319,6 +320,7 @@ static struct attribute *f2fs_attrs[] = {ATTR_LIST (min_ipu_util),ATTR_LIST (min_fsync_blocks),ATTR_LIST (min_hot_blocks), +ATTR_LIST (min_ssr_sections),ATTR_LIST (max_victim_search),ATTR_LIST (dir_level), ATTR_LIST(ram_thresh),
Signature · 1 line
2.13.1.388.g69e6b9b4f4a9