Re: [BUG REPORT] General protection fault while discarding extents on XFS on next-20240305

Christoph Hellwig
2024-03-06T12:35:10Z

On Wed, Mar 06, 2024 at 12:49:29PM +0530, Chandan Babu R wrote:
> The above *probably* occured because __blkdev_issue_discard() noticed a pending
> signal, processed the bio, freed the bio and returned a non-NULL bio pointer
> to the caller (i.e. xfs_discard_extents()).
>
> xfs_discard_extents() then tries to process the freed bio once again.

Yes, __blkdev_issue_discard really needs to clear *biop to NULL for
this case, i.e.:

diff --git a/block/blk-lib.c b/block/blk-lib.c
index dc8e35d0a51d6d..26850d4895cdaf 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -99,6 +99,7 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
cond_resched();
if (fatal_signal_pending(current)) {
await_bio_chain(bio);
+ *biop = NULL;
return -EINTR;
}
}