All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 3/5] scsi_debug: add Capacity Changed Unit Attention
@ 2014-11-25  4:05 Douglas Gilbert
  2014-11-25  6:59 ` Hannes Reinecke
  2014-12-04 16:45 ` Ewan Milne
  0 siblings, 2 replies; 3+ messages in thread
From: Douglas Gilbert @ 2014-11-25  4:05 UTC (permalink / raw)
  To: SCSI development list, Hannes Reinecke, Christoph Hellwig
  Cc: Martin K. Petersen

[-- Attachment #1: Type: text/plain, Size: 484 bytes --]

From: Douglas Gilbert <dgilbert@interlog.com>
Date: Mon, 24 Nov 2014 20:27:51 -0500
Subject: [PATCH 3/5] add Capacity Changed Unit Attention

Via sysfs the virtual_gb scsi_debug parameter can be changed while
LUs are in use. If that changes, the 'Capacity data has changed'
Unit Attention is queued on all LUs.
---
  drivers/scsi/scsi_debug.c | 28 ++++++++++++++++++++++++----
  1 file changed, 24 insertions(+), 4 deletions(-)

Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>

[-- Attachment #2: 0003-add-Capacity-Changed-Unit-Attention.patch --]
[-- Type: text/x-patch, Size: 2289 bytes --]

>From 54eeff05237c4872fb1f5dcf1edddaace467d5b0 Mon Sep 17 00:00:00 2001
From: Douglas Gilbert <dgilbert@interlog.com>
Date: Mon, 24 Nov 2014 20:27:51 -0500
Subject: [PATCH 3/5] add Capacity Changed Unit Attention

Via sysfs the virtual_gb scsi_debug parameter can be changed while
LUs are in use. If that changes, the 'Capacity data has changed'
Unit Attention is queued on all LUs.
---
 drivers/scsi/scsi_debug.c | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index d337eaa..ee99aca 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -179,7 +179,8 @@ static const char *scsi_debug_version_date = "20141022";
 #define SDEBUG_UA_POR 0		/* Power on, reset, or bus device reset */
 #define SDEBUG_UA_BUS_RESET 1
 #define SDEBUG_UA_MODE_CHANGED 2
-#define SDEBUG_NUM_UAS 3
+#define SDEBUG_UA_CAPACITY_CHANGED 3
+#define SDEBUG_NUM_UAS 4
 
 /* for check_readiness() */
 #define UAS_ONLY 1
@@ -582,6 +583,11 @@ static int check_readiness(struct scsi_cmnd *SCpnt, int uas_only,
 			if (debug)
 				cp = "mode parameters changed";
 			break;
+		case SDEBUG_UA_CAPACITY_CHANGED:
+			mk_sense_buffer(SCpnt, UNIT_ATTENTION,
+					UA_CHANGED_ASC, CAPACITY_CHANGED_ASCQ);
+			if (debug)
+				cp = "capacity data changed";
 		default:
 			pr_warn("%s: unexpected unit attention code=%d\n",
 				__func__, k);
@@ -3638,16 +3644,30 @@ static ssize_t virtual_gb_show(struct device_driver *ddp, char *buf)
 {
         return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_virtual_gb);
 }
+
 static ssize_t virtual_gb_store(struct device_driver *ddp, const char *buf,
 				size_t count)
 {
-        int n;
+	int n;
+	bool changed;
 
 	if ((count > 0) && (1 == sscanf(buf, "%d", &n)) && (n >= 0)) {
+		changed = (scsi_debug_virtual_gb != n);
 		scsi_debug_virtual_gb = n;
-
 		sdebug_capacity = get_sdebug_capacity();
-
+		if (changed) {
+			struct sdebug_host_info *sdhp;
+			struct sdebug_dev_info *dp;
+
+			list_for_each_entry(sdhp, &sdebug_host_list,
+					    host_list) {
+				list_for_each_entry(dp, &sdhp->dev_info_list,
+						    dev_list) {
+					set_bit(SDEBUG_UA_CAPACITY_CHANGED,
+						dp->uas_bm);
+				}
+			}
+		}
 		return count;
 	}
 	return -EINVAL;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 3/5] scsi_debug: add Capacity Changed Unit Attention
  2014-11-25  4:05 [PATCH v2 3/5] scsi_debug: add Capacity Changed Unit Attention Douglas Gilbert
@ 2014-11-25  6:59 ` Hannes Reinecke
  2014-12-04 16:45 ` Ewan Milne
  1 sibling, 0 replies; 3+ messages in thread
From: Hannes Reinecke @ 2014-11-25  6:59 UTC (permalink / raw)
  To: dgilbert, SCSI development list, Christoph Hellwig; +Cc: Martin K. Petersen

On 11/25/2014 05:05 AM, Douglas Gilbert wrote:
> From: Douglas Gilbert <dgilbert@interlog.com>
> Date: Mon, 24 Nov 2014 20:27:51 -0500
> Subject: [PATCH 3/5] add Capacity Changed Unit Attention
> 
> Via sysfs the virtual_gb scsi_debug parameter can be changed while
> LUs are in use. If that changes, the 'Capacity data has changed'
> Unit Attention is queued on all LUs.
> ---
>  drivers/scsi/scsi_debug.c | 28 ++++++++++++++++++++++++----
>  1 file changed, 24 insertions(+), 4 deletions(-)
> 
> Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>

Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 3/5] scsi_debug: add Capacity Changed Unit Attention
  2014-11-25  4:05 [PATCH v2 3/5] scsi_debug: add Capacity Changed Unit Attention Douglas Gilbert
  2014-11-25  6:59 ` Hannes Reinecke
@ 2014-12-04 16:45 ` Ewan Milne
  1 sibling, 0 replies; 3+ messages in thread
From: Ewan Milne @ 2014-12-04 16:45 UTC (permalink / raw)
  To: dgilbert
  Cc: SCSI development list, Hannes Reinecke, Christoph Hellwig,
	Martin K. Petersen

On Mon, 2014-11-24 at 23:05 -0500, Douglas Gilbert wrote:
> From: Douglas Gilbert <dgilbert@interlog.com>
> Date: Mon, 24 Nov 2014 20:27:51 -0500
> Subject: [PATCH 3/5] add Capacity Changed Unit Attention
> 
> Via sysfs the virtual_gb scsi_debug parameter can be changed while
> LUs are in use. If that changes, the 'Capacity data has changed'
> Unit Attention is queued on all LUs.
> ---
>   drivers/scsi/scsi_debug.c | 28 ++++++++++++++++++++++++----
>   1 file changed, 24 insertions(+), 4 deletions(-)
> 
> Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>

I found a couple of things with this patch that should be
fixed, I'll send patches to correct them, plus a couple of
other changes while I'm at it.

-Ewan


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-12-04 16:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-25  4:05 [PATCH v2 3/5] scsi_debug: add Capacity Changed Unit Attention Douglas Gilbert
2014-11-25  6:59 ` Hannes Reinecke
2014-12-04 16:45 ` Ewan Milne

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.