All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: "Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>,
	Christoph Hellwig <hch@lst.de>, Ming Lei <ming.lei@redhat.com>,
	Hannes Reinecke <hare@suse.de>,
	John Garry <john.garry@huawei.com>,
	Mike Christie <michael.christie@oracle.com>,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>
Subject: [PATCH v4 4/4] scsi: core: Rework the code for dropping the LLD module reference
Date: Tue, 13 Sep 2022 12:57:16 -0700	[thread overview]
Message-ID: <20220913195716.3966875-5-bvanassche@acm.org> (raw)
In-Reply-To: <20220913195716.3966875-1-bvanassche@acm.org>

Instead of clearing the host template module pointer if the LLD kernel
module is being unloaded, set the 'drop_module_ref' SCSI device member.
This patch prepares for constifying the SCSI host template.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: John Garry <john.garry@huawei.com>
Cc: Mike Christie <michael.christie@oracle.com>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/scsi_sysfs.c  | 7 +++----
 include/scsi/scsi_device.h | 1 +
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 5d61f58399dc..822ae60a64b9 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -454,7 +454,7 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work)
 
 	sdev = container_of(work, struct scsi_device, ew.work);
 
-	mod = sdev->host->hostt->module;
+	mod = sdev->drop_module_ref ? sdev->host->hostt->module : NULL;
 
 	scsi_dh_release_device(sdev);
 
@@ -525,9 +525,8 @@ static void scsi_device_dev_release(struct device *dev)
 {
 	struct scsi_device *sdp = to_scsi_device(dev);
 
-	/* Set module pointer as NULL in case of module unloading */
-	if (!try_module_get(sdp->host->hostt->module))
-		sdp->host->hostt->module = NULL;
+	if (try_module_get(sdp->host->hostt->module))
+		sdp->drop_module_ref = true;
 
 	execute_in_process_context(scsi_device_dev_release_usercontext,
 				   &sdp->ew);
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 2493bd65351a..b03176b69056 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -214,6 +214,7 @@ struct scsi_device {
 					 * creation time */
 	unsigned ignore_media_change:1; /* Ignore MEDIA CHANGE on resume */
 	unsigned silence_suspend:1;	/* Do not print runtime PM related messages */
+	unsigned drop_module_ref:1;
 
 	unsigned int queue_stopped;	/* request queue is quiesced */
 	bool offline_already;		/* Device offline message logged */

  parent reply	other threads:[~2022-09-13 19:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-13 19:57 [PATCH v4 0/4] Prepare for constifying SCSI host templates Bart Van Assche
2022-09-13 19:57 ` [PATCH v4 1/4] scsi: esas2r: Initialize two host template members implicitly Bart Van Assche
2022-09-14  9:05   ` John Garry
2022-09-13 19:57 ` [PATCH v4 2/4] scsi: esas2r: Introduce scsi_template_proc_dir() Bart Van Assche
2022-09-14  9:06   ` John Garry
2022-09-14 16:43     ` Bart Van Assche
2022-09-14 16:53       ` John Garry
2022-09-13 19:57 ` [PATCH v4 3/4] scsi: core: Introduce a new list for SCSI proc directory entries Bart Van Assche
2022-09-14  9:43   ` John Garry
2022-09-14 16:52     ` Bart Van Assche
2022-09-13 19:57 ` Bart Van Assche [this message]
2022-09-14  9:52   ` [PATCH v4 4/4] scsi: core: Rework the code for dropping the LLD module reference John Garry
2022-09-14 17:54     ` Bart Van Assche
2022-09-14  9:21 ` [PATCH v4 0/4] Prepare for constifying SCSI host templates John Garry
2022-09-14 17:06   ` Bart Van Assche

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=20220913195716.3966875-5-bvanassche@acm.org \
    --to=bvanassche@acm.org \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=jejb@linux.ibm.com \
    --cc=john.garry@huawei.com \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=michael.christie@oracle.com \
    --cc=ming.lei@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.