mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH v3] dm-io: don't warn if flush takes too long time
       [not found] <754d1973-31cb-d3ca-1f6f-2d35b96364db@redhat.com>
@ 2024-04-17 14:50 ` Christoph Hellwig
  0 siblings, 0 replies; only message in thread
From: Christoph Hellwig @ 2024-04-17 14:50 UTC (permalink / raw)
  To: Mikulas Patocka
  Cc: Mike Snitzer, Damien Le Moal, Guangwu Zhang, dm-devel,
	Jens Axboe, linux-block, Peter Zijlstra, Thomas Gleixner,
	linux-kernel

> --- linux-2.6.orig/include/linux/completion.h	2024-04-15 15:54:22.000000000 +0200
> +++ linux-2.6/include/linux/completion.h	2024-04-15 15:57:14.000000000 +0200
> @@ -10,6 +10,7 @@
>   */
>  
>  #include <linux/swait.h>
> +#include <linux/sched/sysctl.h>

If you're touching completion.h you need to CC lkml and the people
who wrote/maintain it even if we don't have a proper maintainer.

I don't think adding yet another include into it is a good idea.

As is this whole hack here.  Pleas just add the proper TASK_STATE for
task that can legitimately sleep for very long times  instead of
extending this hack again and again, just like I told Kent when he messed with the timeout.

>  
>  /*
>   * struct completion - structure used to maintain state for a "completion"
> @@ -119,4 +120,20 @@ extern void complete(struct completion *
>  extern void complete_on_current_cpu(struct completion *x);
>  extern void complete_all(struct completion *);
>  
> +/**
> + * wait_for_completion_long_io - this is like wait_for_completion_io,
> + * but it doesn't warn if the wait takes too long.
> + */
> +static inline void wait_for_completion_long_io(struct completion *done)
> +{
> +	/* Prevent hang_check timer from firing at us during very long I/O */
> +	unsigned long timeout = sysctl_hung_task_timeout_secs * HZ / 2;
> +
> +	if (timeout)
> +		while (!wait_for_completion_io_timeout(done, timeout))
> +			;
> +	else
> +		wait_for_completion_io(done);
> +}
> +
>  #endif
> Index: linux-2.6/block/bio.c
> ===================================================================
> --- linux-2.6.orig/block/bio.c	2024-03-30 20:07:03.000000000 +0100
> +++ linux-2.6/block/bio.c	2024-04-15 15:55:13.000000000 +0200
> @@ -1378,7 +1378,7 @@ int submit_bio_wait(struct bio *bio)
>  	bio->bi_end_io = submit_bio_wait_endio;
>  	bio->bi_opf |= REQ_SYNC;
>  	submit_bio(bio);
> -	blk_wait_io(&done);
> +	wait_for_completion_long_io(&done);
>  
>  	return blk_status_to_errno(bio->bi_status);
>  }
> Index: linux-2.6/block/blk-mq.c
> ===================================================================
> --- linux-2.6.orig/block/blk-mq.c	2024-03-30 20:07:03.000000000 +0100
> +++ linux-2.6/block/blk-mq.c	2024-04-15 15:55:05.000000000 +0200
> @@ -1407,7 +1407,7 @@ blk_status_t blk_execute_rq(struct reque
>  	if (blk_rq_is_poll(rq))
>  		blk_rq_poll_completion(rq, &wait.done);
>  	else
> -		blk_wait_io(&wait.done);
> +		wait_for_completion_long_io(&wait.done);
>  
>  	return wait.ret;
>  }
> 
> 
---end quoted text---

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-17 14:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <754d1973-31cb-d3ca-1f6f-2d35b96364db@redhat.com>
2024-04-17 14:50 ` [PATCH v3] dm-io: don't warn if flush takes too long time Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®