aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2014-11-24 20:27:51 -0500
committerChristoph Hellwig <hch@lst.de>2014-11-25 09:42:56 -0500
commit0d01c5df5cd470515a88a454ba69126f4b7abdab (patch)
tree6a09abfc3527fee50ec14cfb28c5a3c9daf2ee2b
parent817fd66beb779dbbe44c46dd11e64d8275efb593 (diff)
scsi_debug: 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. Signed-off-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r--drivers/scsi/scsi_debug.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index d337eaa128d0..ee99aca92bca 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";
179#define SDEBUG_UA_POR 0 /* Power on, reset, or bus device reset */ 179#define SDEBUG_UA_POR 0 /* Power on, reset, or bus device reset */
180#define SDEBUG_UA_BUS_RESET 1 180#define SDEBUG_UA_BUS_RESET 1
181#define SDEBUG_UA_MODE_CHANGED 2 181#define SDEBUG_UA_MODE_CHANGED 2
182#define SDEBUG_NUM_UAS 3 182#define SDEBUG_UA_CAPACITY_CHANGED 3
183#define SDEBUG_NUM_UAS 4
183 184
184/* for check_readiness() */ 185/* for check_readiness() */
185#define UAS_ONLY 1 186#define UAS_ONLY 1
@@ -582,6 +583,11 @@ static int check_readiness(struct scsi_cmnd *SCpnt, int uas_only,
582 if (debug) 583 if (debug)
583 cp = "mode parameters changed"; 584 cp = "mode parameters changed";
584 break; 585 break;
586 case SDEBUG_UA_CAPACITY_CHANGED:
587 mk_sense_buffer(SCpnt, UNIT_ATTENTION,
588 UA_CHANGED_ASC, CAPACITY_CHANGED_ASCQ);
589 if (debug)
590 cp = "capacity data changed";
585 default: 591 default:
586 pr_warn("%s: unexpected unit attention code=%d\n", 592 pr_warn("%s: unexpected unit attention code=%d\n",
587 __func__, k); 593 __func__, k);
@@ -3638,16 +3644,30 @@ static ssize_t virtual_gb_show(struct device_driver *ddp, char *buf)
3638{ 3644{
3639 return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_virtual_gb); 3645 return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_virtual_gb);
3640} 3646}
3647
3641static ssize_t virtual_gb_store(struct device_driver *ddp, const char *buf, 3648static ssize_t virtual_gb_store(struct device_driver *ddp, const char *buf,
3642 size_t count) 3649 size_t count)
3643{ 3650{
3644 int n; 3651 int n;
3652 bool changed;
3645 3653
3646 if ((count > 0) && (1 == sscanf(buf, "%d", &n)) && (n >= 0)) { 3654 if ((count > 0) && (1 == sscanf(buf, "%d", &n)) && (n >= 0)) {
3655 changed = (scsi_debug_virtual_gb != n);
3647 scsi_debug_virtual_gb = n; 3656 scsi_debug_virtual_gb = n;
3648
3649 sdebug_capacity = get_sdebug_capacity(); 3657 sdebug_capacity = get_sdebug_capacity();
3650 3658 if (changed) {
3659 struct sdebug_host_info *sdhp;
3660 struct sdebug_dev_info *dp;
3661
3662 list_for_each_entry(sdhp, &sdebug_host_list,
3663 host_list) {
3664 list_for_each_entry(dp, &sdhp->dev_info_list,
3665 dev_list) {
3666 set_bit(SDEBUG_UA_CAPACITY_CHANGED,
3667 dp->uas_bm);
3668 }
3669 }
3670 }
3651 return count; 3671 return count;
3652 } 3672 }
3653 return -EINVAL; 3673 return -EINVAL;