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 04: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 9f7fc39891b8..e04c302fa4f7 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, | |||
262 | } | 262 | } |
263 | 263 | ||
264 | static ssize_t | 264 | static ssize_t |
265 | sd_store_protection_type(struct device *dev, struct device_attribute *attr, | ||
266 | const char *buf, size_t count) | ||
267 | { | ||
268 | struct scsi_disk *sdkp = to_scsi_disk(dev); | ||
269 | unsigned int val; | ||
270 | int err; | ||
271 | |||
272 | if (!capable(CAP_SYS_ADMIN)) | ||
273 | return -EACCES; | ||
274 | |||
275 | err = kstrtouint(buf, 10, &val); | ||
276 | |||
277 | if (err) | ||
278 | return err; | ||
279 | |||
280 | if (val >= 0 && val <= SD_DIF_TYPE3_PROTECTION) | ||
281 | sdkp->protection_type = val; | ||
282 | |||
283 | return count; | ||
284 | } | ||
285 | |||
286 | static ssize_t | ||
265 | sd_show_protection_mode(struct device *dev, struct device_attribute *attr, | 287 | sd_show_protection_mode(struct device *dev, struct device_attribute *attr, |
266 | char *buf) | 288 | char *buf) |
267 | { | 289 | { |
@@ -381,7 +403,8 @@ static struct device_attribute sd_disk_attrs[] = { | |||
381 | sd_store_allow_restart), | 403 | sd_store_allow_restart), |
382 | __ATTR(manage_start_stop, S_IRUGO|S_IWUSR, sd_show_manage_start_stop, | 404 | __ATTR(manage_start_stop, S_IRUGO|S_IWUSR, sd_show_manage_start_stop, |
383 | sd_store_manage_start_stop), | 405 | sd_store_manage_start_stop), |
384 | __ATTR(protection_type, S_IRUGO, sd_show_protection_type, NULL), | 406 | __ATTR(protection_type, S_IRUGO|S_IWUSR, sd_show_protection_type, |
407 | sd_store_protection_type), | ||
385 | __ATTR(protection_mode, S_IRUGO, sd_show_protection_mode, NULL), | 408 | __ATTR(protection_mode, S_IRUGO, sd_show_protection_mode, NULL), |
386 | __ATTR(app_tag_own, S_IRUGO, sd_show_app_tag_own, NULL), | 409 | __ATTR(app_tag_own, S_IRUGO, sd_show_app_tag_own, NULL), |
387 | __ATTR(thin_provisioning, S_IRUGO, sd_show_thin_provisioning, NULL), | 410 | __ATTR(thin_provisioning, S_IRUGO, sd_show_thin_provisioning, NULL), |