linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Christie <michaelc@cs.wisc.edu>
To: Hannes Reinecke <hare@suse.de>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH 4/4] SCSI: send KOBJ_CHANGE when device is set to running v2
Date: Mon, 21 May 2012 10:46:49 -0500	[thread overview]
Message-ID: <4FBA6369.2030804@cs.wisc.edu> (raw)
In-Reply-To: <4FBA6009.8040407@cs.wisc.edu>

On 05/21/2012 10:32 AM, Mike Christie wrote:
> On 05/21/2012 06:45 AM, Hannes Reinecke wrote:
>> On 05/18/2012 06:56 AM, michaelc@cs.wisc.edu wrote:
>>> From: Mike Christie <michaelc@cs.wisc.edu>
>>>
>>> If a device goes offline while the device is opened then closed
>>> while it is still offline, udev will remove the /dev/disk/by-id
>>> link. If the device comes back and is set to running, userspace
>>> is not notified, and the by-id link will not get remade.
>>>
>>> This patch has scsi-ml send a KOBJ_CHANGE event so tools like udev
>>> will know that it can being to use the device again. With this patch
>>> udev see the KOBJ_CHANGE event and will reprobe the device and recreate
>>> a /dev/disk/by-id link.
>>>
>>> v2
>>> - Added SDEV_EVT_STATE_RUNNING evt type.
>>>
>>> Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
>>> ---
>>>  drivers/scsi/scsi_lib.c    |    9 +++++++++
>>>  include/scsi/scsi_device.h |    2 ++
>>>  2 files changed, 11 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
>>> index d15b243..b54030d 100644
>>> --- a/drivers/scsi/scsi_lib.c
>>> +++ b/drivers/scsi/scsi_lib.c
>>> @@ -2061,6 +2061,7 @@ int
>>>  scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state)
>>>  {
>>>  	enum scsi_device_state oldstate = sdev->sdev_state;
>>> +	int change_evt = 0;
>>>  
>>>  	if (state == oldstate)
>>>  		return 0;
>>> @@ -2079,6 +2080,11 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state)
>>>  		switch (oldstate) {
>>>  		case SDEV_OFFLINE:
>>>  		case SDEV_TRANSPORT_OFFLINE:
>>> +			/*
>>> +			 * Notify userspace we can accept IO by sending
>>> +			 * change event.
>>> +			 */
>>> +			change_evt = 1;
>>>  		case SDEV_QUIESCE:
>>>  		case SDEV_BLOCK:
>>>  		case SDEV_CREATED:
>>> @@ -2160,6 +2166,8 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state)
>>>  
>>>  	}
>>>  	sdev->sdev_state = state;
>>> +	if (change_evt)
>>> +		sdev_evt_send_simple(sdev, SDEV_EVT_STATE_RUNNING, GFP_ATOMIC);
>>>  	return 0;
>>>  
>>>   illegal:
>>> @@ -2283,6 +2291,7 @@ struct scsi_event *sdev_evt_alloc(enum scsi_device_event evt_type,
>>>  	/* evt_type-specific initialization, if any */
>>>  	switch (evt_type) {
>>>  	case SDEV_EVT_MEDIA_CHANGE:
>>> +	case SDEV_EVT_STATE_RUNNING:
>>>  	default:
>>>  		/* do nothing */
>>>  		break;
>> Hmm. So we're only getting notified if the device switched to OFFLINE?
> 
> No from one of the offlines to running.
> 

I think I know what happened. Maybe you did not reivew all the patches
at the same time. With all patches in the set applied we have this:


scsi_device_set_state()
......

        case SDEV_RUNNING:	<- so we are going into running
                switch (oldstate) {
                case SDEV_OFFLINE:    <- we were in one of the offlines
                case SDEV_TRANSPORT_OFFLINE:
                        /*
                         * Notify userspace we can accept IO by sending
                         * change event.
                         */
                        change_evt = 1;   <- so we send evt for *offline
to running transistions


  reply	other threads:[~2012-05-21 15:46 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-18  4:56 [PATCH 0/4] notify userspace of offline->running transitions (v2) michaelc
2012-05-18  4:56 ` [PATCH 1/4] SCSI: add new SDEV_TRANSPORT_OFFLINE state michaelc
2012-05-21 11:50   ` Hannes Reinecke
2012-05-18  4:56 ` [PATCH 2/4] SCSI, classes, mpt2sas: have scsi_internal_device_unblock take new state (v2) michaelc
2012-05-18  4:56 ` [PATCH 3/4] SCSI: remove old comment from block/unblock functions (v2) michaelc
2012-05-18  4:56 ` [PATCH 4/4] SCSI: send KOBJ_CHANGE when device is set to running v2 michaelc
2012-05-21 11:45   ` Hannes Reinecke
2012-05-21 15:32     ` Mike Christie
2012-05-21 15:46       ` Mike Christie [this message]
2012-05-21 11:50 ` [PATCH 0/4] notify userspace of offline->running transitions (v2) Hannes Reinecke
2012-05-21 15:35   ` Mike Christie
2012-05-21 16:49     ` Kay Sievers
2012-05-21 17:04       ` Mike Christie
2012-05-21 19:15         ` Kay Sievers
2012-05-22 13:33         ` Hannes Reinecke
2012-06-06 21:18 ` Mike Christie
2012-06-26 21:48   ` Mike Snitzer
  -- strict thread matches above, loose matches on Subject: below --
2012-05-04 10:23 [PATCH 0/4] notify userspace of offline->running transitions michaelc
2012-05-04 10:23 ` [PATCH 4/4] SCSI: send KOBJ_CHANGE when device is set to running v2 michaelc

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=4FBA6369.2030804@cs.wisc.edu \
    --to=michaelc@cs.wisc.edu \
    --cc=hare@suse.de \
    --cc=linux-scsi@vger.kernel.org \
    /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).