Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: target: perform t10_wwn ID initialisation in target_alloc_device()

Initialise the t10_wwn vendor, model and revision defaults when a device is
allocated instead of when it's enabled. This ensures that custom vendor or
model strings set prior to enablement are not later overwritten with
default values.

The TRANSPORT_FLAG_PASSTHROUGH conditional can be dropped for the following
reasons:

- target_core_pscsi overwrites the defaults in the
pscsi_configure_device() callback.
+ the contents is then only used for ConfigFS via
$pscsi_dev/statistics/scsi_lu/vend, etc.

- target_core_user doesn't touch the defaults, nor are they used for
anything outside of ConfigFS.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

David Disseldorp and committed by
Martin K. Petersen
3beeabd5 2d882847

+7 -14
+7 -14
drivers/target/target_core_device.c
··· 810 810 mutex_init(&xcopy_lun->lun_tg_pt_md_mutex); 811 811 xcopy_lun->lun_tpg = &xcopy_pt_tpg; 812 812 813 + /* Preload the default INQUIRY const values */ 814 + strlcpy(dev->t10_wwn.vendor, "LIO-ORG", sizeof(dev->t10_wwn.vendor)); 815 + strlcpy(dev->t10_wwn.model, dev->transport->inquiry_prod, 816 + sizeof(dev->t10_wwn.model)); 817 + strlcpy(dev->t10_wwn.revision, dev->transport->inquiry_rev, 818 + sizeof(dev->t10_wwn.revision)); 819 + 813 820 return dev; 814 821 } 815 822 ··· 978 971 * Setup work_queue for QUEUE_FULL 979 972 */ 980 973 INIT_WORK(&dev->qf_work_queue, target_qf_do_work); 981 - 982 - /* 983 - * Preload the initial INQUIRY const values if we are doing 984 - * anything virtual (IBLOCK, FILEIO, RAMDISK), but not for TCM/pSCSI 985 - * passthrough because this is being provided by the backend LLD. 986 - */ 987 - if (!(dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH)) { 988 - strlcpy(dev->t10_wwn.vendor, "LIO-ORG", 989 - sizeof(dev->t10_wwn.vendor)); 990 - strlcpy(dev->t10_wwn.model, dev->transport->inquiry_prod, 991 - sizeof(dev->t10_wwn.model)); 992 - strlcpy(dev->t10_wwn.revision, dev->transport->inquiry_rev, 993 - sizeof(dev->t10_wwn.revision)); 994 - } 995 974 996 975 scsi_dump_inquiry(dev); 997 976