mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	f2fs: drop inplace IO if fs status is abnormal
If filesystem has cp_error or need_fsck status, let's drop inplace IO to avoid further corruption of fs data. Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
		
							parent
							
								
									8af85f712f
								
							
						
					
					
						commit
						9557727876
					
				
					 1 changed files with 16 additions and 1 deletions
				
			
		| 
						 | 
					@ -3552,7 +3552,13 @@ int f2fs_inplace_write_data(struct f2fs_io_info *fio)
 | 
				
			||||||
		set_sbi_flag(sbi, SBI_NEED_FSCK);
 | 
							set_sbi_flag(sbi, SBI_NEED_FSCK);
 | 
				
			||||||
		f2fs_warn(sbi, "%s: incorrect segment(%u) type, run fsck to fix.",
 | 
							f2fs_warn(sbi, "%s: incorrect segment(%u) type, run fsck to fix.",
 | 
				
			||||||
			  __func__, segno);
 | 
								  __func__, segno);
 | 
				
			||||||
		return -EFSCORRUPTED;
 | 
							err = -EFSCORRUPTED;
 | 
				
			||||||
 | 
							goto drop_bio;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (is_sbi_flag_set(sbi, SBI_NEED_FSCK) || f2fs_cp_error(sbi)) {
 | 
				
			||||||
 | 
							err = -EIO;
 | 
				
			||||||
 | 
							goto drop_bio;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	stat_inc_inplace_blocks(fio->sbi);
 | 
						stat_inc_inplace_blocks(fio->sbi);
 | 
				
			||||||
| 
						 | 
					@ -3566,6 +3572,15 @@ int f2fs_inplace_write_data(struct f2fs_io_info *fio)
 | 
				
			||||||
		f2fs_update_iostat(fio->sbi, fio->io_type, F2FS_BLKSIZE);
 | 
							f2fs_update_iostat(fio->sbi, fio->io_type, F2FS_BLKSIZE);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return err;
 | 
				
			||||||
 | 
					drop_bio:
 | 
				
			||||||
 | 
						if (fio->bio) {
 | 
				
			||||||
 | 
							struct bio *bio = *(fio->bio);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							bio->bi_status = BLK_STS_IOERR;
 | 
				
			||||||
 | 
							bio_endio(bio);
 | 
				
			||||||
 | 
							fio->bio = NULL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	return err;
 | 
						return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue