mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	f2fs: use sbi->blocks_per_seg to avoid unnecessary calculation
Use sbi->blocks_per_seg directly to avoid unnecessary calculation when using 1 << sbi->log_blocks_per_seg. Signed-off-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
		
							parent
							
								
									9006f2c93f
								
							
						
					
					
						commit
						3519e3f992
					
				
					 5 changed files with 7 additions and 9 deletions
				
			
		| 
						 | 
					@ -105,7 +105,7 @@ static void update_sit_info(struct f2fs_sb_info *sbi)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bimodal = 0;
 | 
						bimodal = 0;
 | 
				
			||||||
	total_vblocks = 0;
 | 
						total_vblocks = 0;
 | 
				
			||||||
	blks_per_sec = sbi->segs_per_sec * (1 << sbi->log_blocks_per_seg);
 | 
						blks_per_sec = sbi->segs_per_sec * sbi->blocks_per_seg;
 | 
				
			||||||
	hblks_per_sec = blks_per_sec / 2;
 | 
						hblks_per_sec = blks_per_sec / 2;
 | 
				
			||||||
	for (segno = 0; segno < MAIN_SEGS(sbi); segno += sbi->segs_per_sec) {
 | 
						for (segno = 0; segno < MAIN_SEGS(sbi); segno += sbi->segs_per_sec) {
 | 
				
			||||||
		vblocks = get_valid_blocks(sbi, segno, sbi->segs_per_sec);
 | 
							vblocks = get_valid_blocks(sbi, segno, sbi->segs_per_sec);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1099,8 +1099,7 @@ static inline int get_dirty_pages(struct inode *inode)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline int get_blocktype_secs(struct f2fs_sb_info *sbi, int block_type)
 | 
					static inline int get_blocktype_secs(struct f2fs_sb_info *sbi, int block_type)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	unsigned int pages_per_sec = sbi->segs_per_sec *
 | 
						unsigned int pages_per_sec = sbi->segs_per_sec * sbi->blocks_per_seg;
 | 
				
			||||||
					(1 << sbi->log_blocks_per_seg);
 | 
					 | 
				
			||||||
	return ((get_pages(sbi, block_type) + pages_per_sec - 1)
 | 
						return ((get_pages(sbi, block_type) + pages_per_sec - 1)
 | 
				
			||||||
			>> sbi->log_blocks_per_seg) / sbi->segs_per_sec;
 | 
								>> sbi->log_blocks_per_seg) / sbi->segs_per_sec;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1654,10 +1654,9 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
 | 
				
			||||||
	struct f2fs_map_blocks map;
 | 
						struct f2fs_map_blocks map;
 | 
				
			||||||
	struct extent_info ei;
 | 
						struct extent_info ei;
 | 
				
			||||||
	pgoff_t pg_start, pg_end;
 | 
						pgoff_t pg_start, pg_end;
 | 
				
			||||||
	unsigned int blk_per_seg = 1 << sbi->log_blocks_per_seg;
 | 
						unsigned int blk_per_seg = sbi->blocks_per_seg;
 | 
				
			||||||
	unsigned int total = 0, sec_num;
 | 
						unsigned int total = 0, sec_num;
 | 
				
			||||||
	unsigned int pages_per_sec = sbi->segs_per_sec *
 | 
						unsigned int pages_per_sec = sbi->segs_per_sec * blk_per_seg;
 | 
				
			||||||
					(1 << sbi->log_blocks_per_seg);
 | 
					 | 
				
			||||||
	block_t blk_end = 0;
 | 
						block_t blk_end = 0;
 | 
				
			||||||
	bool fragmented = false;
 | 
						bool fragmented = false;
 | 
				
			||||||
	int err;
 | 
						int err;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -173,9 +173,9 @@ static unsigned int get_max_cost(struct f2fs_sb_info *sbi,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	/* SSR allocates in a segment unit */
 | 
						/* SSR allocates in a segment unit */
 | 
				
			||||||
	if (p->alloc_mode == SSR)
 | 
						if (p->alloc_mode == SSR)
 | 
				
			||||||
		return 1 << sbi->log_blocks_per_seg;
 | 
							return sbi->blocks_per_seg;
 | 
				
			||||||
	if (p->gc_mode == GC_GREEDY)
 | 
						if (p->gc_mode == GC_GREEDY)
 | 
				
			||||||
		return (1 << sbi->log_blocks_per_seg) * p->ofs_unit;
 | 
							return sbi->blocks_per_seg * p->ofs_unit;
 | 
				
			||||||
	else if (p->gc_mode == GC_CB)
 | 
						else if (p->gc_mode == GC_CB)
 | 
				
			||||||
		return UINT_MAX;
 | 
							return UINT_MAX;
 | 
				
			||||||
	else /* No other gc_mode */
 | 
						else /* No other gc_mode */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -183,7 +183,7 @@ static inline pgoff_t current_nat_addr(struct f2fs_sb_info *sbi, nid_t start)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	block_addr = (pgoff_t)(nm_i->nat_blkaddr +
 | 
						block_addr = (pgoff_t)(nm_i->nat_blkaddr +
 | 
				
			||||||
		(seg_off << sbi->log_blocks_per_seg << 1) +
 | 
							(seg_off << sbi->log_blocks_per_seg << 1) +
 | 
				
			||||||
		(block_off & ((1 << sbi->log_blocks_per_seg) - 1)));
 | 
							(block_off & (sbi->blocks_per_seg - 1)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (f2fs_test_bit(block_off, nm_i->nat_bitmap))
 | 
						if (f2fs_test_bit(block_off, nm_i->nat_bitmap))
 | 
				
			||||||
		block_addr += sbi->blocks_per_seg;
 | 
							block_addr += sbi->blocks_per_seg;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue