linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ye Bin <yebin@huaweicloud.com>
To: jejb@linux.ibm.com, martin.petersen@oracle.com,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Ye Bin <yebin10@huawei.com>
Subject: [PATCH] scsi: fix hung_task when change host from recovery to running via sysfs
Date: Tue, 21 Mar 2023 16:42:04 +0800	[thread overview]
Message-ID: <20230321084204.1860900-1-yebin@huaweicloud.com> (raw)

From: Ye Bin <yebin10@huawei.com>

When do follow test:
Step1: echo  "recovery" > /sys/class/scsi_host/host0/state
Step2: dd if=/dev/sda  of=/dev/null  count=1  &
Step3: echo  "running" > /sys/class/scsi_host/host0/state
Got issue as follows:
INFO: task dd:14545 blocked for more than 143 seconds.
      Not tainted 6.3.0-rc2-next-20230315-dirty #406
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:dd              state:D stack:23376 pid:14545 ppid:14439  flags:0x00000000
Call Trace:
 <TASK>
 __schedule+0x232e/0x55a0
 schedule+0xde/0x1a0
 scsi_block_when_processing_errors+0x2e9/0x350
 sd_open+0x10c/0x6d0
 blkdev_get_whole+0x99/0x260
 blkdev_get_by_dev+0x556/0xbe0
 blkdev_open+0x140/0x2c0
 do_dentry_open+0x6cc/0x13f0
 path_openat+0x1b3b/0x26b0
 do_filp_open+0x1ce/0x2a0
 do_sys_openat2+0x61b/0x990
 do_sys_open+0xc7/0x150
 do_syscall_64+0x39/0xb0
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Above issue happens as when change host state by sysfs, there isn't wakeup
waiter.
To solve above issue, just wakeup waiter when change state success. There is
no additional judgment here because modifying the host state is more used in
testing.

Signed-off-by: Ye Bin <yebin10@huawei.com>
---
 drivers/scsi/scsi_sysfs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index ee28f73af4d4..ae6b1476b869 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -216,6 +216,9 @@ store_shost_state(struct device *dev, struct device_attribute *attr,
 
 	if (scsi_host_set_state(shost, state))
 		return -EINVAL;
+	else
+		wake_up(&shost->host_wait);
+
 	return count;
 }
 
-- 
2.31.1


             reply	other threads:[~2023-03-21  8:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-21  8:42 Ye Bin [this message]
2023-03-21 14:22 ` [PATCH] scsi: fix hung_task when change host from recovery to running via sysfs Benjamin Block
2023-03-22  1:24   ` yebin (H)
2023-03-23 10:21     ` Benjamin Block
2023-03-23 15:57       ` Mike Christie
2023-03-23 16:12     ` Mike Christie
2023-03-24  1:41       ` yebin (H)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230321084204.1860900-1-yebin@huaweicloud.com \
    --to=yebin@huaweicloud.com \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=yebin10@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).