public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: James Bottomley <James.Bottomley@HansenPartnership.com>,
	Jens Axboe <axboe@kernel.dk>
Cc: Linux-Next Mailing List <linux-next@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Ming Lei <ming.lei@redhat.com>,
	Bart Van Assche <Bart.VanAssche@sandisk.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Subject: linux-next: manual merge of the scsi tree with the block tree
Date: Mon, 19 Jun 2017 15:35:48 +1000	[thread overview]
Message-ID: <20170619153548.5a676fde@canb.auug.org.au> (raw)

Hi all,

Today's linux-next merge of the scsi tree got a conflict in:

  drivers/scsi/scsi_lib.c

between commit:

  f660174e8bcd ("blk-mq: use the introduced blk_mq_unquiesce_queue()")

from the block tree and commits:

  551eb598e5ea ("scsi: Split scsi_internal_device_block()")
  66483a4a9f34 ("scsi: Introduce scsi_start_queue()")

from the scsi tree.

I fixed it up (I think - see below) and can carry the fix as
necessary. This is now fixed as far as linux-next is concerned, but any
non trivial conflicts should be mentioned to your upstream maintainer
when your tree is submitted for merging.  You may also want to consider
cooperating with the maintainer of the conflicting tree to minimise any
particularly complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/scsi/scsi_lib.c
index fb18ed284e55,41c19c75dab4..000000000000
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@@ -2959,10 -2989,7 +2974,7 @@@ int scsi_internal_device_block_nowait(s
  	 * request queue. 
  	 */
  	if (q->mq_ops) {
- 		if (wait)
- 			blk_mq_quiesce_queue(q);
- 		else
- 			blk_mq_quiesce_queue_nowait(q);
 -		blk_mq_stop_hw_queues(q);
++		blk_mq_quiesce_queue_nowait(q);
  	} else {
  		spin_lock_irqsave(q->queue_lock, flags);
  		blk_stop_queue(q);
@@@ -2973,31 -2998,77 +2983,77 @@@
  
  	return 0;
  }
- EXPORT_SYMBOL_GPL(scsi_internal_device_block);
-  
+ EXPORT_SYMBOL_GPL(scsi_internal_device_block_nowait);
+ 
  /**
-  * scsi_internal_device_unblock - resume a device after a block request
-  * @sdev:	device to resume
-  * @new_state:	state to set devices to after unblocking
+  * scsi_internal_device_block - try to transition to the SDEV_BLOCK state
+  * @sdev: device to block
+  *
+  * Pause SCSI command processing on the specified device and wait until all
+  * ongoing scsi_request_fn() / scsi_queue_rq() calls have finished. May sleep.
   *
-  * Called by scsi lld's or the midlayer to restart the device queue
-  * for the previously suspended scsi device.  Called from interrupt or
-  * normal process context.
+  * Returns zero if successful or a negative error code upon failure.
   *
-  * Returns zero if successful or error if not.
+  * Note:
+  * This routine transitions the device to the SDEV_BLOCK state (which must be
+  * a legal transition). When the device is in this state, command processing
+  * is paused until the device leaves the SDEV_BLOCK state. See also
+  * scsi_internal_device_unblock().
   *
-  * Notes:       
-  *	This routine transitions the device to the SDEV_RUNNING state
-  *	or to one of the offline states (which must be a legal transition)
-  *	allowing the midlayer to goose the queue for this device.
+  * To do: avoid that scsi_send_eh_cmnd() calls queuecommand() after
+  * scsi_internal_device_block() has blocked a SCSI device and also
+  * remove the rport mutex lock and unlock calls from srp_queuecommand().
   */
- int
- scsi_internal_device_unblock(struct scsi_device *sdev,
- 			     enum scsi_device_state new_state)
+ static int scsi_internal_device_block(struct scsi_device *sdev)
  {
- 	struct request_queue *q = sdev->request_queue; 
+ 	struct request_queue *q = sdev->request_queue;
+ 	int err;
+ 
+ 	mutex_lock(&sdev->state_mutex);
+ 	err = scsi_internal_device_block_nowait(sdev);
+ 	if (err == 0) {
+ 		if (q->mq_ops)
+ 			blk_mq_quiesce_queue(q);
+ 		else
+ 			scsi_wait_for_queuecommand(sdev);
+ 	}
+ 	mutex_unlock(&sdev->state_mutex);
+ 
+ 	return err;
+ }
+  
+ void scsi_start_queue(struct scsi_device *sdev)
+ {
+ 	struct request_queue *q = sdev->request_queue;
  	unsigned long flags;
  
+ 	if (q->mq_ops) {
 -		blk_mq_start_stopped_hw_queues(q, false);
++		blk_mq_unquiesce_queue(q);
+ 	} else {
+ 		spin_lock_irqsave(q->queue_lock, flags);
+ 		blk_start_queue(q);
+ 		spin_unlock_irqrestore(q->queue_lock, flags);
+ 	}
+ }
+ 
+ /**
+  * scsi_internal_device_unblock_nowait - resume a device after a block request
+  * @sdev:	device to resume
+  * @new_state:	state to set the device to after unblocking
+  *
+  * Restart the device queue for a previously suspended SCSI device. Does not
+  * sleep.
+  *
+  * Returns zero if successful or a negative error code upon failure.
+  *
+  * Notes:
+  * This routine transitions the device to the SDEV_RUNNING state or to one of
+  * the offline states (which must be a legal transition) allowing the midlayer
+  * to goose the queue for this device.
+  */
+ int scsi_internal_device_unblock_nowait(struct scsi_device *sdev,
+ 					enum scsi_device_state new_state)
+ {
  	/*
  	 * Try to transition the scsi device to SDEV_RUNNING or one of the
  	 * offlined states and goose the device queue if successful.

             reply	other threads:[~2017-06-19  5:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-19  5:35 Stephen Rothwell [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-01-07  4:09 linux-next: manual merge of the scsi tree with the block tree Stephen Rothwell
2025-01-07  6:03 ` Christoph Hellwig
2023-06-19  3:14 Stephen Rothwell
2022-03-07  4:18 Stephen Rothwell
2022-03-07  4:14 Stephen Rothwell
2021-11-01  5:08 Stephen Rothwell
2021-08-24  6:32 Stephen Rothwell
2021-08-24  6:39 ` Christoph Hellwig
2020-03-25  5:04 Stephen Rothwell
2019-04-15  5:59 Stephen Rothwell
2019-04-15 13:48 ` Bart Van Assche
2019-04-17 19:11   ` Martin Wilck
2019-02-18  5:10 Stephen Rothwell
2017-06-21  5:55 Stephen Rothwell
2016-11-08  5:48 Stephen Rothwell
2016-11-08 16:17 ` James Bottomley

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=20170619153548.5a676fde@canb.auug.org.au \
    --to=sfr@canb.auug.org.au \
    --cc=Bart.VanAssche@sandisk.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=martin.petersen@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox