f2fs: fix to check bio after __blkdev_issue_discard()
Chao Yu
maintainerPATCH 1/1 f2fs: fix to check bio after __blkdev_issue_discard()
Previously, __blkdev_issue_discard() will always returned valid bio, after commit e8b4869bc78d ("block: add a blk_alloc_discard_bio helper"), it can return bio w/ NULL value, which may trigger panic or warning in __submit_discard_cmd(), let's fix to check bio instread of return value after __blkdev_issue_discard().
--- fs/f2fs/segment.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/segment.c +1 -1
@@ -1351,7 +1351,7 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi,SECTOR_FROM_BLOCK (len), GFP_NOFS, &bio); } -if (err) { +if (err || bio ==NULL ) {spin_lock_irqsave (&dc->lock, flags);if (dc->state ==D_PARTIAL ) dc->state =D_SUBMIT ;
Signature · 1 line
2.49.0
Quoted 5 lines · Chao Yu
Previously,
__blkdev_issue_discard()will always returned valid bio, after commite8b4869bc78d("block: add ablk_alloc_discard_biohelper"), it can return bio w/ NULL value, which may trigger panic or warning in__submit_discard_cmd(), let's fix to check bio instread of return value after__blkdev_issue_discard().
It can only return blk_alloc_discard_bio if the the gfp_mask doesn't allow sleeping (which isn't the case here), or nr_sect is zero, which I hope is also not the case as __submit_discard_cmd would run into various other problems. So no, I don't think this is patch makes any sense.
Chao Yu
maintainerQuoted 5 lines · Christoph Hellwig
It can only return
blk_alloc_discard_bioif the thegfp_maskdoesn't allow sleeping (which isn't the case here), ornr_sectis zero, which I hope is also not the case as__submit_discard_cmdwould run into various other problems. So no, I don't think this is patch makes any sense.
Oh, I checked details in bio_alloc_bioset() again, it seems I missed something for mempool_alloc(), as you mentioned, it may only fail due to caller is in non-sleep context passing gfp w/ GFP_ATOMIC or GFP_NOWAIT, which is not the case for f2fs discard.
Thanks,