* [PATCH] Revert "blk-lib: check for kill signal"
@ 2024-03-14 2:16 Christoph Hellwig
2024-03-14 2:17 ` Keith Busch
2024-03-14 2:36 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: Christoph Hellwig @ 2024-03-14 2:16 UTC (permalink / raw)
To: axboe; +Cc: kbusch, linux-block, Chandan Babu R
This reverts commit 8a08c5fd89b447a7de7eb293a7a274c46b932ba2.
It turns out while this is a perfectly valid and long overdue thing to do
for user initiated discards / zeroing from the ioctl handler, it actually
breaks file system use of the discard helper by interrupting in places
the file system doesn't expect, and by leaving the bio chain in a state
that the file system callers of (at least) __blkdev_issue_discard do
not expect.
Revert the change for now, we'll redo it for the next merge window
after refactoring the code to better split the file system vs ioctl
callers and cleaning up a few other loose ends.
Reported-by: Chandan Babu R <chandanbabu@kernel.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-lib.c | 40 +---------------------------------------
1 file changed, 1 insertion(+), 39 deletions(-)
diff --git a/block/blk-lib.c b/block/blk-lib.c
index dc8e35d0a51d6d..a6954eafb8c8af 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -35,26 +35,6 @@ static sector_t bio_discard_limit(struct block_device *bdev, sector_t sector)
return round_down(UINT_MAX, discard_granularity) >> SECTOR_SHIFT;
}
-static void await_bio_endio(struct bio *bio)
-{
- complete(bio->bi_private);
- bio_put(bio);
-}
-
-/*
- * await_bio_chain - ends @bio and waits for every chained bio to complete
- */
-static void await_bio_chain(struct bio *bio)
-{
- DECLARE_COMPLETION_ONSTACK_MAP(done,
- bio->bi_bdev->bd_disk->lockdep_map);
-
- bio->bi_private = &done;
- bio->bi_end_io = await_bio_endio;
- bio_endio(bio);
- blk_wait_io(&done);
-}
-
int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
sector_t nr_sects, gfp_t gfp_mask, struct bio **biop)
{
@@ -97,10 +77,6 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
* is disabled.
*/
cond_resched();
- if (fatal_signal_pending(current)) {
- await_bio_chain(bio);
- return -EINTR;
- }
}
*biop = bio;
@@ -167,10 +143,6 @@ static int __blkdev_issue_write_zeroes(struct block_device *bdev,
nr_sects -= len;
sector += len;
cond_resched();
- if (fatal_signal_pending(current)) {
- await_bio_chain(bio);
- return -EINTR;
- }
}
*biop = bio;
@@ -215,10 +187,6 @@ static int __blkdev_issue_zero_pages(struct block_device *bdev,
break;
}
cond_resched();
- if (fatal_signal_pending(current)) {
- await_bio_chain(bio);
- return -EINTR;
- }
}
*biop = bio;
@@ -309,7 +277,7 @@ int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
bio_put(bio);
}
blk_finish_plug(&plug);
- if (ret && ret != -EINTR && try_write_zeroes) {
+ if (ret && try_write_zeroes) {
if (!(flags & BLKDEV_ZERO_NOFALLBACK)) {
try_write_zeroes = false;
goto retry;
@@ -361,12 +329,6 @@ int blkdev_issue_secure_erase(struct block_device *bdev, sector_t sector,
sector += len;
nr_sects -= len;
cond_resched();
- if (fatal_signal_pending(current)) {
- await_bio_chain(bio);
- ret = -EINTR;
- bio = NULL;
- break;
- }
}
if (bio) {
ret = submit_bio_wait(bio);
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Revert "blk-lib: check for kill signal"
2024-03-14 2:16 [PATCH] Revert "blk-lib: check for kill signal" Christoph Hellwig
@ 2024-03-14 2:17 ` Keith Busch
2024-03-14 2:36 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Keith Busch @ 2024-03-14 2:17 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: axboe, linux-block, Chandan Babu R
On Wed, Mar 13, 2024 at 07:16:23PM -0700, Christoph Hellwig wrote:
> This reverts commit 8a08c5fd89b447a7de7eb293a7a274c46b932ba2.
>
> It turns out while this is a perfectly valid and long overdue thing to do
> for user initiated discards / zeroing from the ioctl handler, it actually
> breaks file system use of the discard helper by interrupting in places
> the file system doesn't expect, and by leaving the bio chain in a state
> that the file system callers of (at least) __blkdev_issue_discard do
> not expect.
>
> Revert the change for now, we'll redo it for the next merge window
> after refactoring the code to better split the file system vs ioctl
> callers and cleaning up a few other loose ends.
>
> Reported-by: Chandan Babu R <chandanbabu@kernel.org>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Keith Busch <kbusch@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Revert "blk-lib: check for kill signal"
2024-03-14 2:16 [PATCH] Revert "blk-lib: check for kill signal" Christoph Hellwig
2024-03-14 2:17 ` Keith Busch
@ 2024-03-14 2:36 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2024-03-14 2:36 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: kbusch, linux-block, Chandan Babu R
On Wed, 13 Mar 2024 19:16:23 -0700, Christoph Hellwig wrote:
> This reverts commit 8a08c5fd89b447a7de7eb293a7a274c46b932ba2.
>
> It turns out while this is a perfectly valid and long overdue thing to do
> for user initiated discards / zeroing from the ioctl handler, it actually
> breaks file system use of the discard helper by interrupting in places
> the file system doesn't expect, and by leaving the bio chain in a state
> that the file system callers of (at least) __blkdev_issue_discard do
> not expect.
>
> [...]
Applied, thanks!
[1/1] Revert "blk-lib: check for kill signal"
commit: bf5e3a30f777b6e763f6a46c10e1250c20237e97
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-14 2:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-14 2:16 [PATCH] Revert "blk-lib: check for kill signal" Christoph Hellwig
2024-03-14 2:17 ` Keith Busch
2024-03-14 2:36 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox