linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Omar Sandoval <osandov@fb.com>
Cc: linux-block@vger.kernel.org, Ming Lei <ming.lei@redhat.com>,
	Yi Zhang <yi.zhang@redhat.com>
Subject: [PATCH] block/001: don't exit test with pending async scan
Date: Mon, 30 Aug 2021 10:38:44 +0800	[thread overview]
Message-ID: <20210830023844.1870471-1-ming.lei@redhat.com> (raw)

We have to run scan and delete together, otherwise pending async
may prevent scsi_debug from being unloaded, and cause failure of
'modprobe: FATAL: Module scsi_debug is in use.'

Fix the issue by always running both scan and delete together.

Fixes: f3bcd8c ("block/001: wait until device is added")
Reported-by: Yi Zhang <yi.zhang@redhat.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 tests/block/001 | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/tests/block/001 b/tests/block/001
index c26792b..be33962 100755
--- a/tests/block/001
+++ b/tests/block/001
@@ -29,13 +29,8 @@ stress_scsi_debug() {
 		scan="${scan//:/ }"
 		while [[ ! -e "$TMPDIR/stop" ]]; do
 			echo "${scan}" > "/sys/class/scsi_host/host${host}/scan"
-			while [[ ! -e "$TMPDIR/stop" ]]; do
-				if [[ -d "/sys/class/scsi_device/${target}" ]]; then
-					echo 1 > "/sys/class/scsi_device/${target}/device/delete"
-					break
-				fi
-				sleep 0.01
-			done
+			while [[ ! -d "/sys/class/scsi_device/${target}" ]]; do sleep 0.01; done
+			echo 1 > "/sys/class/scsi_device/${target}/device/delete"
 		done
 		) &
 	done
-- 
2.31.1


             reply	other threads:[~2021-08-30  2:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-30  2:38 Ming Lei [this message]
2021-08-31 23:42 ` [PATCH] block/001: don't exit test with pending async scan Omar Sandoval

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=20210830023844.1870471-1-ming.lei@redhat.com \
    --to=ming.lei@redhat.com \
    --cc=linux-block@vger.kernel.org \
    --cc=osandov@fb.com \
    --cc=yi.zhang@redhat.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).