linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: target-devel@vger.kernel.org
Cc: linux-scsi@vger.kernel.org,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	"Ahmed S . Darwish" <a.darwish@linutronix.de>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Subject: [PATCH 6/6] scsi: target: Remove in_interrupt() check in transport_handle_cdb_direct()
Date: Sun, 20 Dec 2020 21:36:38 +0100	[thread overview]
Message-ID: <20201220203638.43615-7-bigeasy@linutronix.de> (raw)
In-Reply-To: <20201220203638.43615-1-bigeasy@linutronix.de>

From: "Ahmed S. Darwish" <a.darwish@linutronix.de>

transport_handle_cdb_direct() uses in_interrupt() to detect if it is
safe to sleep. It produces a stack trace and returns with an error which
is clearly for debugging.

The usage of in_interrupt() in drivers is phased out and Linus clearly
requested that code which changes behaviour depending on context should
either be separated or the context be conveyed in an argument passed by the
caller, which usually knows the context.

transport_handle_cdb_direct() has a comment saying that it may only be
invoked from process context. It invokes transport_generic_new_cmd()
which performs GFP_KERNEL memory allocations. in_interrupt() does not
detect all the contexts where it is invalid to sleep (for the blocking
GFP_KERNEL allocation) as it fails to detect sections with disabled
preemption.

Replace the in_interrupt() based check with a might_sleep() annotation.

Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/target/target_core_transport.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index b4fdc3f41e90a..d47bfd8b0f87c 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1512,17 +1512,14 @@ int transport_handle_cdb_direct(
 {
 	sense_reason_t ret;
 
+	might_sleep();
+
 	if (!cmd->se_lun) {
 		dump_stack();
 		pr_err("cmd->se_lun is NULL\n");
 		return -EINVAL;
 	}
-	if (in_interrupt()) {
-		dump_stack();
-		pr_err("transport_generic_handle_cdb cannot be called"
-				" from interrupt context\n");
-		return -EINVAL;
-	}
+
 	/*
 	 * Set TRANSPORT_NEW_CMD state and CMD_T_ACTIVE to ensure that
 	 * outstanding descriptors are handled correctly during shutdown via
-- 
2.29.2


  parent reply	other threads:[~2020-12-20 20:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-20 20:36 [PATCH 0/6] scsi: target: Remove in_interrupt() usage Sebastian Andrzej Siewior
2020-12-20 20:36 ` [PATCH 1/6] scsi: target: iscsi: Avoid in_interrupt() usage in iscsit_close_session() Sebastian Andrzej Siewior
2020-12-20 20:36 ` [PATCH 2/6] scsi: target: iscsi: Avoid in_interrupt() usage in iscsit_check_session_usage_count() Sebastian Andrzej Siewior
2020-12-20 20:36 ` [PATCH 3/6] scsi: target: iscsi: Redo iscsit_check_session_usage_count() return code Sebastian Andrzej Siewior
2020-12-20 20:36 ` [PATCH 4/6] scsi: target: Remove in_interrupt() usage in core_alua_check_nonop_delay() Sebastian Andrzej Siewior
2020-12-20 20:36 ` [PATCH 5/6] scsi: target: Replace in_interrupt() usage in target_submit_cmd_map_sgls() Sebastian Andrzej Siewior
2020-12-20 20:36 ` Sebastian Andrzej Siewior [this message]
2021-01-22 16:51 ` [PATCH 0/6] scsi: target: Remove in_interrupt() usage Sebastian Andrzej Siewior
2021-01-23  1:28   ` Martin K. Petersen
2021-01-27  4:54 ` Martin K. Petersen

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=20201220203638.43615-7-bigeasy@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=a.darwish@linutronix.de \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=target-devel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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).