diff options
| -rw-r--r-- | drivers/target/target_core_device.c | 12 | ||||
| -rw-r--r-- | drivers/target/target_core_sbc.c | 3 | ||||
| -rw-r--r-- | drivers/target/target_core_spc.c | 19 | ||||
| -rw-r--r-- | include/target/target_core_backend.h | 1 |
4 files changed, 17 insertions, 18 deletions
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 7fc5eae875de..79b4ec3ca2db 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c | |||
| @@ -650,6 +650,18 @@ static u32 se_dev_align_max_sectors(u32 max_sectors, u32 block_size) | |||
| 650 | return aligned_max_sectors; | 650 | return aligned_max_sectors; |
| 651 | } | 651 | } |
| 652 | 652 | ||
| 653 | bool se_dev_check_wce(struct se_device *dev) | ||
| 654 | { | ||
| 655 | bool wce = false; | ||
| 656 | |||
| 657 | if (dev->transport->get_write_cache) | ||
| 658 | wce = dev->transport->get_write_cache(dev); | ||
| 659 | else if (dev->dev_attrib.emulate_write_cache > 0) | ||
| 660 | wce = true; | ||
| 661 | |||
| 662 | return wce; | ||
| 663 | } | ||
| 664 | |||
| 653 | int se_dev_set_max_unmap_lba_count( | 665 | int se_dev_set_max_unmap_lba_count( |
| 654 | struct se_device *dev, | 666 | struct se_device *dev, |
| 655 | u32 max_unmap_lba_count) | 667 | u32 max_unmap_lba_count) |
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index 9a2f9d3a6e70..3e7297411110 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c | |||
| @@ -708,8 +708,7 @@ sbc_check_dpofua(struct se_device *dev, struct se_cmd *cmd, unsigned char *cdb) | |||
| 708 | } | 708 | } |
| 709 | } | 709 | } |
| 710 | if (cdb[1] & 0x8) { | 710 | if (cdb[1] & 0x8) { |
| 711 | if (!dev->dev_attrib.emulate_fua_write || | 711 | if (!dev->dev_attrib.emulate_fua_write || !se_dev_check_wce(dev)) { |
| 712 | !dev->dev_attrib.emulate_write_cache) { | ||
| 713 | pr_err("Got CDB: 0x%02x with FUA bit set, but device" | 712 | pr_err("Got CDB: 0x%02x with FUA bit set, but device" |
| 714 | " does not advertise support for FUA write\n", | 713 | " does not advertise support for FUA write\n", |
| 715 | cdb[0]); | 714 | cdb[0]); |
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c index 460e93109473..6c8bd6bc175c 100644 --- a/drivers/target/target_core_spc.c +++ b/drivers/target/target_core_spc.c | |||
| @@ -454,19 +454,6 @@ check_scsi_name: | |||
| 454 | } | 454 | } |
| 455 | EXPORT_SYMBOL(spc_emulate_evpd_83); | 455 | EXPORT_SYMBOL(spc_emulate_evpd_83); |
| 456 | 456 | ||
| 457 | static bool | ||
| 458 | spc_check_dev_wce(struct se_device *dev) | ||
| 459 | { | ||
| 460 | bool wce = false; | ||
| 461 | |||
| 462 | if (dev->transport->get_write_cache) | ||
| 463 | wce = dev->transport->get_write_cache(dev); | ||
| 464 | else if (dev->dev_attrib.emulate_write_cache > 0) | ||
| 465 | wce = true; | ||
| 466 | |||
| 467 | return wce; | ||
| 468 | } | ||
| 469 | |||
| 470 | /* Extended INQUIRY Data VPD Page */ | 457 | /* Extended INQUIRY Data VPD Page */ |
| 471 | static sense_reason_t | 458 | static sense_reason_t |
| 472 | spc_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf) | 459 | spc_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf) |
| @@ -490,7 +477,7 @@ spc_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf) | |||
| 490 | buf[5] = 0x07; | 477 | buf[5] = 0x07; |
| 491 | 478 | ||
| 492 | /* If WriteCache emulation is enabled, set V_SUP */ | 479 | /* If WriteCache emulation is enabled, set V_SUP */ |
| 493 | if (spc_check_dev_wce(dev)) | 480 | if (se_dev_check_wce(dev)) |
| 494 | buf[6] = 0x01; | 481 | buf[6] = 0x01; |
| 495 | /* If an LBA map is present set R_SUP */ | 482 | /* If an LBA map is present set R_SUP */ |
| 496 | spin_lock(&cmd->se_dev->t10_alua.lba_map_lock); | 483 | spin_lock(&cmd->se_dev->t10_alua.lba_map_lock); |
| @@ -897,7 +884,7 @@ static int spc_modesense_caching(struct se_cmd *cmd, u8 pc, u8 *p) | |||
| 897 | if (pc == 1) | 884 | if (pc == 1) |
| 898 | goto out; | 885 | goto out; |
| 899 | 886 | ||
| 900 | if (spc_check_dev_wce(dev)) | 887 | if (se_dev_check_wce(dev)) |
| 901 | p[2] = 0x04; /* Write Cache Enable */ | 888 | p[2] = 0x04; /* Write Cache Enable */ |
| 902 | p[12] = 0x20; /* Disabled Read Ahead */ | 889 | p[12] = 0x20; /* Disabled Read Ahead */ |
| 903 | 890 | ||
| @@ -1009,7 +996,7 @@ static sense_reason_t spc_emulate_modesense(struct se_cmd *cmd) | |||
| 1009 | (cmd->se_deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY))) | 996 | (cmd->se_deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY))) |
| 1010 | spc_modesense_write_protect(&buf[length], type); | 997 | spc_modesense_write_protect(&buf[length], type); |
| 1011 | 998 | ||
| 1012 | if ((spc_check_dev_wce(dev)) && | 999 | if ((se_dev_check_wce(dev)) && |
| 1013 | (dev->dev_attrib.emulate_fua_write > 0)) | 1000 | (dev->dev_attrib.emulate_fua_write > 0)) |
| 1014 | spc_modesense_dpofua(&buf[length], type); | 1001 | spc_modesense_dpofua(&buf[length], type); |
| 1015 | 1002 | ||
diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index db81c65b8f48..d61be7297b2c 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h | |||
| @@ -111,6 +111,7 @@ void array_free(void *array, int n); | |||
| 111 | void target_core_setup_sub_cits(struct se_subsystem_api *); | 111 | void target_core_setup_sub_cits(struct se_subsystem_api *); |
| 112 | 112 | ||
| 113 | /* attribute helpers from target_core_device.c for backend drivers */ | 113 | /* attribute helpers from target_core_device.c for backend drivers */ |
| 114 | bool se_dev_check_wce(struct se_device *); | ||
| 114 | int se_dev_set_max_unmap_lba_count(struct se_device *, u32); | 115 | int se_dev_set_max_unmap_lba_count(struct se_device *, u32); |
| 115 | int se_dev_set_max_unmap_block_desc_count(struct se_device *, u32); | 116 | int se_dev_set_max_unmap_block_desc_count(struct se_device *, u32); |
| 116 | int se_dev_set_unmap_granularity(struct se_device *, u32); | 117 | int se_dev_set_unmap_granularity(struct se_device *, u32); |
