Hi Nicholas, I also patched rtslib (pull request on github) to work around not being able to resolve the /dev/* device to the HCL and back the other way. [root@tvtln01-eth SOURCES]# head /sys/kernel/config/target/core/pscsi_*/*/info ==> /sys/kernel/config/target/core/pscsi_0/changer1/info <== Status: ACTIVATED Max Queue Depth: 0 SectorSize: 0 HwMaxSectors: 0 SCSI Device Bus Location: Channel ID: 0 Target ID: 0 LUN: 0 Host ID: 10 Vendor: STK Model: L700 Rev: 0105 ==> /sys/kernel/config/target/core/pscsi_1/tape1/info <== Status: ACTIVATED Max Queue Depth: 0 SectorSize: 0 HwMaxSectors: 0 SCSI Device Bus Location: Channel ID: 0 Target ID: 1 LUN: 0 Host ID: 10 Vendor: IBM Model: ULT3580-TD5 Rev: 0105 ==> /sys/kernel/config/target/core/pscsi_0/changer1/attrib/block_size <== 0 ==> /sys/kernel/config/target/core/pscsi_0/changer1/attrib/emulate_dpo <== 0 ==> /sys/kernel/config/target/core/pscsi_0/changer1/attrib/emulate_fua_read <== 0 ==> /sys/kernel/config/target/core/pscsi_0/changer1/attrib/emulate_fua_write <== 1 ==> /sys/kernel/config/target/core/pscsi_0/changer1/attrib/emulate_model_alias <== 0 ==> /sys/kernel/config/target/core/pscsi_0/changer1/attrib/emulate_rest_reord <== 0 ==> /sys/kernel/config/target/core/pscsi_0/changer1/attrib/emulate_tas <== 1 ==> /sys/kernel/config/target/core/pscsi_0/changer1/attrib/emulate_tpu <== 0 ==> /sys/kernel/config/target/core/pscsi_0/changer1/attrib/emulate_tpws <== 0 ==> /sys/kernel/config/target/core/pscsi_0/changer1/attrib/emulate_ua_intlck_ctrl <== 0 ==> /sys/kernel/config/target/core/pscsi_0/changer1/attrib/emulate_write_cache <== 0 ==> /sys/kernel/config/target/core/pscsi_0/changer1/attrib/enforce_pr_isids <== 1 ==> /sys/kernel/config/target/core/pscsi_0/changer1/attrib/fabric_max_sectors <== 8192 ==> /sys/kernel/config/target/core/pscsi_0/changer1/attrib/hw_block_size <== 0 ==> /sys/kernel/config/target/core/pscsi_0/changer1/attrib/hw_max_sectors <== 0 ==> /sys/kernel/config/target/core/pscsi_0/changer1/attrib/hw_queue_depth <== 32 ==> /sys/kernel/config/target/core/pscsi_0/changer1/attrib/is_nonrot <== 0 ==> /sys/kernel/config/target/core/pscsi_0/changer1/attrib/max_unmap_block_desc_count <== 0 ==> /sys/kernel/config/target/core/pscsi_0/changer1/attrib/max_unmap_lba_count <== 0 ==> /sys/kernel/config/target/core/pscsi_0/changer1/attrib/max_write_same_len <== 0 ==> /sys/kernel/config/target/core/pscsi_0/changer1/attrib/optimal_sectors <== 8192 ==> /sys/kernel/config/target/core/pscsi_0/changer1/attrib/queue_depth <== 32 ==> /sys/kernel/config/target/core/pscsi_0/changer1/attrib/unmap_granularity <== 0 ==> /sys/kernel/config/target/core/pscsi_0/changer1/attrib/unmap_granularity_alignment <== 0 ==> /sys/kernel/config/target/core/pscsi_1/tape1/attrib/block_size <== 0 ==> /sys/kernel/config/target/core/pscsi_1/tape1/attrib/emulate_dpo <== 0 ==> /sys/kernel/config/target/core/pscsi_1/tape1/attrib/emulate_fua_read <== 0 ==> /sys/kernel/config/target/core/pscsi_1/tape1/attrib/emulate_fua_write <== 1 ==> /sys/kernel/config/target/core/pscsi_1/tape1/attrib/emulate_model_alias <== 0 ==> /sys/kernel/config/target/core/pscsi_1/tape1/attrib/emulate_rest_reord <== 0 ==> /sys/kernel/config/target/core/pscsi_1/tape1/attrib/emulate_tas <== 1 ==> /sys/kernel/config/target/core/pscsi_1/tape1/attrib/emulate_tpu <== 0 ==> /sys/kernel/config/target/core/pscsi_1/tape1/attrib/emulate_tpws <== 0 ==> /sys/kernel/config/target/core/pscsi_1/tape1/attrib/emulate_ua_intlck_ctrl <== 0 ==> /sys/kernel/config/target/core/pscsi_1/tape1/attrib/emulate_write_cache <== 0 ==> /sys/kernel/config/target/core/pscsi_1/tape1/attrib/enforce_pr_isids <== 1 ==> /sys/kernel/config/target/core/pscsi_1/tape1/attrib/fabric_max_sectors <== 8192 ==> /sys/kernel/config/target/core/pscsi_1/tape1/attrib/hw_block_size <== 0 ==> /sys/kernel/config/target/core/pscsi_1/tape1/attrib/hw_max_sectors <== 0 ==> /sys/kernel/config/target/core/pscsi_1/tape1/attrib/hw_queue_depth <== 32 ==> /sys/kernel/config/target/core/pscsi_1/tape1/attrib/is_nonrot <== 0 ==> /sys/kernel/config/target/core/pscsi_1/tape1/attrib/max_unmap_block_desc_count <== 0 ==> /sys/kernel/config/target/core/pscsi_1/tape1/attrib/max_unmap_lba_count <== 0 ==> /sys/kernel/config/target/core/pscsi_1/tape1/attrib/max_write_same_len <== 0 ==> /sys/kernel/config/target/core/pscsi_1/tape1/attrib/optimal_sectors <== 8192 ==> /sys/kernel/config/target/core/pscsi_1/tape1/attrib/queue_depth <== 32 ==> /sys/kernel/config/target/core/pscsi_1/tape1/attrib/unmap_granularity <== 0 ==> /sys/kernel/config/target/core/pscsi_1/tape1/attrib/unmap_granularity_alignment <== 0 Here is my patch below. I went with <1 because I was too lazy to check if the value was signed or not, so it can probably be changed to an = It's not a big patch at all but it works quite well! *** a/drivers/target/target_core_device.c 2015-01-29 18:15:53.000000000 -0500 --- b/drivers/target/target_core_device.c.mod 2016-10-30 03:21:41.955410797 -0400 *************** *** 639,644 **** --- 639,647 ---- * Limit max_sectors to a PAGE_SIZE aligned value for modern * transport_allocate_data_tasks() operation. */ + + if (block_size < 1) + return 0; alignment = max(1ul, PAGE_SIZE / block_size); aligned_max_sectors = rounddown(max_sectors, alignment); On Mon, Oct 31, 2016 at 5:00 PM, Nicholas A. Bellinger <nab@xxxxxxxxxxxxxxx> wrote: > Hi Malcolm, > > On Mon, 2016-10-31 at 12:16 +1100, Malcolm Haak wrote: >> Hi all, >> >> In my quest to get targetcli exporting mhvtl devices I ran into a dev0 >> in se_dev_align_max_sectors. >> > > Thanks for reporting this long standing PSCSI w/ TYPE_TAPE bug. > >> Now I am running kernel-3.10.0-229.el7 so it might be patched in newer >> kernels, but it seems that when using pscsi to export tape/changer >> scsi devices (being that they aren't block devices) it encounters a >> zero value for block_size. >> >> I've made my self a patch that sets a zero block size to PAGE_SIZE and >> it's working, but I'm not sure if this is the correct fix. (Patch is >> just a simple if block_size == 0 then block_size = PAGE_SIZE) >> > > Sure, let's have a look. Feel free to post your patch here. > > Btw, how do your PSCSI backend settings look..? > > head /sys/kernel/config/target/core/pscsi_*/*/info > head /sys/kernel/config/target/core/pscsi_*/*/attrib/* > >> So I guess I'm trying to a) find out if that is a valid fix and b) >> regardless if it is/isn't get a fix into mainline for other people to >> use. >> >> > > IIRC, there is an ancient hack in pscsi_transport_complete() to set the > correct sd->sector_size during MODE_SELECT from the underlying > scsi_device. Once upon a time ~10 years ago this was required to get > things working.. > > I'd be amazed if we still need that hack, but as you've noticed it's > been awhile since someone made PSCSI w/ TYPE_TAPE export work. > > Nice work btw. > -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html