diff options
author | Martin K. Petersen <martin.petersen@oracle.com> | 2012-08-28 14:29:34 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2012-09-24 12:10:59 +0400 |
commit | 8172499aae4d375334cfe6361900929c3b31a03f (patch) | |
tree | 0eea141d22039a743ab4306ff2ee6c18aea74251 /drivers/scsi/sd.c | |
parent | 8c579ab69d50a416887390ba4b89598a7b2fa0b6 (diff) |
[SCSI] sd: Allow protection_type to be overridden
We have encountered a few devices that misbehaved when operating in T10
PI mode. Allow T10 PI protection type to be overridden from userland.
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/sd.c')
-rw-r--r-- | drivers/scsi/sd.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 9f7fc39891b..e04c302fa4f 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -262,6 +262,28 @@ sd_show_protection_type(struct device *dev, struct device_attribute *attr, } static ssize_t +sd_store_protection_type(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct scsi_disk *sdkp = to_scsi_disk(dev); + unsigned int val; + int err; + + if (!capable(CAP_SYS_ADMIN)) + return -EACCES; + + err = kstrtouint(buf, 10, &val); + + if (err) + return err; + + if (val >= 0 && val <= SD_DIF_TYPE3_PROTECTION) + sdkp->protection_type = val; + + return count; +} + +static ssize_t sd_show_protection_mode(struct device *dev, struct device_attribute *attr, char *buf) { @@ -381,7 +403,8 @@ static struct device_attribute sd_disk_attrs[] = { sd_store_allow_restart), __ATTR(manage_start_stop, S_IRUGO|S_IWUSR, sd_show_manage_start_stop, sd_store_manage_start_stop), - __ATTR(protection_type, S_IRUGO, sd_show_protection_type, NULL), + __ATTR(protection_type, S_IRUGO|S_IWUSR, sd_show_protection_type, + sd_store_protection_type), __ATTR(protection_mode, S_IRUGO, sd_show_protection_mode, NULL), __ATTR(app_tag_own, S_IRUGO, sd_show_app_tag_own, NULL), __ATTR(thin_provisioning, S_IRUGO, sd_show_thin_provisioning, NULL), |