f2fs: introduce inmem curseg
Subsystems (2)
RFC PATCH 1/5 f2fs: introduce inmem curseg
Previous implementation of aligned pinfile allocation will:
- allocate new segment on cold data log no matter whether last used segment is partially used or not, it makes IOs more random;
- force concurrent cold data/GCed IO going into warm data area, it can make a bad effect on hot/cold data separation;
In this patch, we introduce a new type of log named 'inmem curseg', the differents from normal curseg is:
- it reuses existed segment type (CURSEG_XXX_NODE/DATA);
- it only exists in memory, its segno, blkofs, summary will not b persisted into checkpoint area;
With this new feature, we can enhance scalability of log, special allocators can be created for purposes:
- pure lfs allocator for aligned pinfile allocation or file defragmentation
- pure ssr allocator for later feature
So that, let's update aligned pinfile allocation to use this new inmem curseg fwk.
--- fs/f2fs/checkpoint.c | 7 ++- fs/f2fs/debug.c | 6 ++- fs/f2fs/f2fs.h | 12 +++-- fs/f2fs/file.c | 3 +- fs/f2fs/gc.c | 2 +- fs/f2fs/segment.c | 107 ++++++++++++++++++++++++++++++------------- fs/f2fs/segment.h | 17 ++++--- fs/f2fs/super.c | 9 ++-- 8 files changed, 112 insertions(+), 51 deletions(-)
fs/f2fs/checkpoint.c +6 -1
@@ -1623,11 +1623,16 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)f2fs_flush_sit_entries (sbi, cpc); +/* save inmem log status */ +f2fs_save_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); + err =do_checkpoint (sbi, cpc);if (err)f2fs_release_discard_addrs (sbi);else f2fs_clear_prefree_segments (sbi, cpc); + +f2fs_restore_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); stop:unblock_operations (sbi);stat_inc_cp_count (sbi->stat_info);
@@ -1658,7 +1663,7 @@ void f2fs_init_ino_entry_info(struct f2fs_sb_info *sbi) } sbi->max_orphans = (sbi->blocks_per_seg -F2FS_CP_PACKS - -NR_CURSEG_TYPE -__cp_payload (sbi)) * +NR_CURSEG_PERSIST_TYPE -__cp_payload (sbi)) *F2FS_ORPHANS_PER_BLOCK ; }
fs/f2fs/debug.c +5 -1
@@ -164,7 +164,7 @@ static void update_general_status(struct f2fs_sb_info *sbi) *100 / (int )(sbi->user_block_count >> sbi->log_blocks_per_seg) /2 ; si->util_invalid =50 - si->util_free - si->util_valid; -for (i =CURSEG_HOT_DATA ; i <=CURSEG_COLD_NODE ; i++) { +for (i =CURSEG_HOT_DATA ; i <NO_CHECK_TYPE ; i++) {struct curseg_info *curseg =CURSEG_I (sbi, i); si->curseg[i] = curseg->segno; si->cursec[i] =GET_SEC_FROM_SEG (sbi, curseg->segno);
@@ -393,6 +393,10 @@ static int stat_show(struct seq_file *s, void *v) si->dirty_seg[CURSEG_COLD_NODE ], si->full_seg[CURSEG_COLD_NODE ], si->valid_blks[CURSEG_COLD_NODE]); +seq_printf (s," - Pinned file: %8d %8d %8d\n" , + si->curseg[CURSEG_COLD_DATA_PINNED ], + si->cursec[CURSEG_COLD_DATA_PINNED ], + si->curzone[CURSEG_COLD_DATA_PINNED ]); seq_printf(s, "\n - Valid: %d\n - Dirty: %d\n", si->main_area_segs - si->dirty_count - si->prefree_count - si->free_segs,
fs/f2fs/f2fs.h +9 -3
@@ -996,7 +996,9 @@ static inline void set_new_dnode(struct dnode_of_data *dn, struct inode *inode,*/ #define NR_CURSEG_DATA_TYPE (3)#define NR_CURSEG_NODE_TYPE (3) -#define NR_CURSEG_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) +#define NR_CURSEG_INMEM_TYPE (1) +#define NR_CURSEG_PERSIST_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) +#define NR_CURSEG_TYPE (NR_CURSEG_INMEM_TYPE + NR_CURSEG_PERSIST_TYPE)enum {CURSEG_HOT_DATA =0 ,/* directory entry blocks */
@@ -1005,8 +1007,10 @@ enum {CURSEG_HOT_NODE ,/* direct node blocks of directory files */ CURSEG_WARM_NODE ,/* direct node blocks of normal files */ CURSEG_COLD_NODE ,/* indirect node blocks */ -NO_CHECK_TYPE , - CURSEG_COLD_DATA_PINNED,/* cold data for pinned file */ +NR_PERSISTENT_LOG ,/* number of persistent log */ +CURSEG_COLD_DATA_PINNED =NR_PERSISTENT_LOG , +/* pinned file that needs consecutive block address */ + NO_CHECK_TYPE, /* number of persistent & inmem log */ }; struct flush_cmd {
@@ -3359,6 +3363,8 @@ block_t f2fs_get_unusable_blocks(struct f2fs_sb_info *sbi);int f2fs_disable_cp_again (struct f2fs_sb_info *sbi,block_t unusable);void f2fs_release_discard_addrs (struct f2fs_sb_info *sbi);int f2fs_npages_for_summary_flush (struct f2fs_sb_info *sbi,bool for_ra); +void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi,int type); +void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi,int type);void f2fs_allocate_segment_for_resize (struct f2fs_sb_info *sbi,int type,unsigned int start,unsigned int end);void f2fs_allocate_new_segment (struct f2fs_sb_info *sbi,int type);
fs/f2fs/file.c +2 -1
@@ -1656,13 +1656,14 @@ static int expand_inode_data(struct inode *inode, loff_t offset, }down_write (&sbi->pin_sem); - map.m_seg_type =CURSEG_COLD_DATA_PINNED ;f2fs_lock_op (sbi);f2fs_allocate_new_segment (sbi,CURSEG_COLD_DATA );f2fs_unlock_op (sbi); + map.m_seg_type =CURSEG_COLD_DATA_PINNED ; err =f2fs_map_blocks (inode, &map,1 ,F2FS_GET_BLOCK_PRE_DIO ); +up_write (&sbi->pin_sem); done += map.m_len;
fs/f2fs/gc.c +1 -1
@@ -1448,7 +1448,7 @@ static int free_segment_range(struct f2fs_sb_info *sbi,mutex_unlock (&DIRTY_I (sbi)->seglist_lock);/* Move out cursegs from the target range */ -for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_TYPE ; type++) +for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_PERSIST_TYPE ; type++)f2fs_allocate_segment_for_resize (sbi, type, start, end);/* do GC to move out valid blocks in the range */
fs/f2fs/segment.c +74 -33
226 lines not on this page · raw message
fs/f2fs/segment.h +10 -7
@@ -22,7 +22,7 @@#define GET_R2L_SEGNO (free_i, segno) ((segno) + (free_i)->start_segno)#define IS_DATASEG (t) ((t) <= CURSEG_COLD_DATA) -#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE) +#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE && (t) <= CURSEG_COLD_NODE)#define IS_HOT (t) ((t) == CURSEG_HOT_NODE || (t) == CURSEG_HOT_DATA)#define IS_WARM (t) ((t) == CURSEG_WARM_NODE || (t) == CURSEG_WARM_DATA)
@@ -34,7 +34,8 @@ ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_HOT_NODE)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno) || \ - ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno)) + ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno) || \ + ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno))#define IS_CURSEC (sbi, secno) \ (((secno) == CURSEG_I(sbi, CURSEG_HOT_DATA)->segno / \
@@ -48,7 +49,9 @@ ((secno) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno / \ (sbi)->segs_per_sec) || \ ((secno) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno / \ - (sbi)->segs_per_sec)) \ + (sbi)->segs_per_sec) || \ + ((secno) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno / \ + (sbi)->segs_per_sec))#define MAIN_BLKADDR (sbi) \ (SM_I(sbi) ? SM_I(sbi)->main_blkaddr : \
@@ -288,10 +291,12 @@ struct curseg_info {struct rw_semaphore journal_rwsem;/* protect journal area */ struct f2fs_journal *journal;/* cached journal info */ unsigned char alloc_type;/* current allocation type */ +unsigned short seg_type;/* segment type like CURSEG_XXX_TYPE */ unsigned int segno;/* current segment number */ unsigned short next_blkoff;/* next block offset to write */ unsigned int zone;/* current zone number */ unsigned int next_segno;/* preallocated segment */ +bool inited;/* indicate inmem log is inited */ };struct sit_entry_set {
@@ -305,8 +310,6 @@ struct sit_entry_set {*/ static inline struct curseg_info *CURSEG_I (struct f2fs_sb_info *sbi,int type) { -if (type ==CURSEG_COLD_DATA_PINNED ) - type =CURSEG_COLD_DATA ;return (struct curseg_info *)(SM_I (sbi)->curseg_array + type); }
@@ -438,7 +441,7 @@ static inline void __set_inuse(struct f2fs_sb_info *sbi, }static inline void __set_test_and_free (struct f2fs_sb_info *sbi, -unsigned int segno) +unsigned int segno,bool inmem) {struct free_segmap_info *free_i =FREE_I (sbi);unsigned int secno =GET_SEC_FROM_SEG (sbi, segno);
@@ -449,7 +452,7 @@ static inline void __set_test_and_free(struct f2fs_sb_info *sbi,if (test_and_clear_bit (segno, free_i->free_segmap)) { free_i->free_segments++; -if (IS_CURSEC (sbi, secno)) +if (!inmem &&IS_CURSEC (sbi, secno)) goto skip_free; next =find_next_bit (free_i->free_segmap, start_segno + sbi->segs_per_sec, start_segno);
fs/f2fs/super.c +5 -4
@@ -575,7 +575,8 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)case Opt_active_logs:if (args->from &&match_int (args, &arg))return -EINVAL ; -if (arg !=2 && arg !=4 && arg !=NR_CURSEG_TYPE ) +if (arg !=2 && arg !=4 && + arg !=NR_CURSEG_PERSIST_TYPE )return -EINVAL ;F2FS_OPTION (sbi).active_logs = arg;break ;
@@ -981,7 +982,7 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) }/* Not pass down write hints if the number of active logs is lesser -* than NR_CURSEG_TYPE. +* than NR_CURSEG_PERSIST_TYPE. */ if (F2FS_OPTION (sbi).active_logs !=NR_CURSEG_TYPE )F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ;
@@ -1614,7 +1615,7 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)static void default_options (struct f2fs_sb_info *sbi) {/* init some FS parameters */ -F2FS_OPTION (sbi).active_logs =NR_CURSEG_TYPE ; +F2FS_OPTION (sbi).active_logs =NR_CURSEG_PERSIST_TYPE ;F2FS_OPTION (sbi).inline_xattr_size =DEFAULT_INLINE_XATTR_ADDRS ;F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ;F2FS_OPTION (sbi).alloc_mode =ALLOC_MODE_DEFAULT ;
@@ -2946,7 +2947,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi) cp_payload =__cp_payload (sbi);if (cp_pack_start_sum < cp_payload +1 || cp_pack_start_sum > blocks_per_seg -1 - -NR_CURSEG_TYPE ) { +NR_CURSEG_PERSIST_TYPE ) {f2fs_err (sbi,"Wrong cp_pack_start_sum: %u" , cp_pack_start_sum);return 1 ;
Signature · 1 line
2.26.2
RFC PATCH 2/5 f2fs: record average update time of segment
Previously, once we update one block in segment, we will update mtime of segment to last time, making aged segment becoming freshest, result in that GC with cost benefit algorithm missing such segment, So this patch changes to record mtime as average block updating time instead of last updating time.
It's not needed to reset mtime for prefree segment, as se->valid_blocks is zero, then old se->mtime won't take any weight with below calculation:
se->mtime = (se->mtime * se->valid_blocks + mtime) / (se->valid_blocks + 1);
--- fs/f2fs/segment.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
fs/f2fs/segment.c +18 -3
@@ -2150,6 +2150,22 @@ static void __set_sit_entry_type(struct f2fs_sb_info *sbi, int type,__mark_sit_entry_dirty (sbi, segno); } +static void update_segment_mtime (struct f2fs_sb_info *sbi,block_t blkaddr) +{ +unsigned int segno =GET_SEGNO (sbi, blkaddr); +struct seg_entry *se =get_seg_entry (sbi, segno); +unsigned long long mtime =get_mtime (sbi, false); + +if (!se->mtime) { + se->mtime = mtime; + }else { + se->mtime = (se->mtime * se->valid_blocks + mtime) / + (se->valid_blocks +1 ); + } +if (mtime >SIT_I (sbi)->max_mtime) +SIT_I (sbi)->max_mtime = mtime; +} +static void update_sit_entry (struct f2fs_sb_info *sbi,block_t blkaddr,int del) {struct seg_entry *se;
@@ -2169,10 +2185,9 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del)f2fs_bug_on (sbi, (new_vblocks >> (sizeof (unsigned short ) <<3 ) || (new_vblocks > sbi->blocks_per_seg))); +update_segment_mtime (sbi, blkaddr); + se->valid_blocks = new_vblocks; - se->mtime =get_mtime (sbi, false); -if (se->mtime >SIT_I (sbi)->max_mtime) -SIT_I (sbi)->max_mtime = se->mtime;/* Update valid block bitmap */ if (del >0 ) {
Signature · 1 line
2.26.2
Jaegeuk Kim
maintainerRe: [PATCH RFC 2/5] f2fs: record average update time of segment
Quoted 22 lines · Chao Yu
Previously, once we update one block in segment, we will update mtime of segment to last time, making aged segment becoming freshest, result in that GC with cost benefit algorithm missing such segment, So this patch changes to record mtime as average block updating time instead of last updating time.
It's not needed to reset mtime for prefree segment, as
se->valid_blocksis zero, then oldse->mtimewon't take any weight with below calculation:se->mtime = (se->mtime * se->valid_blocks + mtime) / (se->valid_blocks + 1);Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/segment.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)fs/f2fs/segment.c +0
-0
fs/f2fs/segment.c static void __set_sit_entry_type(struct f2fs_sb_info *sbi, int type, · line 2159
Quoted 10 lines
fs/f2fs/segment.c +7
-0@@ -2150,6 +2150,22 @@ static void __set_sit_entry_type(struct f2fs_sb_info *sbi, int type,__mark_sit_entry_dirty (sbi, segno); } +static void update_segment_mtime (struct f2fs_sb_info *sbi,block_t blkaddr) +{ +unsigned int segno =GET_SEGNO (sbi, blkaddr); +struct seg_entry *se =get_seg_entry (sbi, segno); +unsigned long long mtime =get_mtime (sbi, false); + +if (!se->mtime) {
Don't need {}.
Quoted 27 lines
fs/f2fs/segment.c +11
-3+ se->mtime = mtime; + }else { + se->mtime = (se->mtime * se->valid_blocks + mtime) / + (se->valid_blocks +1 ); + } +if (mtime >SIT_I (sbi)->max_mtime) +SIT_I (sbi)->max_mtime = mtime; +} +static void update_sit_entry (struct f2fs_sb_info *sbi,block_t blkaddr,int del) {struct seg_entry *se;@@ -2169,10 +2185,9 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del)f2fs_bug_on (sbi, (new_vblocks >> (sizeof (unsigned short ) <<3 ) || (new_vblocks > sbi->blocks_per_seg))); +update_segment_mtime (sbi, blkaddr); + se->valid_blocks = new_vblocks; - se->mtime =get_mtime (sbi, false); -if (se->mtime >SIT_I (sbi)->max_mtime) -SIT_I (sbi)->max_mtime = se->mtime;/* Update valid block bitmap */ if (del >0 ) {Signature · 1 line
2.26.2
Re: [PATCH RFC 2/5] f2fs: record average update time of segment
Quoted 26 lines · Jaegeuk Kim
Quoted 25 lines · Chao Yu
Previously, once we update one block in segment, we will update mtime of segment to last time, making aged segment becoming freshest, result in that GC with cost benefit algorithm missing such segment, So this patch changes to record mtime as average block updating time instead of last updating time.
It's not needed to reset mtime for prefree segment, as
se->valid_blocksis zero, then oldse->mtimewon't take any weight with below calculation:se->mtime = (se->mtime * se->valid_blocks + mtime) / (se->valid_blocks + 1);Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/segment.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)fs/f2fs/segment.c +0
-0@@ -2150,6 +2150,22 @@ static void __set_sit_entry_type(struct f2fs_sb_info *sbi, int type,__mark_sit_entry_dirty (sbi, segno); }
Quoted 9 lines
fs/f2fs/segment.c static void __set_sit_entry_type(struct f2fs_sb_info *sbi, int type, · line 2159
Quoted 7 lines
fs/f2fs/segment.c +7
-0+static void update_segment_mtime (struct f2fs_sb_info *sbi,block_t blkaddr) +{ +unsigned int segno =GET_SEGNO (sbi, blkaddr); +struct seg_entry *se =get_seg_entry (sbi, segno); +unsigned long long mtime =get_mtime (sbi, false); + +if (!se->mtime) {Don't need {}.
Updated,
BTW, have fixed below compile error:
m68k-linux-ld: fs/f2fs/segment.o: in function `update_segment_mtime':
fs/f2fs/segment.c:2162: undefined reference to `__udivdi3'
Thanks,
Quoted 24 lines
Quoted 24 lines
fs/f2fs/segment.c +11
-3+ se->mtime = mtime; + }else { + se->mtime = (se->mtime * se->valid_blocks + mtime) / + (se->valid_blocks +1 ); + } +if (mtime >SIT_I (sbi)->max_mtime) +SIT_I (sbi)->max_mtime = mtime; +} +static void update_sit_entry (struct f2fs_sb_info *sbi,block_t blkaddr,int del) {struct seg_entry *se;@@ -2169,10 +2185,9 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del)f2fs_bug_on (sbi, (new_vblocks >> (sizeof (unsigned short ) <<3 ) || (new_vblocks > sbi->blocks_per_seg))); +update_segment_mtime (sbi, blkaddr); + se->valid_blocks = new_vblocks; - se->mtime =get_mtime (sbi, false); -if (se->mtime >SIT_I (sbi)->max_mtime) -SIT_I (sbi)->max_mtime = se->mtime;
Quoted 6 lines
Quoted 4 lines
fs/f2fs/segment.c +0
-0/* Update valid block bitmap */ if (del >0 ) {Signature · 1 line
2.26.2.
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 3/5 f2fs: inherit mtime of original block during GC
In reply to Chao YuDon't let f2fs inner GC ruins original aging degree of segment.
--- fs/f2fs/data.c | 2 +- fs/f2fs/f2fs.h | 5 +++-- fs/f2fs/gc.c | 4 ++-- fs/f2fs/segment.c | 55 ++++++++++++++++++++++++++++++++++++----------- 4 files changed, 49 insertions(+), 17 deletions(-)
fs/f2fs/data.c +1 -1
@@ -1366,7 +1366,7 @@ static int __allocate_data_block(struct dnode_of_data *dn, int seg_type)set_summary (&sum, dn->nid, dn->ofs_in_node, ni.version); old_blkaddr = dn->data_blkaddr;f2fs_allocate_data_block (sbi,NULL , old_blkaddr, &dn->data_blkaddr, - &sum, seg_type,NULL ); + &sum, seg_type,NULL , false);if (GET_SEGNO (sbi, old_blkaddr) !=NULL_SEGNO )invalidate_mapping_pages (META_MAPPING (sbi), old_blkaddr, old_blkaddr);
fs/f2fs/f2fs.h +3 -2
@@ -3383,7 +3383,8 @@ void f2fs_outplace_write_data(struct dnode_of_data *dn,int f2fs_inplace_write_data (struct f2fs_io_info *fio);void f2fs_do_replace_block (struct f2fs_sb_info *sbi,struct f2fs_summary *sum,block_t old_blkaddr,block_t new_blkaddr, -bool recover_curseg,bool recover_newaddr); +bool recover_curseg,bool recover_newaddr, +bool from_gc); void f2fs_replace_block(struct f2fs_sb_info *sbi, struct dnode_of_data *dn, block_t old_addr, block_t new_addr, unsigned char version, bool recover_curseg,
@@ -3391,7 +3392,7 @@ void f2fs_replace_block(struct f2fs_sb_info *sbi, struct dnode_of_data *dn,void f2fs_allocate_data_block (struct f2fs_sb_info *sbi,struct page *page,block_t old_blkaddr,block_t *new_blkaddr,struct f2fs_summary *sum,int type, -struct f2fs_io_info *fio); +struct f2fs_io_info *fio,bool from_gc);void f2fs_wait_on_page_writeback (struct page *page,enum page_type type,bool ordered,bool locked);void f2fs_wait_on_block_writeback (struct inode *inode,block_t blkaddr);
fs/f2fs/gc.c +2 -2
@@ -875,7 +875,7 @@ static int move_data_block(struct inode *inode, block_t bidx, }f2fs_allocate_data_block (fio.sbi,NULL , fio.old_blkaddr, &newaddr, - &sum,CURSEG_COLD_DATA ,NULL ); + &sum,CURSEG_COLD_DATA ,NULL , true); fio.encrypted_page =f2fs_pagecache_get_page (META_MAPPING (fio.sbi), newaddr,FGP_LOCK |FGP_CREAT ,GFP_NOFS );
@@ -925,7 +925,7 @@ static int move_data_block(struct inode *inode, block_t bidx, recover_block:if (err)f2fs_do_replace_block (fio.sbi, &sum, newaddr, fio.old_blkaddr, - true, true); + true, true, true); up_out:if (lfs_mode)up_write (&fio.sbi->io_order_lock);
fs/f2fs/segment.c +43 -12
125 lines not on this page · raw message
Signature · 1 line
2.26.2
RFC PATCH 4/5 f2fs: support 64-bits key in f2fs rb-tree node entry
In reply to Chao Yuthen, we can add specified entry into rb-tree with 64-bits segment time as key.
--- fs/f2fs/extent_cache.c | 37 +++++++++++++++++++++++++++++++++++-- fs/f2fs/f2fs.h | 15 ++++++++++++--- fs/f2fs/segment.c | 4 ++-- 3 files changed, 49 insertions(+), 7 deletions(-)
fs/f2fs/extent_cache.c +35 -2
@@ -58,6 +58,29 @@ struct rb_entry *f2fs_lookup_rb_tree(struct rb_root_cached *root,return re; } +struct rb_node **f2fs_lookup_rb_tree_ext (struct f2fs_sb_info *sbi, +struct rb_root_cached *root, +struct rb_node **parent, +unsigned long long key,bool *leftmost) +{ +struct rb_node **p = &root->rb_root.rb_node; +struct rb_entry *re; + +while (*p) { + *parent = *p; + re = rb_entry(*parent, struct rb_entry, rb_node); + +if (key < re->key) { + p = &(*p)->rb_left; + }else { + p = &(*p)->rb_right; + *leftmost = false; + } + } + +return p; +} + struct rb_node **f2fs_lookup_rb_tree_for_insert(struct f2fs_sb_info *sbi, struct rb_root_cached *root, struct rb_node **parent,
@@ -166,7 +189,7 @@ struct rb_entry *f2fs_lookup_rb_tree_ret(struct rb_root_cached *root, }bool f2fs_check_rb_tree_consistence (struct f2fs_sb_info *sbi, -struct rb_root_cached *root) +struct rb_root_cached *root,bool check_key) {#ifdef CONFIG_F2FS_CHECK_FS struct rb_node *cur =rb_first_cached (root), *next;
@@ -183,13 +206,23 @@ bool f2fs_check_rb_tree_consistence(struct f2fs_sb_info *sbi, cur_re = rb_entry(cur, struct rb_entry, rb_node); next_re = rb_entry(next, struct rb_entry, rb_node); +if (check_key) { +if (cur_re->key > next_re->key) { +f2fs_info (sbi,"inconsistent rbtree, " +"cur(%llu) next(%llu)" , + cur_re->key, next_re->key); +return false; + } + goto next; + } +if (cur_re->ofs + cur_re->len > next_re->ofs) {f2fs_info (sbi,"inconsistent rbtree, cur(%u, %u) next(%u, %u)" , cur_re->ofs, cur_re->len, next_re->ofs, next_re->len);return false; } - +next: cur = next; }#endif
fs/f2fs/f2fs.h +12 -3
@@ -635,8 +635,13 @@ enum {struct rb_entry {struct rb_node rb_node;/* rb node located in rb-tree */ -unsigned int ofs;/* start offset of the entry */ -unsigned int len;/* length of the entry */ +union { +struct { +unsigned int ofs;/* start offset of the entry */ +unsigned int len;/* length of the entry */ + }; +unsigned long long key;/* 64-bits key */ + }; };struct extent_info {
@@ -3828,6 +3833,10 @@ void f2fs_leave_shrinker(struct f2fs_sb_info *sbi);*/ struct rb_entry *f2fs_lookup_rb_tree (struct rb_root_cached *root,struct rb_entry *cached_re,unsigned int ofs); +struct rb_node **f2fs_lookup_rb_tree_ext (struct f2fs_sb_info *sbi, +struct rb_root_cached *root, +struct rb_node **parent, +unsigned long long key,bool *left_most); struct rb_node **f2fs_lookup_rb_tree_for_insert(struct f2fs_sb_info *sbi, struct rb_root_cached *root, struct rb_node **parent,
@@ -3838,7 +3847,7 @@ struct rb_entry *f2fs_lookup_rb_tree_ret(struct rb_root_cached *root, struct rb_node ***insert_p, struct rb_node **insert_parent, bool force, bool *leftmost);bool f2fs_check_rb_tree_consistence (struct f2fs_sb_info *sbi, -struct rb_root_cached *root); +struct rb_root_cached *root,bool check_key);unsigned int f2fs_shrink_extent_tree (struct f2fs_sb_info *sbi,int nr_shrink);void f2fs_init_extent_tree (struct inode *inode,struct page *ipage);void f2fs_drop_extent_tree (struct inode *inode);
fs/f2fs/segment.c +2 -2
@@ -1521,7 +1521,7 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi, goto next;if (unlikely (dcc->rbtree_check))f2fs_bug_on (sbi, !f2fs_check_rb_tree_consistence (sbi, - &dcc->root)); + &dcc->root, false));blk_start_plug (&plug);list_for_each_entry_safe (dc, tmp, pend_list, list) {f2fs_bug_on (sbi, dc->state !=D_PREP );
@@ -2887,7 +2887,7 @@ static unsigned int __issue_discard_cmd_range(struct f2fs_sb_info *sbi,mutex_lock (&dcc->cmd_lock);if (unlikely (dcc->rbtree_check))f2fs_bug_on (sbi, !f2fs_check_rb_tree_consistence (sbi, - &dcc->root)); + &dcc->root, false)); dc = (struct discard_cmd *)f2fs_lookup_rb_tree_ret(&dcc->root, NULL, start,
Signature · 1 line
2.26.2
RFC PATCH 5/5 f2fs: support age threshold based garbage collection
In reply to Chao YuThere are several issues in current background GC algorithm:
- valid blocks is one of key factors during cost overhead calculation, so if segment has less valid block, however even its age is young or it locates hot segment, CB algorithm will still choose the segment as victim, it's not appropriate.
- GCed data/node will go to existing logs, no matter in-there datas' update frequency is the same or not, it may mix hot and cold data again.
- GC alloctor mainly use LFS type segment, it will cost free segment more quickly.
This patch introduces a new algorithm named age threshold based garbage collection to solve above issues, there are three steps mainly:
1. select a source victim:
- set an age threshold, and select candidates beased threshold:
e.g.
0 means youngest, 100 means oldest, if we set age threshold to 80 then select dirty segments which has age in range of [80, 100] as candiddates;
- set candidate_ratio threshold, and select candidates based the ratio, so that we can shrink candidates to those oldest segments;
- select target segment with fewest valid blocks in order to migrate blocks with minimum cost;
2. select a target victim:
- select candidates beased age threshold;
- set candidate_radius threshold, search candidates whose age is around source victims, searching radius should less than the radius threshold.
- select target segment with most valid blocks in order to avoid migrating current target segment.
3. merge valid blocks from source victim into target victim with SSR alloctor.
Test steps:
- create 160 dirty segments:
* half of them have 128 valid blocks per segment
* left of them have 384 valid blocks per segment
- run background GC
Benefit: GC count and block movement count both decrease obviously:
- Before:
- Valid: 86
- Dirty: 1
- Prefree: 11
- Free: 6001 (6001)
GC calls: 162 (BG: 220)
- data segments : 160 (160)
- node segments : 2 (2)
Try to move 41454 blocks (BG: 41454)
- data blocks : 40960 (40960)
- node blocks : 494 (494)
IPU: 0 blocks
SSR: 0 blocks in 0 segments
LFS: 41364 blocks in 81 segments
- After:
- Valid: 87
- Dirty: 0
- Prefree: 4
- Free: 6008 (6008)
GC calls: 75 (BG: 76)
- data segments : 74 (74)
- node segments : 1 (1)
Try to move 12813 blocks (BG: 12813)
- data blocks : 12544 (12544)
- node blocks : 269 (269)
IPU: 0 blocks
SSR: 12032 blocks in 77 segments
LFS: 855 blocks in 2 segments
--- fs/f2fs/checkpoint.c | 4 +- fs/f2fs/data.c | 2 +- fs/f2fs/debug.c | 4 + fs/f2fs/f2fs.h | 28 ++- fs/f2fs/gc.c | 371 +++++++++++++++++++++++++++++++++++- fs/f2fs/gc.h | 25 +++ fs/f2fs/segment.c | 184 ++++++++++++++---- fs/f2fs/segment.h | 25 ++- fs/f2fs/super.c | 10 +- include/trace/events/f2fs.h | 8 +- 10 files changed, 602 insertions(+), 59 deletions(-)
fs/f2fs/checkpoint.c +2 -2
@@ -1624,7 +1624,7 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)f2fs_flush_sit_entries (sbi, cpc);/* save inmem log status */ -f2fs_save_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); +f2fs_save_inmem_curseg (sbi); err =do_checkpoint (sbi, cpc);if (err)
@@ -1632,7 +1632,7 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)else f2fs_clear_prefree_segments (sbi, cpc); -f2fs_restore_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); +f2fs_restore_inmem_curseg (sbi); stop:unblock_operations (sbi);stat_inc_cp_count (sbi->stat_info);
fs/f2fs/data.c +1 -1
@@ -1366,7 +1366,7 @@ static int __allocate_data_block(struct dnode_of_data *dn, int seg_type)set_summary (&sum, dn->nid, dn->ofs_in_node, ni.version); old_blkaddr = dn->data_blkaddr;f2fs_allocate_data_block (sbi,NULL , old_blkaddr, &dn->data_blkaddr, - &sum, seg_type,NULL , false); + &sum, seg_type,NULL );if (GET_SEGNO (sbi, old_blkaddr) !=NULL_SEGNO )invalidate_mapping_pages (META_MAPPING (sbi), old_blkaddr, old_blkaddr);
fs/f2fs/debug.c +4 -0
@@ -397,6 +397,10 @@ static int stat_show(struct seq_file *s, void *v) si->curseg[CURSEG_COLD_DATA_PINNED ], si->cursec[CURSEG_COLD_DATA_PINNED ], si->curzone[CURSEG_COLD_DATA_PINNED]); +seq_printf (s," - ATGC data: %8d %8d %8d\n" , + si->curseg[CURSEG_ALL_DATA_ATGC ], + si->cursec[CURSEG_ALL_DATA_ATGC ], + si->curzone[CURSEG_ALL_DATA_ATGC ]); seq_printf(s, "\n - Valid: %d\n - Dirty: %d\n", si->main_area_segs - si->dirty_count - si->prefree_count - si->free_segs,
fs/f2fs/f2fs.h +24 -4
@@ -1001,7 +1001,7 @@ static inline void set_new_dnode(struct dnode_of_data *dn, struct inode *inode,*/ #define NR_CURSEG_DATA_TYPE (3)#define NR_CURSEG_NODE_TYPE (3) -#define NR_CURSEG_INMEM_TYPE (1) +#define NR_CURSEG_INMEM_TYPE (2)#define NR_CURSEG_PERSIST_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE)#define NR_CURSEG_TYPE (NR_CURSEG_INMEM_TYPE + NR_CURSEG_PERSIST_TYPE)
@@ -1015,6 +1015,7 @@ enum {NR_PERSISTENT_LOG ,/* number of persistent log */ CURSEG_COLD_DATA_PINNED =NR_PERSISTENT_LOG ,/* pinned file that needs consecutive block address */ +CURSEG_ALL_DATA_ATGC ,/* SSR alloctor in hot/warm/cold data area */ NO_CHECK_TYPE, /* number of persistent & inmem log */ };
@@ -1260,6 +1261,18 @@ struct inode_management {unsigned long ino_num;/* number of entries */ }; +/* for GC_AT */ +struct atgc_management { +bool atgc_enabled;/* ATGC is enabled or not */ +struct rb_root_cached root;/* root of victim rb-tree */ +struct list_head victim_list;/* linked with all victim entries */ +unsigned int victim_count;/* victim count in rb-tree */ +unsigned int candidate_ratio;/* candidate ratio */ +unsigned int max_candidate_count;/* max candidate count */ +unsigned int age_weight;/* age weight, vblock_weight = 100 - age_weight */ +unsigned long long age_threshold;/* age threshold */ +}; +/* For s_flag in struct f2fs_sb_info */ enum {SBI_IS_DIRTY ,/* dirty flag for checkpoint */
@@ -1292,6 +1305,7 @@ enum {GC_NORMAL ,GC_IDLE_CB ,GC_IDLE_GREEDY , +GC_IDLE_AT ,GC_URGENT_HIGH , GC_URGENT_LOW, };
@@ -1549,6 +1563,7 @@ struct f2fs_sb_info {* race between GC and GC or CP */ struct f2fs_gc_kthread *gc_thread;/* GC thread */ +struct atgc_management am;/* atgc management */ unsigned int cur_victim_sec;/* current victim section num */ unsigned int gc_mode;/* current GC state */ unsigned int next_victim_seg[2 ];/* next segment in victim section */
@@ -3368,8 +3383,11 @@ block_t f2fs_get_unusable_blocks(struct f2fs_sb_info *sbi);int f2fs_disable_cp_again (struct f2fs_sb_info *sbi,block_t unusable);void f2fs_release_discard_addrs (struct f2fs_sb_info *sbi);int f2fs_npages_for_summary_flush (struct f2fs_sb_info *sbi,bool for_ra); -void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi,int type); -void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi,int type); +void f2fs_init_inmem_curseg (struct f2fs_sb_info *sbi); +void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi); +void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi); +void f2fs_get_new_segment (struct f2fs_sb_info *sbi, +unsigned int *newseg,bool new_sec,int dir);void f2fs_allocate_segment_for_resize (struct f2fs_sb_info *sbi,int type,unsigned int start,unsigned int end);void f2fs_allocate_new_segment (struct f2fs_sb_info *sbi,int type);
@@ -3397,7 +3415,7 @@ void f2fs_replace_block(struct f2fs_sb_info *sbi, struct dnode_of_data *dn,void f2fs_allocate_data_block (struct f2fs_sb_info *sbi,struct page *page,block_t old_blkaddr,block_t *new_blkaddr,struct f2fs_summary *sum,int type, -struct f2fs_io_info *fio,bool from_gc); +struct f2fs_io_info *fio);void f2fs_wait_on_page_writeback (struct page *page,enum page_type type,bool ordered,bool locked);void f2fs_wait_on_block_writeback (struct inode *inode,block_t blkaddr);
@@ -3532,6 +3550,8 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync, bool background, unsigned int segno);void f2fs_build_gc_manager (struct f2fs_sb_info *sbi);int f2fs_resize_fs (struct f2fs_sb_info *sbi,__u64 block_count); +int __init f2fs_create_garbage_collection_cache (void ); +void f2fs_destroy_garbage_collection_cache (void );/* * recovery.c
fs/f2fs/gc.c +364 -7
495 lines not on this page · raw message
fs/f2fs/gc.h +25 -0
@@ -14,6 +14,14 @@#define DEF_GC_THREAD_MIN_SLEEP_TIME 30000/* milliseconds */ #define DEF_GC_THREAD_MAX_SLEEP_TIME 60000#define DEF_GC_THREAD_NOGC_SLEEP_TIME 300000/* wait 5 min */ + +/* choose candidates from sections which has age of more than 7 days */ +#define DEF_GC_THREAD_AGE_THRESHOLD (60 * 60 * 24 * 7) +#define DEF_GC_THREAD_CANDIDATE_RATIO 20/* select 20% oldest sections as candidates */ +#define DEF_GC_THREAD_MAX_CANDIDATE_COUNT 10/* select at most 10 sections as candidates */ +#define DEF_GC_THREAD_AGE_WEIGHT 60/* age weight */ +#define DEFAULT_ACCURACY_CLASS 10000/* accuracy class */ +#define LIMIT_INVALID_BLOCK 40/* percentage over total user space */ #define LIMIT_FREE_BLOCK 40/* percentage over invalid + free space */
@@ -41,6 +49,23 @@ struct gc_inode_list {struct radix_tree_root iroot; }; +struct victim_info { +unsigned long long mtime;/* mtime of section */ +unsigned int segno;/* section No. */ +}; + +struct victim_entry { +struct rb_node rb_node;/* rb node located in rb-tree */ +union { +struct { +unsigned long long mtime;/* mtime of section */ +unsigned int segno;/* segment No. */ + }; +struct victim_info vi;/* victim info */ + }; +struct list_head list; +}; +/* * inline functions */
fs/f2fs/segment.c +146 -38
372 lines not on this page · raw message
fs/f2fs/segment.h +22 -3
@@ -24,6 +24,12 @@#define IS_DATASEG (t) ((t) <= CURSEG_COLD_DATA)#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE && (t) <= CURSEG_COLD_NODE) +static inline void sanity_check_seg_type (struct f2fs_sb_info *sbi, +unsigned short seg_type) +{ +f2fs_bug_on (sbi, seg_type >=NR_PERSISTENT_LOG ); +} +#define IS_HOT (t) ((t) == CURSEG_HOT_NODE || (t) == CURSEG_HOT_DATA)#define IS_WARM (t) ((t) == CURSEG_WARM_NODE || (t) == CURSEG_WARM_DATA)#define IS_COLD (t) ((t) == CURSEG_COLD_NODE || (t) == CURSEG_COLD_DATA)
@@ -35,7 +41,8 @@ ((seg) == CURSEG_I(sbi, CURSEG_HOT_NODE)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno) || \ - ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno)) + ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno) || \ + ((seg) == CURSEG_I(sbi, CURSEG_ALL_DATA_ATGC)->segno))#define IS_CURSEC (sbi, secno) \ (((secno) == CURSEG_I(sbi, CURSEG_HOT_DATA)->segno / \
@@ -51,6 +58,8 @@ ((secno) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno / \ (sbi)->segs_per_sec) || \ ((secno) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno / \ + (sbi)->segs_per_sec) || \ + ((secno) == CURSEG_I(sbi, CURSEG_ALL_DATA_ATGC)->segno / \ (sbi)->segs_per_sec))#define MAIN_BLKADDR (sbi) \
@@ -135,20 +144,25 @@ enum {* In the victim_sel_policy->alloc_mode, there are two block allocation modes. * LFS writes data sequentially with cleaning operations. * SSR (Slack Space Recycle) reuses obsolete space without cleaning operations. +* AT_SSR (Age Threshold based Slack Space Recycle) merges fragments into +* fragmented segment which has similar aging degree. */ enum {LFS =0 , -SSR +SSR , +AT_SSR , };/* * In the victim_sel_policy->gc_mode, there are two gc, aka cleaning, modes. * GC_CB is based on cost-benefit algorithm. * GC_GREEDY is based on greedy algorithm. +* GC_AT is based on age-threshold algorithm. */ enum {GC_CB =0 ,GC_GREEDY , +GC_AT ,ALLOC_NEXT ,FLUSH_DEVICE ,MAX_GC_POLICY ,
@@ -177,7 +191,10 @@ struct victim_sel_policy {unsigned int offset;/* last scanned bitmap offset */ unsigned int ofs_unit;/* bitmap search unit */ unsigned int min_cost;/* minimum cost */ +unsigned long long oldest_age;/* oldest age of segments having the same min cost */ unsigned int min_segno;/* segment # having min. cost */ +unsigned long long age;/* mtime of GCed section*/ +unsigned long long age_threshold;/* age threshold */ };struct seg_entry {
@@ -243,6 +260,8 @@ struct sit_info {unsigned long long mounted_time;/* mount time */ unsigned long long min_mtime;/* min. modification time */ unsigned long long max_mtime;/* max. modification time */ +unsigned long long dirty_min_mtime;/* rerange candidates in GC_AT */ +unsigned long long dirty_max_mtime;/* rerange candidates in GC_AT */ unsigned int last_victim[MAX_GC_POLICY ];/* last victim segment # */ };
@@ -281,7 +300,7 @@ struct dirty_seglist_info {/* victim selection function for cleaning and SSR */ struct victim_selection {int (*get_victim)(struct f2fs_sb_info *,unsigned int *, -int ,int ,char ); +int ,int ,char ,unsigned long long ); };/* for active log information */
fs/f2fs/super.c +9 -1
@@ -3714,6 +3714,8 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) } reset_checkpoint: +f2fs_init_inmem_curseg (sbi); +/* f2fs_recover_fsync_data() cleared this already */ clear_sbi_flag (sbi,SBI_POR_DOING );
@@ -3919,9 +3921,12 @@ static int __init init_f2fs_fs(void) err =f2fs_create_extent_cache ();if (err) goto free_checkpoint_caches; - err =f2fs_init_sysfs (); + err =f2fs_create_garbage_collection_cache ();if (err) goto free_extent_cache; + err =f2fs_init_sysfs (); +if (err) + goto free_garbage_collection_cache; err =register_shrinker (&f2fs_shrinker_info);if (err) goto free_sysfs;
@@ -3955,6 +3960,8 @@ static int __init init_f2fs_fs(void)unregister_shrinker (&f2fs_shrinker_info); free_sysfs:f2fs_exit_sysfs (); +free_garbage_collection_cache: +f2fs_destroy_garbage_collection_cache (); free_extent_cache:f2fs_destroy_extent_cache (); free_checkpoint_caches:
@@ -3979,6 +3986,7 @@ static void __exit exit_f2fs_fs(void)unregister_filesystem (&f2fs_fs_type);unregister_shrinker (&f2fs_shrinker_info);f2fs_exit_sysfs (); +f2fs_destroy_garbage_collection_cache ();f2fs_destroy_extent_cache ();f2fs_destroy_checkpoint_caches ();f2fs_destroy_segment_manager_caches ();
include/trace/events/f2fs.h +5 -3
@@ -111,13 +111,15 @@ TRACE_DEFINE_ENUM(CP_RESIZE);#define show_alloc_mode (type) \ __print_symbolic(type, \ - { LFS, "LFS-mode" }, \ - { SSR, "SSR-mode" }) + { LFS, "LFS-mode" }, \ + { SSR, "SSR-mode" }, \ + { AT_SSR, "AT_SSR-mode" })#define show_victim_policy (type) \ __print_symbolic(type, \ { GC_GREEDY, "Greedy" }, \ - { GC_CB, "Cost-Benefit" }) + { GC_CB, "Cost-Benefit" }, \ + { GC_AT, "Age-threshold" })#define show_cpreason (type) \ __print_flags(type, "|", \
Signature · 8 lines
2.26.2 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [PATCH RFC 5/5] f2fs: support age threshold based garbage collection
Jaegeuk,
This is a commercialized feature in huawei products for years, I think it's time to try to upstream it, could you please take a look at this idea, to see whether it could be a formal feature of f2fs?
Quoted 79 lines · Chao Yu
There are several issues in current background GC algorithm:
- valid blocks is one of key factors during cost overhead calculation, so if segment has less valid block, however even its age is young or it locates hot segment, CB algorithm will still choose the segment as victim, it's not appropriate.
- GCed data/node will go to existing logs, no matter in-there datas' update frequency is the same or not, it may mix hot and cold data again.
- GC alloctor mainly use LFS type segment, it will cost free segment more quickly.This patch introduces a new algorithm named age threshold based garbage collection to solve above issues, there are three steps mainly:
1. select a source victim:
- set an age threshold, and select candidates beased threshold:
e.g.
0 means youngest, 100 means oldest, if we set age threshold to 80 then select dirty segments which has age in range of [80, 100] as candiddates;
- setcandidate_ratiothreshold, and select candidates based the ratio, so that we can shrink candidates to those oldest segments;
- select target segment with fewest valid blocks in order to migrate blocks with minimum cost;2. select a target victim:
- select candidates beased age threshold;
- setcandidate_radiusthreshold, search candidates whose age is around source victims, searching radius should less than the radius threshold.
- select target segment with most valid blocks in order to avoid migrating current target segment.3. merge valid blocks from source victim into target victim with SSR alloctor.
Test steps:
- create 160 dirty segments:
* half of them have 128 valid blocks per segment
* left of them have 384 valid blocks per segment
- run background GCBenefit: GC count and block movement count both decrease obviously:
- Before:
- Valid: 86
- Dirty: 1
- Prefree: 11
- Free: 6001 (6001)GC calls: 162 (BG: 220)
- data segments : 160 (160)
- node segments : 2 (2)
Try to move 41454 blocks (BG: 41454)
- data blocks : 40960 (40960)
- node blocks : 494 (494)IPU: 0 blocks
SSR: 0 blocks in 0 segments
LFS: 41364 blocks in 81 segments- After:
- Valid: 87
- Dirty: 0
- Prefree: 4
- Free: 6008 (6008)GC calls: 75 (BG: 76)
- data segments : 74 (74)
- node segments : 1 (1)
Try to move 12813 blocks (BG: 12813)
- data blocks : 12544 (12544)
- node blocks : 269 (269)IPU: 0 blocks
SSR: 12032 blocks in 77 segments
LFS: 855 blocks in 2 segments
Jaegeuk Kim
maintainerHi Chao,
Do you have any brief design doc to present the idea?
Thanks,
Quoted 519 lines · Chao Yu
Previous implementation of aligned pinfile allocation will:
- allocate new segment on cold data log no matter whether last used segment is partially used or not, it makes IOs more random;
- force concurrent cold data/GCed IO going into warm data area, it can make a bad effect on hot/cold data separation;In this patch, we introduce a new type of log named 'inmem curseg', the differents from normal curseg is:
- it reuses existed segment type (CURSEG_XXX_NODE/DATA);
- it only exists in memory, its segno, blkofs, summary will not b persisted into checkpoint area;With this new feature, we can enhance scalability of log, special allocators can be created for purposes:
- pure lfs allocator for aligned pinfile allocation or file defragmentation
- pure ssr allocator for later featureSo that, let's update aligned pinfile allocation to use this new inmem curseg fwk.
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/checkpoint.c | 7 ++- fs/f2fs/debug.c | 6 ++- fs/f2fs/f2fs.h | 12 +++-- fs/f2fs/file.c | 3 +- fs/f2fs/gc.c | 2 +- fs/f2fs/segment.c | 107 ++++++++++++++++++++++++++++++------------- fs/f2fs/segment.h | 17 ++++--- fs/f2fs/super.c | 9 ++-- 8 files changed, 112 insertions(+), 51 deletions(-)fs/f2fs/checkpoint.c +6
-1@@ -1623,11 +1623,16 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)f2fs_flush_sit_entries (sbi, cpc); +/* save inmem log status */ +f2fs_save_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); + err =do_checkpoint (sbi, cpc);if (err)f2fs_release_discard_addrs (sbi);else f2fs_clear_prefree_segments (sbi, cpc); + +f2fs_restore_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); stop:unblock_operations (sbi);stat_inc_cp_count (sbi->stat_info);@@ -1658,7 +1663,7 @@ void f2fs_init_ino_entry_info(struct f2fs_sb_info *sbi) } sbi->max_orphans = (sbi->blocks_per_seg -F2FS_CP_PACKS - -NR_CURSEG_TYPE -__cp_payload (sbi)) * +NR_CURSEG_PERSIST_TYPE -__cp_payload (sbi)) *F2FS_ORPHANS_PER_BLOCK ; }fs/f2fs/debug.c +5
-1@@ -164,7 +164,7 @@ static void update_general_status(struct f2fs_sb_info *sbi) *100 / (int )(sbi->user_block_count >> sbi->log_blocks_per_seg) /2 ; si->util_invalid =50 - si->util_free - si->util_valid; -for (i =CURSEG_HOT_DATA ; i <=CURSEG_COLD_NODE ; i++) { +for (i =CURSEG_HOT_DATA ; i <NO_CHECK_TYPE ; i++) {struct curseg_info *curseg =CURSEG_I (sbi, i); si->curseg[i] = curseg->segno; si->cursec[i] =GET_SEC_FROM_SEG (sbi, curseg->segno);@@ -393,6 +393,10 @@ static int stat_show(struct seq_file *s, void *v) si->dirty_seg[CURSEG_COLD_NODE ], si->full_seg[CURSEG_COLD_NODE ], si->valid_blks[CURSEG_COLD_NODE]); +seq_printf (s," - Pinned file: %8d %8d %8d\n" , + si->curseg[CURSEG_COLD_DATA_PINNED ], + si->cursec[CURSEG_COLD_DATA_PINNED ], + si->curzone[CURSEG_COLD_DATA_PINNED ]); seq_printf(s, "\n - Valid: %d\n - Dirty: %d\n", si->main_area_segs - si->dirty_count - si->prefree_count - si->free_segs,fs/f2fs/f2fs.h +9
-3@@ -996,7 +996,9 @@ static inline void set_new_dnode(struct dnode_of_data *dn, struct inode *inode,*/ #define NR_CURSEG_DATA_TYPE (3)#define NR_CURSEG_NODE_TYPE (3) -#define NR_CURSEG_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) +#define NR_CURSEG_INMEM_TYPE (1) +#define NR_CURSEG_PERSIST_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) +#define NR_CURSEG_TYPE (NR_CURSEG_INMEM_TYPE + NR_CURSEG_PERSIST_TYPE)enum {CURSEG_HOT_DATA =0 ,/* directory entry blocks */ @@ -1005,8 +1007,10 @@ enum {CURSEG_HOT_NODE ,/* direct node blocks of directory files */ CURSEG_WARM_NODE ,/* direct node blocks of normal files */ CURSEG_COLD_NODE ,/* indirect node blocks */ -NO_CHECK_TYPE , - CURSEG_COLD_DATA_PINNED,/* cold data for pinned file */ +NR_PERSISTENT_LOG ,/* number of persistent log */ +CURSEG_COLD_DATA_PINNED =NR_PERSISTENT_LOG , +/* pinned file that needs consecutive block address */ + NO_CHECK_TYPE, /* number of persistent & inmem log */ }; struct flush_cmd {@@ -3359,6 +3363,8 @@ block_t f2fs_get_unusable_blocks(struct f2fs_sb_info *sbi);int f2fs_disable_cp_again (struct f2fs_sb_info *sbi,block_t unusable);void f2fs_release_discard_addrs (struct f2fs_sb_info *sbi);int f2fs_npages_for_summary_flush (struct f2fs_sb_info *sbi,bool for_ra); +void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi,int type); +void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi,int type);void f2fs_allocate_segment_for_resize (struct f2fs_sb_info *sbi,int type,unsigned int start,unsigned int end);void f2fs_allocate_new_segment (struct f2fs_sb_info *sbi,int type);fs/f2fs/file.c +2
-1@@ -1656,13 +1656,14 @@ static int expand_inode_data(struct inode *inode, loff_t offset, }down_write (&sbi->pin_sem); - map.m_seg_type =CURSEG_COLD_DATA_PINNED ;f2fs_lock_op (sbi);f2fs_allocate_new_segment (sbi,CURSEG_COLD_DATA );f2fs_unlock_op (sbi); + map.m_seg_type =CURSEG_COLD_DATA_PINNED ; err =f2fs_map_blocks (inode, &map,1 ,F2FS_GET_BLOCK_PRE_DIO ); +up_write (&sbi->pin_sem); done += map.m_len;fs/f2fs/gc.c +1
-1@@ -1448,7 +1448,7 @@ static int free_segment_range(struct f2fs_sb_info *sbi,mutex_unlock (&DIRTY_I (sbi)->seglist_lock);/* Move out cursegs from the target range */ -for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_TYPE ; type++) +for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_PERSIST_TYPE ; type++)f2fs_allocate_segment_for_resize (sbi, type, start, end);/* do GC to move out valid blocks in the range */ fs/f2fs/segment.c +74
-33@@ -1958,7 +1958,7 @@ static void set_prefree_as_free_segments(struct f2fs_sb_info *sbi)mutex_lock (&dirty_i->seglist_lock);for_each_set_bit (segno, dirty_i->dirty_segmap[PRE ],MAIN_SEGS (sbi)) -__set_test_and_free (sbi, segno); +__set_test_and_free (sbi, segno, false);mutex_unlock (&dirty_i->seglist_lock); }@@ -2496,6 +2496,7 @@ static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified)struct curseg_info *curseg =CURSEG_I (sbi, type);struct summary_footer *sum_footer; + curseg->inited = true; curseg->segno = curseg->next_segno; curseg->zone =GET_ZONE_FROM_SEG (sbi, curseg->segno); curseg->next_blkoff =0 ;@@ -2503,24 +2504,31 @@ static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified) sum_footer = &(curseg->sum_blk->footer);memset (sum_footer,0 ,sizeof (struct summary_footer )); -if (IS_DATASEG (type)) +if (IS_DATASEG (curseg->seg_type))SET_SUM_TYPE (sum_footer,SUM_TYPE_DATA ); -if (IS_NODESEG (type)) +if (IS_NODESEG (curseg->seg_type))SET_SUM_TYPE (sum_footer,SUM_TYPE_NODE ); -__set_sit_entry_type (sbi, type, curseg->segno, modified); +__set_sit_entry_type (sbi, curseg->seg_type, curseg->segno, modified); }static unsigned int __get_next_segno (struct f2fs_sb_info *sbi,int type) { +struct curseg_info *curseg =CURSEG_I (sbi, type); +/* if segs_per_sec is large than 1, we need to keep original policy. */ if (__is_large_section (sbi)) -return CURSEG_I (sbi, type)->segno; +return curseg->segno; + +/* inmem log may not locate on any segment after mount */ +if (!curseg->inited) +return 0 ;if (unlikely (is_sbi_flag_set (sbi,SBI_CP_DISABLED )))return 0 ;if (test_opt (sbi,NOHEAP ) && - (type ==CURSEG_HOT_DATA ||IS_NODESEG (type))) + (curseg->seg_type ==CURSEG_HOT_DATA || +IS_NODESEG (curseg->seg_type)))return 0 ;if (SIT_I (sbi)->last_victim[ALLOC_NEXT ])@@ -2530,7 +2538,7 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)if (F2FS_OPTION (sbi).alloc_mode ==ALLOC_MODE_REUSE )return 0 ; -return CURSEG_I (sbi, type)->segno; +return curseg->segno; }/* @@ -2540,12 +2548,14 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)static void new_curseg (struct f2fs_sb_info *sbi,int type,bool new_sec) {struct curseg_info *curseg =CURSEG_I (sbi, type); +unsigned short seg_type = curseg->seg_type;unsigned int segno = curseg->segno;int dir =ALLOC_LEFT ; -write_sum_page (sbi, curseg->sum_blk, +if (curseg->inited) +write_sum_page (sbi, curseg->sum_blk,GET_SUM_BLOCK (sbi, segno)); -if (type ==CURSEG_WARM_DATA || type ==CURSEG_COLD_DATA ) +if (seg_type ==CURSEG_WARM_DATA || seg_type ==CURSEG_COLD_DATA ) dir =ALLOC_RIGHT ;if (test_opt (sbi,NOHEAP ))@@ -2622,6 +2632,43 @@ static void change_curseg(struct f2fs_sb_info *sbi, int type)f2fs_put_page (sum_page,1 ); } +void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi,int type) +{ +struct curseg_info *curseg =CURSEG_I (sbi, type); + +mutex_lock (&curseg->curseg_mutex); +if (!curseg->inited) + goto out; + +if (get_valid_blocks (sbi, curseg->segno, false)) { +write_sum_page (sbi, curseg->sum_blk, +GET_SUM_BLOCK (sbi, curseg->segno)); + }else { +mutex_lock (&DIRTY_I (sbi)->seglist_lock); +__set_test_and_free (sbi, curseg->segno, true); +mutex_unlock (&DIRTY_I (sbi)->seglist_lock); + } +out: +mutex_unlock (&curseg->curseg_mutex); +} + +void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi,int type) +{ +struct curseg_info *curseg =CURSEG_I (sbi, type); + +mutex_lock (&curseg->curseg_mutex); +if (!curseg->inited) + goto out; +if (get_valid_blocks (sbi, curseg->segno, false)) + goto out; + +mutex_lock (&DIRTY_I (sbi)->seglist_lock); +__set_test_and_inuse (sbi, curseg->segno); +mutex_unlock (&DIRTY_I (sbi)->seglist_lock); +out: +mutex_unlock (&curseg->curseg_mutex); +} +static int get_ssr_segment (struct f2fs_sb_info *sbi,int type) {struct curseg_info *curseg =CURSEG_I (sbi, type);@@ -2738,11 +2785,15 @@ void __allocate_new_segment(struct f2fs_sb_info *sbi, int type)struct curseg_info *curseg =CURSEG_I (sbi, type);unsigned int old_segno; +if (!curseg->inited) + goto alloc; +if (!curseg->next_blkoff && !get_valid_blocks (sbi, curseg->segno, false) && !get_ckpt_valid_blocks (sbi, curseg->segno))return ; +alloc: old_segno = curseg->segno;SIT_I (sbi)->s_ops->allocate_segment (sbi, type, true);locate_dirty_segment (sbi, old_segno);@@ -3126,19 +3177,6 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, {struct sit_info *sit_i =SIT_I (sbi);struct curseg_info *curseg =CURSEG_I (sbi, type); -bool put_pin_sem = false; - -if (type ==CURSEG_COLD_DATA ) { -/* GC during CURSEG_COLD_DATA_PINNED allocation */ -if (down_read_trylock (&sbi->pin_sem)) { - put_pin_sem = true; - }else { - type =CURSEG_WARM_DATA ; - curseg =CURSEG_I (sbi, type); - } - }else if (type ==CURSEG_COLD_DATA_PINNED ) { - type =CURSEG_COLD_DATA ; - }down_read (&SM_I (sbi)->curseg_lock);@@ -3204,9 +3242,6 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,mutex_unlock (&curseg->curseg_mutex);up_read (&SM_I (sbi)->curseg_lock); - -if (put_pin_sem) -up_read (&sbi->pin_sem); }static void update_device_state (struct f2fs_io_info *fio)@@ -3574,7 +3609,7 @@ static int read_normal_summaries(struct f2fs_sb_info *sbi, int type) blk_off =le16_to_cpu (ckpt->cur_data_blkoff[type -CURSEG_HOT_DATA ]);if (__exist_node_summaries (sbi)) - blk_addr =sum_blk_addr (sbi,NR_CURSEG_TYPE , type); + blk_addr =sum_blk_addr (sbi,NR_CURSEG_PERSIST_TYPE , type);else blk_addr =sum_blk_addr (sbi,NR_CURSEG_DATA_TYPE , type); }else {@@ -3652,8 +3687,9 @@ static int restore_curseg_summaries(struct f2fs_sb_info *sbi) }if (__exist_node_summaries (sbi)) -f2fs_ra_meta_pages (sbi,sum_blk_addr (sbi,NR_CURSEG_TYPE , type), -NR_CURSEG_TYPE - type,META_CP , true); +f2fs_ra_meta_pages (sbi, +sum_blk_addr (sbi,NR_CURSEG_PERSIST_TYPE , type), +NR_CURSEG_PERSIST_TYPE - type,META_CP , true);for (; type <=CURSEG_COLD_NODE ; type++) { err =read_normal_summaries (sbi, type);@@ -4155,14 +4191,14 @@ static int build_curseg(struct f2fs_sb_info *sbi)struct curseg_info *array;int i; - array =f2fs_kzalloc (sbi,array_size (NR_CURSEG_TYPE ,sizeof (*array)), -GFP_KERNEL ); + array =f2fs_kzalloc (sbi,array_size (NR_CURSEG_TYPE , +sizeof (*array)),GFP_KERNEL );if (!array)return -ENOMEM ;SM_I (sbi)->curseg_array = array; -for (i =0 ; i <NR_CURSEG_TYPE ; i++) { +for (i =0 ; i <NO_CHECK_TYPE ; i++) {mutex_init (&array[i].curseg_mutex); array[i].sum_blk =f2fs_kzalloc (sbi,PAGE_SIZE ,GFP_KERNEL );if (!array[i].sum_blk)@@ -4172,8 +4208,13 @@ static int build_curseg(struct f2fs_sb_info *sbi) sizeof(struct f2fs_journal), GFP_KERNEL);if (!array[i].journal)return -ENOMEM ; +if (i <NR_PERSISTENT_LOG ) + array[i].seg_type =CURSEG_HOT_DATA + i; +else if (i ==CURSEG_COLD_DATA_PINNED ) + array[i].seg_type =CURSEG_COLD_DATA ; array[i].segno =NULL_SEGNO ; array[i].next_blkoff =0 ; + array[i].inited = false; }return restore_curseg_summaries (sbi); }@@ -4408,7 +4449,7 @@ static int sanity_check_curseg(struct f2fs_sb_info *sbi)* In LFS/SSR curseg, .next_blkoff should point to an unused blkaddr; * In LFS curseg, all blkaddr after .next_blkoff should be unused. */ -for (i =0 ; i <NO_CHECK_TYPE ; i++) { +for (i =0 ; i <NR_PERSISTENT_LOG ; i++) {struct curseg_info *curseg =CURSEG_I (sbi, i);struct seg_entry *se =get_seg_entry (sbi, curseg->segno);unsigned int blkofs = curseg->next_blkoff;@@ -4637,7 +4678,7 @@ int f2fs_fix_curseg_write_pointer(struct f2fs_sb_info *sbi) {int i, ret; -for (i =0 ; i <NO_CHECK_TYPE ; i++) { +for (i =0 ; i <NR_PERSISTENT_LOG ; i++) { ret =fix_curseg_write_pointer (sbi, i);if (ret)return ret;fs/f2fs/segment.h +10
-7@@ -22,7 +22,7 @@#define GET_R2L_SEGNO (free_i, segno) ((segno) + (free_i)->start_segno)#define IS_DATASEG (t) ((t) <= CURSEG_COLD_DATA) -#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE) +#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE && (t) <= CURSEG_COLD_NODE)#define IS_HOT (t) ((t) == CURSEG_HOT_NODE || (t) == CURSEG_HOT_DATA)#define IS_WARM (t) ((t) == CURSEG_WARM_NODE || (t) == CURSEG_WARM_DATA)@@ -34,7 +34,8 @@ ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_HOT_NODE)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno) || \ - ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno)) + ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno) || \ + ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno))#define IS_CURSEC (sbi, secno) \ (((secno) == CURSEG_I(sbi, CURSEG_HOT_DATA)->segno / \@@ -48,7 +49,9 @@ ((secno) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno / \ (sbi)->segs_per_sec) || \ ((secno) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno / \ - (sbi)->segs_per_sec)) \ + (sbi)->segs_per_sec) || \ + ((secno) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno / \ + (sbi)->segs_per_sec))#define MAIN_BLKADDR (sbi) \ (SM_I(sbi) ? SM_I(sbi)->main_blkaddr : \@@ -288,10 +291,12 @@ struct curseg_info {struct rw_semaphore journal_rwsem;/* protect journal area */ struct f2fs_journal *journal;/* cached journal info */ unsigned char alloc_type;/* current allocation type */ +unsigned short seg_type;/* segment type like CURSEG_XXX_TYPE */ unsigned int segno;/* current segment number */ unsigned short next_blkoff;/* next block offset to write */ unsigned int zone;/* current zone number */ unsigned int next_segno;/* preallocated segment */ +bool inited;/* indicate inmem log is inited */ };struct sit_entry_set {@@ -305,8 +310,6 @@ struct sit_entry_set {*/ static inline struct curseg_info *CURSEG_I (struct f2fs_sb_info *sbi,int type) { -if (type ==CURSEG_COLD_DATA_PINNED ) - type =CURSEG_COLD_DATA ;return (struct curseg_info *)(SM_I (sbi)->curseg_array + type); }@@ -438,7 +441,7 @@ static inline void __set_inuse(struct f2fs_sb_info *sbi, }static inline void __set_test_and_free (struct f2fs_sb_info *sbi, -unsigned int segno) +unsigned int segno,bool inmem) {struct free_segmap_info *free_i =FREE_I (sbi);unsigned int secno =GET_SEC_FROM_SEG (sbi, segno);@@ -449,7 +452,7 @@ static inline void __set_test_and_free(struct f2fs_sb_info *sbi,if (test_and_clear_bit (segno, free_i->free_segmap)) { free_i->free_segments++; -if (IS_CURSEC (sbi, secno)) +if (!inmem &&IS_CURSEC (sbi, secno)) goto skip_free; next =find_next_bit (free_i->free_segmap, start_segno + sbi->segs_per_sec, start_segno);fs/f2fs/super.c +5
-4@@ -575,7 +575,8 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)case Opt_active_logs:if (args->from &&match_int (args, &arg))return -EINVAL ; -if (arg !=2 && arg !=4 && arg !=NR_CURSEG_TYPE ) +if (arg !=2 && arg !=4 && + arg !=NR_CURSEG_PERSIST_TYPE )return -EINVAL ;F2FS_OPTION (sbi).active_logs = arg;break ;@@ -981,7 +982,7 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) }/* Not pass down write hints if the number of active logs is lesser -* than NR_CURSEG_TYPE. +* than NR_CURSEG_PERSIST_TYPE. */ if (F2FS_OPTION (sbi).active_logs !=NR_CURSEG_TYPE )F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ;@@ -1614,7 +1615,7 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)static void default_options (struct f2fs_sb_info *sbi) {/* init some FS parameters */ -F2FS_OPTION (sbi).active_logs =NR_CURSEG_TYPE ; +F2FS_OPTION (sbi).active_logs =NR_CURSEG_PERSIST_TYPE ;F2FS_OPTION (sbi).inline_xattr_size =DEFAULT_INLINE_XATTR_ADDRS ;F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ;F2FS_OPTION (sbi).alloc_mode =ALLOC_MODE_DEFAULT ;@@ -2946,7 +2947,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi) cp_payload =__cp_payload (sbi);if (cp_pack_start_sum < cp_payload +1 || cp_pack_start_sum > blocks_per_seg -1 - -NR_CURSEG_TYPE ) { +NR_CURSEG_PERSIST_TYPE ) {f2fs_err (sbi,"Wrong cp_pack_start_sum: %u" , cp_pack_start_sum);return 1 ;Signature · 1 line
2.26.2
Quoted 3 lines · Jaegeuk Kim
Hi Chao,
Do you have any brief design doc to present the idea?
Hi Jaegeuk,
You mean this whole patchset, right?
I can add a brief design description in patch 0/5.
Quoted 525 lines
Thanks,
Quoted 519 lines · Chao Yu
Previous implementation of aligned pinfile allocation will:
- allocate new segment on cold data log no matter whether last used segment is partially used or not, it makes IOs more random;
- force concurrent cold data/GCed IO going into warm data area, it can make a bad effect on hot/cold data separation;In this patch, we introduce a new type of log named 'inmem curseg', the differents from normal curseg is:
- it reuses existed segment type (CURSEG_XXX_NODE/DATA);
- it only exists in memory, its segno, blkofs, summary will not b persisted into checkpoint area;With this new feature, we can enhance scalability of log, special allocators can be created for purposes:
- pure lfs allocator for aligned pinfile allocation or file defragmentation
- pure ssr allocator for later featureSo that, let's update aligned pinfile allocation to use this new inmem curseg fwk.
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/checkpoint.c | 7 ++- fs/f2fs/debug.c | 6 ++- fs/f2fs/f2fs.h | 12 +++-- fs/f2fs/file.c | 3 +- fs/f2fs/gc.c | 2 +- fs/f2fs/segment.c | 107 ++++++++++++++++++++++++++++++------------- fs/f2fs/segment.h | 17 ++++--- fs/f2fs/super.c | 9 ++-- 8 files changed, 112 insertions(+), 51 deletions(-)fs/f2fs/checkpoint.c +6
-1@@ -1623,11 +1623,16 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)f2fs_flush_sit_entries (sbi, cpc); +/* save inmem log status */ +f2fs_save_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); + err =do_checkpoint (sbi, cpc);if (err)f2fs_release_discard_addrs (sbi);else f2fs_clear_prefree_segments (sbi, cpc); + +f2fs_restore_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); stop:unblock_operations (sbi);stat_inc_cp_count (sbi->stat_info);@@ -1658,7 +1663,7 @@ void f2fs_init_ino_entry_info(struct f2fs_sb_info *sbi) } sbi->max_orphans = (sbi->blocks_per_seg -F2FS_CP_PACKS - -NR_CURSEG_TYPE -__cp_payload (sbi)) * +NR_CURSEG_PERSIST_TYPE -__cp_payload (sbi)) *F2FS_ORPHANS_PER_BLOCK ; }fs/f2fs/debug.c +5
-1@@ -164,7 +164,7 @@ static void update_general_status(struct f2fs_sb_info *sbi) *100 / (int )(sbi->user_block_count >> sbi->log_blocks_per_seg) /2 ; si->util_invalid =50 - si->util_free - si->util_valid; -for (i =CURSEG_HOT_DATA ; i <=CURSEG_COLD_NODE ; i++) { +for (i =CURSEG_HOT_DATA ; i <NO_CHECK_TYPE ; i++) {struct curseg_info *curseg =CURSEG_I (sbi, i); si->curseg[i] = curseg->segno; si->cursec[i] =GET_SEC_FROM_SEG (sbi, curseg->segno);@@ -393,6 +393,10 @@ static int stat_show(struct seq_file *s, void *v) si->dirty_seg[CURSEG_COLD_NODE ], si->full_seg[CURSEG_COLD_NODE ], si->valid_blks[CURSEG_COLD_NODE]); +seq_printf (s," - Pinned file: %8d %8d %8d\n" , + si->curseg[CURSEG_COLD_DATA_PINNED ], + si->cursec[CURSEG_COLD_DATA_PINNED ], + si->curzone[CURSEG_COLD_DATA_PINNED ]); seq_printf(s, "\n - Valid: %d\n - Dirty: %d\n", si->main_area_segs - si->dirty_count - si->prefree_count - si->free_segs,fs/f2fs/f2fs.h +9
-3@@ -996,7 +996,9 @@ static inline void set_new_dnode(struct dnode_of_data *dn, struct inode *inode,*/ #define NR_CURSEG_DATA_TYPE (3)#define NR_CURSEG_NODE_TYPE (3) -#define NR_CURSEG_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) +#define NR_CURSEG_INMEM_TYPE (1) +#define NR_CURSEG_PERSIST_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) +#define NR_CURSEG_TYPE (NR_CURSEG_INMEM_TYPE + NR_CURSEG_PERSIST_TYPE)enum {CURSEG_HOT_DATA =0 ,/* directory entry blocks */ @@ -1005,8 +1007,10 @@ enum {CURSEG_HOT_NODE ,/* direct node blocks of directory files */ CURSEG_WARM_NODE ,/* direct node blocks of normal files */ CURSEG_COLD_NODE ,/* indirect node blocks */ -NO_CHECK_TYPE , - CURSEG_COLD_DATA_PINNED,/* cold data for pinned file */ +NR_PERSISTENT_LOG ,/* number of persistent log */ +CURSEG_COLD_DATA_PINNED =NR_PERSISTENT_LOG , +/* pinned file that needs consecutive block address */ + NO_CHECK_TYPE, /* number of persistent & inmem log */ }; struct flush_cmd {@@ -3359,6 +3363,8 @@ block_t f2fs_get_unusable_blocks(struct f2fs_sb_info *sbi);int f2fs_disable_cp_again (struct f2fs_sb_info *sbi,block_t unusable);void f2fs_release_discard_addrs (struct f2fs_sb_info *sbi);int f2fs_npages_for_summary_flush (struct f2fs_sb_info *sbi,bool for_ra); +void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi,int type); +void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi,int type);void f2fs_allocate_segment_for_resize (struct f2fs_sb_info *sbi,int type,unsigned int start,unsigned int end);void f2fs_allocate_new_segment (struct f2fs_sb_info *sbi,int type);fs/f2fs/file.c +2
-1@@ -1656,13 +1656,14 @@ static int expand_inode_data(struct inode *inode, loff_t offset, }down_write (&sbi->pin_sem); - map.m_seg_type =CURSEG_COLD_DATA_PINNED ;f2fs_lock_op (sbi);f2fs_allocate_new_segment (sbi,CURSEG_COLD_DATA );f2fs_unlock_op (sbi); + map.m_seg_type =CURSEG_COLD_DATA_PINNED ; err =f2fs_map_blocks (inode, &map,1 ,F2FS_GET_BLOCK_PRE_DIO ); +up_write (&sbi->pin_sem); done += map.m_len;fs/f2fs/gc.c +1
-1@@ -1448,7 +1448,7 @@ static int free_segment_range(struct f2fs_sb_info *sbi,mutex_unlock (&DIRTY_I (sbi)->seglist_lock);/* Move out cursegs from the target range */ -for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_TYPE ; type++) +for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_PERSIST_TYPE ; type++)f2fs_allocate_segment_for_resize (sbi, type, start, end);/* do GC to move out valid blocks in the range */ fs/f2fs/segment.c +74
-33@@ -1958,7 +1958,7 @@ static void set_prefree_as_free_segments(struct f2fs_sb_info *sbi)mutex_lock (&dirty_i->seglist_lock);for_each_set_bit (segno, dirty_i->dirty_segmap[PRE ],MAIN_SEGS (sbi)) -__set_test_and_free (sbi, segno); +__set_test_and_free (sbi, segno, false);mutex_unlock (&dirty_i->seglist_lock); }@@ -2496,6 +2496,7 @@ static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified)struct curseg_info *curseg =CURSEG_I (sbi, type);struct summary_footer *sum_footer; + curseg->inited = true; curseg->segno = curseg->next_segno; curseg->zone =GET_ZONE_FROM_SEG (sbi, curseg->segno); curseg->next_blkoff =0 ;@@ -2503,24 +2504,31 @@ static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified) sum_footer = &(curseg->sum_blk->footer);memset (sum_footer,0 ,sizeof (struct summary_footer )); -if (IS_DATASEG (type)) +if (IS_DATASEG (curseg->seg_type))SET_SUM_TYPE (sum_footer,SUM_TYPE_DATA ); -if (IS_NODESEG (type)) +if (IS_NODESEG (curseg->seg_type))SET_SUM_TYPE (sum_footer,SUM_TYPE_NODE ); -__set_sit_entry_type (sbi, type, curseg->segno, modified); +__set_sit_entry_type (sbi, curseg->seg_type, curseg->segno, modified); }static unsigned int __get_next_segno (struct f2fs_sb_info *sbi,int type) { +struct curseg_info *curseg =CURSEG_I (sbi, type); +/* if segs_per_sec is large than 1, we need to keep original policy. */ if (__is_large_section (sbi)) -return CURSEG_I (sbi, type)->segno; +return curseg->segno; + +/* inmem log may not locate on any segment after mount */ +if (!curseg->inited) +return 0 ;if (unlikely (is_sbi_flag_set (sbi,SBI_CP_DISABLED )))return 0 ;if (test_opt (sbi,NOHEAP ) && - (type ==CURSEG_HOT_DATA ||IS_NODESEG (type))) + (curseg->seg_type ==CURSEG_HOT_DATA || +IS_NODESEG (curseg->seg_type)))return 0 ;if (SIT_I (sbi)->last_victim[ALLOC_NEXT ])@@ -2530,7 +2538,7 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)if (F2FS_OPTION (sbi).alloc_mode ==ALLOC_MODE_REUSE )return 0 ; -return CURSEG_I (sbi, type)->segno; +return curseg->segno; }/* @@ -2540,12 +2548,14 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)static void new_curseg (struct f2fs_sb_info *sbi,int type,bool new_sec) {struct curseg_info *curseg =CURSEG_I (sbi, type); +unsigned short seg_type = curseg->seg_type;unsigned int segno = curseg->segno;int dir =ALLOC_LEFT ; -write_sum_page (sbi, curseg->sum_blk, +if (curseg->inited) +write_sum_page (sbi, curseg->sum_blk,GET_SUM_BLOCK (sbi, segno)); -if (type ==CURSEG_WARM_DATA || type ==CURSEG_COLD_DATA ) +if (seg_type ==CURSEG_WARM_DATA || seg_type ==CURSEG_COLD_DATA ) dir =ALLOC_RIGHT ;if (test_opt (sbi,NOHEAP ))@@ -2622,6 +2632,43 @@ static void change_curseg(struct f2fs_sb_info *sbi, int type)f2fs_put_page (sum_page,1 ); } +void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi,int type) +{ +struct curseg_info *curseg =CURSEG_I (sbi, type); + +mutex_lock (&curseg->curseg_mutex); +if (!curseg->inited) + goto out; + +if (get_valid_blocks (sbi, curseg->segno, false)) { +write_sum_page (sbi, curseg->sum_blk, +GET_SUM_BLOCK (sbi, curseg->segno)); + }else { +mutex_lock (&DIRTY_I (sbi)->seglist_lock); +__set_test_and_free (sbi, curseg->segno, true); +mutex_unlock (&DIRTY_I (sbi)->seglist_lock); + } +out: +mutex_unlock (&curseg->curseg_mutex); +} + +void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi,int type) +{ +struct curseg_info *curseg =CURSEG_I (sbi, type); + +mutex_lock (&curseg->curseg_mutex); +if (!curseg->inited) + goto out; +if (get_valid_blocks (sbi, curseg->segno, false)) + goto out; + +mutex_lock (&DIRTY_I (sbi)->seglist_lock); +__set_test_and_inuse (sbi, curseg->segno); +mutex_unlock (&DIRTY_I (sbi)->seglist_lock); +out: +mutex_unlock (&curseg->curseg_mutex); +} +static int get_ssr_segment (struct f2fs_sb_info *sbi,int type) {struct curseg_info *curseg =CURSEG_I (sbi, type);@@ -2738,11 +2785,15 @@ void __allocate_new_segment(struct f2fs_sb_info *sbi, int type)struct curseg_info *curseg =CURSEG_I (sbi, type);unsigned int old_segno; +if (!curseg->inited) + goto alloc; +if (!curseg->next_blkoff && !get_valid_blocks (sbi, curseg->segno, false) && !get_ckpt_valid_blocks (sbi, curseg->segno))return ; +alloc: old_segno = curseg->segno;SIT_I (sbi)->s_ops->allocate_segment (sbi, type, true);locate_dirty_segment (sbi, old_segno);@@ -3126,19 +3177,6 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, {struct sit_info *sit_i =SIT_I (sbi);struct curseg_info *curseg =CURSEG_I (sbi, type); -bool put_pin_sem = false; - -if (type ==CURSEG_COLD_DATA ) { -/* GC during CURSEG_COLD_DATA_PINNED allocation */ -if (down_read_trylock (&sbi->pin_sem)) { - put_pin_sem = true; - }else { - type =CURSEG_WARM_DATA ; - curseg =CURSEG_I (sbi, type); - } - }else if (type ==CURSEG_COLD_DATA_PINNED ) { - type =CURSEG_COLD_DATA ; - }down_read (&SM_I (sbi)->curseg_lock);@@ -3204,9 +3242,6 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,mutex_unlock (&curseg->curseg_mutex);up_read (&SM_I (sbi)->curseg_lock); - -if (put_pin_sem) -up_read (&sbi->pin_sem); }static void update_device_state (struct f2fs_io_info *fio)@@ -3574,7 +3609,7 @@ static int read_normal_summaries(struct f2fs_sb_info *sbi, int type) blk_off =le16_to_cpu (ckpt->cur_data_blkoff[type -CURSEG_HOT_DATA ]);if (__exist_node_summaries (sbi)) - blk_addr =sum_blk_addr (sbi,NR_CURSEG_TYPE , type); + blk_addr =sum_blk_addr (sbi,NR_CURSEG_PERSIST_TYPE , type);else blk_addr =sum_blk_addr (sbi,NR_CURSEG_DATA_TYPE , type); }else {@@ -3652,8 +3687,9 @@ static int restore_curseg_summaries(struct f2fs_sb_info *sbi) }if (__exist_node_summaries (sbi)) -f2fs_ra_meta_pages (sbi,sum_blk_addr (sbi,NR_CURSEG_TYPE , type), -NR_CURSEG_TYPE - type,META_CP , true); +f2fs_ra_meta_pages (sbi, +sum_blk_addr (sbi,NR_CURSEG_PERSIST_TYPE , type), +NR_CURSEG_PERSIST_TYPE - type,META_CP , true);for (; type <=CURSEG_COLD_NODE ; type++) { err =read_normal_summaries (sbi, type);@@ -4155,14 +4191,14 @@ static int build_curseg(struct f2fs_sb_info *sbi)struct curseg_info *array;int i; - array =f2fs_kzalloc (sbi,array_size (NR_CURSEG_TYPE ,sizeof (*array)), -GFP_KERNEL ); + array =f2fs_kzalloc (sbi,array_size (NR_CURSEG_TYPE , +sizeof (*array)),GFP_KERNEL );if (!array)return -ENOMEM ;SM_I (sbi)->curseg_array = array; -for (i =0 ; i <NR_CURSEG_TYPE ; i++) { +for (i =0 ; i <NO_CHECK_TYPE ; i++) {mutex_init (&array[i].curseg_mutex); array[i].sum_blk =f2fs_kzalloc (sbi,PAGE_SIZE ,GFP_KERNEL );if (!array[i].sum_blk)@@ -4172,8 +4208,13 @@ static int build_curseg(struct f2fs_sb_info *sbi) sizeof(struct f2fs_journal), GFP_KERNEL);if (!array[i].journal)return -ENOMEM ; +if (i <NR_PERSISTENT_LOG ) + array[i].seg_type =CURSEG_HOT_DATA + i; +else if (i ==CURSEG_COLD_DATA_PINNED ) + array[i].seg_type =CURSEG_COLD_DATA ; array[i].segno =NULL_SEGNO ; array[i].next_blkoff =0 ; + array[i].inited = false; }return restore_curseg_summaries (sbi); }@@ -4408,7 +4449,7 @@ static int sanity_check_curseg(struct f2fs_sb_info *sbi)* In LFS/SSR curseg, .next_blkoff should point to an unused blkaddr; * In LFS curseg, all blkaddr after .next_blkoff should be unused. */ -for (i =0 ; i <NO_CHECK_TYPE ; i++) { +for (i =0 ; i <NR_PERSISTENT_LOG ; i++) {struct curseg_info *curseg =CURSEG_I (sbi, i);struct seg_entry *se =get_seg_entry (sbi, curseg->segno);unsigned int blkofs = curseg->next_blkoff;@@ -4637,7 +4678,7 @@ int f2fs_fix_curseg_write_pointer(struct f2fs_sb_info *sbi) {int i, ret; -for (i =0 ; i <NO_CHECK_TYPE ; i++) { +for (i =0 ; i <NR_PERSISTENT_LOG ; i++) { ret =fix_curseg_write_pointer (sbi, i);if (ret)return ret;fs/f2fs/segment.h +10
-7@@ -22,7 +22,7 @@#define GET_R2L_SEGNO (free_i, segno) ((segno) + (free_i)->start_segno)#define IS_DATASEG (t) ((t) <= CURSEG_COLD_DATA) -#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE) +#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE && (t) <= CURSEG_COLD_NODE)#define IS_HOT (t) ((t) == CURSEG_HOT_NODE || (t) == CURSEG_HOT_DATA)#define IS_WARM (t) ((t) == CURSEG_WARM_NODE || (t) == CURSEG_WARM_DATA)@@ -34,7 +34,8 @@ ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_HOT_NODE)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno) || \ - ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno)) + ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno) || \ + ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno))#define IS_CURSEC (sbi, secno) \ (((secno) == CURSEG_I(sbi, CURSEG_HOT_DATA)->segno / \@@ -48,7 +49,9 @@ ((secno) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno / \ (sbi)->segs_per_sec) || \ ((secno) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno / \ - (sbi)->segs_per_sec)) \ + (sbi)->segs_per_sec) || \ + ((secno) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno / \ + (sbi)->segs_per_sec))#define MAIN_BLKADDR (sbi) \ (SM_I(sbi) ? SM_I(sbi)->main_blkaddr : \@@ -288,10 +291,12 @@ struct curseg_info {struct rw_semaphore journal_rwsem;/* protect journal area */ struct f2fs_journal *journal;/* cached journal info */ unsigned char alloc_type;/* current allocation type */ +unsigned short seg_type;/* segment type like CURSEG_XXX_TYPE */ unsigned int segno;/* current segment number */ unsigned short next_blkoff;/* next block offset to write */ unsigned int zone;/* current zone number */ unsigned int next_segno;/* preallocated segment */ +bool inited;/* indicate inmem log is inited */ };struct sit_entry_set {@@ -305,8 +310,6 @@ struct sit_entry_set {*/ static inline struct curseg_info *CURSEG_I (struct f2fs_sb_info *sbi,int type) { -if (type ==CURSEG_COLD_DATA_PINNED ) - type =CURSEG_COLD_DATA ;return (struct curseg_info *)(SM_I (sbi)->curseg_array + type); }@@ -438,7 +441,7 @@ static inline void __set_inuse(struct f2fs_sb_info *sbi, }static inline void __set_test_and_free (struct f2fs_sb_info *sbi, -unsigned int segno) +unsigned int segno,bool inmem) {struct free_segmap_info *free_i =FREE_I (sbi);unsigned int secno =GET_SEC_FROM_SEG (sbi, segno);@@ -449,7 +452,7 @@ static inline void __set_test_and_free(struct f2fs_sb_info *sbi,if (test_and_clear_bit (segno, free_i->free_segmap)) { free_i->free_segments++; -if (IS_CURSEC (sbi, secno)) +if (!inmem &&IS_CURSEC (sbi, secno)) goto skip_free; next =find_next_bit (free_i->free_segmap, start_segno + sbi->segs_per_sec, start_segno);fs/f2fs/super.c +5
-4@@ -575,7 +575,8 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)case Opt_active_logs:if (args->from &&match_int (args, &arg))return -EINVAL ; -if (arg !=2 && arg !=4 && arg !=NR_CURSEG_TYPE ) +if (arg !=2 && arg !=4 && + arg !=NR_CURSEG_PERSIST_TYPE )return -EINVAL ;F2FS_OPTION (sbi).active_logs = arg;break ;@@ -981,7 +982,7 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) }/* Not pass down write hints if the number of active logs is lesser -* than NR_CURSEG_TYPE. +* than NR_CURSEG_PERSIST_TYPE. */ if (F2FS_OPTION (sbi).active_logs !=NR_CURSEG_TYPE )F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ;@@ -1614,7 +1615,7 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)static void default_options (struct f2fs_sb_info *sbi) {/* init some FS parameters */ -F2FS_OPTION (sbi).active_logs =NR_CURSEG_TYPE ; +F2FS_OPTION (sbi).active_logs =NR_CURSEG_PERSIST_TYPE ;F2FS_OPTION (sbi).inline_xattr_size =DEFAULT_INLINE_XATTR_ADDRS ;F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ;F2FS_OPTION (sbi).alloc_mode =ALLOC_MODE_DEFAULT ;@@ -2946,7 +2947,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi) cp_payload =__cp_payload (sbi);if (cp_pack_start_sum < cp_payload +1 || cp_pack_start_sum > blocks_per_seg -1 - -NR_CURSEG_TYPE ) { +NR_CURSEG_PERSIST_TYPE ) {f2fs_err (sbi,"Wrong cp_pack_start_sum: %u" , cp_pack_start_sum);return 1 ;Signature · 1 line
2.26.2.
Jaegeuk Kim
maintainerQuoted 10 lines · Chao Yu
Quoted 3 lines · Jaegeuk Kim
Hi Chao,
Do you have any brief design doc to present the idea?
Hi Jaegeuk,
You mean this whole patchset, right?
I can add a brief design description in patch 0/5.
Yeah, it's a bit hard to understand the whole flow.
Thanks,
Quoted 526 lines
Quoted 526 lines
Thanks,
Quoted 519 lines · Chao Yu
Previous implementation of aligned pinfile allocation will:
- allocate new segment on cold data log no matter whether last used segment is partially used or not, it makes IOs more random;
- force concurrent cold data/GCed IO going into warm data area, it can make a bad effect on hot/cold data separation;In this patch, we introduce a new type of log named 'inmem curseg', the differents from normal curseg is:
- it reuses existed segment type (CURSEG_XXX_NODE/DATA);
- it only exists in memory, its segno, blkofs, summary will not b persisted into checkpoint area;With this new feature, we can enhance scalability of log, special allocators can be created for purposes:
- pure lfs allocator for aligned pinfile allocation or file defragmentation
- pure ssr allocator for later featureSo that, let's update aligned pinfile allocation to use this new inmem curseg fwk.
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/checkpoint.c | 7 ++- fs/f2fs/debug.c | 6 ++- fs/f2fs/f2fs.h | 12 +++-- fs/f2fs/file.c | 3 +- fs/f2fs/gc.c | 2 +- fs/f2fs/segment.c | 107 ++++++++++++++++++++++++++++++------------- fs/f2fs/segment.h | 17 ++++--- fs/f2fs/super.c | 9 ++-- 8 files changed, 112 insertions(+), 51 deletions(-)fs/f2fs/checkpoint.c +6
-1@@ -1623,11 +1623,16 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)f2fs_flush_sit_entries (sbi, cpc); +/* save inmem log status */ +f2fs_save_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); + err =do_checkpoint (sbi, cpc);if (err)f2fs_release_discard_addrs (sbi);else f2fs_clear_prefree_segments (sbi, cpc); + +f2fs_restore_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); stop:unblock_operations (sbi);stat_inc_cp_count (sbi->stat_info);@@ -1658,7 +1663,7 @@ void f2fs_init_ino_entry_info(struct f2fs_sb_info *sbi) } sbi->max_orphans = (sbi->blocks_per_seg -F2FS_CP_PACKS - -NR_CURSEG_TYPE -__cp_payload (sbi)) * +NR_CURSEG_PERSIST_TYPE -__cp_payload (sbi)) *F2FS_ORPHANS_PER_BLOCK ; }fs/f2fs/debug.c +5
-1@@ -164,7 +164,7 @@ static void update_general_status(struct f2fs_sb_info *sbi) *100 / (int )(sbi->user_block_count >> sbi->log_blocks_per_seg) /2 ; si->util_invalid =50 - si->util_free - si->util_valid; -for (i =CURSEG_HOT_DATA ; i <=CURSEG_COLD_NODE ; i++) { +for (i =CURSEG_HOT_DATA ; i <NO_CHECK_TYPE ; i++) {struct curseg_info *curseg =CURSEG_I (sbi, i); si->curseg[i] = curseg->segno; si->cursec[i] =GET_SEC_FROM_SEG (sbi, curseg->segno);@@ -393,6 +393,10 @@ static int stat_show(struct seq_file *s, void *v) si->dirty_seg[CURSEG_COLD_NODE ], si->full_seg[CURSEG_COLD_NODE ], si->valid_blks[CURSEG_COLD_NODE]); +seq_printf (s," - Pinned file: %8d %8d %8d\n" , + si->curseg[CURSEG_COLD_DATA_PINNED ], + si->cursec[CURSEG_COLD_DATA_PINNED ], + si->curzone[CURSEG_COLD_DATA_PINNED ]); seq_printf(s, "\n - Valid: %d\n - Dirty: %d\n", si->main_area_segs - si->dirty_count - si->prefree_count - si->free_segs,fs/f2fs/f2fs.h +9
-3@@ -996,7 +996,9 @@ static inline void set_new_dnode(struct dnode_of_data *dn, struct inode *inode,*/ #define NR_CURSEG_DATA_TYPE (3)#define NR_CURSEG_NODE_TYPE (3) -#define NR_CURSEG_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) +#define NR_CURSEG_INMEM_TYPE (1) +#define NR_CURSEG_PERSIST_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) +#define NR_CURSEG_TYPE (NR_CURSEG_INMEM_TYPE + NR_CURSEG_PERSIST_TYPE)enum {CURSEG_HOT_DATA =0 ,/* directory entry blocks */ @@ -1005,8 +1007,10 @@ enum {CURSEG_HOT_NODE ,/* direct node blocks of directory files */ CURSEG_WARM_NODE ,/* direct node blocks of normal files */ CURSEG_COLD_NODE ,/* indirect node blocks */ -NO_CHECK_TYPE , - CURSEG_COLD_DATA_PINNED,/* cold data for pinned file */ +NR_PERSISTENT_LOG ,/* number of persistent log */ +CURSEG_COLD_DATA_PINNED =NR_PERSISTENT_LOG , +/* pinned file that needs consecutive block address */ + NO_CHECK_TYPE, /* number of persistent & inmem log */ }; struct flush_cmd {@@ -3359,6 +3363,8 @@ block_t f2fs_get_unusable_blocks(struct f2fs_sb_info *sbi);int f2fs_disable_cp_again (struct f2fs_sb_info *sbi,block_t unusable);void f2fs_release_discard_addrs (struct f2fs_sb_info *sbi);int f2fs_npages_for_summary_flush (struct f2fs_sb_info *sbi,bool for_ra); +void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi,int type); +void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi,int type);void f2fs_allocate_segment_for_resize (struct f2fs_sb_info *sbi,int type,unsigned int start,unsigned int end);void f2fs_allocate_new_segment (struct f2fs_sb_info *sbi,int type);fs/f2fs/file.c +2
-1@@ -1656,13 +1656,14 @@ static int expand_inode_data(struct inode *inode, loff_t offset, }down_write (&sbi->pin_sem); - map.m_seg_type =CURSEG_COLD_DATA_PINNED ;f2fs_lock_op (sbi);f2fs_allocate_new_segment (sbi,CURSEG_COLD_DATA );f2fs_unlock_op (sbi); + map.m_seg_type =CURSEG_COLD_DATA_PINNED ; err =f2fs_map_blocks (inode, &map,1 ,F2FS_GET_BLOCK_PRE_DIO ); +up_write (&sbi->pin_sem); done += map.m_len;fs/f2fs/gc.c +1
-1@@ -1448,7 +1448,7 @@ static int free_segment_range(struct f2fs_sb_info *sbi,mutex_unlock (&DIRTY_I (sbi)->seglist_lock);/* Move out cursegs from the target range */ -for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_TYPE ; type++) +for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_PERSIST_TYPE ; type++)f2fs_allocate_segment_for_resize (sbi, type, start, end);/* do GC to move out valid blocks in the range */ fs/f2fs/segment.c +74
-33@@ -1958,7 +1958,7 @@ static void set_prefree_as_free_segments(struct f2fs_sb_info *sbi)mutex_lock (&dirty_i->seglist_lock);for_each_set_bit (segno, dirty_i->dirty_segmap[PRE ],MAIN_SEGS (sbi)) -__set_test_and_free (sbi, segno); +__set_test_and_free (sbi, segno, false);mutex_unlock (&dirty_i->seglist_lock); }@@ -2496,6 +2496,7 @@ static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified)struct curseg_info *curseg =CURSEG_I (sbi, type);struct summary_footer *sum_footer; + curseg->inited = true; curseg->segno = curseg->next_segno; curseg->zone =GET_ZONE_FROM_SEG (sbi, curseg->segno); curseg->next_blkoff =0 ;@@ -2503,24 +2504,31 @@ static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified) sum_footer = &(curseg->sum_blk->footer);memset (sum_footer,0 ,sizeof (struct summary_footer )); -if (IS_DATASEG (type)) +if (IS_DATASEG (curseg->seg_type))SET_SUM_TYPE (sum_footer,SUM_TYPE_DATA ); -if (IS_NODESEG (type)) +if (IS_NODESEG (curseg->seg_type))SET_SUM_TYPE (sum_footer,SUM_TYPE_NODE ); -__set_sit_entry_type (sbi, type, curseg->segno, modified); +__set_sit_entry_type (sbi, curseg->seg_type, curseg->segno, modified); }static unsigned int __get_next_segno (struct f2fs_sb_info *sbi,int type) { +struct curseg_info *curseg =CURSEG_I (sbi, type); +/* if segs_per_sec is large than 1, we need to keep original policy. */ if (__is_large_section (sbi)) -return CURSEG_I (sbi, type)->segno; +return curseg->segno; + +/* inmem log may not locate on any segment after mount */ +if (!curseg->inited) +return 0 ;if (unlikely (is_sbi_flag_set (sbi,SBI_CP_DISABLED )))return 0 ;if (test_opt (sbi,NOHEAP ) && - (type ==CURSEG_HOT_DATA ||IS_NODESEG (type))) + (curseg->seg_type ==CURSEG_HOT_DATA || +IS_NODESEG (curseg->seg_type)))return 0 ;if (SIT_I (sbi)->last_victim[ALLOC_NEXT ])@@ -2530,7 +2538,7 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)if (F2FS_OPTION (sbi).alloc_mode ==ALLOC_MODE_REUSE )return 0 ; -return CURSEG_I (sbi, type)->segno; +return curseg->segno; }/* @@ -2540,12 +2548,14 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)static void new_curseg (struct f2fs_sb_info *sbi,int type,bool new_sec) {struct curseg_info *curseg =CURSEG_I (sbi, type); +unsigned short seg_type = curseg->seg_type;unsigned int segno = curseg->segno;int dir =ALLOC_LEFT ; -write_sum_page (sbi, curseg->sum_blk, +if (curseg->inited) +write_sum_page (sbi, curseg->sum_blk,GET_SUM_BLOCK (sbi, segno)); -if (type ==CURSEG_WARM_DATA || type ==CURSEG_COLD_DATA ) +if (seg_type ==CURSEG_WARM_DATA || seg_type ==CURSEG_COLD_DATA ) dir =ALLOC_RIGHT ;if (test_opt (sbi,NOHEAP ))@@ -2622,6 +2632,43 @@ static void change_curseg(struct f2fs_sb_info *sbi, int type)f2fs_put_page (sum_page,1 ); } +void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi,int type) +{ +struct curseg_info *curseg =CURSEG_I (sbi, type); + +mutex_lock (&curseg->curseg_mutex); +if (!curseg->inited) + goto out; + +if (get_valid_blocks (sbi, curseg->segno, false)) { +write_sum_page (sbi, curseg->sum_blk, +GET_SUM_BLOCK (sbi, curseg->segno)); + }else { +mutex_lock (&DIRTY_I (sbi)->seglist_lock); +__set_test_and_free (sbi, curseg->segno, true); +mutex_unlock (&DIRTY_I (sbi)->seglist_lock); + } +out: +mutex_unlock (&curseg->curseg_mutex); +} + +void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi,int type) +{ +struct curseg_info *curseg =CURSEG_I (sbi, type); + +mutex_lock (&curseg->curseg_mutex); +if (!curseg->inited) + goto out; +if (get_valid_blocks (sbi, curseg->segno, false)) + goto out; + +mutex_lock (&DIRTY_I (sbi)->seglist_lock); +__set_test_and_inuse (sbi, curseg->segno); +mutex_unlock (&DIRTY_I (sbi)->seglist_lock); +out: +mutex_unlock (&curseg->curseg_mutex); +} +static int get_ssr_segment (struct f2fs_sb_info *sbi,int type) {struct curseg_info *curseg =CURSEG_I (sbi, type);@@ -2738,11 +2785,15 @@ void __allocate_new_segment(struct f2fs_sb_info *sbi, int type)struct curseg_info *curseg =CURSEG_I (sbi, type);unsigned int old_segno; +if (!curseg->inited) + goto alloc; +if (!curseg->next_blkoff && !get_valid_blocks (sbi, curseg->segno, false) && !get_ckpt_valid_blocks (sbi, curseg->segno))return ; +alloc: old_segno = curseg->segno;SIT_I (sbi)->s_ops->allocate_segment (sbi, type, true);locate_dirty_segment (sbi, old_segno);@@ -3126,19 +3177,6 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, {struct sit_info *sit_i =SIT_I (sbi);struct curseg_info *curseg =CURSEG_I (sbi, type); -bool put_pin_sem = false; - -if (type ==CURSEG_COLD_DATA ) { -/* GC during CURSEG_COLD_DATA_PINNED allocation */ -if (down_read_trylock (&sbi->pin_sem)) { - put_pin_sem = true; - }else { - type =CURSEG_WARM_DATA ; - curseg =CURSEG_I (sbi, type); - } - }else if (type ==CURSEG_COLD_DATA_PINNED ) { - type =CURSEG_COLD_DATA ; - }down_read (&SM_I (sbi)->curseg_lock);@@ -3204,9 +3242,6 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,mutex_unlock (&curseg->curseg_mutex);up_read (&SM_I (sbi)->curseg_lock); - -if (put_pin_sem) -up_read (&sbi->pin_sem); }static void update_device_state (struct f2fs_io_info *fio)@@ -3574,7 +3609,7 @@ static int read_normal_summaries(struct f2fs_sb_info *sbi, int type) blk_off =le16_to_cpu (ckpt->cur_data_blkoff[type -CURSEG_HOT_DATA ]);if (__exist_node_summaries (sbi)) - blk_addr =sum_blk_addr (sbi,NR_CURSEG_TYPE , type); + blk_addr =sum_blk_addr (sbi,NR_CURSEG_PERSIST_TYPE , type);else blk_addr =sum_blk_addr (sbi,NR_CURSEG_DATA_TYPE , type); }else {@@ -3652,8 +3687,9 @@ static int restore_curseg_summaries(struct f2fs_sb_info *sbi) }if (__exist_node_summaries (sbi)) -f2fs_ra_meta_pages (sbi,sum_blk_addr (sbi,NR_CURSEG_TYPE , type), -NR_CURSEG_TYPE - type,META_CP , true); +f2fs_ra_meta_pages (sbi, +sum_blk_addr (sbi,NR_CURSEG_PERSIST_TYPE , type), +NR_CURSEG_PERSIST_TYPE - type,META_CP , true);for (; type <=CURSEG_COLD_NODE ; type++) { err =read_normal_summaries (sbi, type);@@ -4155,14 +4191,14 @@ static int build_curseg(struct f2fs_sb_info *sbi)struct curseg_info *array;int i; - array =f2fs_kzalloc (sbi,array_size (NR_CURSEG_TYPE ,sizeof (*array)), -GFP_KERNEL ); + array =f2fs_kzalloc (sbi,array_size (NR_CURSEG_TYPE , +sizeof (*array)),GFP_KERNEL );if (!array)return -ENOMEM ;SM_I (sbi)->curseg_array = array; -for (i =0 ; i <NR_CURSEG_TYPE ; i++) { +for (i =0 ; i <NO_CHECK_TYPE ; i++) {mutex_init (&array[i].curseg_mutex); array[i].sum_blk =f2fs_kzalloc (sbi,PAGE_SIZE ,GFP_KERNEL );if (!array[i].sum_blk)@@ -4172,8 +4208,13 @@ static int build_curseg(struct f2fs_sb_info *sbi) sizeof(struct f2fs_journal), GFP_KERNEL);if (!array[i].journal)return -ENOMEM ; +if (i <NR_PERSISTENT_LOG ) + array[i].seg_type =CURSEG_HOT_DATA + i; +else if (i ==CURSEG_COLD_DATA_PINNED ) + array[i].seg_type =CURSEG_COLD_DATA ; array[i].segno =NULL_SEGNO ; array[i].next_blkoff =0 ; + array[i].inited = false; }return restore_curseg_summaries (sbi); }@@ -4408,7 +4449,7 @@ static int sanity_check_curseg(struct f2fs_sb_info *sbi)* In LFS/SSR curseg, .next_blkoff should point to an unused blkaddr; * In LFS curseg, all blkaddr after .next_blkoff should be unused. */ -for (i =0 ; i <NO_CHECK_TYPE ; i++) { +for (i =0 ; i <NR_PERSISTENT_LOG ; i++) {struct curseg_info *curseg =CURSEG_I (sbi, i);struct seg_entry *se =get_seg_entry (sbi, curseg->segno);unsigned int blkofs = curseg->next_blkoff;@@ -4637,7 +4678,7 @@ int f2fs_fix_curseg_write_pointer(struct f2fs_sb_info *sbi) {int i, ret; -for (i =0 ; i <NO_CHECK_TYPE ; i++) { +for (i =0 ; i <NR_PERSISTENT_LOG ; i++) { ret =fix_curseg_write_pointer (sbi, i);if (ret)return ret;fs/f2fs/segment.h +10
-7@@ -22,7 +22,7 @@#define GET_R2L_SEGNO (free_i, segno) ((segno) + (free_i)->start_segno)#define IS_DATASEG (t) ((t) <= CURSEG_COLD_DATA) -#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE) +#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE && (t) <= CURSEG_COLD_NODE)#define IS_HOT (t) ((t) == CURSEG_HOT_NODE || (t) == CURSEG_HOT_DATA)#define IS_WARM (t) ((t) == CURSEG_WARM_NODE || (t) == CURSEG_WARM_DATA)@@ -34,7 +34,8 @@ ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_HOT_NODE)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno) || \ - ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno)) + ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno) || \ + ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno))#define IS_CURSEC (sbi, secno) \ (((secno) == CURSEG_I(sbi, CURSEG_HOT_DATA)->segno / \@@ -48,7 +49,9 @@ ((secno) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno / \ (sbi)->segs_per_sec) || \ ((secno) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno / \ - (sbi)->segs_per_sec)) \ + (sbi)->segs_per_sec) || \ + ((secno) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno / \ + (sbi)->segs_per_sec))#define MAIN_BLKADDR (sbi) \ (SM_I(sbi) ? SM_I(sbi)->main_blkaddr : \@@ -288,10 +291,12 @@ struct curseg_info {struct rw_semaphore journal_rwsem;/* protect journal area */ struct f2fs_journal *journal;/* cached journal info */ unsigned char alloc_type;/* current allocation type */ +unsigned short seg_type;/* segment type like CURSEG_XXX_TYPE */ unsigned int segno;/* current segment number */ unsigned short next_blkoff;/* next block offset to write */ unsigned int zone;/* current zone number */ unsigned int next_segno;/* preallocated segment */ +bool inited;/* indicate inmem log is inited */ };struct sit_entry_set {@@ -305,8 +310,6 @@ struct sit_entry_set {*/ static inline struct curseg_info *CURSEG_I (struct f2fs_sb_info *sbi,int type) { -if (type ==CURSEG_COLD_DATA_PINNED ) - type =CURSEG_COLD_DATA ;return (struct curseg_info *)(SM_I (sbi)->curseg_array + type); }@@ -438,7 +441,7 @@ static inline void __set_inuse(struct f2fs_sb_info *sbi, }static inline void __set_test_and_free (struct f2fs_sb_info *sbi, -unsigned int segno) +unsigned int segno,bool inmem) {struct free_segmap_info *free_i =FREE_I (sbi);unsigned int secno =GET_SEC_FROM_SEG (sbi, segno);@@ -449,7 +452,7 @@ static inline void __set_test_and_free(struct f2fs_sb_info *sbi,if (test_and_clear_bit (segno, free_i->free_segmap)) { free_i->free_segments++; -if (IS_CURSEC (sbi, secno)) +if (!inmem &&IS_CURSEC (sbi, secno)) goto skip_free; next =find_next_bit (free_i->free_segmap, start_segno + sbi->segs_per_sec, start_segno);fs/f2fs/super.c +5
-4@@ -575,7 +575,8 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)case Opt_active_logs:if (args->from &&match_int (args, &arg))return -EINVAL ; -if (arg !=2 && arg !=4 && arg !=NR_CURSEG_TYPE ) +if (arg !=2 && arg !=4 && + arg !=NR_CURSEG_PERSIST_TYPE )return -EINVAL ;F2FS_OPTION (sbi).active_logs = arg;break ;@@ -981,7 +982,7 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) }/* Not pass down write hints if the number of active logs is lesser -* than NR_CURSEG_TYPE. +* than NR_CURSEG_PERSIST_TYPE. */ if (F2FS_OPTION (sbi).active_logs !=NR_CURSEG_TYPE )F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ;@@ -1614,7 +1615,7 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)static void default_options (struct f2fs_sb_info *sbi) {/* init some FS parameters */ -F2FS_OPTION (sbi).active_logs =NR_CURSEG_TYPE ; +F2FS_OPTION (sbi).active_logs =NR_CURSEG_PERSIST_TYPE ;F2FS_OPTION (sbi).inline_xattr_size =DEFAULT_INLINE_XATTR_ADDRS ;F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ;F2FS_OPTION (sbi).alloc_mode =ALLOC_MODE_DEFAULT ;@@ -2946,7 +2947,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi) cp_payload =__cp_payload (sbi);if (cp_pack_start_sum < cp_payload +1 || cp_pack_start_sum > blocks_per_seg -1 - -NR_CURSEG_TYPE ) { +NR_CURSEG_PERSIST_TYPE ) {f2fs_err (sbi,"Wrong cp_pack_start_sum: %u" , cp_pack_start_sum);return 1 ;Signature · 1 line
2.26.2.
Quoted 6 lines · Jaegeuk Kim
Quoted 5 lines · Chao Yu
Quoted 3 lines · Jaegeuk Kim
Hi Chao,
Do you have any brief design doc to present the idea?
Quoted 7 lines
Quoted 5 lines
Hi Jaegeuk,
You mean this whole patchset, right?
I can add a brief design description in patch 0/5.
Yeah, it's a bit hard to understand the whole flow.
Jaegeuk,
Do you have time to take a look at this idea summarized in [PATCH 0/5]'s cover letter?
Quoted 531 lines
Thanks,
Quoted 518 lines
Quoted 518 lines
Thanks,
Quoted 513 lines · Chao Yu
Previous implementation of aligned pinfile allocation will:
- allocate new segment on cold data log no matter whether last used segment is partially used or not, it makes IOs more random;
- force concurrent cold data/GCed IO going into warm data area, it can make a bad effect on hot/cold data separation;In this patch, we introduce a new type of log named 'inmem curseg', the differents from normal curseg is:
- it reuses existed segment type (CURSEG_XXX_NODE/DATA);
- it only exists in memory, its segno, blkofs, summary will not b persisted into checkpoint area;With this new feature, we can enhance scalability of log, special allocators can be created for purposes:
- pure lfs allocator for aligned pinfile allocation or file defragmentation
- pure ssr allocator for later featureSo that, let's update aligned pinfile allocation to use this new inmem curseg fwk.
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/checkpoint.c | 7 ++- fs/f2fs/debug.c | 6 ++- fs/f2fs/f2fs.h | 12 +++-- fs/f2fs/file.c | 3 +- fs/f2fs/gc.c | 2 +- fs/f2fs/segment.c | 107 ++++++++++++++++++++++++++++++------------- fs/f2fs/segment.h | 17 ++++--- fs/f2fs/super.c | 9 ++-- 8 files changed, 112 insertions(+), 51 deletions(-)fs/f2fs/checkpoint.c +6
-1@@ -1623,11 +1623,16 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)f2fs_flush_sit_entries (sbi, cpc); +/* save inmem log status */ +f2fs_save_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); + err =do_checkpoint (sbi, cpc);if (err)f2fs_release_discard_addrs (sbi);else f2fs_clear_prefree_segments (sbi, cpc); + +f2fs_restore_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); stop:unblock_operations (sbi);stat_inc_cp_count (sbi->stat_info);@@ -1658,7 +1663,7 @@ void f2fs_init_ino_entry_info(struct f2fs_sb_info *sbi) } sbi->max_orphans = (sbi->blocks_per_seg -F2FS_CP_PACKS - -NR_CURSEG_TYPE -__cp_payload (sbi)) * +NR_CURSEG_PERSIST_TYPE -__cp_payload (sbi)) *F2FS_ORPHANS_PER_BLOCK ; }fs/f2fs/debug.c +5
-1@@ -164,7 +164,7 @@ static void update_general_status(struct f2fs_sb_info *sbi) *100 / (int )(sbi->user_block_count >> sbi->log_blocks_per_seg) /2 ; si->util_invalid =50 - si->util_free - si->util_valid; -for (i =CURSEG_HOT_DATA ; i <=CURSEG_COLD_NODE ; i++) { +for (i =CURSEG_HOT_DATA ; i <NO_CHECK_TYPE ; i++) {struct curseg_info *curseg =CURSEG_I (sbi, i); si->curseg[i] = curseg->segno; si->cursec[i] =GET_SEC_FROM_SEG (sbi, curseg->segno);@@ -393,6 +393,10 @@ static int stat_show(struct seq_file *s, void *v) si->dirty_seg[CURSEG_COLD_NODE ], si->full_seg[CURSEG_COLD_NODE ], si->valid_blks[CURSEG_COLD_NODE]); +seq_printf (s," - Pinned file: %8d %8d %8d\n" , + si->curseg[CURSEG_COLD_DATA_PINNED ], + si->cursec[CURSEG_COLD_DATA_PINNED ], + si->curzone[CURSEG_COLD_DATA_PINNED ]); seq_printf(s, "\n - Valid: %d\n - Dirty: %d\n", si->main_area_segs - si->dirty_count - si->prefree_count - si->free_segs,fs/f2fs/f2fs.h +9
-3@@ -996,7 +996,9 @@ static inline void set_new_dnode(struct dnode_of_data *dn, struct inode *inode,*/ #define NR_CURSEG_DATA_TYPE (3)#define NR_CURSEG_NODE_TYPE (3) -#define NR_CURSEG_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) +#define NR_CURSEG_INMEM_TYPE (1) +#define NR_CURSEG_PERSIST_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) +#define NR_CURSEG_TYPE (NR_CURSEG_INMEM_TYPE + NR_CURSEG_PERSIST_TYPE)enum {CURSEG_HOT_DATA =0 ,/* directory entry blocks */ @@ -1005,8 +1007,10 @@ enum {CURSEG_HOT_NODE ,/* direct node blocks of directory files */ CURSEG_WARM_NODE ,/* direct node blocks of normal files */ CURSEG_COLD_NODE ,/* indirect node blocks */ -NO_CHECK_TYPE , - CURSEG_COLD_DATA_PINNED,/* cold data for pinned file */ +NR_PERSISTENT_LOG ,/* number of persistent log */ +CURSEG_COLD_DATA_PINNED =NR_PERSISTENT_LOG , +/* pinned file that needs consecutive block address */ + NO_CHECK_TYPE, /* number of persistent & inmem log */ }; struct flush_cmd {@@ -3359,6 +3363,8 @@ block_t f2fs_get_unusable_blocks(struct f2fs_sb_info *sbi);int f2fs_disable_cp_again (struct f2fs_sb_info *sbi,block_t unusable);void f2fs_release_discard_addrs (struct f2fs_sb_info *sbi);int f2fs_npages_for_summary_flush (struct f2fs_sb_info *sbi,bool for_ra); +void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi,int type); +void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi,int type);void f2fs_allocate_segment_for_resize (struct f2fs_sb_info *sbi,int type,unsigned int start,unsigned int end);void f2fs_allocate_new_segment (struct f2fs_sb_info *sbi,int type);fs/f2fs/file.c +2
-1@@ -1656,13 +1656,14 @@ static int expand_inode_data(struct inode *inode, loff_t offset, }down_write (&sbi->pin_sem); - map.m_seg_type =CURSEG_COLD_DATA_PINNED ;f2fs_lock_op (sbi);f2fs_allocate_new_segment (sbi,CURSEG_COLD_DATA );f2fs_unlock_op (sbi); + map.m_seg_type =CURSEG_COLD_DATA_PINNED ; err =f2fs_map_blocks (inode, &map,1 ,F2FS_GET_BLOCK_PRE_DIO ); +up_write (&sbi->pin_sem); done += map.m_len;fs/f2fs/gc.c +1
-1@@ -1448,7 +1448,7 @@ static int free_segment_range(struct f2fs_sb_info *sbi,mutex_unlock (&DIRTY_I (sbi)->seglist_lock);/* Move out cursegs from the target range */ -for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_TYPE ; type++) +for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_PERSIST_TYPE ; type++)f2fs_allocate_segment_for_resize (sbi, type, start, end);/* do GC to move out valid blocks in the range */ fs/f2fs/segment.c +74
-33@@ -1958,7 +1958,7 @@ static void set_prefree_as_free_segments(struct f2fs_sb_info *sbi)mutex_lock (&dirty_i->seglist_lock);for_each_set_bit (segno, dirty_i->dirty_segmap[PRE ],MAIN_SEGS (sbi)) -__set_test_and_free (sbi, segno); +__set_test_and_free (sbi, segno, false);mutex_unlock (&dirty_i->seglist_lock); }@@ -2496,6 +2496,7 @@ static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified)struct curseg_info *curseg =CURSEG_I (sbi, type);struct summary_footer *sum_footer; + curseg->inited = true; curseg->segno = curseg->next_segno; curseg->zone =GET_ZONE_FROM_SEG (sbi, curseg->segno); curseg->next_blkoff =0 ;@@ -2503,24 +2504,31 @@ static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified) sum_footer = &(curseg->sum_blk->footer);memset (sum_footer,0 ,sizeof (struct summary_footer )); -if (IS_DATASEG (type)) +if (IS_DATASEG (curseg->seg_type))SET_SUM_TYPE (sum_footer,SUM_TYPE_DATA ); -if (IS_NODESEG (type)) +if (IS_NODESEG (curseg->seg_type))SET_SUM_TYPE (sum_footer,SUM_TYPE_NODE ); -__set_sit_entry_type (sbi, type, curseg->segno, modified); +__set_sit_entry_type (sbi, curseg->seg_type, curseg->segno, modified); }static unsigned int __get_next_segno (struct f2fs_sb_info *sbi,int type) { +struct curseg_info *curseg =CURSEG_I (sbi, type); +/* if segs_per_sec is large than 1, we need to keep original policy. */ if (__is_large_section (sbi)) -return CURSEG_I (sbi, type)->segno; +return curseg->segno; + +/* inmem log may not locate on any segment after mount */ +if (!curseg->inited) +return 0 ;if (unlikely (is_sbi_flag_set (sbi,SBI_CP_DISABLED )))return 0 ;if (test_opt (sbi,NOHEAP ) && - (type ==CURSEG_HOT_DATA ||IS_NODESEG (type))) + (curseg->seg_type ==CURSEG_HOT_DATA || +IS_NODESEG (curseg->seg_type)))return 0 ;if (SIT_I (sbi)->last_victim[ALLOC_NEXT ])@@ -2530,7 +2538,7 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)if (F2FS_OPTION (sbi).alloc_mode ==ALLOC_MODE_REUSE )return 0 ; -return CURSEG_I (sbi, type)->segno; +return curseg->segno; }/* @@ -2540,12 +2548,14 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)static void new_curseg (struct f2fs_sb_info *sbi,int type,bool new_sec) {struct curseg_info *curseg =CURSEG_I (sbi, type); +unsigned short seg_type = curseg->seg_type;unsigned int segno = curseg->segno;int dir =ALLOC_LEFT ; -write_sum_page (sbi, curseg->sum_blk, +if (curseg->inited) +write_sum_page (sbi, curseg->sum_blk,GET_SUM_BLOCK (sbi, segno)); -if (type ==CURSEG_WARM_DATA || type ==CURSEG_COLD_DATA ) +if (seg_type ==CURSEG_WARM_DATA || seg_type ==CURSEG_COLD_DATA ) dir =ALLOC_RIGHT ;if (test_opt (sbi,NOHEAP ))@@ -2622,6 +2632,43 @@ static void change_curseg(struct f2fs_sb_info *sbi, int type)f2fs_put_page (sum_page,1 ); } +void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi,int type) +{ +struct curseg_info *curseg =CURSEG_I (sbi, type); + +mutex_lock (&curseg->curseg_mutex); +if (!curseg->inited) + goto out; + +if (get_valid_blocks (sbi, curseg->segno, false)) { +write_sum_page (sbi, curseg->sum_blk, +GET_SUM_BLOCK (sbi, curseg->segno)); + }else { +mutex_lock (&DIRTY_I (sbi)->seglist_lock); +__set_test_and_free (sbi, curseg->segno, true); +mutex_unlock (&DIRTY_I (sbi)->seglist_lock); + } +out: +mutex_unlock (&curseg->curseg_mutex); +} + +void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi,int type) +{ +struct curseg_info *curseg =CURSEG_I (sbi, type); + +mutex_lock (&curseg->curseg_mutex); +if (!curseg->inited) + goto out; +if (get_valid_blocks (sbi, curseg->segno, false)) + goto out; + +mutex_lock (&DIRTY_I (sbi)->seglist_lock); +__set_test_and_inuse (sbi, curseg->segno); +mutex_unlock (&DIRTY_I (sbi)->seglist_lock); +out: +mutex_unlock (&curseg->curseg_mutex); +} +static int get_ssr_segment (struct f2fs_sb_info *sbi,int type) {struct curseg_info *curseg =CURSEG_I (sbi, type);@@ -2738,11 +2785,15 @@ void __allocate_new_segment(struct f2fs_sb_info *sbi, int type)struct curseg_info *curseg =CURSEG_I (sbi, type);unsigned int old_segno; +if (!curseg->inited) + goto alloc; +if (!curseg->next_blkoff && !get_valid_blocks (sbi, curseg->segno, false) && !get_ckpt_valid_blocks (sbi, curseg->segno))return ; +alloc: old_segno = curseg->segno;SIT_I (sbi)->s_ops->allocate_segment (sbi, type, true);locate_dirty_segment (sbi, old_segno);@@ -3126,19 +3177,6 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, {struct sit_info *sit_i =SIT_I (sbi);struct curseg_info *curseg =CURSEG_I (sbi, type); -bool put_pin_sem = false; - -if (type ==CURSEG_COLD_DATA ) { -/* GC during CURSEG_COLD_DATA_PINNED allocation */ -if (down_read_trylock (&sbi->pin_sem)) { - put_pin_sem = true; - }else { - type =CURSEG_WARM_DATA ; - curseg =CURSEG_I (sbi, type); - } - }else if (type ==CURSEG_COLD_DATA_PINNED ) { - type =CURSEG_COLD_DATA ; - }down_read (&SM_I (sbi)->curseg_lock);@@ -3204,9 +3242,6 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,mutex_unlock (&curseg->curseg_mutex);up_read (&SM_I (sbi)->curseg_lock); - -if (put_pin_sem) -up_read (&sbi->pin_sem); }static void update_device_state (struct f2fs_io_info *fio)@@ -3574,7 +3609,7 @@ static int read_normal_summaries(struct f2fs_sb_info *sbi, int type) blk_off =le16_to_cpu (ckpt->cur_data_blkoff[type -CURSEG_HOT_DATA ]);if (__exist_node_summaries (sbi)) - blk_addr =sum_blk_addr (sbi,NR_CURSEG_TYPE , type); + blk_addr =sum_blk_addr (sbi,NR_CURSEG_PERSIST_TYPE , type);else blk_addr =sum_blk_addr (sbi,NR_CURSEG_DATA_TYPE , type); }else {@@ -3652,8 +3687,9 @@ static int restore_curseg_summaries(struct f2fs_sb_info *sbi) }if (__exist_node_summaries (sbi)) -f2fs_ra_meta_pages (sbi,sum_blk_addr (sbi,NR_CURSEG_TYPE , type), -NR_CURSEG_TYPE - type,META_CP , true); +f2fs_ra_meta_pages (sbi, +sum_blk_addr (sbi,NR_CURSEG_PERSIST_TYPE , type), +NR_CURSEG_PERSIST_TYPE - type,META_CP , true);for (; type <=CURSEG_COLD_NODE ; type++) { err =read_normal_summaries (sbi, type);@@ -4155,14 +4191,14 @@ static int build_curseg(struct f2fs_sb_info *sbi)struct curseg_info *array;int i; - array =f2fs_kzalloc (sbi,array_size (NR_CURSEG_TYPE ,sizeof (*array)), -GFP_KERNEL ); + array =f2fs_kzalloc (sbi,array_size (NR_CURSEG_TYPE , +sizeof (*array)),GFP_KERNEL );if (!array)return -ENOMEM ;SM_I (sbi)->curseg_array = array; -for (i =0 ; i <NR_CURSEG_TYPE ; i++) { +for (i =0 ; i <NO_CHECK_TYPE ; i++) {mutex_init (&array[i].curseg_mutex); array[i].sum_blk =f2fs_kzalloc (sbi,PAGE_SIZE ,GFP_KERNEL );if (!array[i].sum_blk)@@ -4172,8 +4208,13 @@ static int build_curseg(struct f2fs_sb_info *sbi) sizeof(struct f2fs_journal), GFP_KERNEL);if (!array[i].journal)return -ENOMEM ; +if (i <NR_PERSISTENT_LOG ) + array[i].seg_type =CURSEG_HOT_DATA + i; +else if (i ==CURSEG_COLD_DATA_PINNED ) + array[i].seg_type =CURSEG_COLD_DATA ; array[i].segno =NULL_SEGNO ; array[i].next_blkoff =0 ; + array[i].inited = false; }return restore_curseg_summaries (sbi); }@@ -4408,7 +4449,7 @@ static int sanity_check_curseg(struct f2fs_sb_info *sbi)* In LFS/SSR curseg, .next_blkoff should point to an unused blkaddr; * In LFS curseg, all blkaddr after .next_blkoff should be unused. */ -for (i =0 ; i <NO_CHECK_TYPE ; i++) { +for (i =0 ; i <NR_PERSISTENT_LOG ; i++) {struct curseg_info *curseg =CURSEG_I (sbi, i);struct seg_entry *se =get_seg_entry (sbi, curseg->segno);unsigned int blkofs = curseg->next_blkoff;@@ -4637,7 +4678,7 @@ int f2fs_fix_curseg_write_pointer(struct f2fs_sb_info *sbi) {int i, ret; -for (i =0 ; i <NO_CHECK_TYPE ; i++) { +for (i =0 ; i <NR_PERSISTENT_LOG ; i++) { ret =fix_curseg_write_pointer (sbi, i);if (ret)return ret;fs/f2fs/segment.h +10
-7@@ -22,7 +22,7 @@#define GET_R2L_SEGNO (free_i, segno) ((segno) + (free_i)->start_segno)#define IS_DATASEG (t) ((t) <= CURSEG_COLD_DATA) -#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE) +#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE && (t) <= CURSEG_COLD_NODE)#define IS_HOT (t) ((t) == CURSEG_HOT_NODE || (t) == CURSEG_HOT_DATA)#define IS_WARM (t) ((t) == CURSEG_WARM_NODE || (t) == CURSEG_WARM_DATA)@@ -34,7 +34,8 @@ ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_HOT_NODE)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno) || \ - ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno)) + ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno) || \ + ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno))#define IS_CURSEC (sbi, secno) \ (((secno) == CURSEG_I(sbi, CURSEG_HOT_DATA)->segno / \@@ -48,7 +49,9 @@ ((secno) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno / \ (sbi)->segs_per_sec) || \ ((secno) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno / \ - (sbi)->segs_per_sec)) \ + (sbi)->segs_per_sec) || \ + ((secno) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno / \ + (sbi)->segs_per_sec))#define MAIN_BLKADDR (sbi) \ (SM_I(sbi) ? SM_I(sbi)->main_blkaddr : \@@ -288,10 +291,12 @@ struct curseg_info {struct rw_semaphore journal_rwsem;/* protect journal area */ struct f2fs_journal *journal;/* cached journal info */ unsigned char alloc_type;/* current allocation type */ +unsigned short seg_type;/* segment type like CURSEG_XXX_TYPE */ unsigned int segno;/* current segment number */ unsigned short next_blkoff;/* next block offset to write */ unsigned int zone;/* current zone number */ unsigned int next_segno;/* preallocated segment */ +bool inited;/* indicate inmem log is inited */ };struct sit_entry_set {@@ -305,8 +310,6 @@ struct sit_entry_set {*/ static inline struct curseg_info *CURSEG_I (struct f2fs_sb_info *sbi,int type) { -if (type ==CURSEG_COLD_DATA_PINNED ) - type =CURSEG_COLD_DATA ;return (struct curseg_info *)(SM_I (sbi)->curseg_array + type); }@@ -438,7 +441,7 @@ static inline void __set_inuse(struct f2fs_sb_info *sbi, }static inline void __set_test_and_free (struct f2fs_sb_info *sbi, -unsigned int segno) +unsigned int segno,bool inmem) {struct free_segmap_info *free_i =FREE_I (sbi);unsigned int secno =GET_SEC_FROM_SEG (sbi, segno);@@ -449,7 +452,7 @@ static inline void __set_test_and_free(struct f2fs_sb_info *sbi,if (test_and_clear_bit (segno, free_i->free_segmap)) { free_i->free_segments++; -if (IS_CURSEC (sbi, secno)) +if (!inmem &&IS_CURSEC (sbi, secno)) goto skip_free; next =find_next_bit (free_i->free_segmap, start_segno + sbi->segs_per_sec, start_segno);fs/f2fs/super.c +4
-4@@ -575,7 +575,8 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)case Opt_active_logs:if (args->from &&match_int (args, &arg))return -EINVAL ; -if (arg !=2 && arg !=4 && arg !=NR_CURSEG_TYPE ) +if (arg !=2 && arg !=4 && + arg !=NR_CURSEG_PERSIST_TYPE )return -EINVAL ;F2FS_OPTION (sbi).active_logs = arg;break ;@@ -981,7 +982,7 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) }/* Not pass down write hints if the number of active logs is lesser -* than NR_CURSEG_TYPE. +* than NR_CURSEG_PERSIST_TYPE. */ if (F2FS_OPTION (sbi).active_logs !=NR_CURSEG_TYPE )F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ;@@ -1614,7 +1615,7 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)static void default_options (struct f2fs_sb_info *sbi) {/* init some FS parameters */ -F2FS_OPTION (sbi).active_logs =NR_CURSEG_TYPE ; +F2FS_OPTION (sbi).active_logs =NR_CURSEG_PERSIST_TYPE ;F2FS_OPTION (sbi).inline_xattr_size =DEFAULT_INLINE_XATTR_ADDRS ;F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ;F2FS_OPTION (sbi).alloc_mode =ALLOC_MODE_DEFAULT ;@@ -2946,7 +2947,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi) cp_payload =__cp_payload (sbi);if (cp_pack_start_sum < cp_payload +1 || cp_pack_start_sum > blocks_per_seg - 1 - -NR_CURSEG_TYPE ) {Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
fs/f2fs/super.c +1
-0+ NR_CURSEG_PERSIST_TYPE) {f2fs_err (sbi,"Wrong cp_pack_start_sum: %u" , cp_pack_start_sum);return 1 ;Signature · 1 line
2.26.2.
.
Jaegeuk Kim
maintainerQuoted 11 lines · Chao Yu
Quoted 10 lines · Jaegeuk Kim
Quoted 9 lines · Chao Yu
Quoted 3 lines · Jaegeuk Kim
Hi Chao,
Do you have any brief design doc to present the idea?
Hi Jaegeuk,
You mean this whole patchset, right?
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
I can add a brief design description in patch 0/5.
Yeah, it's a bit hard to understand the whole flow.
Jaegeuk,
Do you have time to take a look at this idea summarized in [PATCH 0/5]'s cover letter?
Sorry, I couldn't afford to sitting down to review the design. Let me give it a try soon.
Quoted 530 lines
Quoted 530 lines
Thanks,
Quoted 526 lines
Quoted 526 lines
Thanks,
Quoted 519 lines · Chao Yu
Previous implementation of aligned pinfile allocation will:
- allocate new segment on cold data log no matter whether last used segment is partially used or not, it makes IOs more random;
- force concurrent cold data/GCed IO going into warm data area, it can make a bad effect on hot/cold data separation;In this patch, we introduce a new type of log named 'inmem curseg', the differents from normal curseg is:
- it reuses existed segment type (CURSEG_XXX_NODE/DATA);
- it only exists in memory, its segno, blkofs, summary will not b persisted into checkpoint area;With this new feature, we can enhance scalability of log, special allocators can be created for purposes:
- pure lfs allocator for aligned pinfile allocation or file defragmentation
- pure ssr allocator for later featureSo that, let's update aligned pinfile allocation to use this new inmem curseg fwk.
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/checkpoint.c | 7 ++- fs/f2fs/debug.c | 6 ++- fs/f2fs/f2fs.h | 12 +++-- fs/f2fs/file.c | 3 +- fs/f2fs/gc.c | 2 +- fs/f2fs/segment.c | 107 ++++++++++++++++++++++++++++++------------- fs/f2fs/segment.h | 17 ++++--- fs/f2fs/super.c | 9 ++-- 8 files changed, 112 insertions(+), 51 deletions(-)fs/f2fs/checkpoint.c +6
-1@@ -1623,11 +1623,16 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)f2fs_flush_sit_entries (sbi, cpc); +/* save inmem log status */ +f2fs_save_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); + err =do_checkpoint (sbi, cpc);if (err)f2fs_release_discard_addrs (sbi);else f2fs_clear_prefree_segments (sbi, cpc); + +f2fs_restore_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); stop:unblock_operations (sbi);stat_inc_cp_count (sbi->stat_info);@@ -1658,7 +1663,7 @@ void f2fs_init_ino_entry_info(struct f2fs_sb_info *sbi) } sbi->max_orphans = (sbi->blocks_per_seg -F2FS_CP_PACKS - -NR_CURSEG_TYPE -__cp_payload (sbi)) * +NR_CURSEG_PERSIST_TYPE -__cp_payload (sbi)) *F2FS_ORPHANS_PER_BLOCK ; }fs/f2fs/debug.c +5
-1@@ -164,7 +164,7 @@ static void update_general_status(struct f2fs_sb_info *sbi) *100 / (int )(sbi->user_block_count >> sbi->log_blocks_per_seg) /2 ; si->util_invalid =50 - si->util_free - si->util_valid; -for (i =CURSEG_HOT_DATA ; i <=CURSEG_COLD_NODE ; i++) { +for (i =CURSEG_HOT_DATA ; i <NO_CHECK_TYPE ; i++) {struct curseg_info *curseg =CURSEG_I (sbi, i); si->curseg[i] = curseg->segno; si->cursec[i] =GET_SEC_FROM_SEG (sbi, curseg->segno);@@ -393,6 +393,10 @@ static int stat_show(struct seq_file *s, void *v) si->dirty_seg[CURSEG_COLD_NODE ], si->full_seg[CURSEG_COLD_NODE ], si->valid_blks[CURSEG_COLD_NODE]); +seq_printf (s," - Pinned file: %8d %8d %8d\n" , + si->curseg[CURSEG_COLD_DATA_PINNED ], + si->cursec[CURSEG_COLD_DATA_PINNED ], + si->curzone[CURSEG_COLD_DATA_PINNED ]); seq_printf(s, "\n - Valid: %d\n - Dirty: %d\n", si->main_area_segs - si->dirty_count - si->prefree_count - si->free_segs,fs/f2fs/f2fs.h +9
-3@@ -996,7 +996,9 @@ static inline void set_new_dnode(struct dnode_of_data *dn, struct inode *inode,*/ #define NR_CURSEG_DATA_TYPE (3)#define NR_CURSEG_NODE_TYPE (3) -#define NR_CURSEG_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) +#define NR_CURSEG_INMEM_TYPE (1) +#define NR_CURSEG_PERSIST_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) +#define NR_CURSEG_TYPE (NR_CURSEG_INMEM_TYPE + NR_CURSEG_PERSIST_TYPE)enum {CURSEG_HOT_DATA =0 ,/* directory entry blocks */ @@ -1005,8 +1007,10 @@ enum {CURSEG_HOT_NODE ,/* direct node blocks of directory files */ CURSEG_WARM_NODE ,/* direct node blocks of normal files */ CURSEG_COLD_NODE ,/* indirect node blocks */ -NO_CHECK_TYPE , - CURSEG_COLD_DATA_PINNED,/* cold data for pinned file */ +NR_PERSISTENT_LOG ,/* number of persistent log */ +CURSEG_COLD_DATA_PINNED =NR_PERSISTENT_LOG , +/* pinned file that needs consecutive block address */ + NO_CHECK_TYPE, /* number of persistent & inmem log */ }; struct flush_cmd {@@ -3359,6 +3363,8 @@ block_t f2fs_get_unusable_blocks(struct f2fs_sb_info *sbi);int f2fs_disable_cp_again (struct f2fs_sb_info *sbi,block_t unusable);void f2fs_release_discard_addrs (struct f2fs_sb_info *sbi);int f2fs_npages_for_summary_flush (struct f2fs_sb_info *sbi,bool for_ra); +void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi,int type); +void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi,int type);void f2fs_allocate_segment_for_resize (struct f2fs_sb_info *sbi,int type,unsigned int start,unsigned int end);void f2fs_allocate_new_segment (struct f2fs_sb_info *sbi,int type);fs/f2fs/file.c +2
-1@@ -1656,13 +1656,14 @@ static int expand_inode_data(struct inode *inode, loff_t offset, }down_write (&sbi->pin_sem); - map.m_seg_type =CURSEG_COLD_DATA_PINNED ;f2fs_lock_op (sbi);f2fs_allocate_new_segment (sbi,CURSEG_COLD_DATA );f2fs_unlock_op (sbi); + map.m_seg_type =CURSEG_COLD_DATA_PINNED ; err =f2fs_map_blocks (inode, &map,1 ,F2FS_GET_BLOCK_PRE_DIO ); +up_write (&sbi->pin_sem); done += map.m_len;fs/f2fs/gc.c +1
-1@@ -1448,7 +1448,7 @@ static int free_segment_range(struct f2fs_sb_info *sbi,mutex_unlock (&DIRTY_I (sbi)->seglist_lock);/* Move out cursegs from the target range */ -for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_TYPE ; type++) +for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_PERSIST_TYPE ; type++)f2fs_allocate_segment_for_resize (sbi, type, start, end);/* do GC to move out valid blocks in the range */ fs/f2fs/segment.c +74
-33@@ -1958,7 +1958,7 @@ static void set_prefree_as_free_segments(struct f2fs_sb_info *sbi)mutex_lock (&dirty_i->seglist_lock);for_each_set_bit (segno, dirty_i->dirty_segmap[PRE ],MAIN_SEGS (sbi)) -__set_test_and_free (sbi, segno); +__set_test_and_free (sbi, segno, false);mutex_unlock (&dirty_i->seglist_lock); }@@ -2496,6 +2496,7 @@ static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified)struct curseg_info *curseg =CURSEG_I (sbi, type);struct summary_footer *sum_footer; + curseg->inited = true; curseg->segno = curseg->next_segno; curseg->zone =GET_ZONE_FROM_SEG (sbi, curseg->segno); curseg->next_blkoff =0 ;@@ -2503,24 +2504,31 @@ static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified) sum_footer = &(curseg->sum_blk->footer);memset (sum_footer,0 ,sizeof (struct summary_footer )); -if (IS_DATASEG (type)) +if (IS_DATASEG (curseg->seg_type))SET_SUM_TYPE (sum_footer,SUM_TYPE_DATA ); -if (IS_NODESEG (type)) +if (IS_NODESEG (curseg->seg_type))SET_SUM_TYPE (sum_footer,SUM_TYPE_NODE ); -__set_sit_entry_type (sbi, type, curseg->segno, modified); +__set_sit_entry_type (sbi, curseg->seg_type, curseg->segno, modified); }static unsigned int __get_next_segno (struct f2fs_sb_info *sbi,int type) { +struct curseg_info *curseg =CURSEG_I (sbi, type); +/* if segs_per_sec is large than 1, we need to keep original policy. */ if (__is_large_section (sbi)) -return CURSEG_I (sbi, type)->segno; +return curseg->segno; + +/* inmem log may not locate on any segment after mount */ +if (!curseg->inited) +return 0 ;if (unlikely (is_sbi_flag_set (sbi,SBI_CP_DISABLED )))return 0 ;if (test_opt (sbi,NOHEAP ) && - (type ==CURSEG_HOT_DATA ||IS_NODESEG (type))) + (curseg->seg_type ==CURSEG_HOT_DATA || +IS_NODESEG (curseg->seg_type)))return 0 ;if (SIT_I (sbi)->last_victim[ALLOC_NEXT ])@@ -2530,7 +2538,7 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)if (F2FS_OPTION (sbi).alloc_mode ==ALLOC_MODE_REUSE )return 0 ; -return CURSEG_I (sbi, type)->segno; +return curseg->segno; }/* @@ -2540,12 +2548,14 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)static void new_curseg (struct f2fs_sb_info *sbi,int type,bool new_sec) {struct curseg_info *curseg =CURSEG_I (sbi, type); +unsigned short seg_type = curseg->seg_type;unsigned int segno = curseg->segno;int dir =ALLOC_LEFT ; -write_sum_page (sbi, curseg->sum_blk, +if (curseg->inited) +write_sum_page (sbi, curseg->sum_blk,GET_SUM_BLOCK (sbi, segno)); -if (type ==CURSEG_WARM_DATA || type ==CURSEG_COLD_DATA ) +if (seg_type ==CURSEG_WARM_DATA || seg_type ==CURSEG_COLD_DATA ) dir =ALLOC_RIGHT ;if (test_opt (sbi,NOHEAP ))@@ -2622,6 +2632,43 @@ static void change_curseg(struct f2fs_sb_info *sbi, int type)f2fs_put_page (sum_page,1 ); } +void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi,int type) +{ +struct curseg_info *curseg =CURSEG_I (sbi, type); + +mutex_lock (&curseg->curseg_mutex); +if (!curseg->inited) + goto out; + +if (get_valid_blocks (sbi, curseg->segno, false)) { +write_sum_page (sbi, curseg->sum_blk, +GET_SUM_BLOCK (sbi, curseg->segno)); + }else { +mutex_lock (&DIRTY_I (sbi)->seglist_lock); +__set_test_and_free (sbi, curseg->segno, true); +mutex_unlock (&DIRTY_I (sbi)->seglist_lock); + } +out: +mutex_unlock (&curseg->curseg_mutex); +} + +void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi,int type) +{ +struct curseg_info *curseg =CURSEG_I (sbi, type); + +mutex_lock (&curseg->curseg_mutex); +if (!curseg->inited) + goto out; +if (get_valid_blocks (sbi, curseg->segno, false)) + goto out; + +mutex_lock (&DIRTY_I (sbi)->seglist_lock); +__set_test_and_inuse (sbi, curseg->segno); +mutex_unlock (&DIRTY_I (sbi)->seglist_lock); +out: +mutex_unlock (&curseg->curseg_mutex); +} +static int get_ssr_segment (struct f2fs_sb_info *sbi,int type) {struct curseg_info *curseg =CURSEG_I (sbi, type);@@ -2738,11 +2785,15 @@ void __allocate_new_segment(struct f2fs_sb_info *sbi, int type)struct curseg_info *curseg =CURSEG_I (sbi, type);unsigned int old_segno; +if (!curseg->inited) + goto alloc; +if (!curseg->next_blkoff && !get_valid_blocks (sbi, curseg->segno, false) && !get_ckpt_valid_blocks (sbi, curseg->segno))return ; +alloc: old_segno = curseg->segno;SIT_I (sbi)->s_ops->allocate_segment (sbi, type, true);locate_dirty_segment (sbi, old_segno);@@ -3126,19 +3177,6 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, {struct sit_info *sit_i =SIT_I (sbi);struct curseg_info *curseg =CURSEG_I (sbi, type); -bool put_pin_sem = false; - -if (type ==CURSEG_COLD_DATA ) { -/* GC during CURSEG_COLD_DATA_PINNED allocation */ -if (down_read_trylock (&sbi->pin_sem)) { - put_pin_sem = true; - }else { - type =CURSEG_WARM_DATA ; - curseg =CURSEG_I (sbi, type); - } - }else if (type ==CURSEG_COLD_DATA_PINNED ) { - type =CURSEG_COLD_DATA ; - }down_read (&SM_I (sbi)->curseg_lock);@@ -3204,9 +3242,6 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,mutex_unlock (&curseg->curseg_mutex);up_read (&SM_I (sbi)->curseg_lock); - -if (put_pin_sem) -up_read (&sbi->pin_sem); }static void update_device_state (struct f2fs_io_info *fio)@@ -3574,7 +3609,7 @@ static int read_normal_summaries(struct f2fs_sb_info *sbi, int type) blk_off =le16_to_cpu (ckpt->cur_data_blkoff[type -CURSEG_HOT_DATA ]);if (__exist_node_summaries (sbi)) - blk_addr =sum_blk_addr (sbi,NR_CURSEG_TYPE , type); + blk_addr =sum_blk_addr (sbi,NR_CURSEG_PERSIST_TYPE , type);else blk_addr =sum_blk_addr (sbi,NR_CURSEG_DATA_TYPE , type); }else {@@ -3652,8 +3687,9 @@ static int restore_curseg_summaries(struct f2fs_sb_info *sbi) }if (__exist_node_summaries (sbi)) -f2fs_ra_meta_pages (sbi,sum_blk_addr (sbi,NR_CURSEG_TYPE , type), -NR_CURSEG_TYPE - type,META_CP , true); +f2fs_ra_meta_pages (sbi, +sum_blk_addr (sbi,NR_CURSEG_PERSIST_TYPE , type), +NR_CURSEG_PERSIST_TYPE - type,META_CP , true);for (; type <=CURSEG_COLD_NODE ; type++) { err =read_normal_summaries (sbi, type);@@ -4155,14 +4191,14 @@ static int build_curseg(struct f2fs_sb_info *sbi)struct curseg_info *array;int i; - array =f2fs_kzalloc (sbi,array_size (NR_CURSEG_TYPE ,sizeof (*array)), -GFP_KERNEL ); + array =f2fs_kzalloc (sbi,array_size (NR_CURSEG_TYPE , +sizeof (*array)),GFP_KERNEL );if (!array)return -ENOMEM ;SM_I (sbi)->curseg_array = array; -for (i =0 ; i <NR_CURSEG_TYPE ; i++) { +for (i =0 ; i <NO_CHECK_TYPE ; i++) {mutex_init (&array[i].curseg_mutex); array[i].sum_blk =f2fs_kzalloc (sbi,PAGE_SIZE ,GFP_KERNEL );if (!array[i].sum_blk)@@ -4172,8 +4208,13 @@ static int build_curseg(struct f2fs_sb_info *sbi) sizeof(struct f2fs_journal), GFP_KERNEL);if (!array[i].journal)return -ENOMEM ; +if (i <NR_PERSISTENT_LOG ) + array[i].seg_type =CURSEG_HOT_DATA + i; +else if (i ==CURSEG_COLD_DATA_PINNED ) + array[i].seg_type =CURSEG_COLD_DATA ; array[i].segno =NULL_SEGNO ; array[i].next_blkoff =0 ; + array[i].inited = false; }return restore_curseg_summaries (sbi); }@@ -4408,7 +4449,7 @@ static int sanity_check_curseg(struct f2fs_sb_info *sbi)* In LFS/SSR curseg, .next_blkoff should point to an unused blkaddr; * In LFS curseg, all blkaddr after .next_blkoff should be unused. */ -for (i =0 ; i <NO_CHECK_TYPE ; i++) { +for (i =0 ; i <NR_PERSISTENT_LOG ; i++) {struct curseg_info *curseg =CURSEG_I (sbi, i);struct seg_entry *se =get_seg_entry (sbi, curseg->segno);unsigned int blkofs = curseg->next_blkoff;@@ -4637,7 +4678,7 @@ int f2fs_fix_curseg_write_pointer(struct f2fs_sb_info *sbi) {int i, ret; -for (i =0 ; i <NO_CHECK_TYPE ; i++) { +for (i =0 ; i <NR_PERSISTENT_LOG ; i++) { ret =fix_curseg_write_pointer (sbi, i);if (ret)return ret;fs/f2fs/segment.h +10
-7@@ -22,7 +22,7 @@#define GET_R2L_SEGNO (free_i, segno) ((segno) + (free_i)->start_segno)#define IS_DATASEG (t) ((t) <= CURSEG_COLD_DATA) -#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE) +#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE && (t) <= CURSEG_COLD_NODE)#define IS_HOT (t) ((t) == CURSEG_HOT_NODE || (t) == CURSEG_HOT_DATA)#define IS_WARM (t) ((t) == CURSEG_WARM_NODE || (t) == CURSEG_WARM_DATA)@@ -34,7 +34,8 @@ ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_HOT_NODE)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno) || \ - ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno)) + ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno) || \ + ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno))#define IS_CURSEC (sbi, secno) \ (((secno) == CURSEG_I(sbi, CURSEG_HOT_DATA)->segno / \@@ -48,7 +49,9 @@ ((secno) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno / \ (sbi)->segs_per_sec) || \ ((secno) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno / \ - (sbi)->segs_per_sec)) \ + (sbi)->segs_per_sec) || \ + ((secno) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno / \ + (sbi)->segs_per_sec))#define MAIN_BLKADDR (sbi) \ (SM_I(sbi) ? SM_I(sbi)->main_blkaddr : \@@ -288,10 +291,12 @@ struct curseg_info {struct rw_semaphore journal_rwsem;/* protect journal area */ struct f2fs_journal *journal;/* cached journal info */ unsigned char alloc_type;/* current allocation type */ +unsigned short seg_type;/* segment type like CURSEG_XXX_TYPE */ unsigned int segno;/* current segment number */ unsigned short next_blkoff;/* next block offset to write */ unsigned int zone;/* current zone number */ unsigned int next_segno;/* preallocated segment */ +bool inited;/* indicate inmem log is inited */ };struct sit_entry_set {@@ -305,8 +310,6 @@ struct sit_entry_set {*/ static inline struct curseg_info *CURSEG_I (struct f2fs_sb_info *sbi,int type) { -if (type ==CURSEG_COLD_DATA_PINNED ) - type =CURSEG_COLD_DATA ;return (struct curseg_info *)(SM_I (sbi)->curseg_array + type); }@@ -438,7 +441,7 @@ static inline void __set_inuse(struct f2fs_sb_info *sbi, }static inline void __set_test_and_free (struct f2fs_sb_info *sbi, -unsigned int segno) +unsigned int segno,bool inmem) {struct free_segmap_info *free_i =FREE_I (sbi);unsigned int secno =GET_SEC_FROM_SEG (sbi, segno);@@ -449,7 +452,7 @@ static inline void __set_test_and_free(struct f2fs_sb_info *sbi,if (test_and_clear_bit (segno, free_i->free_segmap)) { free_i->free_segments++; -if (IS_CURSEC (sbi, secno)) +if (!inmem &&IS_CURSEC (sbi, secno)) goto skip_free; next =find_next_bit (free_i->free_segmap, start_segno + sbi->segs_per_sec, start_segno);fs/f2fs/super.c +5
-4@@ -575,7 +575,8 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)case Opt_active_logs:if (args->from &&match_int (args, &arg))return -EINVAL ; -if (arg !=2 && arg !=4 && arg !=NR_CURSEG_TYPE ) +if (arg !=2 && arg !=4 && + arg !=NR_CURSEG_PERSIST_TYPE )return -EINVAL ;F2FS_OPTION (sbi).active_logs = arg;break ;@@ -981,7 +982,7 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) }/* Not pass down write hints if the number of active logs is lesser -* than NR_CURSEG_TYPE. +* than NR_CURSEG_PERSIST_TYPE. */ if (F2FS_OPTION (sbi).active_logs !=NR_CURSEG_TYPE )F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ;@@ -1614,7 +1615,7 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)static void default_options (struct f2fs_sb_info *sbi) {/* init some FS parameters */ -F2FS_OPTION (sbi).active_logs =NR_CURSEG_TYPE ; +F2FS_OPTION (sbi).active_logs =NR_CURSEG_PERSIST_TYPE ;F2FS_OPTION (sbi).inline_xattr_size =DEFAULT_INLINE_XATTR_ADDRS ;F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ;F2FS_OPTION (sbi).alloc_mode =ALLOC_MODE_DEFAULT ;@@ -2946,7 +2947,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi) cp_payload =__cp_payload (sbi);if (cp_pack_start_sum < cp_payload +1 || cp_pack_start_sum > blocks_per_seg -1 - -NR_CURSEG_TYPE ) { +NR_CURSEG_PERSIST_TYPE ) {f2fs_err (sbi,"Wrong cp_pack_start_sum: %u" , cp_pack_start_sum);return 1 ;Signature · 1 line
2.26.2.
Quoted 2 lines
Quoted 2 lines
.
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 16 lines · Jaegeuk Kim
Quoted 15 lines · Chao Yu
Quoted 13 lines · Jaegeuk Kim
Quoted 10 lines · Chao Yu
Quoted 3 lines · Jaegeuk Kim
Hi Chao,
Do you have any brief design doc to present the idea?
Hi Jaegeuk,
You mean this whole patchset, right?
I can add a brief design description in patch 0/5.
Yeah, it's a bit hard to understand the whole flow.
Quoted 7 lines
Quoted 4 lines
Jaegeuk,
Do you have time to take a look at this idea summarized in [PATCH 0/5]'s cover letter?
Sorry, I couldn't afford to sitting down to review the design. Let me give it a try soon.
Alright, let me know if you have any question about the idea.
Quoted 535 lines
Quoted 531 lines
Quoted 531 lines
Thanks,
Quoted 526 lines
Quoted 526 lines
Thanks,
Quoted 519 lines · Chao Yu
Previous implementation of aligned pinfile allocation will:
- allocate new segment on cold data log no matter whether last used segment is partially used or not, it makes IOs more random;
- force concurrent cold data/GCed IO going into warm data area, it can make a bad effect on hot/cold data separation;In this patch, we introduce a new type of log named 'inmem curseg', the differents from normal curseg is:
- it reuses existed segment type (CURSEG_XXX_NODE/DATA);
- it only exists in memory, its segno, blkofs, summary will not b persisted into checkpoint area;With this new feature, we can enhance scalability of log, special allocators can be created for purposes:
- pure lfs allocator for aligned pinfile allocation or file defragmentation
- pure ssr allocator for later featureSo that, let's update aligned pinfile allocation to use this new inmem curseg fwk.
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/checkpoint.c | 7 ++- fs/f2fs/debug.c | 6 ++- fs/f2fs/f2fs.h | 12 +++-- fs/f2fs/file.c | 3 +- fs/f2fs/gc.c | 2 +- fs/f2fs/segment.c | 107 ++++++++++++++++++++++++++++++------------- fs/f2fs/segment.h | 17 ++++--- fs/f2fs/super.c | 9 ++-- 8 files changed, 112 insertions(+), 51 deletions(-)fs/f2fs/checkpoint.c +6
-1@@ -1623,11 +1623,16 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)f2fs_flush_sit_entries (sbi, cpc); +/* save inmem log status */ +f2fs_save_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); + err =do_checkpoint (sbi, cpc);if (err)f2fs_release_discard_addrs (sbi);else f2fs_clear_prefree_segments (sbi, cpc); + +f2fs_restore_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); stop:unblock_operations (sbi);stat_inc_cp_count (sbi->stat_info);@@ -1658,7 +1663,7 @@ void f2fs_init_ino_entry_info(struct f2fs_sb_info *sbi) } sbi->max_orphans = (sbi->blocks_per_seg -F2FS_CP_PACKS - -NR_CURSEG_TYPE -__cp_payload (sbi)) * +NR_CURSEG_PERSIST_TYPE -__cp_payload (sbi)) *F2FS_ORPHANS_PER_BLOCK ; }fs/f2fs/debug.c +5
-1@@ -164,7 +164,7 @@ static void update_general_status(struct f2fs_sb_info *sbi) *100 / (int )(sbi->user_block_count >> sbi->log_blocks_per_seg) /2 ; si->util_invalid =50 - si->util_free - si->util_valid; -for (i =CURSEG_HOT_DATA ; i <=CURSEG_COLD_NODE ; i++) { +for (i =CURSEG_HOT_DATA ; i <NO_CHECK_TYPE ; i++) {struct curseg_info *curseg =CURSEG_I (sbi, i); si->curseg[i] = curseg->segno; si->cursec[i] =GET_SEC_FROM_SEG (sbi, curseg->segno);@@ -393,6 +393,10 @@ static int stat_show(struct seq_file *s, void *v) si->dirty_seg[CURSEG_COLD_NODE ], si->full_seg[CURSEG_COLD_NODE ], si->valid_blks[CURSEG_COLD_NODE]); +seq_printf (s," - Pinned file: %8d %8d %8d\n" , + si->curseg[CURSEG_COLD_DATA_PINNED ], + si->cursec[CURSEG_COLD_DATA_PINNED ], + si->curzone[CURSEG_COLD_DATA_PINNED ]); seq_printf(s, "\n - Valid: %d\n - Dirty: %d\n", si->main_area_segs - si->dirty_count - si->prefree_count - si->free_segs,fs/f2fs/f2fs.h +9
-3@@ -996,7 +996,9 @@ static inline void set_new_dnode(struct dnode_of_data *dn, struct inode *inode,*/ #define NR_CURSEG_DATA_TYPE (3)#define NR_CURSEG_NODE_TYPE (3) -#define NR_CURSEG_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) +#define NR_CURSEG_INMEM_TYPE (1) +#define NR_CURSEG_PERSIST_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) +#define NR_CURSEG_TYPE (NR_CURSEG_INMEM_TYPE + NR_CURSEG_PERSIST_TYPE)enum {CURSEG_HOT_DATA =0 ,/* directory entry blocks */ @@ -1005,8 +1007,10 @@ enum {CURSEG_HOT_NODE ,/* direct node blocks of directory files */ CURSEG_WARM_NODE ,/* direct node blocks of normal files */ CURSEG_COLD_NODE ,/* indirect node blocks */ -NO_CHECK_TYPE , - CURSEG_COLD_DATA_PINNED,/* cold data for pinned file */ +NR_PERSISTENT_LOG ,/* number of persistent log */ +CURSEG_COLD_DATA_PINNED =NR_PERSISTENT_LOG , +/* pinned file that needs consecutive block address */ + NO_CHECK_TYPE, /* number of persistent & inmem log */ }; struct flush_cmd {@@ -3359,6 +3363,8 @@ block_t f2fs_get_unusable_blocks(struct f2fs_sb_info *sbi);int f2fs_disable_cp_again (struct f2fs_sb_info *sbi,block_t unusable);void f2fs_release_discard_addrs (struct f2fs_sb_info *sbi);int f2fs_npages_for_summary_flush (struct f2fs_sb_info *sbi,bool for_ra); +void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi,int type); +void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi,int type);void f2fs_allocate_segment_for_resize (struct f2fs_sb_info *sbi,int type,unsigned int start,unsigned int end);void f2fs_allocate_new_segment (struct f2fs_sb_info *sbi,int type);fs/f2fs/file.c +2
-1@@ -1656,13 +1656,14 @@ static int expand_inode_data(struct inode *inode, loff_t offset, }down_write (&sbi->pin_sem); - map.m_seg_type =CURSEG_COLD_DATA_PINNED ;f2fs_lock_op (sbi);f2fs_allocate_new_segment (sbi,CURSEG_COLD_DATA );f2fs_unlock_op (sbi); + map.m_seg_type =CURSEG_COLD_DATA_PINNED ; err =f2fs_map_blocks (inode, &map,1 ,F2FS_GET_BLOCK_PRE_DIO ); +up_write (&sbi->pin_sem); done += map.m_len;fs/f2fs/gc.c +1
-1@@ -1448,7 +1448,7 @@ static int free_segment_range(struct f2fs_sb_info *sbi,mutex_unlock (&DIRTY_I (sbi)->seglist_lock);/* Move out cursegs from the target range */ -for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_TYPE ; type++) +for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_PERSIST_TYPE ; type++)f2fs_allocate_segment_for_resize (sbi, type, start, end);/* do GC to move out valid blocks in the range */ fs/f2fs/segment.c +74
-33@@ -1958,7 +1958,7 @@ static void set_prefree_as_free_segments(struct f2fs_sb_info *sbi)mutex_lock (&dirty_i->seglist_lock);for_each_set_bit (segno, dirty_i->dirty_segmap[PRE ],MAIN_SEGS (sbi)) -__set_test_and_free (sbi, segno); +__set_test_and_free (sbi, segno, false);mutex_unlock (&dirty_i->seglist_lock); }@@ -2496,6 +2496,7 @@ static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified)struct curseg_info *curseg =CURSEG_I (sbi, type);struct summary_footer *sum_footer; + curseg->inited = true; curseg->segno = curseg->next_segno; curseg->zone =GET_ZONE_FROM_SEG (sbi, curseg->segno); curseg->next_blkoff =0 ;@@ -2503,24 +2504,31 @@ static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified) sum_footer = &(curseg->sum_blk->footer);memset (sum_footer,0 ,sizeof (struct summary_footer )); -if (IS_DATASEG (type)) +if (IS_DATASEG (curseg->seg_type))SET_SUM_TYPE (sum_footer,SUM_TYPE_DATA ); -if (IS_NODESEG (type)) +if (IS_NODESEG (curseg->seg_type))SET_SUM_TYPE (sum_footer,SUM_TYPE_NODE ); -__set_sit_entry_type (sbi, type, curseg->segno, modified); +__set_sit_entry_type (sbi, curseg->seg_type, curseg->segno, modified); }static unsigned int __get_next_segno (struct f2fs_sb_info *sbi,int type) { +struct curseg_info *curseg =CURSEG_I (sbi, type); +/* if segs_per_sec is large than 1, we need to keep original policy. */ if (__is_large_section (sbi)) -return CURSEG_I (sbi, type)->segno; +return curseg->segno; + +/* inmem log may not locate on any segment after mount */ +if (!curseg->inited) +return 0 ;if (unlikely (is_sbi_flag_set (sbi,SBI_CP_DISABLED )))return 0 ;if (test_opt (sbi,NOHEAP ) && - (type ==CURSEG_HOT_DATA ||IS_NODESEG (type))) + (curseg->seg_type ==CURSEG_HOT_DATA || +IS_NODESEG (curseg->seg_type)))return 0 ;if (SIT_I (sbi)->last_victim[ALLOC_NEXT ])@@ -2530,7 +2538,7 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)if (F2FS_OPTION (sbi).alloc_mode ==ALLOC_MODE_REUSE )return 0 ; -return CURSEG_I (sbi, type)->segno; +return curseg->segno; }/* @@ -2540,12 +2548,14 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)static void new_curseg (struct f2fs_sb_info *sbi,int type,bool new_sec) {struct curseg_info *curseg =CURSEG_I (sbi, type); +unsigned short seg_type = curseg->seg_type;unsigned int segno = curseg->segno;int dir =ALLOC_LEFT ; -write_sum_page (sbi, curseg->sum_blk, +if (curseg->inited) +write_sum_page (sbi, curseg->sum_blk,GET_SUM_BLOCK (sbi, segno)); -if (type ==CURSEG_WARM_DATA || type ==CURSEG_COLD_DATA ) +if (seg_type ==CURSEG_WARM_DATA || seg_type ==CURSEG_COLD_DATA ) dir =ALLOC_RIGHT ;if (test_opt (sbi,NOHEAP ))@@ -2622,6 +2632,43 @@ static void change_curseg(struct f2fs_sb_info *sbi, int type)f2fs_put_page (sum_page,1 ); } +void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi,int type) +{ +struct curseg_info *curseg =CURSEG_I (sbi, type); + +mutex_lock (&curseg->curseg_mutex); +if (!curseg->inited) + goto out; + +if (get_valid_blocks (sbi, curseg->segno, false)) { +write_sum_page (sbi, curseg->sum_blk, +GET_SUM_BLOCK (sbi, curseg->segno)); + }else { +mutex_lock (&DIRTY_I (sbi)->seglist_lock); +__set_test_and_free (sbi, curseg->segno, true); +mutex_unlock (&DIRTY_I (sbi)->seglist_lock); + } +out: +mutex_unlock (&curseg->curseg_mutex); +} + +void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi,int type) +{ +struct curseg_info *curseg =CURSEG_I (sbi, type); + +mutex_lock (&curseg->curseg_mutex); +if (!curseg->inited) + goto out; +if (get_valid_blocks (sbi, curseg->segno, false)) + goto out; + +mutex_lock (&DIRTY_I (sbi)->seglist_lock); +__set_test_and_inuse (sbi, curseg->segno); +mutex_unlock (&DIRTY_I (sbi)->seglist_lock); +out: +mutex_unlock (&curseg->curseg_mutex); +} +static int get_ssr_segment (struct f2fs_sb_info *sbi,int type) {struct curseg_info *curseg =CURSEG_I (sbi, type);@@ -2738,11 +2785,15 @@ void __allocate_new_segment(struct f2fs_sb_info *sbi, int type)struct curseg_info *curseg =CURSEG_I (sbi, type);unsigned int old_segno; +if (!curseg->inited) + goto alloc; +if (!curseg->next_blkoff && !get_valid_blocks (sbi, curseg->segno, false) && !get_ckpt_valid_blocks (sbi, curseg->segno))return ; +alloc: old_segno = curseg->segno;SIT_I (sbi)->s_ops->allocate_segment (sbi, type, true);locate_dirty_segment (sbi, old_segno);@@ -3126,19 +3177,6 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, {struct sit_info *sit_i =SIT_I (sbi);struct curseg_info *curseg =CURSEG_I (sbi, type); -bool put_pin_sem = false; - -if (type ==CURSEG_COLD_DATA ) { -/* GC during CURSEG_COLD_DATA_PINNED allocation */ -if (down_read_trylock (&sbi->pin_sem)) { - put_pin_sem = true; - }else { - type =CURSEG_WARM_DATA ; - curseg =CURSEG_I (sbi, type); - } - }else if (type ==CURSEG_COLD_DATA_PINNED ) { - type =CURSEG_COLD_DATA ; - }down_read (&SM_I (sbi)->curseg_lock);@@ -3204,9 +3242,6 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,mutex_unlock (&curseg->curseg_mutex);up_read (&SM_I (sbi)->curseg_lock); - -if (put_pin_sem) -up_read (&sbi->pin_sem); }static void update_device_state (struct f2fs_io_info *fio)@@ -3574,7 +3609,7 @@ static int read_normal_summaries(struct f2fs_sb_info *sbi, int type) blk_off =le16_to_cpu (ckpt->cur_data_blkoff[type -CURSEG_HOT_DATA ]);if (__exist_node_summaries (sbi)) - blk_addr =sum_blk_addr (sbi,NR_CURSEG_TYPE , type); + blk_addr =sum_blk_addr (sbi,NR_CURSEG_PERSIST_TYPE , type);else blk_addr =sum_blk_addr (sbi,NR_CURSEG_DATA_TYPE , type); }else {@@ -3652,8 +3687,9 @@ static int restore_curseg_summaries(struct f2fs_sb_info *sbi) }if (__exist_node_summaries (sbi)) -f2fs_ra_meta_pages (sbi,sum_blk_addr (sbi,NR_CURSEG_TYPE , type), -NR_CURSEG_TYPE - type,META_CP , true); +f2fs_ra_meta_pages (sbi, +sum_blk_addr (sbi,NR_CURSEG_PERSIST_TYPE , type), +NR_CURSEG_PERSIST_TYPE - type,META_CP , true);for (; type <=CURSEG_COLD_NODE ; type++) { err =read_normal_summaries (sbi, type);@@ -4155,14 +4191,14 @@ static int build_curseg(struct f2fs_sb_info *sbi)struct curseg_info *array;int i; - array =f2fs_kzalloc (sbi,array_size (NR_CURSEG_TYPE ,sizeof (*array)), -GFP_KERNEL ); + array =f2fs_kzalloc (sbi,array_size (NR_CURSEG_TYPE , +sizeof (*array)),GFP_KERNEL );if (!array)return -ENOMEM ;SM_I (sbi)->curseg_array = array; -for (i =0 ; i <NR_CURSEG_TYPE ; i++) { +for (i =0 ; i <NO_CHECK_TYPE ; i++) {mutex_init (&array[i].curseg_mutex); array[i].sum_blk =f2fs_kzalloc (sbi,PAGE_SIZE ,GFP_KERNEL );if (!array[i].sum_blk)@@ -4172,8 +4208,13 @@ static int build_curseg(struct f2fs_sb_info *sbi) sizeof(struct f2fs_journal), GFP_KERNEL);if (!array[i].journal)return -ENOMEM ; +if (i <NR_PERSISTENT_LOG ) + array[i].seg_type =CURSEG_HOT_DATA + i; +else if (i ==CURSEG_COLD_DATA_PINNED ) + array[i].seg_type =CURSEG_COLD_DATA ; array[i].segno =NULL_SEGNO ; array[i].next_blkoff =0 ; + array[i].inited = false; }return restore_curseg_summaries (sbi); }@@ -4408,7 +4449,7 @@ static int sanity_check_curseg(struct f2fs_sb_info *sbi)* In LFS/SSR curseg, .next_blkoff should point to an unused blkaddr; * In LFS curseg, all blkaddr after .next_blkoff should be unused. */ -for (i =0 ; i <NO_CHECK_TYPE ; i++) { +for (i =0 ; i <NR_PERSISTENT_LOG ; i++) {struct curseg_info *curseg =CURSEG_I (sbi, i);struct seg_entry *se =get_seg_entry (sbi, curseg->segno);unsigned int blkofs = curseg->next_blkoff;@@ -4637,7 +4678,7 @@ int f2fs_fix_curseg_write_pointer(struct f2fs_sb_info *sbi) {int i, ret; -for (i =0 ; i <NO_CHECK_TYPE ; i++) { +for (i =0 ; i <NR_PERSISTENT_LOG ; i++) { ret =fix_curseg_write_pointer (sbi, i);if (ret)return ret;fs/f2fs/segment.h +10
-7@@ -22,7 +22,7 @@#define GET_R2L_SEGNO (free_i, segno) ((segno) + (free_i)->start_segno)#define IS_DATASEG (t) ((t) <= CURSEG_COLD_DATA) -#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE) +#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE && (t) <= CURSEG_COLD_NODE)#define IS_HOT (t) ((t) == CURSEG_HOT_NODE || (t) == CURSEG_HOT_DATA)#define IS_WARM (t) ((t) == CURSEG_WARM_NODE || (t) == CURSEG_WARM_DATA)@@ -34,7 +34,8 @@ ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_HOT_NODE)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno) || \ - ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno)) + ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno) || \ + ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno))#define IS_CURSEC (sbi, secno) \ (((secno) == CURSEG_I(sbi, CURSEG_HOT_DATA)->segno / \@@ -48,7 +49,9 @@ ((secno) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno / \ (sbi)->segs_per_sec) || \ ((secno) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno / \ - (sbi)->segs_per_sec)) \ + (sbi)->segs_per_sec) || \ + ((secno) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno / \ + (sbi)->segs_per_sec))#define MAIN_BLKADDR (sbi) \ (SM_I(sbi) ? SM_I(sbi)->main_blkaddr : \@@ -288,10 +291,12 @@ struct curseg_info {struct rw_semaphore journal_rwsem;/* protect journal area */ struct f2fs_journal *journal;/* cached journal info */ unsigned char alloc_type;/* current allocation type */ +unsigned short seg_type;/* segment type like CURSEG_XXX_TYPE */ unsigned int segno;/* current segment number */ unsigned short next_blkoff;/* next block offset to write */ unsigned int zone;/* current zone number */ unsigned int next_segno;/* preallocated segment */ +bool inited;/* indicate inmem log is inited */ };struct sit_entry_set {@@ -305,8 +310,6 @@ struct sit_entry_set {*/ static inline struct curseg_info *CURSEG_I (struct f2fs_sb_info *sbi,int type) { -if (type ==CURSEG_COLD_DATA_PINNED ) - type =CURSEG_COLD_DATA ;return (struct curseg_info *)(SM_I (sbi)->curseg_array + type); }@@ -438,7 +441,7 @@ static inline void __set_inuse(struct f2fs_sb_info *sbi, }static inline void __set_test_and_free (struct f2fs_sb_info *sbi, -unsigned int segno) +unsigned int segno,bool inmem) {struct free_segmap_info *free_i =FREE_I (sbi);unsigned int secno =GET_SEC_FROM_SEG (sbi, segno);@@ -449,7 +452,7 @@ static inline void __set_test_and_free(struct f2fs_sb_info *sbi,if (test_and_clear_bit (segno, free_i->free_segmap)) { free_i->free_segments++; -if (IS_CURSEC (sbi, secno)) +if (!inmem &&IS_CURSEC (sbi, secno)) goto skip_free; next =find_next_bit (free_i->free_segmap, start_segno + sbi->segs_per_sec, start_segno);fs/f2fs/super.c +5
-4@@ -575,7 +575,8 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)case Opt_active_logs:if (args->from &&match_int (args, &arg))return -EINVAL ; -if (arg !=2 && arg !=4 && arg !=NR_CURSEG_TYPE ) +if (arg !=2 && arg !=4 && + arg !=NR_CURSEG_PERSIST_TYPE )return -EINVAL ;F2FS_OPTION (sbi).active_logs = arg;break ;@@ -981,7 +982,7 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) }/* Not pass down write hints if the number of active logs is lesser -* than NR_CURSEG_TYPE. +* than NR_CURSEG_PERSIST_TYPE. */ if (F2FS_OPTION (sbi).active_logs !=NR_CURSEG_TYPE )F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ;@@ -1614,7 +1615,7 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)static void default_options (struct f2fs_sb_info *sbi) {/* init some FS parameters */ -F2FS_OPTION (sbi).active_logs =NR_CURSEG_TYPE ; +F2FS_OPTION (sbi).active_logs =NR_CURSEG_PERSIST_TYPE ;F2FS_OPTION (sbi).inline_xattr_size =DEFAULT_INLINE_XATTR_ADDRS ;F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ;F2FS_OPTION (sbi).alloc_mode =ALLOC_MODE_DEFAULT ;@@ -2946,7 +2947,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi) cp_payload =__cp_payload (sbi);if (cp_pack_start_sum < cp_payload +1 || cp_pack_start_sum > blocks_per_seg -1 - -NR_CURSEG_TYPE ) { +NR_CURSEG_PERSIST_TYPE ) {f2fs_err (sbi,"Wrong cp_pack_start_sum: %u" , cp_pack_start_sum);return 1 ;Signature · 1 line
2.26.2.
Quoted 2 lines
Quoted 2 lines
.
.
Quoted 19 lines · Chao Yu
Quoted 18 lines · Jaegeuk Kim
Quoted 17 lines · Chao Yu
Quoted 6 lines · Jaegeuk Kim
Quoted 5 lines · Chao Yu
Quoted 3 lines · Jaegeuk Kim
Hi Chao,
Do you have any brief design doc to present the idea?
Quoted 7 lines
Quoted 5 lines
Hi Jaegeuk,
You mean this whole patchset, right?
I can add a brief design description in patch 0/5.
Yeah, it's a bit hard to understand the whole flow.
Jaegeuk,
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Do you have time to take a look at this idea summarized in [PATCH 0/5]'s cover letter?
Sorry, I couldn't afford to sitting down to review the design. Let me give it a try soon.
Alright, let me know if you have any question about the idea.
Ping,
Jaegeuk, still be too busy...? :P
Thanks,
Quoted 544 lines
Quoted 532 lines
Quoted 532 lines
Quoted 532 lines
Thanks,
Quoted 526 lines
Quoted 526 lines
Thanks,
Quoted 519 lines · Chao Yu
Previous implementation of aligned pinfile allocation will:
- allocate new segment on cold data log no matter whether last used segment is partially used or not, it makes IOs more random;
- force concurrent cold data/GCed IO going into warm data area, it can make a bad effect on hot/cold data separation;In this patch, we introduce a new type of log named 'inmem curseg', the differents from normal curseg is:
- it reuses existed segment type (CURSEG_XXX_NODE/DATA);
- it only exists in memory, its segno, blkofs, summary will not b persisted into checkpoint area;With this new feature, we can enhance scalability of log, special allocators can be created for purposes:
- pure lfs allocator for aligned pinfile allocation or file defragmentation
- pure ssr allocator for later featureSo that, let's update aligned pinfile allocation to use this new inmem curseg fwk.
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/checkpoint.c | 7 ++- fs/f2fs/debug.c | 6 ++- fs/f2fs/f2fs.h | 12 +++-- fs/f2fs/file.c | 3 +- fs/f2fs/gc.c | 2 +- fs/f2fs/segment.c | 107 ++++++++++++++++++++++++++++++------------- fs/f2fs/segment.h | 17 ++++--- fs/f2fs/super.c | 9 ++-- 8 files changed, 112 insertions(+), 51 deletions(-)fs/f2fs/checkpoint.c +6
-1@@ -1623,11 +1623,16 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)f2fs_flush_sit_entries (sbi, cpc); +/* save inmem log status */ +f2fs_save_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); + err =do_checkpoint (sbi, cpc);if (err)f2fs_release_discard_addrs (sbi);else f2fs_clear_prefree_segments (sbi, cpc); + +f2fs_restore_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); stop:unblock_operations (sbi);stat_inc_cp_count (sbi->stat_info);@@ -1658,7 +1663,7 @@ void f2fs_init_ino_entry_info(struct f2fs_sb_info *sbi) } sbi->max_orphans = (sbi->blocks_per_seg -F2FS_CP_PACKS - -NR_CURSEG_TYPE -__cp_payload (sbi)) * +NR_CURSEG_PERSIST_TYPE -__cp_payload (sbi)) *F2FS_ORPHANS_PER_BLOCK ; }fs/f2fs/debug.c +5
-1@@ -164,7 +164,7 @@ static void update_general_status(struct f2fs_sb_info *sbi) *100 / (int )(sbi->user_block_count >> sbi->log_blocks_per_seg) /2 ; si->util_invalid =50 - si->util_free - si->util_valid; -for (i =CURSEG_HOT_DATA ; i <=CURSEG_COLD_NODE ; i++) { +for (i =CURSEG_HOT_DATA ; i <NO_CHECK_TYPE ; i++) {struct curseg_info *curseg =CURSEG_I (sbi, i); si->curseg[i] = curseg->segno; si->cursec[i] =GET_SEC_FROM_SEG (sbi, curseg->segno);@@ -393,6 +393,10 @@ static int stat_show(struct seq_file *s, void *v) si->dirty_seg[CURSEG_COLD_NODE ], si->full_seg[CURSEG_COLD_NODE ], si->valid_blks[CURSEG_COLD_NODE]); +seq_printf (s," - Pinned file: %8d %8d %8d\n" , + si->curseg[CURSEG_COLD_DATA_PINNED ], + si->cursec[CURSEG_COLD_DATA_PINNED ], + si->curzone[CURSEG_COLD_DATA_PINNED ]); seq_printf(s, "\n - Valid: %d\n - Dirty: %d\n", si->main_area_segs - si->dirty_count - si->prefree_count - si->free_segs,fs/f2fs/f2fs.h +9
-3@@ -996,7 +996,9 @@ static inline void set_new_dnode(struct dnode_of_data *dn, struct inode *inode,*/ #define NR_CURSEG_DATA_TYPE (3)#define NR_CURSEG_NODE_TYPE (3) -#define NR_CURSEG_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) +#define NR_CURSEG_INMEM_TYPE (1) +#define NR_CURSEG_PERSIST_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) +#define NR_CURSEG_TYPE (NR_CURSEG_INMEM_TYPE + NR_CURSEG_PERSIST_TYPE)enum {CURSEG_HOT_DATA =0 ,/* directory entry blocks */ @@ -1005,8 +1007,10 @@ enum {CURSEG_HOT_NODE ,/* direct node blocks of directory files */ CURSEG_WARM_NODE ,/* direct node blocks of normal files */ CURSEG_COLD_NODE ,/* indirect node blocks */ -NO_CHECK_TYPE , - CURSEG_COLD_DATA_PINNED,/* cold data for pinned file */ +NR_PERSISTENT_LOG ,/* number of persistent log */ +CURSEG_COLD_DATA_PINNED =NR_PERSISTENT_LOG , +/* pinned file that needs consecutive block address */ + NO_CHECK_TYPE, /* number of persistent & inmem log */ }; struct flush_cmd {@@ -3359,6 +3363,8 @@ block_t f2fs_get_unusable_blocks(struct f2fs_sb_info *sbi);int f2fs_disable_cp_again (struct f2fs_sb_info *sbi,block_t unusable);void f2fs_release_discard_addrs (struct f2fs_sb_info *sbi);int f2fs_npages_for_summary_flush (struct f2fs_sb_info *sbi,bool for_ra); +void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi,int type); +void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi,int type);void f2fs_allocate_segment_for_resize (struct f2fs_sb_info *sbi,int type,unsigned int start,unsigned int end);void f2fs_allocate_new_segment (struct f2fs_sb_info *sbi,int type);fs/f2fs/file.c +2
-1@@ -1656,13 +1656,14 @@ static int expand_inode_data(struct inode *inode, loff_t offset, }down_write (&sbi->pin_sem); - map.m_seg_type =CURSEG_COLD_DATA_PINNED ;f2fs_lock_op (sbi);f2fs_allocate_new_segment (sbi,CURSEG_COLD_DATA );f2fs_unlock_op (sbi); + map.m_seg_type =CURSEG_COLD_DATA_PINNED ; err =f2fs_map_blocks (inode, &map,1 ,F2FS_GET_BLOCK_PRE_DIO ); +up_write (&sbi->pin_sem); done += map.m_len;fs/f2fs/gc.c +1
-1@@ -1448,7 +1448,7 @@ static int free_segment_range(struct f2fs_sb_info *sbi,mutex_unlock (&DIRTY_I (sbi)->seglist_lock);/* Move out cursegs from the target range */ -for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_TYPE ; type++) +for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_PERSIST_TYPE ; type++)f2fs_allocate_segment_for_resize (sbi, type, start, end);/* do GC to move out valid blocks in the range */ fs/f2fs/segment.c +74
-33@@ -1958,7 +1958,7 @@ static void set_prefree_as_free_segments(struct f2fs_sb_info *sbi)mutex_lock (&dirty_i->seglist_lock);for_each_set_bit (segno, dirty_i->dirty_segmap[PRE ],MAIN_SEGS (sbi)) -__set_test_and_free (sbi, segno); +__set_test_and_free (sbi, segno, false);mutex_unlock (&dirty_i->seglist_lock); }@@ -2496,6 +2496,7 @@ static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified)struct curseg_info *curseg =CURSEG_I (sbi, type);struct summary_footer *sum_footer; + curseg->inited = true; curseg->segno = curseg->next_segno; curseg->zone =GET_ZONE_FROM_SEG (sbi, curseg->segno); curseg->next_blkoff =0 ;@@ -2503,24 +2504,31 @@ static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified) sum_footer = &(curseg->sum_blk->footer);memset (sum_footer,0 ,sizeof (struct summary_footer )); -if (IS_DATASEG (type)) +if (IS_DATASEG (curseg->seg_type))SET_SUM_TYPE (sum_footer,SUM_TYPE_DATA ); -if (IS_NODESEG (type)) +if (IS_NODESEG (curseg->seg_type))SET_SUM_TYPE (sum_footer,SUM_TYPE_NODE ); -__set_sit_entry_type (sbi, type, curseg->segno, modified); +__set_sit_entry_type (sbi, curseg->seg_type, curseg->segno, modified); }static unsigned int __get_next_segno (struct f2fs_sb_info *sbi,int type) { +struct curseg_info *curseg =CURSEG_I (sbi, type); +/* if segs_per_sec is large than 1, we need to keep original policy. */ if (__is_large_section (sbi)) -return CURSEG_I (sbi, type)->segno; +return curseg->segno; + +/* inmem log may not locate on any segment after mount */ +if (!curseg->inited) +return 0 ;if (unlikely (is_sbi_flag_set (sbi,SBI_CP_DISABLED )))return 0 ;if (test_opt (sbi,NOHEAP ) && - (type ==CURSEG_HOT_DATA ||IS_NODESEG (type))) + (curseg->seg_type ==CURSEG_HOT_DATA || +IS_NODESEG (curseg->seg_type)))return 0 ;if (SIT_I (sbi)->last_victim[ALLOC_NEXT ])@@ -2530,7 +2538,7 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)if (F2FS_OPTION (sbi).alloc_mode ==ALLOC_MODE_REUSE )return 0 ; -return CURSEG_I (sbi, type)->segno; +return curseg->segno; }/* @@ -2540,12 +2548,14 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)static void new_curseg (struct f2fs_sb_info *sbi,int type,bool new_sec) {struct curseg_info *curseg =CURSEG_I (sbi, type); +unsigned short seg_type = curseg->seg_type;unsigned int segno = curseg->segno;int dir =ALLOC_LEFT ; -write_sum_page (sbi, curseg->sum_blk, +if (curseg->inited) +write_sum_page (sbi, curseg->sum_blk,GET_SUM_BLOCK (sbi, segno)); -if (type ==CURSEG_WARM_DATA || type ==CURSEG_COLD_DATA ) +if (seg_type ==CURSEG_WARM_DATA || seg_type ==CURSEG_COLD_DATA ) dir =ALLOC_RIGHT ;if (test_opt (sbi,NOHEAP ))@@ -2622,6 +2632,43 @@ static void change_curseg(struct f2fs_sb_info *sbi, int type)f2fs_put_page (sum_page,1 ); } +void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi,int type) +{ +struct curseg_info *curseg =CURSEG_I (sbi, type); + +mutex_lock (&curseg->curseg_mutex); +if (!curseg->inited) + goto out; + +if (get_valid_blocks (sbi, curseg->segno, false)) { +write_sum_page (sbi, curseg->sum_blk, +GET_SUM_BLOCK (sbi, curseg->segno)); + }else { +mutex_lock (&DIRTY_I (sbi)->seglist_lock); +__set_test_and_free (sbi, curseg->segno, true); +mutex_unlock (&DIRTY_I (sbi)->seglist_lock); + } +out: +mutex_unlock (&curseg->curseg_mutex); +} + +void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi,int type) +{ +struct curseg_info *curseg =CURSEG_I (sbi, type); + +mutex_lock (&curseg->curseg_mutex); +if (!curseg->inited) + goto out; +if (get_valid_blocks (sbi, curseg->segno, false)) + goto out; + +mutex_lock (&DIRTY_I (sbi)->seglist_lock); +__set_test_and_inuse (sbi, curseg->segno); +mutex_unlock (&DIRTY_I (sbi)->seglist_lock); +out: +mutex_unlock (&curseg->curseg_mutex); +} +static int get_ssr_segment (struct f2fs_sb_info *sbi,int type) {struct curseg_info *curseg =CURSEG_I (sbi, type);@@ -2738,11 +2785,15 @@ void __allocate_new_segment(struct f2fs_sb_info *sbi, int type)struct curseg_info *curseg =CURSEG_I (sbi, type);unsigned int old_segno; +if (!curseg->inited) + goto alloc; +if (!curseg->next_blkoff && !get_valid_blocks (sbi, curseg->segno, false) && !get_ckpt_valid_blocks (sbi, curseg->segno))return ; +alloc: old_segno = curseg->segno;SIT_I (sbi)->s_ops->allocate_segment (sbi, type, true);locate_dirty_segment (sbi, old_segno);@@ -3126,19 +3177,6 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, {struct sit_info *sit_i =SIT_I (sbi);struct curseg_info *curseg =CURSEG_I (sbi, type); -bool put_pin_sem = false; - -if (type ==CURSEG_COLD_DATA ) { -/* GC during CURSEG_COLD_DATA_PINNED allocation */ -if (down_read_trylock (&sbi->pin_sem)) { - put_pin_sem = true; - }else { - type =CURSEG_WARM_DATA ; - curseg =CURSEG_I (sbi, type); - } - }else if (type ==CURSEG_COLD_DATA_PINNED ) { - type =CURSEG_COLD_DATA ; - }down_read (&SM_I (sbi)->curseg_lock);@@ -3204,9 +3242,6 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,mutex_unlock (&curseg->curseg_mutex);up_read (&SM_I (sbi)->curseg_lock); - -if (put_pin_sem) -up_read (&sbi->pin_sem); }static void update_device_state (struct f2fs_io_info *fio)@@ -3574,7 +3609,7 @@ static int read_normal_summaries(struct f2fs_sb_info *sbi, int type) blk_off =le16_to_cpu (ckpt->cur_data_blkoff[type -CURSEG_HOT_DATA ]);if (__exist_node_summaries (sbi)) - blk_addr =sum_blk_addr (sbi,NR_CURSEG_TYPE , type); + blk_addr =sum_blk_addr (sbi,NR_CURSEG_PERSIST_TYPE , type);else blk_addr =sum_blk_addr (sbi,NR_CURSEG_DATA_TYPE , type); }else {@@ -3652,8 +3687,9 @@ static int restore_curseg_summaries(struct f2fs_sb_info *sbi) }if (__exist_node_summaries (sbi)) -f2fs_ra_meta_pages (sbi,sum_blk_addr (sbi,NR_CURSEG_TYPE , type), -NR_CURSEG_TYPE - type,META_CP , true); +f2fs_ra_meta_pages (sbi, +sum_blk_addr (sbi,NR_CURSEG_PERSIST_TYPE , type), +NR_CURSEG_PERSIST_TYPE - type,META_CP , true);for (; type <=CURSEG_COLD_NODE ; type++) { err =read_normal_summaries (sbi, type);@@ -4155,14 +4191,14 @@ static int build_curseg(struct f2fs_sb_info *sbi)struct curseg_info *array;int i; - array =f2fs_kzalloc (sbi,array_size (NR_CURSEG_TYPE ,sizeof (*array)), -GFP_KERNEL ); + array =f2fs_kzalloc (sbi,array_size (NR_CURSEG_TYPE , +sizeof (*array)),GFP_KERNEL );if (!array)return -ENOMEM ;SM_I (sbi)->curseg_array = array; -for (i =0 ; i <NR_CURSEG_TYPE ; i++) { +for (i =0 ; i <NO_CHECK_TYPE ; i++) {mutex_init (&array[i].curseg_mutex); array[i].sum_blk =f2fs_kzalloc (sbi,PAGE_SIZE ,GFP_KERNEL );if (!array[i].sum_blk)@@ -4172,8 +4208,13 @@ static int build_curseg(struct f2fs_sb_info *sbi) sizeof(struct f2fs_journal), GFP_KERNEL);if (!array[i].journal)return -ENOMEM ; +if (i <NR_PERSISTENT_LOG ) + array[i].seg_type =CURSEG_HOT_DATA + i; +else if (i ==CURSEG_COLD_DATA_PINNED ) + array[i].seg_type =CURSEG_COLD_DATA ; array[i].segno =NULL_SEGNO ; array[i].next_blkoff =0 ; + array[i].inited = false; }return restore_curseg_summaries (sbi); }@@ -4408,7 +4449,7 @@ static int sanity_check_curseg(struct f2fs_sb_info *sbi)* In LFS/SSR curseg, .next_blkoff should point to an unused blkaddr; * In LFS curseg, all blkaddr after .next_blkoff should be unused. */ -for (i =0 ; i <NO_CHECK_TYPE ; i++) { +for (i =0 ; i <NR_PERSISTENT_LOG ; i++) {struct curseg_info *curseg =CURSEG_I (sbi, i);struct seg_entry *se =get_seg_entry (sbi, curseg->segno);unsigned int blkofs = curseg->next_blkoff;@@ -4637,7 +4678,7 @@ int f2fs_fix_curseg_write_pointer(struct f2fs_sb_info *sbi) {int i, ret; -for (i =0 ; i <NO_CHECK_TYPE ; i++) { +for (i =0 ; i <NR_PERSISTENT_LOG ; i++) { ret =fix_curseg_write_pointer (sbi, i);if (ret)return ret;fs/f2fs/segment.h +10
-7@@ -22,7 +22,7 @@#define GET_R2L_SEGNO (free_i, segno) ((segno) + (free_i)->start_segno)#define IS_DATASEG (t) ((t) <= CURSEG_COLD_DATA) -#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE) +#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE && (t) <= CURSEG_COLD_NODE)#define IS_HOT (t) ((t) == CURSEG_HOT_NODE || (t) == CURSEG_HOT_DATA)#define IS_WARM (t) ((t) == CURSEG_WARM_NODE || (t) == CURSEG_WARM_DATA)@@ -34,7 +34,8 @@ ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_HOT_NODE)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno) || \ - ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno)) + ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno) || \ + ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno))#define IS_CURSEC (sbi, secno) \ (((secno) == CURSEG_I(sbi, CURSEG_HOT_DATA)->segno / \@@ -48,7 +49,9 @@ ((secno) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno / \ (sbi)->segs_per_sec) || \ ((secno) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno / \ - (sbi)->segs_per_sec)) \ + (sbi)->segs_per_sec) || \ + ((secno) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno / \ + (sbi)->segs_per_sec))#define MAIN_BLKADDR (sbi) \ (SM_I(sbi) ? SM_I(sbi)->main_blkaddr : \@@ -288,10 +291,12 @@ struct curseg_info {struct rw_semaphore journal_rwsem;/* protect journal area */ struct f2fs_journal *journal;/* cached journal info */ unsigned char alloc_type;/* current allocation type */ +unsigned short seg_type;/* segment type like CURSEG_XXX_TYPE */ unsigned int segno;/* current segment number */ unsigned short next_blkoff;/* next block offset to write */ unsigned int zone;/* current zone number */ unsigned int next_segno;/* preallocated segment */ +bool inited;/* indicate inmem log is inited */ };struct sit_entry_set {@@ -305,8 +310,6 @@ struct sit_entry_set {*/ static inline struct curseg_info *CURSEG_I (struct f2fs_sb_info *sbi,int type) { -if (type ==CURSEG_COLD_DATA_PINNED ) - type =CURSEG_COLD_DATA ;return (struct curseg_info *)(SM_I (sbi)->curseg_array + type); }@@ -438,7 +441,7 @@ static inline void __set_inuse(struct f2fs_sb_info *sbi, }static inline void __set_test_and_free (struct f2fs_sb_info *sbi, -unsigned int segno) +unsigned int segno,bool inmem) {struct free_segmap_info *free_i =FREE_I (sbi);unsigned int secno =GET_SEC_FROM_SEG (sbi, segno);@@ -449,7 +452,7 @@ static inline void __set_test_and_free(struct f2fs_sb_info *sbi,if (test_and_clear_bit (segno, free_i->free_segmap)) { free_i->free_segments++; -if (IS_CURSEC (sbi, secno)) +if (!inmem &&IS_CURSEC (sbi, secno)) goto skip_free; next =find_next_bit (free_i->free_segmap, start_segno + sbi->segs_per_sec, start_segno);fs/f2fs/super.c +5
-4@@ -575,7 +575,8 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)case Opt_active_logs:if (args->from &&match_int (args, &arg))return -EINVAL ; -if (arg !=2 && arg !=4 && arg !=NR_CURSEG_TYPE ) +if (arg !=2 && arg !=4 && + arg !=NR_CURSEG_PERSIST_TYPE )return -EINVAL ;F2FS_OPTION (sbi).active_logs = arg;break ;@@ -981,7 +982,7 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) }/* Not pass down write hints if the number of active logs is lesser -* than NR_CURSEG_TYPE. +* than NR_CURSEG_PERSIST_TYPE. */ if (F2FS_OPTION (sbi).active_logs !=NR_CURSEG_TYPE )F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ;@@ -1614,7 +1615,7 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)static void default_options (struct f2fs_sb_info *sbi) {/* init some FS parameters */ -F2FS_OPTION (sbi).active_logs =NR_CURSEG_TYPE ; +F2FS_OPTION (sbi).active_logs =NR_CURSEG_PERSIST_TYPE ;F2FS_OPTION (sbi).inline_xattr_size =DEFAULT_INLINE_XATTR_ADDRS ;F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ;F2FS_OPTION (sbi).alloc_mode =ALLOC_MODE_DEFAULT ;@@ -2946,7 +2947,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi) cp_payload =__cp_payload (sbi);if (cp_pack_start_sum < cp_payload +1 || cp_pack_start_sum > blocks_per_seg -1 - -NR_CURSEG_TYPE ) { +NR_CURSEG_PERSIST_TYPE ) {f2fs_err (sbi,"Wrong cp_pack_start_sum: %u" , cp_pack_start_sum);return 1 ;Signature · 1 line
2.26.2.
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
.
.
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
.
Quoted 23 lines · Chao Yu
Quoted 22 lines · Chao Yu
Quoted 21 lines · Jaegeuk Kim
Quoted 19 lines · Chao Yu
Quoted 6 lines · Jaegeuk Kim
Quoted 5 lines · Chao Yu
Quoted 3 lines · Jaegeuk Kim
Hi Chao,
Do you have any brief design doc to present the idea?
Quoted 7 lines
Quoted 5 lines
Hi Jaegeuk,
You mean this whole patchset, right?
I can add a brief design description in patch 0/5.
Yeah, it's a bit hard to understand the whole flow.
Jaegeuk,
Do you have time to take a look at this idea summarized in [PATCH 0/5]'s cover letter?
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Sorry, I couldn't afford to sitting down to review the design. Let me give it a try soon.
Alright, let me know if you have any question about the idea.
Ping,
Jaegeuk, still be too busy...? :P
Ping again...
Any thoughts about left patches in patchset?
Quoted 555 lines
Thanks,
Quoted 538 lines
Quoted 532 lines
Quoted 532 lines
Quoted 532 lines
Thanks,
Quoted 526 lines
Quoted 526 lines
Thanks,
Quoted 519 lines · Chao Yu
Previous implementation of aligned pinfile allocation will:
- allocate new segment on cold data log no matter whether last used segment is partially used or not, it makes IOs more random;
- force concurrent cold data/GCed IO going into warm data area, it can make a bad effect on hot/cold data separation;In this patch, we introduce a new type of log named 'inmem curseg', the differents from normal curseg is:
- it reuses existed segment type (CURSEG_XXX_NODE/DATA);
- it only exists in memory, its segno, blkofs, summary will not b persisted into checkpoint area;With this new feature, we can enhance scalability of log, special allocators can be created for purposes:
- pure lfs allocator for aligned pinfile allocation or file defragmentation
- pure ssr allocator for later featureSo that, let's update aligned pinfile allocation to use this new inmem curseg fwk.
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/checkpoint.c | 7 ++- fs/f2fs/debug.c | 6 ++- fs/f2fs/f2fs.h | 12 +++-- fs/f2fs/file.c | 3 +- fs/f2fs/gc.c | 2 +- fs/f2fs/segment.c | 107 ++++++++++++++++++++++++++++++------------- fs/f2fs/segment.h | 17 ++++--- fs/f2fs/super.c | 9 ++-- 8 files changed, 112 insertions(+), 51 deletions(-)fs/f2fs/checkpoint.c +6
-1@@ -1623,11 +1623,16 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)f2fs_flush_sit_entries (sbi, cpc); +/* save inmem log status */ +f2fs_save_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); + err =do_checkpoint (sbi, cpc);if (err)f2fs_release_discard_addrs (sbi);else f2fs_clear_prefree_segments (sbi, cpc); + +f2fs_restore_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); stop:unblock_operations (sbi);stat_inc_cp_count (sbi->stat_info);@@ -1658,7 +1663,7 @@ void f2fs_init_ino_entry_info(struct f2fs_sb_info *sbi) } sbi->max_orphans = (sbi->blocks_per_seg -F2FS_CP_PACKS - -NR_CURSEG_TYPE -__cp_payload (sbi)) * +NR_CURSEG_PERSIST_TYPE -__cp_payload (sbi)) *F2FS_ORPHANS_PER_BLOCK ; }fs/f2fs/debug.c +5
-1@@ -164,7 +164,7 @@ static void update_general_status(struct f2fs_sb_info *sbi) *100 / (int )(sbi->user_block_count >> sbi->log_blocks_per_seg) /2 ; si->util_invalid =50 - si->util_free - si->util_valid; -for (i =CURSEG_HOT_DATA ; i <=CURSEG_COLD_NODE ; i++) { +for (i =CURSEG_HOT_DATA ; i <NO_CHECK_TYPE ; i++) {struct curseg_info *curseg =CURSEG_I (sbi, i); si->curseg[i] = curseg->segno; si->cursec[i] =GET_SEC_FROM_SEG (sbi, curseg->segno);@@ -393,6 +393,10 @@ static int stat_show(struct seq_file *s, void *v) si->dirty_seg[CURSEG_COLD_NODE ], si->full_seg[CURSEG_COLD_NODE ], si->valid_blks[CURSEG_COLD_NODE]); +seq_printf (s," - Pinned file: %8d %8d %8d\n" , + si->curseg[CURSEG_COLD_DATA_PINNED ], + si->cursec[CURSEG_COLD_DATA_PINNED ], + si->curzone[CURSEG_COLD_DATA_PINNED ]); seq_printf(s, "\n - Valid: %d\n - Dirty: %d\n", si->main_area_segs - si->dirty_count - si->prefree_count - si->free_segs,fs/f2fs/f2fs.h +9
-3@@ -996,7 +996,9 @@ static inline void set_new_dnode(struct dnode_of_data *dn, struct inode *inode,*/ #define NR_CURSEG_DATA_TYPE (3)#define NR_CURSEG_NODE_TYPE (3) -#define NR_CURSEG_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) +#define NR_CURSEG_INMEM_TYPE (1) +#define NR_CURSEG_PERSIST_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) +#define NR_CURSEG_TYPE (NR_CURSEG_INMEM_TYPE + NR_CURSEG_PERSIST_TYPE)enum {CURSEG_HOT_DATA =0 ,/* directory entry blocks */ @@ -1005,8 +1007,10 @@ enum {CURSEG_HOT_NODE ,/* direct node blocks of directory files */ CURSEG_WARM_NODE ,/* direct node blocks of normal files */ CURSEG_COLD_NODE ,/* indirect node blocks */ -NO_CHECK_TYPE , - CURSEG_COLD_DATA_PINNED,/* cold data for pinned file */ +NR_PERSISTENT_LOG ,/* number of persistent log */ +CURSEG_COLD_DATA_PINNED =NR_PERSISTENT_LOG , +/* pinned file that needs consecutive block address */ + NO_CHECK_TYPE, /* number of persistent & inmem log */ }; struct flush_cmd {@@ -3359,6 +3363,8 @@ block_t f2fs_get_unusable_blocks(struct f2fs_sb_info *sbi);int f2fs_disable_cp_again (struct f2fs_sb_info *sbi,block_t unusable);void f2fs_release_discard_addrs (struct f2fs_sb_info *sbi);int f2fs_npages_for_summary_flush (struct f2fs_sb_info *sbi,bool for_ra); +void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi,int type); +void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi,int type);void f2fs_allocate_segment_for_resize (struct f2fs_sb_info *sbi,int type,unsigned int start,unsigned int end);void f2fs_allocate_new_segment (struct f2fs_sb_info *sbi,int type);fs/f2fs/file.c +2
-1@@ -1656,13 +1656,14 @@ static int expand_inode_data(struct inode *inode, loff_t offset, }down_write (&sbi->pin_sem); - map.m_seg_type =CURSEG_COLD_DATA_PINNED ;f2fs_lock_op (sbi);f2fs_allocate_new_segment (sbi,CURSEG_COLD_DATA );f2fs_unlock_op (sbi); + map.m_seg_type =CURSEG_COLD_DATA_PINNED ; err =f2fs_map_blocks (inode, &map,1 ,F2FS_GET_BLOCK_PRE_DIO ); +up_write (&sbi->pin_sem); done += map.m_len;fs/f2fs/gc.c +1
-1@@ -1448,7 +1448,7 @@ static int free_segment_range(struct f2fs_sb_info *sbi,mutex_unlock (&DIRTY_I (sbi)->seglist_lock);/* Move out cursegs from the target range */ -for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_TYPE ; type++) +for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_PERSIST_TYPE ; type++)f2fs_allocate_segment_for_resize (sbi, type, start, end);/* do GC to move out valid blocks in the range */ fs/f2fs/segment.c +74
-33@@ -1958,7 +1958,7 @@ static void set_prefree_as_free_segments(struct f2fs_sb_info *sbi)mutex_lock (&dirty_i->seglist_lock);for_each_set_bit (segno, dirty_i->dirty_segmap[PRE ],MAIN_SEGS (sbi)) -__set_test_and_free (sbi, segno); +__set_test_and_free (sbi, segno, false);mutex_unlock (&dirty_i->seglist_lock); }@@ -2496,6 +2496,7 @@ static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified)struct curseg_info *curseg =CURSEG_I (sbi, type);struct summary_footer *sum_footer; + curseg->inited = true; curseg->segno = curseg->next_segno; curseg->zone =GET_ZONE_FROM_SEG (sbi, curseg->segno); curseg->next_blkoff =0 ;@@ -2503,24 +2504,31 @@ static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified) sum_footer = &(curseg->sum_blk->footer);memset (sum_footer,0 ,sizeof (struct summary_footer )); -if (IS_DATASEG (type)) +if (IS_DATASEG (curseg->seg_type))SET_SUM_TYPE (sum_footer,SUM_TYPE_DATA ); -if (IS_NODESEG (type)) +if (IS_NODESEG (curseg->seg_type))SET_SUM_TYPE (sum_footer,SUM_TYPE_NODE ); -__set_sit_entry_type (sbi, type, curseg->segno, modified); +__set_sit_entry_type (sbi, curseg->seg_type, curseg->segno, modified); }static unsigned int __get_next_segno (struct f2fs_sb_info *sbi,int type) { +struct curseg_info *curseg =CURSEG_I (sbi, type); +/* if segs_per_sec is large than 1, we need to keep original policy. */ if (__is_large_section (sbi)) -return CURSEG_I (sbi, type)->segno; +return curseg->segno; + +/* inmem log may not locate on any segment after mount */ +if (!curseg->inited) +return 0 ;if (unlikely (is_sbi_flag_set (sbi,SBI_CP_DISABLED )))return 0 ;if (test_opt (sbi,NOHEAP ) && - (type ==CURSEG_HOT_DATA ||IS_NODESEG (type))) + (curseg->seg_type ==CURSEG_HOT_DATA || +IS_NODESEG (curseg->seg_type)))return 0 ;if (SIT_I (sbi)->last_victim[ALLOC_NEXT ])@@ -2530,7 +2538,7 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)if (F2FS_OPTION (sbi).alloc_mode ==ALLOC_MODE_REUSE )return 0 ; -return CURSEG_I (sbi, type)->segno; +return curseg->segno; }/* @@ -2540,12 +2548,14 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)static void new_curseg (struct f2fs_sb_info *sbi,int type,bool new_sec) {struct curseg_info *curseg =CURSEG_I (sbi, type); +unsigned short seg_type = curseg->seg_type;unsigned int segno = curseg->segno;int dir =ALLOC_LEFT ; -write_sum_page (sbi, curseg->sum_blk, +if (curseg->inited) +write_sum_page (sbi, curseg->sum_blk,GET_SUM_BLOCK (sbi, segno)); -if (type ==CURSEG_WARM_DATA || type ==CURSEG_COLD_DATA ) +if (seg_type ==CURSEG_WARM_DATA || seg_type ==CURSEG_COLD_DATA ) dir =ALLOC_RIGHT ;if (test_opt (sbi,NOHEAP ))@@ -2622,6 +2632,43 @@ static void change_curseg(struct f2fs_sb_info *sbi, int type)f2fs_put_page (sum_page,1 ); } +void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi,int type) +{ +struct curseg_info *curseg =CURSEG_I (sbi, type); + +mutex_lock (&curseg->curseg_mutex); +if (!curseg->inited) + goto out; + +if (get_valid_blocks (sbi, curseg->segno, false)) { +write_sum_page (sbi, curseg->sum_blk, +GET_SUM_BLOCK (sbi, curseg->segno)); + }else { +mutex_lock (&DIRTY_I (sbi)->seglist_lock); +__set_test_and_free (sbi, curseg->segno, true); +mutex_unlock (&DIRTY_I (sbi)->seglist_lock); + } +out: +mutex_unlock (&curseg->curseg_mutex); +} + +void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi,int type) +{ +struct curseg_info *curseg =CURSEG_I (sbi, type); + +mutex_lock (&curseg->curseg_mutex); +if (!curseg->inited) + goto out; +if (get_valid_blocks (sbi, curseg->segno, false)) + goto out; + +mutex_lock (&DIRTY_I (sbi)->seglist_lock); +__set_test_and_inuse (sbi, curseg->segno); +mutex_unlock (&DIRTY_I (sbi)->seglist_lock); +out: +mutex_unlock (&curseg->curseg_mutex); +} +static int get_ssr_segment (struct f2fs_sb_info *sbi,int type) {struct curseg_info *curseg =CURSEG_I (sbi, type);@@ -2738,11 +2785,15 @@ void __allocate_new_segment(struct f2fs_sb_info *sbi, int type)struct curseg_info *curseg =CURSEG_I (sbi, type);unsigned int old_segno; +if (!curseg->inited) + goto alloc; +if (!curseg->next_blkoff && !get_valid_blocks (sbi, curseg->segno, false) && !get_ckpt_valid_blocks (sbi, curseg->segno))return ; +alloc: old_segno = curseg->segno;SIT_I (sbi)->s_ops->allocate_segment (sbi, type, true);locate_dirty_segment (sbi, old_segno);@@ -3126,19 +3177,6 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, {struct sit_info *sit_i =SIT_I (sbi);struct curseg_info *curseg =CURSEG_I (sbi, type); -bool put_pin_sem = false; - -if (type ==CURSEG_COLD_DATA ) { -/* GC during CURSEG_COLD_DATA_PINNED allocation */ -if (down_read_trylock (&sbi->pin_sem)) { - put_pin_sem = true; - }else { - type =CURSEG_WARM_DATA ; - curseg =CURSEG_I (sbi, type); - } - }else if (type ==CURSEG_COLD_DATA_PINNED ) { - type =CURSEG_COLD_DATA ; - }down_read (&SM_I (sbi)->curseg_lock);@@ -3204,9 +3242,6 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,mutex_unlock (&curseg->curseg_mutex);up_read (&SM_I (sbi)->curseg_lock); - -if (put_pin_sem) -up_read (&sbi->pin_sem); }static void update_device_state (struct f2fs_io_info *fio)@@ -3574,7 +3609,7 @@ static int read_normal_summaries(struct f2fs_sb_info *sbi, int type) blk_off =le16_to_cpu (ckpt->cur_data_blkoff[type -CURSEG_HOT_DATA ]);if (__exist_node_summaries (sbi)) - blk_addr =sum_blk_addr (sbi,NR_CURSEG_TYPE , type); + blk_addr =sum_blk_addr (sbi,NR_CURSEG_PERSIST_TYPE , type);else blk_addr =sum_blk_addr (sbi,NR_CURSEG_DATA_TYPE , type); }else {@@ -3652,8 +3687,9 @@ static int restore_curseg_summaries(struct f2fs_sb_info *sbi) }if (__exist_node_summaries (sbi)) -f2fs_ra_meta_pages (sbi,sum_blk_addr (sbi,NR_CURSEG_TYPE , type), -NR_CURSEG_TYPE - type,META_CP , true); +f2fs_ra_meta_pages (sbi, +sum_blk_addr (sbi,NR_CURSEG_PERSIST_TYPE , type), +NR_CURSEG_PERSIST_TYPE - type,META_CP , true);for (; type <=CURSEG_COLD_NODE ; type++) { err =read_normal_summaries (sbi, type);@@ -4155,14 +4191,14 @@ static int build_curseg(struct f2fs_sb_info *sbi)struct curseg_info *array;int i; - array =f2fs_kzalloc (sbi,array_size (NR_CURSEG_TYPE ,sizeof (*array)), -GFP_KERNEL ); + array =f2fs_kzalloc (sbi,array_size (NR_CURSEG_TYPE , +sizeof (*array)),GFP_KERNEL );if (!array)return -ENOMEM ;SM_I (sbi)->curseg_array = array; -for (i =0 ; i <NR_CURSEG_TYPE ; i++) { +for (i =0 ; i <NO_CHECK_TYPE ; i++) {mutex_init (&array[i].curseg_mutex); array[i].sum_blk =f2fs_kzalloc (sbi,PAGE_SIZE ,GFP_KERNEL );if (!array[i].sum_blk)@@ -4172,8 +4208,13 @@ static int build_curseg(struct f2fs_sb_info *sbi) sizeof(struct f2fs_journal), GFP_KERNEL);if (!array[i].journal)return -ENOMEM ; +if (i <NR_PERSISTENT_LOG ) + array[i].seg_type =CURSEG_HOT_DATA + i; +else if (i ==CURSEG_COLD_DATA_PINNED ) + array[i].seg_type =CURSEG_COLD_DATA ; array[i].segno =NULL_SEGNO ; array[i].next_blkoff =0 ; + array[i].inited = false; }return restore_curseg_summaries (sbi); }@@ -4408,7 +4449,7 @@ static int sanity_check_curseg(struct f2fs_sb_info *sbi)* In LFS/SSR curseg, .next_blkoff should point to an unused blkaddr; * In LFS curseg, all blkaddr after .next_blkoff should be unused. */ -for (i =0 ; i <NO_CHECK_TYPE ; i++) { +for (i =0 ; i <NR_PERSISTENT_LOG ; i++) {struct curseg_info *curseg =CURSEG_I (sbi, i);struct seg_entry *se =get_seg_entry (sbi, curseg->segno);unsigned int blkofs = curseg->next_blkoff;@@ -4637,7 +4678,7 @@ int f2fs_fix_curseg_write_pointer(struct f2fs_sb_info *sbi) {int i, ret; -for (i =0 ; i <NO_CHECK_TYPE ; i++) { +for (i =0 ; i <NR_PERSISTENT_LOG ; i++) { ret =fix_curseg_write_pointer (sbi, i);if (ret)return ret;fs/f2fs/segment.h +10
-7@@ -22,7 +22,7 @@#define GET_R2L_SEGNO (free_i, segno) ((segno) + (free_i)->start_segno)#define IS_DATASEG (t) ((t) <= CURSEG_COLD_DATA) -#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE) +#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE && (t) <= CURSEG_COLD_NODE)#define IS_HOT (t) ((t) == CURSEG_HOT_NODE || (t) == CURSEG_HOT_DATA)#define IS_WARM (t) ((t) == CURSEG_WARM_NODE || (t) == CURSEG_WARM_DATA)@@ -34,7 +34,8 @@ ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_HOT_NODE)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno) || \ - ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno)) + ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno) || \ + ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno))#define IS_CURSEC (sbi, secno) \ (((secno) == CURSEG_I(sbi, CURSEG_HOT_DATA)->segno / \@@ -48,7 +49,9 @@ ((secno) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno / \ (sbi)->segs_per_sec) || \ ((secno) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno / \ - (sbi)->segs_per_sec)) \ + (sbi)->segs_per_sec) || \ + ((secno) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno / \ + (sbi)->segs_per_sec))#define MAIN_BLKADDR (sbi) \ (SM_I(sbi) ? SM_I(sbi)->main_blkaddr : \@@ -288,10 +291,12 @@ struct curseg_info {struct rw_semaphore journal_rwsem;/* protect journal area */ struct f2fs_journal *journal;/* cached journal info */ unsigned char alloc_type;/* current allocation type */ +unsigned short seg_type;/* segment type like CURSEG_XXX_TYPE */ unsigned int segno;/* current segment number */ unsigned short next_blkoff;/* next block offset to write */ unsigned int zone;/* current zone number */ unsigned int next_segno;/* preallocated segment */ +bool inited;/* indicate inmem log is inited */ };struct sit_entry_set {@@ -305,8 +310,6 @@ struct sit_entry_set {*/ static inline struct curseg_info *CURSEG_I (struct f2fs_sb_info *sbi,int type) { -if (type ==CURSEG_COLD_DATA_PINNED ) - type =CURSEG_COLD_DATA ;return (struct curseg_info *)(SM_I (sbi)->curseg_array + type); }@@ -438,7 +441,7 @@ static inline void __set_inuse(struct f2fs_sb_info *sbi, }static inline void __set_test_and_free (struct f2fs_sb_info *sbi, -unsigned int segno) +unsigned int segno,bool inmem) {struct free_segmap_info *free_i =FREE_I (sbi);unsigned int secno =GET_SEC_FROM_SEG (sbi, segno);@@ -449,7 +452,7 @@ static inline void __set_test_and_free(struct f2fs_sb_info *sbi,if (test_and_clear_bit (segno, free_i->free_segmap)) { free_i->free_segments++; -if (IS_CURSEC (sbi, secno)) +if (!inmem &&IS_CURSEC (sbi, secno)) goto skip_free; next =find_next_bit (free_i->free_segmap, start_segno + sbi->segs_per_sec, start_segno);fs/f2fs/super.c +5
-4@@ -575,7 +575,8 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)case Opt_active_logs:if (args->from &&match_int (args, &arg))return -EINVAL ; -if (arg !=2 && arg !=4 && arg !=NR_CURSEG_TYPE ) +if (arg !=2 && arg !=4 && + arg !=NR_CURSEG_PERSIST_TYPE )return -EINVAL ;F2FS_OPTION (sbi).active_logs = arg;break ;@@ -981,7 +982,7 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) }/* Not pass down write hints if the number of active logs is lesser -* than NR_CURSEG_TYPE. +* than NR_CURSEG_PERSIST_TYPE. */ if (F2FS_OPTION (sbi).active_logs !=NR_CURSEG_TYPE )F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ;@@ -1614,7 +1615,7 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)static void default_options (struct f2fs_sb_info *sbi) {/* init some FS parameters */ -F2FS_OPTION (sbi).active_logs =NR_CURSEG_TYPE ; +F2FS_OPTION (sbi).active_logs =NR_CURSEG_PERSIST_TYPE ;F2FS_OPTION (sbi).inline_xattr_size =DEFAULT_INLINE_XATTR_ADDRS ;F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ;F2FS_OPTION (sbi).alloc_mode =ALLOC_MODE_DEFAULT ;@@ -2946,7 +2947,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi) cp_payload =__cp_payload (sbi);if (cp_pack_start_sum < cp_payload +1 || cp_pack_start_sum > blocks_per_seg -1 - -NR_CURSEG_TYPE ) { +NR_CURSEG_PERSIST_TYPE ) {f2fs_err (sbi,"Wrong cp_pack_start_sum: %u" , cp_pack_start_sum);return 1 ;Signature · 1 line
2.26.2.
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
.
.
Quoted 6 lines
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
._______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
.
Jaegeuk Kim
maintainerQuoted 29 lines · Chao Yu
Quoted 28 lines · Chao Yu
Quoted 26 lines · Chao Yu
Quoted 16 lines · Jaegeuk Kim
Quoted 15 lines · Chao Yu
Quoted 13 lines · Jaegeuk Kim
Quoted 10 lines · Chao Yu
Quoted 3 lines · Jaegeuk Kim
Hi Chao,
Do you have any brief design doc to present the idea?
Hi Jaegeuk,
You mean this whole patchset, right?
I can add a brief design description in patch 0/5.
Yeah, it's a bit hard to understand the whole flow.
Quoted 7 lines
Quoted 4 lines
Jaegeuk,
Do you have time to take a look at this idea summarized in [PATCH 0/5]'s cover letter?
Sorry, I couldn't afford to sitting down to review the design. Let me give it a try soon.
Alright, let me know if you have any question about the idea.
Quoted 7 lines
Quoted 3 lines
Ping,
Jaegeuk, still be too busy...? :P
Ping again...
Any thoughts about left patches in patchset?
Ah, I was waiting for your another patch-set.
Quoted 510 lines
Quoted 510 lines
Thanks,
Quoted 492 lines
Quoted 486 lines
Quoted 486 lines
Quoted 486 lines
Thanks,
Quoted 480 lines
Quoted 480 lines
Thanks,
Quoted 473 lines · Chao Yu
Previous implementation of aligned pinfile allocation will:
- allocate new segment on cold data log no matter whether last used segment is partially used or not, it makes IOs more random;
- force concurrent cold data/GCed IO going into warm data area, it can make a bad effect on hot/cold data separation;In this patch, we introduce a new type of log named 'inmem curseg', the differents from normal curseg is:
- it reuses existed segment type (CURSEG_XXX_NODE/DATA);
- it only exists in memory, its segno, blkofs, summary will not b persisted into checkpoint area;With this new feature, we can enhance scalability of log, special allocators can be created for purposes:
- pure lfs allocator for aligned pinfile allocation or file defragmentation
- pure ssr allocator for later featureSo that, let's update aligned pinfile allocation to use this new inmem curseg fwk.
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/checkpoint.c | 7 ++- fs/f2fs/debug.c | 6 ++- fs/f2fs/f2fs.h | 12 +++-- fs/f2fs/file.c | 3 +- fs/f2fs/gc.c | 2 +- fs/f2fs/segment.c | 107 ++++++++++++++++++++++++++++++------------- fs/f2fs/segment.h | 17 ++++--- fs/f2fs/super.c | 9 ++-- 8 files changed, 112 insertions(+), 51 deletions(-)fs/f2fs/checkpoint.c +6
-1@@ -1623,11 +1623,16 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)f2fs_flush_sit_entries (sbi, cpc); +/* save inmem log status */ +f2fs_save_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); + err =do_checkpoint (sbi, cpc);if (err)f2fs_release_discard_addrs (sbi);else f2fs_clear_prefree_segments (sbi, cpc); + +f2fs_restore_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); stop:unblock_operations (sbi);stat_inc_cp_count (sbi->stat_info);@@ -1658,7 +1663,7 @@ void f2fs_init_ino_entry_info(struct f2fs_sb_info *sbi) } sbi->max_orphans = (sbi->blocks_per_seg -F2FS_CP_PACKS - -NR_CURSEG_TYPE -__cp_payload (sbi)) * +NR_CURSEG_PERSIST_TYPE -__cp_payload (sbi)) *F2FS_ORPHANS_PER_BLOCK ; }fs/f2fs/debug.c +5
-1@@ -164,7 +164,7 @@ static void update_general_status(struct f2fs_sb_info *sbi) *100 / (int )(sbi->user_block_count >> sbi->log_blocks_per_seg) /2 ; si->util_invalid =50 - si->util_free - si->util_valid; -for (i =CURSEG_HOT_DATA ; i <=CURSEG_COLD_NODE ; i++) { +for (i =CURSEG_HOT_DATA ; i <NO_CHECK_TYPE ; i++) {struct curseg_info *curseg =CURSEG_I (sbi, i); si->curseg[i] = curseg->segno; si->cursec[i] =GET_SEC_FROM_SEG (sbi, curseg->segno);@@ -393,6 +393,10 @@ static int stat_show(struct seq_file *s, void *v) si->dirty_seg[CURSEG_COLD_NODE ], si->full_seg[CURSEG_COLD_NODE ], si->valid_blks[CURSEG_COLD_NODE]); +seq_printf (s," - Pinned file: %8d %8d %8d\n" , + si->curseg[CURSEG_COLD_DATA_PINNED ], + si->cursec[CURSEG_COLD_DATA_PINNED ], + si->curzone[CURSEG_COLD_DATA_PINNED ]); seq_printf(s, "\n - Valid: %d\n - Dirty: %d\n", si->main_area_segs - si->dirty_count - si->prefree_count - si->free_segs,fs/f2fs/f2fs.h +9
-3@@ -996,7 +996,9 @@ static inline void set_new_dnode(struct dnode_of_data *dn, struct inode *inode,*/ #define NR_CURSEG_DATA_TYPE (3)#define NR_CURSEG_NODE_TYPE (3) -#define NR_CURSEG_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) +#define NR_CURSEG_INMEM_TYPE (1) +#define NR_CURSEG_PERSIST_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) +#define NR_CURSEG_TYPE (NR_CURSEG_INMEM_TYPE + NR_CURSEG_PERSIST_TYPE)enum {CURSEG_HOT_DATA =0 ,/* directory entry blocks */ @@ -1005,8 +1007,10 @@ enum {CURSEG_HOT_NODE ,/* direct node blocks of directory files */ CURSEG_WARM_NODE ,/* direct node blocks of normal files */ CURSEG_COLD_NODE ,/* indirect node blocks */ -NO_CHECK_TYPE , - CURSEG_COLD_DATA_PINNED,/* cold data for pinned file */ +NR_PERSISTENT_LOG ,/* number of persistent log */ +CURSEG_COLD_DATA_PINNED =NR_PERSISTENT_LOG , +/* pinned file that needs consecutive block address */ + NO_CHECK_TYPE, /* number of persistent & inmem log */ }; struct flush_cmd {@@ -3359,6 +3363,8 @@ block_t f2fs_get_unusable_blocks(struct f2fs_sb_info *sbi);int f2fs_disable_cp_again (struct f2fs_sb_info *sbi,block_t unusable);void f2fs_release_discard_addrs (struct f2fs_sb_info *sbi);int f2fs_npages_for_summary_flush (struct f2fs_sb_info *sbi,bool for_ra); +void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi,int type); +void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi,int type);void f2fs_allocate_segment_for_resize (struct f2fs_sb_info *sbi,int type,unsigned int start,unsigned int end);void f2fs_allocate_new_segment (struct f2fs_sb_info *sbi,int type);fs/f2fs/file.c +2
-1@@ -1656,13 +1656,14 @@ static int expand_inode_data(struct inode *inode, loff_t offset, }down_write (&sbi->pin_sem); - map.m_seg_type =CURSEG_COLD_DATA_PINNED ;f2fs_lock_op (sbi);f2fs_allocate_new_segment (sbi,CURSEG_COLD_DATA );f2fs_unlock_op (sbi); + map.m_seg_type =CURSEG_COLD_DATA_PINNED ; err =f2fs_map_blocks (inode, &map,1 ,F2FS_GET_BLOCK_PRE_DIO ); +up_write (&sbi->pin_sem); done += map.m_len;fs/f2fs/gc.c +1
-1@@ -1448,7 +1448,7 @@ static int free_segment_range(struct f2fs_sb_info *sbi,mutex_unlock (&DIRTY_I (sbi)->seglist_lock);/* Move out cursegs from the target range */ -for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_TYPE ; type++) +for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_PERSIST_TYPE ; type++)f2fs_allocate_segment_for_resize (sbi, type, start, end);/* do GC to move out valid blocks in the range */ fs/f2fs/segment.c +74
-33@@ -1958,7 +1958,7 @@ static void set_prefree_as_free_segments(struct f2fs_sb_info *sbi)mutex_lock (&dirty_i->seglist_lock);for_each_set_bit (segno, dirty_i->dirty_segmap[PRE ],MAIN_SEGS (sbi)) -__set_test_and_free (sbi, segno); +__set_test_and_free (sbi, segno, false);mutex_unlock (&dirty_i->seglist_lock); }@@ -2496,6 +2496,7 @@ static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified)struct curseg_info *curseg =CURSEG_I (sbi, type);struct summary_footer *sum_footer; + curseg->inited = true; curseg->segno = curseg->next_segno; curseg->zone =GET_ZONE_FROM_SEG (sbi, curseg->segno); curseg->next_blkoff =0 ;@@ -2503,24 +2504,31 @@ static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified) sum_footer = &(curseg->sum_blk->footer);memset (sum_footer,0 ,sizeof (struct summary_footer )); -if (IS_DATASEG (type)) +if (IS_DATASEG (curseg->seg_type))SET_SUM_TYPE (sum_footer,SUM_TYPE_DATA ); -if (IS_NODESEG (type)) +if (IS_NODESEG (curseg->seg_type))SET_SUM_TYPE (sum_footer,SUM_TYPE_NODE ); -__set_sit_entry_type (sbi, type, curseg->segno, modified); +__set_sit_entry_type (sbi, curseg->seg_type, curseg->segno, modified); }static unsigned int __get_next_segno (struct f2fs_sb_info *sbi,int type) { +struct curseg_info *curseg =CURSEG_I (sbi, type); +/* if segs_per_sec is large than 1, we need to keep original policy. */ if (__is_large_section (sbi)) -return CURSEG_I (sbi, type)->segno; +return curseg->segno; + +/* inmem log may not locate on any segment after mount */ +if (!curseg->inited) +return 0 ;if (unlikely (is_sbi_flag_set (sbi,SBI_CP_DISABLED )))return 0 ;if (test_opt (sbi,NOHEAP ) && - (type ==CURSEG_HOT_DATA ||IS_NODESEG (type))) + (curseg->seg_type ==CURSEG_HOT_DATA || +IS_NODESEG (curseg->seg_type)))return 0 ;if (SIT_I (sbi)->last_victim[ALLOC_NEXT ])@@ -2530,7 +2538,7 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)if (F2FS_OPTION (sbi).alloc_mode ==ALLOC_MODE_REUSE )return 0 ; -return CURSEG_I (sbi, type)->segno; +return curseg->segno; }/* @@ -2540,12 +2548,14 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)static void new_curseg (struct f2fs_sb_info *sbi,int type,bool new_sec) {struct curseg_info *curseg =CURSEG_I (sbi, type); +unsigned short seg_type = curseg->seg_type;unsigned int segno = curseg->segno;int dir =ALLOC_LEFT ; -write_sum_page (sbi, curseg->sum_blk, +if (curseg->inited) +write_sum_page (sbi, curseg->sum_blk,GET_SUM_BLOCK (sbi, segno)); -if (type ==CURSEG_WARM_DATA || type ==CURSEG_COLD_DATA ) +if (seg_type ==CURSEG_WARM_DATA || seg_type ==CURSEG_COLD_DATA ) dir =ALLOC_RIGHT ;if (test_opt (sbi,NOHEAP ))@@ -2622,6 +2632,43 @@ static void change_curseg(struct f2fs_sb_info *sbi, int type)f2fs_put_page (sum_page,1 ); } +void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi,int type) +{ +struct curseg_info *curseg =CURSEG_I (sbi, type); + +mutex_lock (&curseg->curseg_mutex); +if (!curseg->inited) + goto out; + +if (get_valid_blocks (sbi, curseg->segno, false)) { +write_sum_page (sbi, curseg->sum_blk, +GET_SUM_BLOCK (sbi, curseg->segno)); + }else { +mutex_lock (&DIRTY_I (sbi)->seglist_lock); +__set_test_and_free (sbi, curseg->segno, true); +mutex_unlock (&DIRTY_I (sbi)->seglist_lock); + } +out: +mutex_unlock (&curseg->curseg_mutex); +} + +void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi,int type) +{ +struct curseg_info *curseg =CURSEG_I (sbi, type); + +mutex_lock (&curseg->curseg_mutex); +if (!curseg->inited) + goto out; +if (get_valid_blocks (sbi, curseg->segno, false)) + goto out; + +mutex_lock (&DIRTY_I (sbi)->seglist_lock); +__set_test_and_inuse (sbi, curseg->segno); +mutex_unlock (&DIRTY_I (sbi)->seglist_lock); +out: +mutex_unlock (&curseg->curseg_mutex); +} +static int get_ssr_segment (struct f2fs_sb_info *sbi,int type) {struct curseg_info *curseg =CURSEG_I (sbi, type);@@ -2738,11 +2785,15 @@ void __allocate_new_segment(struct f2fs_sb_info *sbi, int type)struct curseg_info *curseg =CURSEG_I (sbi, type);unsigned int old_segno; +if (!curseg->inited) + goto alloc; +if (!curseg->next_blkoff && !get_valid_blocks (sbi, curseg->segno, false) && !get_ckpt_valid_blocks (sbi, curseg->segno))return ; +alloc: old_segno = curseg->segno;SIT_I (sbi)->s_ops->allocate_segment (sbi, type, true);locate_dirty_segment (sbi, old_segno);@@ -3126,19 +3177,6 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, {struct sit_info *sit_i =SIT_I (sbi);struct curseg_info *curseg =CURSEG_I (sbi, type); -bool put_pin_sem = false; - -if (type ==CURSEG_COLD_DATA ) { -/* GC during CURSEG_COLD_DATA_PINNED allocation */ -if (down_read_trylock (&sbi->pin_sem)) { - put_pin_sem = true; - }else { - type =CURSEG_WARM_DATA ; - curseg =CURSEG_I (sbi, type); - } - }else if (type ==CURSEG_COLD_DATA_PINNED ) { - type =CURSEG_COLD_DATA ; - }down_read (&SM_I (sbi)->curseg_lock);@@ -3204,9 +3242,6 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,mutex_unlock (&curseg->curseg_mutex);up_read (&SM_I (sbi)->curseg_lock); - -if (put_pin_sem) -up_read (&sbi->pin_sem); }static void update_device_state (struct f2fs_io_info *fio)@@ -3574,7 +3609,7 @@ static int read_normal_summaries(struct f2fs_sb_info *sbi, int type) blk_off =le16_to_cpu (ckpt->cur_data_blkoff[type -CURSEG_HOT_DATA ]);if (__exist_node_summaries (sbi)) - blk_addr =sum_blk_addr (sbi,NR_CURSEG_TYPE , type); + blk_addr =sum_blk_addr (sbi,NR_CURSEG_PERSIST_TYPE , type);else blk_addr =sum_blk_addr (sbi,NR_CURSEG_DATA_TYPE , type); }else {@@ -3652,8 +3687,9 @@ static int restore_curseg_summaries(struct f2fs_sb_info *sbi) }if (__exist_node_summaries (sbi)) -f2fs_ra_meta_pages (sbi,sum_blk_addr (sbi,NR_CURSEG_TYPE , type), -NR_CURSEG_TYPE - type,META_CP , true); +f2fs_ra_meta_pages (sbi, +sum_blk_addr (sbi,NR_CURSEG_PERSIST_TYPE , type), +NR_CURSEG_PERSIST_TYPE - type,META_CP , true);for (; type <=CURSEG_COLD_NODE ; type++) { err =read_normal_summaries (sbi, type);@@ -4155,14 +4191,14 @@ static int build_curseg(struct f2fs_sb_info *sbi)struct curseg_info *array;int i; - array =f2fs_kzalloc (sbi,array_size (NR_CURSEG_TYPE ,sizeof (*array)), -GFP_KERNEL ); + array =f2fs_kzalloc (sbi,array_size (NR_CURSEG_TYPE , +sizeof (*array)),GFP_KERNEL );if (!array)return -ENOMEM ;SM_I (sbi)->curseg_array = array; -for (i =0 ; i <NR_CURSEG_TYPE ; i++) { +for (i =0 ; i <NO_CHECK_TYPE ; i++) {mutex_init (&array[i].curseg_mutex); array[i].sum_blk =f2fs_kzalloc (sbi,PAGE_SIZE ,GFP_KERNEL );if (!array[i].sum_blk)@@ -4172,8 +4208,13 @@ static int build_curseg(struct f2fs_sb_info *sbi) sizeof(struct f2fs_journal), GFP_KERNEL);if (!array[i].journal)return -ENOMEM ; +if (i <NR_PERSISTENT_LOG ) + array[i].seg_type =CURSEG_HOT_DATA + i; +else if (i ==CURSEG_COLD_DATA_PINNED ) + array[i].seg_type =CURSEG_COLD_DATA ; array[i].segno =NULL_SEGNO ; array[i].next_blkoff =0 ; + array[i].inited = false; }return restore_curseg_summaries (sbi); }@@ -4408,7 +4449,7 @@ static int sanity_check_curseg(struct f2fs_sb_info *sbi)* In LFS/SSR curseg, .next_blkoff should point to an unused blkaddr; * In LFS curseg, all blkaddr after .next_blkoff should be unused. */ -for (i =0 ; i <NO_CHECK_TYPE ; i++) { +for (i =0 ; i <NR_PERSISTENT_LOG ; i++) {struct curseg_info *curseg =CURSEG_I (sbi, i);struct seg_entry *se =get_seg_entry (sbi, curseg->segno);unsigned int blkofs = curseg->next_blkoff;@@ -4637,7 +4678,7 @@ int f2fs_fix_curseg_write_pointer(struct f2fs_sb_info *sbi) {int i, ret; -for (i =0 ; i <NO_CHECK_TYPE ; i++) { +for (i =0 ; i <NR_PERSISTENT_LOG ; i++) { ret =fix_curseg_write_pointer (sbi, i);if (ret)return ret;fs/f2fs/segment.h +10
-7@@ -22,7 +22,7 @@#define GET_R2L_SEGNO (free_i, segno) ((segno) + (free_i)->start_segno)#define IS_DATASEG (t) ((t) <= CURSEG_COLD_DATA) -#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE) +#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE && (t) <= CURSEG_COLD_NODE)#define IS_HOT (t) ((t) == CURSEG_HOT_NODE || (t) == CURSEG_HOT_DATA)#define IS_WARM (t) ((t) == CURSEG_WARM_NODE || (t) == CURSEG_WARM_DATA)@@ -34,7 +34,8 @@ ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_HOT_NODE)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno) || \ - ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno)) + ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno) || \ + ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno))#define IS_CURSEC (sbi, secno) \ (((secno) == CURSEG_I(sbi, CURSEG_HOT_DATA)->segno / \@@ -48,7 +49,9 @@ ((secno) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno / \ (sbi)->segs_per_sec) || \ ((secno) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno / \ - (sbi)->segs_per_sec)) \ + (sbi)->segs_per_sec) || \ + ((secno) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno / \ + (sbi)->segs_per_sec))#define MAIN_BLKADDR (sbi) \ (SM_I(sbi) ? SM_I(sbi)->main_blkaddr : \@@ -288,10 +291,12 @@ struct curseg_info {struct rw_semaphore journal_rwsem;/* protect journal area */ struct f2fs_journal *journal;/* cached journal info */ unsigned char alloc_type;/* current allocation type */ +unsigned short seg_type;/* segment type like CURSEG_XXX_TYPE */ unsigned int segno;/* current segment number */ unsigned short next_blkoff;/* next block offset to write */ unsigned int zone;/* current zone number */ unsigned int next_segno;/* preallocated segment */ +bool inited;/* indicate inmem log is inited */ };struct sit_entry_set {@@ -305,8 +310,6 @@ struct sit_entry_set {*/ static inline struct curseg_info *CURSEG_I (struct f2fs_sb_info *sbi,int type) { -if (type ==CURSEG_COLD_DATA_PINNED ) - type =CURSEG_COLD_DATA ;return (struct curseg_info *)(SM_I (sbi)->curseg_array + type); }@@ -438,7 +441,7 @@ static inline void __set_inuse(struct f2fs_sb_info *sbi, }static inline void __set_test_and_free (struct f2fs_sb_info *sbi, -unsigned int segno) +unsigned int segno,bool inmem) {struct free_segmap_info *free_i =FREE_I (sbi);unsigned int secno =GET_SEC_FROM_SEG (sbi, segno);@@ -449,7 +452,7 @@ static inline void __set_test_and_free(struct f2fs_sb_info *sbi,if (test_and_clear_bit (segno, free_i->free_segmap)) { free_i->free_segments++; -if (IS_CURSEC (sbi, secno)) +if (!inmem &&IS_CURSEC (sbi, secno)) goto skip_free; next =find_next_bit (free_i->free_segmap, start_segno + sbi->segs_per_sec, start_segno);fs/f2fs/super.c +5
-4@@ -575,7 +575,8 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)case Opt_active_logs:if (args->from &&match_int (args, &arg))return -EINVAL ; -if (arg !=2 && arg !=4 && arg !=NR_CURSEG_TYPE ) +if (arg !=2 && arg !=4 && + arg !=NR_CURSEG_PERSIST_TYPE )return -EINVAL ;F2FS_OPTION (sbi).active_logs = arg;break ;@@ -981,7 +982,7 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) }/* Not pass down write hints if the number of active logs is lesser -* than NR_CURSEG_TYPE. +* than NR_CURSEG_PERSIST_TYPE. */ if (F2FS_OPTION (sbi).active_logs !=NR_CURSEG_TYPE )F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ;@@ -1614,7 +1615,7 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)static void default_options (struct f2fs_sb_info *sbi) {/* init some FS parameters */ -F2FS_OPTION (sbi).active_logs =NR_CURSEG_TYPE ; +F2FS_OPTION (sbi).active_logs =NR_CURSEG_PERSIST_TYPE ;F2FS_OPTION (sbi).inline_xattr_size =DEFAULT_INLINE_XATTR_ADDRS ;F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ;F2FS_OPTION (sbi).alloc_mode =ALLOC_MODE_DEFAULT ;@@ -2946,7 +2947,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi) cp_payload =__cp_payload (sbi);if (cp_pack_start_sum < cp_payload +1 || cp_pack_start_sum > blocks_per_seg -1 - -NR_CURSEG_TYPE ) { +NR_CURSEG_PERSIST_TYPE ) {f2fs_err (sbi,"Wrong cp_pack_start_sum: %u" , cp_pack_start_sum);return 1 ;Signature · 1 line
2.26.2.
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
.
.
Quoted 6 lines
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
._______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
.
Quoted 32 lines · Jaegeuk Kim
Quoted 31 lines · Chao Yu
Quoted 30 lines · Chao Yu
Quoted 19 lines · Chao Yu
Quoted 18 lines · Jaegeuk Kim
Quoted 17 lines · Chao Yu
Quoted 6 lines · Jaegeuk Kim
Quoted 5 lines · Chao Yu
Quoted 3 lines · Jaegeuk Kim
Hi Chao,
Do you have any brief design doc to present the idea?
Quoted 7 lines
Quoted 5 lines
Hi Jaegeuk,
You mean this whole patchset, right?
I can add a brief design description in patch 0/5.
Yeah, it's a bit hard to understand the whole flow.
Jaegeuk,
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Do you have time to take a look at this idea summarized in [PATCH 0/5]'s cover letter?
Sorry, I couldn't afford to sitting down to review the design. Let me give it a try soon.
Alright, let me know if you have any question about the idea.
Ping,
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Jaegeuk, still be too busy...? :P
Ping again...
Any thoughts about left patches in patchset?
Ah, I was waiting for your another patch-set.
Oops, I thought that you have not finished reviewing all patches...
Anyway, let me send v2 w/ changes mentioned by you.
BTW, we can discuss about how to enable such feature, options can be:
- enable when sb feature F2FS_FEATURE_ATGC was set
- enable via mount option
- enable via sysfs
Quoted 513 lines
Quoted 505 lines
Quoted 505 lines
Thanks,
Quoted 498 lines
Quoted 486 lines
Quoted 486 lines
Quoted 486 lines
Thanks,
Quoted 480 lines
Quoted 480 lines
Thanks,
Quoted 473 lines · Chao Yu
Previous implementation of aligned pinfile allocation will:
- allocate new segment on cold data log no matter whether last used segment is partially used or not, it makes IOs more random;
- force concurrent cold data/GCed IO going into warm data area, it can make a bad effect on hot/cold data separation;In this patch, we introduce a new type of log named 'inmem curseg', the differents from normal curseg is:
- it reuses existed segment type (CURSEG_XXX_NODE/DATA);
- it only exists in memory, its segno, blkofs, summary will not bpersisted into checkpoint area;With this new feature, we can enhance scalability of log, special allocators can be created for purposes:
- pure lfs allocator for aligned pinfile allocation or file defragmentation
- pure ssr allocator for later featureSo that, let's update aligned pinfile allocation to use this new inmem curseg fwk.
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/checkpoint.c | 7 ++- fs/f2fs/debug.c | 6 ++- fs/f2fs/f2fs.h | 12 +++-- fs/f2fs/file.c | 3 +- fs/f2fs/gc.c | 2 +- fs/f2fs/segment.c | 107 ++++++++++++++++++++++++++++++------------- fs/f2fs/segment.h | 17 ++++--- fs/f2fs/super.c | 9 ++-- 8 files changed, 112 insertions(+), 51 deletions(-)fs/f2fs/checkpoint.c +6
-1@@ -1623,11 +1623,16 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)f2fs_flush_sit_entries (sbi, cpc); +/* save inmem log status */ +f2fs_save_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); + err =do_checkpoint (sbi, cpc);if (err)f2fs_release_discard_addrs (sbi);else f2fs_clear_prefree_segments (sbi, cpc); + +f2fs_restore_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); stop:unblock_operations (sbi);stat_inc_cp_count (sbi->stat_info);@@ -1658,7 +1663,7 @@ void f2fs_init_ino_entry_info(struct f2fs_sb_info *sbi) } sbi->max_orphans = (sbi->blocks_per_seg -F2FS_CP_PACKS - -NR_CURSEG_TYPE -__cp_payload (sbi)) * +NR_CURSEG_PERSIST_TYPE -__cp_payload (sbi)) *F2FS_ORPHANS_PER_BLOCK ; }fs/f2fs/debug.c +5
-1@@ -164,7 +164,7 @@ static void update_general_status(struct f2fs_sb_info *sbi) *100 / (int )(sbi->user_block_count >> sbi->log_blocks_per_seg) /2 ; si->util_invalid =50 - si->util_free - si->util_valid; -for (i =CURSEG_HOT_DATA ; i <=CURSEG_COLD_NODE ; i++) { +for (i =CURSEG_HOT_DATA ; i <NO_CHECK_TYPE ; i++) {struct curseg_info *curseg =CURSEG_I (sbi, i); si->curseg[i] = curseg->segno; si->cursec[i] =GET_SEC_FROM_SEG (sbi, curseg->segno);@@ -393,6 +393,10 @@ static int stat_show(struct seq_file *s, void *v) si->dirty_seg[CURSEG_COLD_NODE ], si->full_seg[CURSEG_COLD_NODE ], si->valid_blks[CURSEG_COLD_NODE]); +seq_printf (s," - Pinned file: %8d %8d %8d\n" , + si->curseg[CURSEG_COLD_DATA_PINNED ], + si->cursec[CURSEG_COLD_DATA_PINNED ], + si->curzone[CURSEG_COLD_DATA_PINNED ]); seq_printf(s, "\n - Valid: %d\n - Dirty: %d\n", si->main_area_segs - si->dirty_count - si->prefree_count - si->free_segs,fs/f2fs/f2fs.h +9
-3@@ -996,7 +996,9 @@ static inline void set_new_dnode(struct dnode_of_data *dn, struct inode *inode,*/ #define NR_CURSEG_DATA_TYPE (3)#define NR_CURSEG_NODE_TYPE (3) -#define NR_CURSEG_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) +#define NR_CURSEG_INMEM_TYPE (1) +#define NR_CURSEG_PERSIST_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) +#define NR_CURSEG_TYPE (NR_CURSEG_INMEM_TYPE + NR_CURSEG_PERSIST_TYPE)enum {CURSEG_HOT_DATA =0 ,/* directory entry blocks */ @@ -1005,8 +1007,10 @@ enum {CURSEG_HOT_NODE ,/* direct node blocks of directory files */ CURSEG_WARM_NODE ,/* direct node blocks of normal files */ CURSEG_COLD_NODE ,/* indirect node blocks */ -NO_CHECK_TYPE , - CURSEG_COLD_DATA_PINNED,/* cold data for pinned file */ +NR_PERSISTENT_LOG ,/* number of persistent log */ +CURSEG_COLD_DATA_PINNED =NR_PERSISTENT_LOG , +/* pinned file that needs consecutive block address */ + NO_CHECK_TYPE, /* number of persistent & inmem log */ }; struct flush_cmd {@@ -3359,6 +3363,8 @@ block_t f2fs_get_unusable_blocks(struct f2fs_sb_info *sbi);int f2fs_disable_cp_again (struct f2fs_sb_info *sbi,block_t unusable);void f2fs_release_discard_addrs (struct f2fs_sb_info *sbi);int f2fs_npages_for_summary_flush (struct f2fs_sb_info *sbi,bool for_ra); +void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi,int type); +void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi,int type);void f2fs_allocate_segment_for_resize (struct f2fs_sb_info *sbi,int type,unsigned int start,unsigned int end);void f2fs_allocate_new_segment (struct f2fs_sb_info *sbi,int type);fs/f2fs/file.c +2
-1@@ -1656,13 +1656,14 @@ static int expand_inode_data(struct inode *inode, loff_t offset, }down_write (&sbi->pin_sem); - map.m_seg_type =CURSEG_COLD_DATA_PINNED ;f2fs_lock_op (sbi);f2fs_allocate_new_segment (sbi,CURSEG_COLD_DATA );f2fs_unlock_op (sbi); + map.m_seg_type =CURSEG_COLD_DATA_PINNED ; err =f2fs_map_blocks (inode, &map,1 ,F2FS_GET_BLOCK_PRE_DIO ); +up_write (&sbi->pin_sem); done += map.m_len;fs/f2fs/gc.c +1
-1@@ -1448,7 +1448,7 @@ static int free_segment_range(struct f2fs_sb_info *sbi,mutex_unlock (&DIRTY_I (sbi)->seglist_lock);/* Move out cursegs from the target range */ -for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_TYPE ; type++) +for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_PERSIST_TYPE ; type++)f2fs_allocate_segment_for_resize (sbi, type, start, end);/* do GC to move out valid blocks in the range */ fs/f2fs/segment.c +74
-33@@ -1958,7 +1958,7 @@ static void set_prefree_as_free_segments(struct f2fs_sb_info *sbi)mutex_lock (&dirty_i->seglist_lock);for_each_set_bit (segno, dirty_i->dirty_segmap[PRE ],MAIN_SEGS (sbi)) -__set_test_and_free (sbi, segno); +__set_test_and_free (sbi, segno, false);mutex_unlock (&dirty_i->seglist_lock); }@@ -2496,6 +2496,7 @@ static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified)struct curseg_info *curseg =CURSEG_I (sbi, type);struct summary_footer *sum_footer; + curseg->inited = true; curseg->segno = curseg->next_segno; curseg->zone =GET_ZONE_FROM_SEG (sbi, curseg->segno); curseg->next_blkoff =0 ;@@ -2503,24 +2504,31 @@ static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified) sum_footer = &(curseg->sum_blk->footer);memset (sum_footer,0 ,sizeof (struct summary_footer )); -if (IS_DATASEG (type)) +if (IS_DATASEG (curseg->seg_type))SET_SUM_TYPE (sum_footer,SUM_TYPE_DATA ); -if (IS_NODESEG (type)) +if (IS_NODESEG (curseg->seg_type))SET_SUM_TYPE (sum_footer,SUM_TYPE_NODE ); -__set_sit_entry_type (sbi, type, curseg->segno, modified); +__set_sit_entry_type (sbi, curseg->seg_type, curseg->segno, modified); }static unsigned int __get_next_segno (struct f2fs_sb_info *sbi,int type) { +struct curseg_info *curseg =CURSEG_I (sbi, type); +/* if segs_per_sec is large than 1, we need to keep original policy. */ if (__is_large_section (sbi)) -return CURSEG_I (sbi, type)->segno; +return curseg->segno; + +/* inmem log may not locate on any segment after mount */ +if (!curseg->inited) +return 0 ;if (unlikely (is_sbi_flag_set (sbi,SBI_CP_DISABLED )))return 0 ;if (test_opt (sbi,NOHEAP ) && - (type ==CURSEG_HOT_DATA ||IS_NODESEG (type))) + (curseg->seg_type ==CURSEG_HOT_DATA || +IS_NODESEG (curseg->seg_type)))return 0 ;if (SIT_I (sbi)->last_victim[ALLOC_NEXT ])@@ -2530,7 +2538,7 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)if (F2FS_OPTION (sbi).alloc_mode ==ALLOC_MODE_REUSE )return 0 ; -return CURSEG_I (sbi, type)->segno; +return curseg->segno; }/* @@ -2540,12 +2548,14 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)static void new_curseg (struct f2fs_sb_info *sbi,int type,bool new_sec) {struct curseg_info *curseg =CURSEG_I (sbi, type); +unsigned short seg_type = curseg->seg_type;unsigned int segno = curseg->segno;int dir =ALLOC_LEFT ; -write_sum_page (sbi, curseg->sum_blk, +if (curseg->inited) +write_sum_page (sbi, curseg->sum_blk,GET_SUM_BLOCK (sbi, segno)); -if (type ==CURSEG_WARM_DATA || type ==CURSEG_COLD_DATA ) +if (seg_type ==CURSEG_WARM_DATA || seg_type ==CURSEG_COLD_DATA ) dir =ALLOC_RIGHT ;if (test_opt (sbi,NOHEAP ))@@ -2622,6 +2632,43 @@ static void change_curseg(struct f2fs_sb_info *sbi, int type)f2fs_put_page (sum_page,1 ); } +void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi,int type) +{ +struct curseg_info *curseg =CURSEG_I (sbi, type); + +mutex_lock (&curseg->curseg_mutex); +if (!curseg->inited) + goto out; + +if (get_valid_blocks (sbi, curseg->segno, false)) { +write_sum_page (sbi, curseg->sum_blk, +GET_SUM_BLOCK (sbi, curseg->segno)); + }else { +mutex_lock (&DIRTY_I (sbi)->seglist_lock); +__set_test_and_free (sbi, curseg->segno, true); +mutex_unlock (&DIRTY_I (sbi)->seglist_lock); + } +out: +mutex_unlock (&curseg->curseg_mutex); +} + +void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi,int type) +{ +struct curseg_info *curseg =CURSEG_I (sbi, type); + +mutex_lock (&curseg->curseg_mutex); +if (!curseg->inited) + goto out; +if (get_valid_blocks (sbi, curseg->segno, false)) + goto out; + +mutex_lock (&DIRTY_I (sbi)->seglist_lock); +__set_test_and_inuse (sbi, curseg->segno); +mutex_unlock (&DIRTY_I (sbi)->seglist_lock); +out: +mutex_unlock (&curseg->curseg_mutex); +} +static int get_ssr_segment (struct f2fs_sb_info *sbi,int type) {struct curseg_info *curseg =CURSEG_I (sbi, type);@@ -2738,11 +2785,15 @@ void __allocate_new_segment(struct f2fs_sb_info *sbi, int type)struct curseg_info *curseg =CURSEG_I (sbi, type);unsigned int old_segno; +if (!curseg->inited) + goto alloc; +if (!curseg->next_blkoff && !get_valid_blocks (sbi, curseg->segno, false) && !get_ckpt_valid_blocks (sbi, curseg->segno))return ; +alloc: old_segno = curseg->segno;SIT_I (sbi)->s_ops->allocate_segment (sbi, type, true);locate_dirty_segment (sbi, old_segno);@@ -3126,19 +3177,6 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, {struct sit_info *sit_i =SIT_I (sbi);struct curseg_info *curseg =CURSEG_I (sbi, type); -bool put_pin_sem = false; - -if (type ==CURSEG_COLD_DATA ) { -/* GC during CURSEG_COLD_DATA_PINNED allocation */ -if (down_read_trylock (&sbi->pin_sem)) { - put_pin_sem = true; - }else { - type =CURSEG_WARM_DATA ; - curseg =CURSEG_I (sbi, type); - } - }else if (type ==CURSEG_COLD_DATA_PINNED ) { - type =CURSEG_COLD_DATA ; - }down_read (&SM_I (sbi)->curseg_lock);@@ -3204,9 +3242,6 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,mutex_unlock (&curseg->curseg_mutex);up_read (&SM_I (sbi)->curseg_lock); - -if (put_pin_sem) -up_read (&sbi->pin_sem); }static void update_device_state (struct f2fs_io_info *fio)@@ -3574,7 +3609,7 @@ static int read_normal_summaries(struct f2fs_sb_info *sbi, int type) blk_off =le16_to_cpu (ckpt->cur_data_blkoff[type -CURSEG_HOT_DATA ]);if (__exist_node_summaries (sbi)) - blk_addr =sum_blk_addr (sbi,NR_CURSEG_TYPE , type); + blk_addr =sum_blk_addr (sbi,NR_CURSEG_PERSIST_TYPE , type);else blk_addr =sum_blk_addr (sbi,NR_CURSEG_DATA_TYPE , type); }else {@@ -3652,8 +3687,9 @@ static int restore_curseg_summaries(struct f2fs_sb_info *sbi) }if (__exist_node_summaries (sbi)) -f2fs_ra_meta_pages (sbi,sum_blk_addr (sbi,NR_CURSEG_TYPE , type), -NR_CURSEG_TYPE - type,META_CP , true); +f2fs_ra_meta_pages (sbi, +sum_blk_addr (sbi,NR_CURSEG_PERSIST_TYPE , type), +NR_CURSEG_PERSIST_TYPE - type,META_CP , true);for (; type <=CURSEG_COLD_NODE ; type++) { err =read_normal_summaries (sbi, type);@@ -4155,14 +4191,14 @@ static int build_curseg(struct f2fs_sb_info *sbi)struct curseg_info *array;int i; - array =f2fs_kzalloc (sbi,array_size (NR_CURSEG_TYPE ,sizeof (*array)), -GFP_KERNEL ); + array =f2fs_kzalloc (sbi,array_size (NR_CURSEG_TYPE , +sizeof (*array)),GFP_KERNEL );if (!array)return -ENOMEM ;SM_I (sbi)->curseg_array = array; -for (i =0 ; i <NR_CURSEG_TYPE ; i++) { +for (i =0 ; i <NO_CHECK_TYPE ; i++) {mutex_init (&array[i].curseg_mutex); array[i].sum_blk =f2fs_kzalloc (sbi,PAGE_SIZE ,GFP_KERNEL );if (!array[i].sum_blk)@@ -4172,8 +4208,13 @@ static int build_curseg(struct f2fs_sb_info *sbi) sizeof(struct f2fs_journal), GFP_KERNEL);if (!array[i].journal)return -ENOMEM ; +if (i <NR_PERSISTENT_LOG ) + array[i].seg_type =CURSEG_HOT_DATA + i; +else if (i ==CURSEG_COLD_DATA_PINNED ) + array[i].seg_type =CURSEG_COLD_DATA ; array[i].segno =NULL_SEGNO ; array[i].next_blkoff =0 ; + array[i].inited = false; }return restore_curseg_summaries (sbi); }@@ -4408,7 +4449,7 @@ static int sanity_check_curseg(struct f2fs_sb_info *sbi)* In LFS/SSR curseg, .next_blkoff should point to an unused blkaddr; * In LFS curseg, all blkaddr after .next_blkoff should be unused. */ -for (i =0 ; i <NO_CHECK_TYPE ; i++) { +for (i =0 ; i <NR_PERSISTENT_LOG ; i++) {struct curseg_info *curseg =CURSEG_I (sbi, i);struct seg_entry *se =get_seg_entry (sbi, curseg->segno);unsigned int blkofs = curseg->next_blkoff;@@ -4637,7 +4678,7 @@ int f2fs_fix_curseg_write_pointer(struct f2fs_sb_info *sbi) {int i, ret; -for (i =0 ; i <NO_CHECK_TYPE ; i++) { +for (i =0 ; i <NR_PERSISTENT_LOG ; i++) { ret =fix_curseg_write_pointer (sbi, i);if (ret)return ret;fs/f2fs/segment.h +10
-7@@ -22,7 +22,7 @@#define GET_R2L_SEGNO (free_i, segno) ((segno) + (free_i)->start_segno)#define IS_DATASEG (t) ((t) <= CURSEG_COLD_DATA) -#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE) +#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE && (t) <= CURSEG_COLD_NODE)#define IS_HOT (t) ((t) == CURSEG_HOT_NODE || (t) == CURSEG_HOT_DATA)#define IS_WARM (t) ((t) == CURSEG_WARM_NODE || (t) == CURSEG_WARM_DATA)@@ -34,7 +34,8 @@ ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_HOT_NODE)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno) || \ - ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno)) + ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno) || \ + ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno))#define IS_CURSEC (sbi, secno) \ (((secno) == CURSEG_I(sbi, CURSEG_HOT_DATA)->segno / \@@ -48,7 +49,9 @@ ((secno) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno / \ (sbi)->segs_per_sec) || \ ((secno) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno / \ - (sbi)->segs_per_sec)) \ + (sbi)->segs_per_sec) || \ + ((secno) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno / \ + (sbi)->segs_per_sec))#define MAIN_BLKADDR (sbi) \ (SM_I(sbi) ? SM_I(sbi)->main_blkaddr : \@@ -288,10 +291,12 @@ struct curseg_info {struct rw_semaphore journal_rwsem;/* protect journal area */ struct f2fs_journal *journal;/* cached journal info */ unsigned char alloc_type;/* current allocation type */ +unsigned short seg_type;/* segment type like CURSEG_XXX_TYPE */ unsigned int segno;/* current segment number */ unsigned short next_blkoff;/* next block offset to write */ unsigned int zone;/* current zone number */ unsigned int next_segno;/* preallocated segment */ +bool inited;/* indicate inmem log is inited */ };struct sit_entry_set {@@ -305,8 +310,6 @@ struct sit_entry_set {*/ static inline struct curseg_info *CURSEG_I (struct f2fs_sb_info *sbi,int type) { -if (type ==CURSEG_COLD_DATA_PINNED ) - type =CURSEG_COLD_DATA ;return (struct curseg_info *)(SM_I (sbi)->curseg_array + type); }@@ -438,7 +441,7 @@ static inline void __set_inuse(struct f2fs_sb_info *sbi, }static inline void __set_test_and_free (struct f2fs_sb_info *sbi, -unsigned int segno) +unsigned int segno,bool inmem) {struct free_segmap_info *free_i =FREE_I (sbi);unsigned int secno =GET_SEC_FROM_SEG (sbi, segno);@@ -449,7 +452,7 @@ static inline void __set_test_and_free(struct f2fs_sb_info *sbi,if (test_and_clear_bit (segno, free_i->free_segmap)) { free_i->free_segments++; -if (IS_CURSEC (sbi, secno)) +if (!inmem &&IS_CURSEC (sbi, secno)) goto skip_free; next =find_next_bit (free_i->free_segmap, start_segno + sbi->segs_per_sec, start_segno);fs/f2fs/super.c +5
-4@@ -575,7 +575,8 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)case Opt_active_logs:if (args->from &&match_int (args, &arg))return -EINVAL ; -if (arg !=2 && arg !=4 && arg !=NR_CURSEG_TYPE ) +if (arg !=2 && arg !=4 && + arg !=NR_CURSEG_PERSIST_TYPE )return -EINVAL ;F2FS_OPTION (sbi).active_logs = arg;break ;@@ -981,7 +982,7 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) }/* Not pass down write hints if the number of active logs is lesser -* than NR_CURSEG_TYPE. +* than NR_CURSEG_PERSIST_TYPE. */ if (F2FS_OPTION (sbi).active_logs !=NR_CURSEG_TYPE )F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ;@@ -1614,7 +1615,7 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)static void default_options (struct f2fs_sb_info *sbi) {/* init some FS parameters */ -F2FS_OPTION (sbi).active_logs =NR_CURSEG_TYPE ; +F2FS_OPTION (sbi).active_logs =NR_CURSEG_PERSIST_TYPE ;F2FS_OPTION (sbi).inline_xattr_size =DEFAULT_INLINE_XATTR_ADDRS ;F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ;F2FS_OPTION (sbi).alloc_mode =ALLOC_MODE_DEFAULT ;@@ -2946,7 +2947,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi) cp_payload =__cp_payload (sbi);if (cp_pack_start_sum < cp_payload +1 || cp_pack_start_sum > blocks_per_seg -1 - -NR_CURSEG_TYPE ) { +NR_CURSEG_PERSIST_TYPE ) {f2fs_err (sbi,"Wrong cp_pack_start_sum: %u" , cp_pack_start_sum);return 1 ;Signature · 1 line
2.26.2.
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
.
.
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
.Quoted 6 lines
Quoted 6 lines
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
..
Jaegeuk Kim
maintainerQuoted 41 lines · Chao Yu
Quoted 32 lines · Jaegeuk Kim
Quoted 31 lines · Chao Yu
Quoted 30 lines · Chao Yu
Quoted 19 lines · Chao Yu
Quoted 18 lines · Jaegeuk Kim
Quoted 17 lines · Chao Yu
Quoted 6 lines · Jaegeuk Kim
Quoted 5 lines · Chao Yu
Quoted 3 lines · Jaegeuk Kim
Hi Chao,
Do you have any brief design doc to present the idea?
Quoted 7 lines
Quoted 5 lines
Hi Jaegeuk,
You mean this whole patchset, right?
I can add a brief design description in patch 0/5.
Yeah, it's a bit hard to understand the whole flow.
Jaegeuk,
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Do you have time to take a look at this idea summarized in [PATCH 0/5]'s cover letter?
Sorry, I couldn't afford to sitting down to review the design. Let me give it a try soon.
Alright, let me know if you have any question about the idea.
Ping,
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Jaegeuk, still be too busy...? :P
Ping again...
Any thoughts about left patches in patchset?
Ah, I was waiting for your another patch-set.
Quoted 7 lines
Oops, I thought that you have not finished reviewing all patches...
Anyway, let me send v2 w/ changes mentioned by you.
BTW, we can discuss about how to enable such feature, options can be:
- enable when sb featureF2FS_FEATURE_ATGCwas set
- enable via mount option
Looks like mount option would be better.
Quoted 515 lines
- enable via sysfs
Quoted 513 lines
Quoted 505 lines
Quoted 505 lines
Thanks,
Quoted 498 lines
Quoted 486 lines
Quoted 486 lines
Quoted 486 lines
Thanks,
Quoted 480 lines
Quoted 480 lines
Thanks,
Quoted 473 lines · Chao Yu
Previous implementation of aligned pinfile allocation will:
- allocate new segment on cold data log no matter whether last used segment is partially used or not, it makes IOs more random;
- force concurrent cold data/GCed IO going into warm data area, it can make a bad effect on hot/cold data separation;In this patch, we introduce a new type of log named 'inmem curseg', the differents from normal curseg is:
- it reuses existed segment type (CURSEG_XXX_NODE/DATA);
- it only exists in memory, its segno, blkofs, summary will not bpersisted into checkpoint area;With this new feature, we can enhance scalability of log, special allocators can be created for purposes:
- pure lfs allocator for aligned pinfile allocation or file defragmentation
- pure ssr allocator for later featureSo that, let's update aligned pinfile allocation to use this new inmem curseg fwk.
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/checkpoint.c | 7 ++- fs/f2fs/debug.c | 6 ++- fs/f2fs/f2fs.h | 12 +++-- fs/f2fs/file.c | 3 +- fs/f2fs/gc.c | 2 +- fs/f2fs/segment.c | 107 ++++++++++++++++++++++++++++++------------- fs/f2fs/segment.h | 17 ++++--- fs/f2fs/super.c | 9 ++-- 8 files changed, 112 insertions(+), 51 deletions(-)fs/f2fs/checkpoint.c +6
-1@@ -1623,11 +1623,16 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)f2fs_flush_sit_entries (sbi, cpc); +/* save inmem log status */ +f2fs_save_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); + err =do_checkpoint (sbi, cpc);if (err)f2fs_release_discard_addrs (sbi);else f2fs_clear_prefree_segments (sbi, cpc); + +f2fs_restore_inmem_curseg (sbi,CURSEG_COLD_DATA_PINNED ); stop:unblock_operations (sbi);stat_inc_cp_count (sbi->stat_info);@@ -1658,7 +1663,7 @@ void f2fs_init_ino_entry_info(struct f2fs_sb_info *sbi) } sbi->max_orphans = (sbi->blocks_per_seg -F2FS_CP_PACKS - -NR_CURSEG_TYPE -__cp_payload (sbi)) * +NR_CURSEG_PERSIST_TYPE -__cp_payload (sbi)) *F2FS_ORPHANS_PER_BLOCK ; }fs/f2fs/debug.c +5
-1@@ -164,7 +164,7 @@ static void update_general_status(struct f2fs_sb_info *sbi) *100 / (int )(sbi->user_block_count >> sbi->log_blocks_per_seg) /2 ; si->util_invalid =50 - si->util_free - si->util_valid; -for (i =CURSEG_HOT_DATA ; i <=CURSEG_COLD_NODE ; i++) { +for (i =CURSEG_HOT_DATA ; i <NO_CHECK_TYPE ; i++) {struct curseg_info *curseg =CURSEG_I (sbi, i); si->curseg[i] = curseg->segno; si->cursec[i] =GET_SEC_FROM_SEG (sbi, curseg->segno);@@ -393,6 +393,10 @@ static int stat_show(struct seq_file *s, void *v) si->dirty_seg[CURSEG_COLD_NODE ], si->full_seg[CURSEG_COLD_NODE ], si->valid_blks[CURSEG_COLD_NODE]); +seq_printf (s," - Pinned file: %8d %8d %8d\n" , + si->curseg[CURSEG_COLD_DATA_PINNED ], + si->cursec[CURSEG_COLD_DATA_PINNED ], + si->curzone[CURSEG_COLD_DATA_PINNED ]); seq_printf(s, "\n - Valid: %d\n - Dirty: %d\n", si->main_area_segs - si->dirty_count - si->prefree_count - si->free_segs,fs/f2fs/f2fs.h +9
-3@@ -996,7 +996,9 @@ static inline void set_new_dnode(struct dnode_of_data *dn, struct inode *inode,*/ #define NR_CURSEG_DATA_TYPE (3)#define NR_CURSEG_NODE_TYPE (3) -#define NR_CURSEG_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) +#define NR_CURSEG_INMEM_TYPE (1) +#define NR_CURSEG_PERSIST_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) +#define NR_CURSEG_TYPE (NR_CURSEG_INMEM_TYPE + NR_CURSEG_PERSIST_TYPE)enum {CURSEG_HOT_DATA =0 ,/* directory entry blocks */ @@ -1005,8 +1007,10 @@ enum {CURSEG_HOT_NODE ,/* direct node blocks of directory files */ CURSEG_WARM_NODE ,/* direct node blocks of normal files */ CURSEG_COLD_NODE ,/* indirect node blocks */ -NO_CHECK_TYPE , - CURSEG_COLD_DATA_PINNED,/* cold data for pinned file */ +NR_PERSISTENT_LOG ,/* number of persistent log */ +CURSEG_COLD_DATA_PINNED =NR_PERSISTENT_LOG , +/* pinned file that needs consecutive block address */ + NO_CHECK_TYPE, /* number of persistent & inmem log */ }; struct flush_cmd {@@ -3359,6 +3363,8 @@ block_t f2fs_get_unusable_blocks(struct f2fs_sb_info *sbi);int f2fs_disable_cp_again (struct f2fs_sb_info *sbi,block_t unusable);void f2fs_release_discard_addrs (struct f2fs_sb_info *sbi);int f2fs_npages_for_summary_flush (struct f2fs_sb_info *sbi,bool for_ra); +void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi,int type); +void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi,int type);void f2fs_allocate_segment_for_resize (struct f2fs_sb_info *sbi,int type,unsigned int start,unsigned int end);void f2fs_allocate_new_segment (struct f2fs_sb_info *sbi,int type);fs/f2fs/file.c +2
-1@@ -1656,13 +1656,14 @@ static int expand_inode_data(struct inode *inode, loff_t offset, }down_write (&sbi->pin_sem); - map.m_seg_type =CURSEG_COLD_DATA_PINNED ;f2fs_lock_op (sbi);f2fs_allocate_new_segment (sbi,CURSEG_COLD_DATA );f2fs_unlock_op (sbi); + map.m_seg_type =CURSEG_COLD_DATA_PINNED ; err =f2fs_map_blocks (inode, &map,1 ,F2FS_GET_BLOCK_PRE_DIO ); +up_write (&sbi->pin_sem); done += map.m_len;fs/f2fs/gc.c +1
-1@@ -1448,7 +1448,7 @@ static int free_segment_range(struct f2fs_sb_info *sbi,mutex_unlock (&DIRTY_I (sbi)->seglist_lock);/* Move out cursegs from the target range */ -for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_TYPE ; type++) +for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_PERSIST_TYPE ; type++)f2fs_allocate_segment_for_resize (sbi, type, start, end);/* do GC to move out valid blocks in the range */ fs/f2fs/segment.c +74
-33@@ -1958,7 +1958,7 @@ static void set_prefree_as_free_segments(struct f2fs_sb_info *sbi)mutex_lock (&dirty_i->seglist_lock);for_each_set_bit (segno, dirty_i->dirty_segmap[PRE ],MAIN_SEGS (sbi)) -__set_test_and_free (sbi, segno); +__set_test_and_free (sbi, segno, false);mutex_unlock (&dirty_i->seglist_lock); }@@ -2496,6 +2496,7 @@ static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified)struct curseg_info *curseg =CURSEG_I (sbi, type);struct summary_footer *sum_footer; + curseg->inited = true; curseg->segno = curseg->next_segno; curseg->zone =GET_ZONE_FROM_SEG (sbi, curseg->segno); curseg->next_blkoff =0 ;@@ -2503,24 +2504,31 @@ static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified) sum_footer = &(curseg->sum_blk->footer);memset (sum_footer,0 ,sizeof (struct summary_footer )); -if (IS_DATASEG (type)) +if (IS_DATASEG (curseg->seg_type))SET_SUM_TYPE (sum_footer,SUM_TYPE_DATA ); -if (IS_NODESEG (type)) +if (IS_NODESEG (curseg->seg_type))SET_SUM_TYPE (sum_footer,SUM_TYPE_NODE ); -__set_sit_entry_type (sbi, type, curseg->segno, modified); +__set_sit_entry_type (sbi, curseg->seg_type, curseg->segno, modified); }static unsigned int __get_next_segno (struct f2fs_sb_info *sbi,int type) { +struct curseg_info *curseg =CURSEG_I (sbi, type); +/* if segs_per_sec is large than 1, we need to keep original policy. */ if (__is_large_section (sbi)) -return CURSEG_I (sbi, type)->segno; +return curseg->segno; + +/* inmem log may not locate on any segment after mount */ +if (!curseg->inited) +return 0 ;if (unlikely (is_sbi_flag_set (sbi,SBI_CP_DISABLED )))return 0 ;if (test_opt (sbi,NOHEAP ) && - (type ==CURSEG_HOT_DATA ||IS_NODESEG (type))) + (curseg->seg_type ==CURSEG_HOT_DATA || +IS_NODESEG (curseg->seg_type)))return 0 ;if (SIT_I (sbi)->last_victim[ALLOC_NEXT ])@@ -2530,7 +2538,7 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)if (F2FS_OPTION (sbi).alloc_mode ==ALLOC_MODE_REUSE )return 0 ; -return CURSEG_I (sbi, type)->segno; +return curseg->segno; }/* @@ -2540,12 +2548,14 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)static void new_curseg (struct f2fs_sb_info *sbi,int type,bool new_sec) {struct curseg_info *curseg =CURSEG_I (sbi, type); +unsigned short seg_type = curseg->seg_type;unsigned int segno = curseg->segno;int dir =ALLOC_LEFT ; -write_sum_page (sbi, curseg->sum_blk, +if (curseg->inited) +write_sum_page (sbi, curseg->sum_blk,GET_SUM_BLOCK (sbi, segno)); -if (type ==CURSEG_WARM_DATA || type ==CURSEG_COLD_DATA ) +if (seg_type ==CURSEG_WARM_DATA || seg_type ==CURSEG_COLD_DATA ) dir =ALLOC_RIGHT ;if (test_opt (sbi,NOHEAP ))@@ -2622,6 +2632,43 @@ static void change_curseg(struct f2fs_sb_info *sbi, int type)f2fs_put_page (sum_page,1 ); } +void f2fs_save_inmem_curseg (struct f2fs_sb_info *sbi,int type) +{ +struct curseg_info *curseg =CURSEG_I (sbi, type); + +mutex_lock (&curseg->curseg_mutex); +if (!curseg->inited) + goto out; + +if (get_valid_blocks (sbi, curseg->segno, false)) { +write_sum_page (sbi, curseg->sum_blk, +GET_SUM_BLOCK (sbi, curseg->segno)); + }else { +mutex_lock (&DIRTY_I (sbi)->seglist_lock); +__set_test_and_free (sbi, curseg->segno, true); +mutex_unlock (&DIRTY_I (sbi)->seglist_lock); + } +out: +mutex_unlock (&curseg->curseg_mutex); +} + +void f2fs_restore_inmem_curseg (struct f2fs_sb_info *sbi,int type) +{ +struct curseg_info *curseg =CURSEG_I (sbi, type); + +mutex_lock (&curseg->curseg_mutex); +if (!curseg->inited) + goto out; +if (get_valid_blocks (sbi, curseg->segno, false)) + goto out; + +mutex_lock (&DIRTY_I (sbi)->seglist_lock); +__set_test_and_inuse (sbi, curseg->segno); +mutex_unlock (&DIRTY_I (sbi)->seglist_lock); +out: +mutex_unlock (&curseg->curseg_mutex); +} +static int get_ssr_segment (struct f2fs_sb_info *sbi,int type) {struct curseg_info *curseg =CURSEG_I (sbi, type);@@ -2738,11 +2785,15 @@ void __allocate_new_segment(struct f2fs_sb_info *sbi, int type)struct curseg_info *curseg =CURSEG_I (sbi, type);unsigned int old_segno; +if (!curseg->inited) + goto alloc; +if (!curseg->next_blkoff && !get_valid_blocks (sbi, curseg->segno, false) && !get_ckpt_valid_blocks (sbi, curseg->segno))return ; +alloc: old_segno = curseg->segno;SIT_I (sbi)->s_ops->allocate_segment (sbi, type, true);locate_dirty_segment (sbi, old_segno);@@ -3126,19 +3177,6 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, {struct sit_info *sit_i =SIT_I (sbi);struct curseg_info *curseg =CURSEG_I (sbi, type); -bool put_pin_sem = false; - -if (type ==CURSEG_COLD_DATA ) { -/* GC during CURSEG_COLD_DATA_PINNED allocation */ -if (down_read_trylock (&sbi->pin_sem)) { - put_pin_sem = true; - }else { - type =CURSEG_WARM_DATA ; - curseg =CURSEG_I (sbi, type); - } - }else if (type ==CURSEG_COLD_DATA_PINNED ) { - type =CURSEG_COLD_DATA ; - }down_read (&SM_I (sbi)->curseg_lock);@@ -3204,9 +3242,6 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,mutex_unlock (&curseg->curseg_mutex);up_read (&SM_I (sbi)->curseg_lock); - -if (put_pin_sem) -up_read (&sbi->pin_sem); }static void update_device_state (struct f2fs_io_info *fio)@@ -3574,7 +3609,7 @@ static int read_normal_summaries(struct f2fs_sb_info *sbi, int type) blk_off =le16_to_cpu (ckpt->cur_data_blkoff[type -CURSEG_HOT_DATA ]);if (__exist_node_summaries (sbi)) - blk_addr =sum_blk_addr (sbi,NR_CURSEG_TYPE , type); + blk_addr =sum_blk_addr (sbi,NR_CURSEG_PERSIST_TYPE , type);else blk_addr =sum_blk_addr (sbi,NR_CURSEG_DATA_TYPE , type); }else {@@ -3652,8 +3687,9 @@ static int restore_curseg_summaries(struct f2fs_sb_info *sbi) }if (__exist_node_summaries (sbi)) -f2fs_ra_meta_pages (sbi,sum_blk_addr (sbi,NR_CURSEG_TYPE , type), -NR_CURSEG_TYPE - type,META_CP , true); +f2fs_ra_meta_pages (sbi, +sum_blk_addr (sbi,NR_CURSEG_PERSIST_TYPE , type), +NR_CURSEG_PERSIST_TYPE - type,META_CP , true);for (; type <=CURSEG_COLD_NODE ; type++) { err =read_normal_summaries (sbi, type);@@ -4155,14 +4191,14 @@ static int build_curseg(struct f2fs_sb_info *sbi)struct curseg_info *array;int i; - array =f2fs_kzalloc (sbi,array_size (NR_CURSEG_TYPE ,sizeof (*array)), -GFP_KERNEL ); + array =f2fs_kzalloc (sbi,array_size (NR_CURSEG_TYPE , +sizeof (*array)),GFP_KERNEL );if (!array)return -ENOMEM ;SM_I (sbi)->curseg_array = array; -for (i =0 ; i <NR_CURSEG_TYPE ; i++) { +for (i =0 ; i <NO_CHECK_TYPE ; i++) {mutex_init (&array[i].curseg_mutex); array[i].sum_blk =f2fs_kzalloc (sbi,PAGE_SIZE ,GFP_KERNEL );if (!array[i].sum_blk)@@ -4172,8 +4208,13 @@ static int build_curseg(struct f2fs_sb_info *sbi) sizeof(struct f2fs_journal), GFP_KERNEL);if (!array[i].journal)return -ENOMEM ; +if (i <NR_PERSISTENT_LOG ) + array[i].seg_type =CURSEG_HOT_DATA + i; +else if (i ==CURSEG_COLD_DATA_PINNED ) + array[i].seg_type =CURSEG_COLD_DATA ; array[i].segno =NULL_SEGNO ; array[i].next_blkoff =0 ; + array[i].inited = false; }return restore_curseg_summaries (sbi); }@@ -4408,7 +4449,7 @@ static int sanity_check_curseg(struct f2fs_sb_info *sbi)* In LFS/SSR curseg, .next_blkoff should point to an unused blkaddr; * In LFS curseg, all blkaddr after .next_blkoff should be unused. */ -for (i =0 ; i <NO_CHECK_TYPE ; i++) { +for (i =0 ; i <NR_PERSISTENT_LOG ; i++) {struct curseg_info *curseg =CURSEG_I (sbi, i);struct seg_entry *se =get_seg_entry (sbi, curseg->segno);unsigned int blkofs = curseg->next_blkoff;@@ -4637,7 +4678,7 @@ int f2fs_fix_curseg_write_pointer(struct f2fs_sb_info *sbi) {int i, ret; -for (i =0 ; i <NO_CHECK_TYPE ; i++) { +for (i =0 ; i <NR_PERSISTENT_LOG ; i++) { ret =fix_curseg_write_pointer (sbi, i);if (ret)return ret;fs/f2fs/segment.h +10
-7@@ -22,7 +22,7 @@#define GET_R2L_SEGNO (free_i, segno) ((segno) + (free_i)->start_segno)#define IS_DATASEG (t) ((t) <= CURSEG_COLD_DATA) -#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE) +#define IS_NODESEG (t) ((t) >= CURSEG_HOT_NODE && (t) <= CURSEG_COLD_NODE)#define IS_HOT (t) ((t) == CURSEG_HOT_NODE || (t) == CURSEG_HOT_DATA)#define IS_WARM (t) ((t) == CURSEG_WARM_NODE || (t) == CURSEG_WARM_DATA)@@ -34,7 +34,8 @@ ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_HOT_NODE)->segno) || \ ((seg) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno) || \ - ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno)) + ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno) || \ + ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno))#define IS_CURSEC (sbi, secno) \ (((secno) == CURSEG_I(sbi, CURSEG_HOT_DATA)->segno / \@@ -48,7 +49,9 @@ ((secno) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno / \ (sbi)->segs_per_sec) || \ ((secno) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno / \ - (sbi)->segs_per_sec)) \ + (sbi)->segs_per_sec) || \ + ((secno) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno / \ + (sbi)->segs_per_sec))#define MAIN_BLKADDR (sbi) \ (SM_I(sbi) ? SM_I(sbi)->main_blkaddr : \@@ -288,10 +291,12 @@ struct curseg_info {struct rw_semaphore journal_rwsem;/* protect journal area */ struct f2fs_journal *journal;/* cached journal info */ unsigned char alloc_type;/* current allocation type */ +unsigned short seg_type;/* segment type like CURSEG_XXX_TYPE */ unsigned int segno;/* current segment number */ unsigned short next_blkoff;/* next block offset to write */ unsigned int zone;/* current zone number */ unsigned int next_segno;/* preallocated segment */ +bool inited;/* indicate inmem log is inited */ };struct sit_entry_set {@@ -305,8 +310,6 @@ struct sit_entry_set {*/ static inline struct curseg_info *CURSEG_I (struct f2fs_sb_info *sbi,int type) { -if (type ==CURSEG_COLD_DATA_PINNED ) - type =CURSEG_COLD_DATA ;return (struct curseg_info *)(SM_I (sbi)->curseg_array + type); }@@ -438,7 +441,7 @@ static inline void __set_inuse(struct f2fs_sb_info *sbi, }static inline void __set_test_and_free (struct f2fs_sb_info *sbi, -unsigned int segno) +unsigned int segno,bool inmem) {struct free_segmap_info *free_i =FREE_I (sbi);unsigned int secno =GET_SEC_FROM_SEG (sbi, segno);@@ -449,7 +452,7 @@ static inline void __set_test_and_free(struct f2fs_sb_info *sbi,if (test_and_clear_bit (segno, free_i->free_segmap)) { free_i->free_segments++; -if (IS_CURSEC (sbi, secno)) +if (!inmem &&IS_CURSEC (sbi, secno)) goto skip_free; next =find_next_bit (free_i->free_segmap, start_segno + sbi->segs_per_sec, start_segno);fs/f2fs/super.c +5
-4@@ -575,7 +575,8 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)case Opt_active_logs:if (args->from &&match_int (args, &arg))return -EINVAL ; -if (arg !=2 && arg !=4 && arg !=NR_CURSEG_TYPE ) +if (arg !=2 && arg !=4 && + arg !=NR_CURSEG_PERSIST_TYPE )return -EINVAL ;F2FS_OPTION (sbi).active_logs = arg;break ;@@ -981,7 +982,7 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) }/* Not pass down write hints if the number of active logs is lesser -* than NR_CURSEG_TYPE. +* than NR_CURSEG_PERSIST_TYPE. */ if (F2FS_OPTION (sbi).active_logs !=NR_CURSEG_TYPE )F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ;@@ -1614,7 +1615,7 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)static void default_options (struct f2fs_sb_info *sbi) {/* init some FS parameters */ -F2FS_OPTION (sbi).active_logs =NR_CURSEG_TYPE ; +F2FS_OPTION (sbi).active_logs =NR_CURSEG_PERSIST_TYPE ;F2FS_OPTION (sbi).inline_xattr_size =DEFAULT_INLINE_XATTR_ADDRS ;F2FS_OPTION (sbi).whint_mode =WHINT_MODE_OFF ;F2FS_OPTION (sbi).alloc_mode =ALLOC_MODE_DEFAULT ;@@ -2946,7 +2947,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi) cp_payload =__cp_payload (sbi);if (cp_pack_start_sum < cp_payload +1 || cp_pack_start_sum > blocks_per_seg -1 - -NR_CURSEG_TYPE ) { +NR_CURSEG_PERSIST_TYPE ) {f2fs_err (sbi,"Wrong cp_pack_start_sum: %u" , cp_pack_start_sum);return 1 ;Signature · 1 line
2.26.2.
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
.
.
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
.Quoted 6 lines
Quoted 6 lines
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
..