* [RFC PATCH v1] sd: drain a request queue during sd_shutdown()
[not found] <CGME20200709063102epcas2p1e2a624bd881d02b6d3f137f9955eb4b8@epcas2p1.samsung.com>
@ 2020-07-09 6:23 ` Lee Sang Hyun
2020-07-09 15:39 ` Bart Van Assche
0 siblings, 1 reply; 2+ messages in thread
From: Lee Sang Hyun @ 2020-07-09 6:23 UTC (permalink / raw)
To: linux-scsi, alim.akhtar, avri.altman, jejb, martin.petersen,
beanhuo, asutoshd, cang, bvanassche, grant.jung, sc.suh,
hy50.seo, kwmad.kim
Cc: Lee Sang Hyun
Need to set a request queue like below in sd_shutdown()
to prevent pending IOs before UFS shutdown.
Change-Id: I2818cf95944d85baa50b626fcf538f19d06d6d54
Signed-off-by: Lee Sang Hyun <sh425.lee@samsung.com>
---
drivers/scsi/sd.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index d90feff..7418d27 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3564,6 +3564,8 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
static void sd_shutdown(struct device *dev)
{
struct scsi_disk *sdkp = dev_get_drvdata(dev);
+ struct request_queue *q = sdp->request_queue;
+ unsigned long flags;
if (!sdkp)
return; /* this can happen */
@@ -3580,6 +3582,12 @@ static void sd_shutdown(struct device *dev)
sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
sd_start_stop_device(sdkp, 0);
}
+
+ spin_lock_irqsave(q->queue_lock, flags);
+ queue_flag_set(QUEUE_FLAG_DYING, q);
+ __blk_drain_queue(q, true);
+ queue_flag_set(QUEUE_FLAG_DEAD, q);
+ spin_unlock_irqrestore(q->queue_lock, flags);
}
static int sd_suspend_common(struct device *dev, bool ignore_stop_errors)
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [RFC PATCH v1] sd: drain a request queue during sd_shutdown()
2020-07-09 6:23 ` [RFC PATCH v1] sd: drain a request queue during sd_shutdown() Lee Sang Hyun
@ 2020-07-09 15:39 ` Bart Van Assche
0 siblings, 0 replies; 2+ messages in thread
From: Bart Van Assche @ 2020-07-09 15:39 UTC (permalink / raw)
To: Lee Sang Hyun, linux-scsi, alim.akhtar, avri.altman, jejb,
martin.petersen, beanhuo, asutoshd, cang, grant.jung, sc.suh,
hy50.seo, kwmad.kim
On 2020-07-08 23:23, Lee Sang Hyun wrote:
> Need to set a request queue like below in sd_shutdown()
> to prevent pending IOs before UFS shutdown.
>
> Change-Id: I2818cf95944d85baa50b626fcf538f19d06d6d54
> Signed-off-by: Lee Sang Hyun <sh425.lee@samsung.com>
> ---
> drivers/scsi/sd.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index d90feff..7418d27 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -3564,6 +3564,8 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
> static void sd_shutdown(struct device *dev)
> {
> struct scsi_disk *sdkp = dev_get_drvdata(dev);
> + struct request_queue *q = sdp->request_queue;
> + unsigned long flags;
>
> if (!sdkp)
> return; /* this can happen */
> @@ -3580,6 +3582,12 @@ static void sd_shutdown(struct device *dev)
> sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
> sd_start_stop_device(sdkp, 0);
> }
> +
> + spin_lock_irqsave(q->queue_lock, flags);
> + queue_flag_set(QUEUE_FLAG_DYING, q);
> + __blk_drain_queue(q, true);
> + queue_flag_set(QUEUE_FLAG_DEAD, q);
> + spin_unlock_irqrestore(q->queue_lock, flags);
> }
This patch is unacceptable because:
(a) It introduces a layering violation. The code added in sd_shutdown()
belongs in the block layer instead of the sd driver.
(b) A description of which problem has been observed and why the sd
driver is being modified is missing.
(c) An explanation is missing why the blk_cleanup_queue() call in
__scsi_remove_device() is not sufficient. As you may know
blk_cleanup_queue() already drains the request queue.
(d) The above patch breaks the kernel build. __blk_drain_queue() was
removed from the kernel almost two years ago. See also commit
a1ce35fa4985 ("block: remove dead elevator code") # v5.0.
Bart.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-07-09 15:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20200709063102epcas2p1e2a624bd881d02b6d3f137f9955eb4b8@epcas2p1.samsung.com>
2020-07-09 6:23 ` [RFC PATCH v1] sd: drain a request queue during sd_shutdown() Lee Sang Hyun
2020-07-09 15:39 ` Bart Van Assche
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).