mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	f2fs: define MIN_DISCARD_GRANULARITY macro
Do cleanup in f2fs_tuning_parameters() and __init_discard_policy(), let's use macro instead of number. Suggested-by: Chao Yu <chao@kernel.org> Signed-off-by: Yangtao Li <frank.li@vivo.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
		
							parent
							
								
									48c08c51f9
								
							
						
					
					
						commit
						1cd2e6d544
					
				
					 3 changed files with 6 additions and 3 deletions
				
			
		| 
						 | 
					@ -329,6 +329,8 @@ struct discard_entry {
 | 
				
			||||||
	unsigned char discard_map[SIT_VBLOCK_MAP_SIZE];	/* segment discard bitmap */
 | 
						unsigned char discard_map[SIT_VBLOCK_MAP_SIZE];	/* segment discard bitmap */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* minimum discard granularity, unit: block count */
 | 
				
			||||||
 | 
					#define MIN_DISCARD_GRANULARITY		1
 | 
				
			||||||
/* default discard granularity of inner discard thread, unit: block count */
 | 
					/* default discard granularity of inner discard thread, unit: block count */
 | 
				
			||||||
#define DEFAULT_DISCARD_GRANULARITY		16
 | 
					#define DEFAULT_DISCARD_GRANULARITY		16
 | 
				
			||||||
/* default maximum discard granularity of ordered discard, unit: block count */
 | 
					/* default maximum discard granularity of ordered discard, unit: block count */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1065,7 +1065,7 @@ static void __init_discard_policy(struct f2fs_sb_info *sbi,
 | 
				
			||||||
		dpolicy->sync = false;
 | 
							dpolicy->sync = false;
 | 
				
			||||||
		dpolicy->ordered = true;
 | 
							dpolicy->ordered = true;
 | 
				
			||||||
		if (utilization(sbi) > DEF_DISCARD_URGENT_UTIL) {
 | 
							if (utilization(sbi) > DEF_DISCARD_URGENT_UTIL) {
 | 
				
			||||||
			dpolicy->granularity = 1;
 | 
								dpolicy->granularity = MIN_DISCARD_GRANULARITY;
 | 
				
			||||||
			if (atomic_read(&dcc->discard_cmd_cnt))
 | 
								if (atomic_read(&dcc->discard_cmd_cnt))
 | 
				
			||||||
				dpolicy->max_interval =
 | 
									dpolicy->max_interval =
 | 
				
			||||||
					dcc->min_discard_issue_time;
 | 
										dcc->min_discard_issue_time;
 | 
				
			||||||
| 
						 | 
					@ -1080,7 +1080,7 @@ static void __init_discard_policy(struct f2fs_sb_info *sbi,
 | 
				
			||||||
	} else if (discard_type == DPOLICY_UMOUNT) {
 | 
						} else if (discard_type == DPOLICY_UMOUNT) {
 | 
				
			||||||
		dpolicy->io_aware = false;
 | 
							dpolicy->io_aware = false;
 | 
				
			||||||
		/* we need to issue all to keep CP_TRIMMED_FLAG */
 | 
							/* we need to issue all to keep CP_TRIMMED_FLAG */
 | 
				
			||||||
		dpolicy->granularity = 1;
 | 
							dpolicy->granularity = MIN_DISCARD_GRANULARITY;
 | 
				
			||||||
		dpolicy->timeout = true;
 | 
							dpolicy->timeout = true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4080,7 +4080,8 @@ static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi)
 | 
				
			||||||
	/* adjust parameters according to the volume size */
 | 
						/* adjust parameters according to the volume size */
 | 
				
			||||||
	if (MAIN_SEGS(sbi) <= SMALL_VOLUME_SEGMENTS) {
 | 
						if (MAIN_SEGS(sbi) <= SMALL_VOLUME_SEGMENTS) {
 | 
				
			||||||
		if (f2fs_block_unit_discard(sbi))
 | 
							if (f2fs_block_unit_discard(sbi))
 | 
				
			||||||
			SM_I(sbi)->dcc_info->discard_granularity = 1;
 | 
								SM_I(sbi)->dcc_info->discard_granularity =
 | 
				
			||||||
 | 
											MIN_DISCARD_GRANULARITY;
 | 
				
			||||||
		SM_I(sbi)->ipu_policy = 1 << F2FS_IPU_FORCE |
 | 
							SM_I(sbi)->ipu_policy = 1 << F2FS_IPU_FORCE |
 | 
				
			||||||
					1 << F2FS_IPU_HONOR_OPU_WRITE;
 | 
										1 << F2FS_IPU_HONOR_OPU_WRITE;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue