f2fs: fix to avoid triggering IO in write path
If we are in write IO path, we need to avoid using GFP_KERNEL. Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
		
							parent
							
								
									985100035e
								
							
						
					
					
						commit
						0683728ada
					
				| @ -656,7 +656,7 @@ retry: | ||||
| 		struct bio *bio = NULL; | ||||
| 
 | ||||
| 		ret = f2fs_read_multi_pages(cc, &bio, cc->cluster_size, | ||||
| 						&last_block_in_bio, false); | ||||
| 					&last_block_in_bio, false, true); | ||||
| 		f2fs_destroy_compress_ctx(cc); | ||||
| 		if (ret) | ||||
| 			goto release_pages; | ||||
|  | ||||
| @ -925,14 +925,15 @@ static inline bool f2fs_need_verity(const struct inode *inode, pgoff_t idx) | ||||
| 
 | ||||
| static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr, | ||||
| 				      unsigned nr_pages, unsigned op_flag, | ||||
| 				      pgoff_t first_idx) | ||||
| 				      pgoff_t first_idx, bool for_write) | ||||
| { | ||||
| 	struct f2fs_sb_info *sbi = F2FS_I_SB(inode); | ||||
| 	struct bio *bio; | ||||
| 	struct bio_post_read_ctx *ctx; | ||||
| 	unsigned int post_read_steps = 0; | ||||
| 
 | ||||
| 	bio = f2fs_bio_alloc(sbi, min_t(int, nr_pages, BIO_MAX_PAGES), false); | ||||
| 	bio = f2fs_bio_alloc(sbi, min_t(int, nr_pages, BIO_MAX_PAGES), | ||||
| 								for_write); | ||||
| 	if (!bio) | ||||
| 		return ERR_PTR(-ENOMEM); | ||||
| 	f2fs_target_device(sbi, blkaddr, bio); | ||||
| @ -967,12 +968,12 @@ static void f2fs_release_read_bio(struct bio *bio) | ||||
| 
 | ||||
| /* This can handle encryption stuffs */ | ||||
| static int f2fs_submit_page_read(struct inode *inode, struct page *page, | ||||
| 							block_t blkaddr) | ||||
| 						block_t blkaddr, bool for_write) | ||||
| { | ||||
| 	struct f2fs_sb_info *sbi = F2FS_I_SB(inode); | ||||
| 	struct bio *bio; | ||||
| 
 | ||||
| 	bio = f2fs_grab_read_bio(inode, blkaddr, 1, 0, page->index); | ||||
| 	bio = f2fs_grab_read_bio(inode, blkaddr, 1, 0, page->index, for_write); | ||||
| 	if (IS_ERR(bio)) | ||||
| 		return PTR_ERR(bio); | ||||
| 
 | ||||
| @ -1158,7 +1159,7 @@ got_it: | ||||
| 		return page; | ||||
| 	} | ||||
| 
 | ||||
| 	err = f2fs_submit_page_read(inode, page, dn.data_blkaddr); | ||||
| 	err = f2fs_submit_page_read(inode, page, dn.data_blkaddr, for_write); | ||||
| 	if (err) | ||||
| 		goto put_err; | ||||
| 	return page; | ||||
| @ -1971,7 +1972,8 @@ submit_and_realloc: | ||||
| 	} | ||||
| 	if (bio == NULL) { | ||||
| 		bio = f2fs_grab_read_bio(inode, block_nr, nr_pages, | ||||
| 				is_readahead ? REQ_RAHEAD : 0, page->index); | ||||
| 				is_readahead ? REQ_RAHEAD : 0, page->index, | ||||
| 				false); | ||||
| 		if (IS_ERR(bio)) { | ||||
| 			ret = PTR_ERR(bio); | ||||
| 			bio = NULL; | ||||
| @ -2006,7 +2008,7 @@ out: | ||||
| #ifdef CONFIG_F2FS_FS_COMPRESSION | ||||
| int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret, | ||||
| 				unsigned nr_pages, sector_t *last_block_in_bio, | ||||
| 				bool is_readahead) | ||||
| 				bool is_readahead, bool for_write) | ||||
| { | ||||
| 	struct dnode_of_data dn; | ||||
| 	struct inode *inode = cc->inode; | ||||
| @ -2100,7 +2102,7 @@ submit_and_realloc: | ||||
| 		if (!bio) { | ||||
| 			bio = f2fs_grab_read_bio(inode, blkaddr, nr_pages, | ||||
| 					is_readahead ? REQ_RAHEAD : 0, | ||||
| 					page->index); | ||||
| 					page->index, for_write); | ||||
| 			if (IS_ERR(bio)) { | ||||
| 				ret = PTR_ERR(bio); | ||||
| 				bio = NULL; | ||||
| @ -2201,7 +2203,7 @@ int f2fs_mpage_readpages(struct address_space *mapping, | ||||
| 				ret = f2fs_read_multi_pages(&cc, &bio, | ||||
| 							max_nr_pages, | ||||
| 							&last_block_in_bio, | ||||
| 							is_readahead); | ||||
| 							is_readahead, false); | ||||
| 				f2fs_destroy_compress_ctx(&cc); | ||||
| 				if (ret) | ||||
| 					goto set_error_page; | ||||
| @ -2244,7 +2246,7 @@ next_page: | ||||
| 				ret = f2fs_read_multi_pages(&cc, &bio, | ||||
| 							max_nr_pages, | ||||
| 							&last_block_in_bio, | ||||
| 							is_readahead); | ||||
| 							is_readahead, false); | ||||
| 				f2fs_destroy_compress_ctx(&cc); | ||||
| 			} | ||||
| 		} | ||||
| @ -3274,7 +3276,7 @@ repeat: | ||||
| 			err = -EFSCORRUPTED; | ||||
| 			goto fail; | ||||
| 		} | ||||
| 		err = f2fs_submit_page_read(inode, page, blkaddr); | ||||
| 		err = f2fs_submit_page_read(inode, page, blkaddr, true); | ||||
| 		if (err) | ||||
| 			goto fail; | ||||
| 
 | ||||
|  | ||||
| @ -3796,7 +3796,7 @@ int f2fs_write_multi_pages(struct compress_ctx *cc, | ||||
| int f2fs_is_compressed_cluster(struct inode *inode, pgoff_t index); | ||||
| int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret, | ||||
| 				unsigned nr_pages, sector_t *last_block_in_bio, | ||||
| 				bool is_readahead); | ||||
| 				bool is_readahead, bool for_write); | ||||
| struct decompress_io_ctx *f2fs_alloc_dic(struct compress_ctx *cc); | ||||
| void f2fs_free_dic(struct decompress_io_ctx *dic); | ||||
| void f2fs_decompress_end_io(struct page **rpages, | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user