mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	f2fs: introduce FAULT_NO_SEGMENT
Use it to simulate no free segment case during block allocation. Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
		
							parent
							
								
									ea59b12ac6
								
							
						
					
					
						commit
						8b10d36537
					
				
					 5 changed files with 9 additions and 0 deletions
				
			
		| 
						 | 
					@ -724,6 +724,7 @@ Description:	Support configuring fault injection type, should be
 | 
				
			||||||
		FAULT_LOCK_OP                    0x000020000
 | 
							FAULT_LOCK_OP                    0x000020000
 | 
				
			||||||
		FAULT_BLKADDR_VALIDITY           0x000040000
 | 
							FAULT_BLKADDR_VALIDITY           0x000040000
 | 
				
			||||||
		FAULT_BLKADDR_CONSISTENCE        0x000080000
 | 
							FAULT_BLKADDR_CONSISTENCE        0x000080000
 | 
				
			||||||
 | 
							FAULT_NO_SEGMENT                 0x000100000
 | 
				
			||||||
		===========================      ===========
 | 
							===========================      ===========
 | 
				
			||||||
 | 
					
 | 
				
			||||||
What:		/sys/fs/f2fs/<disk>/discard_io_aware_gran
 | 
					What:		/sys/fs/f2fs/<disk>/discard_io_aware_gran
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -205,6 +205,7 @@ fault_type=%d		 Support configuring fault injection type, should be
 | 
				
			||||||
			 FAULT_LOCK_OP                    0x000020000
 | 
								 FAULT_LOCK_OP                    0x000020000
 | 
				
			||||||
			 FAULT_BLKADDR_VALIDITY           0x000040000
 | 
								 FAULT_BLKADDR_VALIDITY           0x000040000
 | 
				
			||||||
			 FAULT_BLKADDR_CONSISTENCE        0x000080000
 | 
								 FAULT_BLKADDR_CONSISTENCE        0x000080000
 | 
				
			||||||
 | 
								 FAULT_NO_SEGMENT                 0x000100000
 | 
				
			||||||
			 ===========================      ===========
 | 
								 ===========================      ===========
 | 
				
			||||||
mode=%s			 Control block allocation mode which supports "adaptive"
 | 
					mode=%s			 Control block allocation mode which supports "adaptive"
 | 
				
			||||||
			 and "lfs". In "lfs" mode, there should be no random
 | 
								 and "lfs". In "lfs" mode, there should be no random
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -62,6 +62,7 @@ enum {
 | 
				
			||||||
	FAULT_LOCK_OP,
 | 
						FAULT_LOCK_OP,
 | 
				
			||||||
	FAULT_BLKADDR_VALIDITY,
 | 
						FAULT_BLKADDR_VALIDITY,
 | 
				
			||||||
	FAULT_BLKADDR_CONSISTENCE,
 | 
						FAULT_BLKADDR_CONSISTENCE,
 | 
				
			||||||
 | 
						FAULT_NO_SEGMENT,
 | 
				
			||||||
	FAULT_MAX,
 | 
						FAULT_MAX,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2656,6 +2656,11 @@ static int get_new_segment(struct f2fs_sb_info *sbi,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spin_lock(&free_i->segmap_lock);
 | 
						spin_lock(&free_i->segmap_lock);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (time_to_inject(sbi, FAULT_NO_SEGMENT)) {
 | 
				
			||||||
 | 
							ret = -ENOSPC;
 | 
				
			||||||
 | 
							goto out_unlock;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!new_sec && ((*newseg + 1) % SEGS_PER_SEC(sbi))) {
 | 
						if (!new_sec && ((*newseg + 1) % SEGS_PER_SEC(sbi))) {
 | 
				
			||||||
		segno = find_next_zero_bit(free_i->free_segmap,
 | 
							segno = find_next_zero_bit(free_i->free_segmap,
 | 
				
			||||||
			GET_SEG_FROM_SEC(sbi, hint + 1), *newseg + 1);
 | 
								GET_SEG_FROM_SEC(sbi, hint + 1), *newseg + 1);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -63,6 +63,7 @@ const char *f2fs_fault_name[FAULT_MAX] = {
 | 
				
			||||||
	[FAULT_LOCK_OP]			= "lock_op",
 | 
						[FAULT_LOCK_OP]			= "lock_op",
 | 
				
			||||||
	[FAULT_BLKADDR_VALIDITY]	= "invalid blkaddr",
 | 
						[FAULT_BLKADDR_VALIDITY]	= "invalid blkaddr",
 | 
				
			||||||
	[FAULT_BLKADDR_CONSISTENCE]	= "inconsistent blkaddr",
 | 
						[FAULT_BLKADDR_CONSISTENCE]	= "inconsistent blkaddr",
 | 
				
			||||||
 | 
						[FAULT_NO_SEGMENT]		= "no free segment",
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void f2fs_build_fault_attr(struct f2fs_sb_info *sbi, unsigned int rate,
 | 
					void f2fs_build_fault_attr(struct f2fs_sb_info *sbi, unsigned int rate,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue