Linux-SCSI Archive on
 help / color / Atom feed
From: Sebastian Andrzej Siewior <>
	"Martin K. Petersen" <>,
	Thomas Gleixner <>,
	"Ahmed S . Darwish" <>,
	Sebastian Andrzej Siewior <>
Subject: [PATCH 5/6] scsi: target: Replace in_interrupt() usage in target_submit_cmd_map_sgls()
Date: Sun, 20 Dec 2020 21:36:37 +0100
Message-ID: <> (raw)
In-Reply-To: <>

target_submit_cmd_map_sgls() uses in_interrupt() to crash if it returns

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.

The usage of in_interrupt() is clearly for debugging. might_sleep() is
better at this because it also detects other contexts in which it is not
allowed to sleep, like preempt-disabled section.

Replace BUG_ON(in_interrupt) with might_sleep().

Signed-off-by: Sebastian Andrzej Siewior <>
 drivers/target/target_core_transport.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index fca4bd079d02c..b4fdc3f41e90a 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1613,10 +1613,11 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess
 	sense_reason_t rc;
 	int ret;
+	might_sleep();
 	se_tpg = se_sess->se_tpg;
 	BUG_ON(se_cmd->se_tfo || se_cmd->se_sess);
-	BUG_ON(in_interrupt());
 	if (flags & TARGET_SCF_USE_CPUID)
 		se_cmd->se_cmd_flags |= SCF_USE_CPUID;

  parent reply index

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 ` Sebastian Andrzej Siewior [this message]
2020-12-20 20:36 ` [PATCH 6/6] scsi: target: Remove in_interrupt() check in transport_handle_cdb_direct() Sebastian Andrzej Siewior
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:

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

  git send-email \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-SCSI Archive on

Archives are clonable:
	git clone --mirror linux-scsi/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-scsi linux-scsi/ \
	public-inbox-index linux-scsi

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone