Re: [PATCH] virtio_scsi: always read VPD pages for multiqueue too

2017-07-05 Thread Fam Zheng
= virtscsi_device_reset, > + .slave_alloc = virtscsi_device_alloc, > > .can_queue = 1024, > .dma_boundary = UINT_MAX, > -- > 1.8.3.1 > Reviewed-by: Fam Zheng <f...@redhat.com>

[PATCH] sd: Explicit type cast to fix calculating rw_max

2017-04-06 Thread Fam Zheng
Some compilers don't like BLK_DEF_MAX_SECTORS being an enum (int) when expanding min_not_zero. Cast it to sector_t so it matches the type of the other operand, logical_to_sectors(). Signed-off-by: Fam Zheng <f...@redhat.com> --- drivers/scsi/sd.c | 2 +- 1 file changed, 1 insertion

Re: [PATCH v2] sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable

2017-03-30 Thread Fam Zheng
On Thu, 03/30 11:30, Martin K. Petersen wrote: > Fam Zheng <f...@redhat.com> writes: > > >>rw_max = min_not_zero(logical_to_sectors(sdp, dev_max), > >> BLK_DEF_MAX_SECTORS); > > > > Yes, it is better. Is it okay to

Re: [PATCH v2] sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable

2017-03-29 Thread Fam Zheng
On Wed, 03/29 22:37, Martin K. Petersen wrote: > Fam Zheng <f...@redhat.com> writes: > > Fam, > > > diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c > > index fcfeddc..a5c7e67 100644 > > --- a/drivers/scsi/sd.c > > +++ b/drivers/scsi/sd.c > > @@

[PATCH v2] sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable

2017-03-27 Thread Fam Zheng
If device reports a small max_xfer_blocks and a zero opt_xfer_blocks, we end up using BLK_DEF_MAX_SECTORS, which is wrong and r/w of that size may get error. Fixes: ca369d51b3e ("block/sd: Fix device-imposed transfer length limits") Signed-off-by: Fam Zheng <f...@redhat.com&g

[PATCH] sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable

2017-03-27 Thread Fam Zheng
If device reports a small max_xfer_blocks and a zero opt_xfer_blocks, we end up using BLK_DEF_MAX_SECTORS, which is wrong and r/w of that size may get error. Fixes: ca369d51b3e ("block/sd: Fix device-imposed transfer length limits") Signed-off-by: Fam Zheng <f...@redhat.com> -

Re: sg driver, sg_io and sg tablesize

2017-03-02 Thread Fam Zheng
On Wed, 03/01 17:11, Laurence Oberman wrote: > This was suggested by Ewan and is the best way to know what the actual max I/O > size for sg_io would be for the LPFC driver. This sounds silly, why is there a "lame" max I/O size as in max_sectors_kb, that is unusable because of a more limiting

[PATCH v2 1/2] virtio_scsi: Add fc_host definitions

2017-01-25 Thread Fam Zheng
Signed-off-by: Fam Zheng <f...@redhat.com> --- include/uapi/linux/virtio_scsi.h | 6 ++ 1 file changed, 6 insertions(+) diff --git a/include/uapi/linux/virtio_scsi.h b/include/uapi/linux/virtio_scsi.h index cc18ef8..a26fb31 100644 --- a/include/uapi/linux/virtio_scsi.h +++ b/includ

[PATCH v2 2/2] virtio_scsi: Implement fc_host

2017-01-25 Thread Fam Zheng
This implements the VIRTIO_SCSI_F_FC_HOST feature by reading the config fields and presenting them as sysfs fc_host attributes. The config change handler is added here because primary_active will toggle during migration. Signed-off-by: Fam Zheng <f...@redhat.com> --- drivers/scsi/virtio_

[PATCH v2 0/2] virtio-scsi: Implement FC_HOST feature

2017-01-25 Thread Fam Zheng
v2: Fix endianness of WWNN/WWPN. [Paolo] This series implements the proposed fc_host feature of virtio-scsi. The first patch updates the data structure changes according to the spec proposal; the second patch actually implements the operations. Fam Zheng (2): virtio_scsi: Add fc_host

Re: [PATCH 2/2] scsi: storvsc: Add support for FC lightweight host.

2017-01-22 Thread Fam Zheng
On Wed, 01/18 15:28, Cathy Avery wrote: > Enable FC lightweight host option so that the luns exposed by > the driver may be manually scanned. Hi Cathy, out of curiosity: how does this relate to issue_lip operation? And how to trigger manual scan with this patch? Fam -- To unsubscribe from this

Re: [PATCH 2/2] virtio_scsi: Implement fc_host

2017-01-17 Thread Fam Zheng
On Tue, 01/17 14:17, Paolo Bonzini wrote: > > > On 16/01/2017 18:26, Fam Zheng wrote: > >> Is the endianness correct for big-endian host here? > > > > I think so. The fc_host sysfs uses u64 to represent port_name and node_name, > > this patch does

Re: [Qemu-devel] [RFC PATCH 0/3] scsi-generic and BLKSECTGET

2017-01-16 Thread Fam Zheng
On Mon, 01/16 22:11, Eric Farman wrote: > (cc'ing linux-scsi for the cover-letter; patches only to QEMU lists.) > > In the Linux kernel, I see two (three) places where the BLKSECTGET ioctl is > handled: > > (1) block/(compat_)ioctl.c -- (compat_)blkdev_ioctl > (2) drivers/scsi/sg.c -- sg_ioctl >

Re: [PATCH 2/2] virtio_scsi: Implement fc_host

2017-01-16 Thread Fam Zheng
gt; https://github.com/0day-ci/linux/commits/Fam-Zheng/virtio-scsi-Implement-FC_HOST-feature/20170117-011950 > config: i386-randconfig-r0-201703 (attached as .config) > compiler: gcc-5 (Debian 5.4.1-2) 5.4.1 20160904 > reproduce: > # save the attached .config to linux build

Re: [PATCH 0/2] virtio-scsi: Implement FC_HOST feature

2017-01-16 Thread Fam Zheng
On Mon, 01/16 09:34, Christoph Hellwig wrote: > On Tue, Jan 17, 2017 at 12:04:28AM +0800, Fam Zheng wrote: > > This series implements the proposed fc_host feature of virtio-scsi. > > Yikes. Why? Hi Christoph, this is mostly to "passthrough" a host NPIV vport (leavin

Re: [PATCH 2/2] virtio_scsi: Implement fc_host

2017-01-16 Thread Fam Zheng
On Mon, 01/16 17:45, Paolo Bonzini wrote: > > > On 16/01/2017 17:04, Fam Zheng wrote: > > + node_name = virtio_cread64(vdev, > > + offsetof(struct virtio_scsi_config, primary_wwnn)); > > + port_name = virtio_cread64(vdev, >

[PATCH 1/2] virtio_scsi: Add fc_host definitions

2017-01-16 Thread Fam Zheng
Signed-off-by: Fam Zheng <f...@redhat.com> --- include/uapi/linux/virtio_scsi.h | 6 ++ 1 file changed, 6 insertions(+) diff --git a/include/uapi/linux/virtio_scsi.h b/include/uapi/linux/virtio_scsi.h index cc18ef8..a26fb31 100644 --- a/include/uapi/linux/virtio_scsi.h +++ b/includ

[PATCH 2/2] virtio_scsi: Implement fc_host

2017-01-16 Thread Fam Zheng
This implements the VIRTIO_SCSI_F_FC_HOST feature by reading the config fields and presenting them as sysfs fc_host attributes. The config change handler is added here because primary_active will toggle during migration. Signed-off-by: Fam Zheng <f...@redhat.com> --- drivers/scsi/virtio_

[PATCH 0/2] virtio-scsi: Implement FC_HOST feature

2017-01-16 Thread Fam Zheng
This series implements the proposed fc_host feature of virtio-scsi. The first patch updates the data structure changes according to the spec proposal; the second patch actually implements the operations. Fam Zheng (2): virtio_scsi: Add fc_host definitions virtio_scsi: Implement fc_host

Re: [PATCH v2] virtio_scsi: Reject commands when virtqueue is broken

2017-01-15 Thread Fam Zheng
gt; > - if (virtscsi_kick_cmd(req_vq, cmd, req_size, sizeof(cmd->resp.cmd)) != > 0) > + ret = virtscsi_kick_cmd(req_vq, cmd, req_size, sizeof(cmd->resp.cmd)); > + if (ret == -EIO) { > + cmd->resp.cmd.response = VIRTIO_SCSI_S_BAD_TARGET; > + spin_lock_irqsave(_vq->vq_

[PATCH] libfc: Fix variable name in fc_set_wwpn

2017-01-12 Thread Fam Zheng
The parameter name should be wwpn instead of wwnn. Signed-off-by: Fam Zheng <f...@redhat.com> --- include/scsi/libfc.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index 96dd0b3..da5033d 100644 --- a/include/scsi/l

Re: [PATCH] virtio_scsi: Reject commands when virtqueue is broken

2017-01-12 Thread Fam Zheng
On Thu, 01/12 08:28, Eric Farman wrote: > > > - if (virtscsi_kick_cmd(req_vq, cmd, req_size, sizeof(cmd->resp.cmd)) != > > > 0) > > > + ret = virtscsi_kick_cmd(req_vq, cmd, req_size, sizeof(cmd->resp.cmd)); > > > + if (ret == -EIO) { > > > + cmd->resp.cmd.response =

Re: [PATCH] virtio_scsi: Reject commands when virtqueue is broken

2017-01-11 Thread Fam Zheng
On Wed, 01/11 17:02, Eric Farman wrote: > In the case of a graceful set of detaches, where the virtio-scsi-ccw > disk is removed from the guest prior to the controller, the guest > behaves quite normally. Specifically, the detach gets us into > sd_sync_cache to issue a Synchronize Cache(10)

Re: [PATCH] Use the correct size to set block max sectors

2016-05-26 Thread Fam Zheng
On Thu, 05/26 17:08, Long Li wrote: > The block sector size should be in unit of 512 bytes, not in bytes. > > Signed-off-by: Long Li > > --- > drivers/scsi/sd.c | 6 -- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/scsi/sd.c

Re: [PATCH] sd: Optimal I/O size is in bytes, not sectors

2016-05-11 Thread Fam Zheng
On Wed, 01/20 11:01, Martin K. Petersen wrote: > Commit ca369d51b3e1 ("block/sd: Fix device-imposed transfer length > limits") accidentally switched optimal I/O size reporting from bytes to > block layer sectors. > > Signed-off-by: Martin K. Petersen > Reported-by:

Re: [PATCH 1/3] block: Return error in rescan_partitions if revalidating disk failed

2015-04-21 Thread Fam Zheng
On Tue, 04/21 19:58, James Bottomley wrote: On Tue, 2015-03-24 at 18:16 +0800, Fam Zheng wrote: If the disk can't read capacity, we should return an error. I'm not sure I buy this: you need to justify why. For instance removable media return an error in revalidate that causes the medium

Re: [PATCH 0/3] Fix return code for ioctl( BLKRRPART ) if device is down

2015-04-15 Thread Fam Zheng
On Tue, 03/24 11:34, Paolo Bonzini wrote: On 24/03/2015 11:16, Fam Zheng wrote: If issued right after link down, blockdev --rereadpt will be stuck for a while and then return normally. Although the underlying capacity and partition table are not correctly updated. And it means

Re: [PATCH 0/3] Fix return code for ioctl( BLKRRPART ) if device is down

2015-03-24 Thread Fam Zheng
On Tue, 03/24 11:34, Paolo Bonzini wrote: On 24/03/2015 11:16, Fam Zheng wrote: If issued right after link down, blockdev --rereadpt will be stuck for a while and then return normally. Although the underlying capacity and partition table are not correctly updated. And it means

[PATCH 3/3] sd: Return -EIO if read capacity failed

2015-03-24 Thread Fam Zheng
This improves the error code if BLKRRPART ioctl failed due to connection issue. Before: $ blockdev --rereadpt /dev/sda BLKRRPART: Invalid argument After: $ blockdev --rereadpt /dev/sda BLKRRPART: Input/output error Signed-off-by: Fam Zheng f...@redhat.com

[PATCH 1/3] block: Return error in rescan_partitions if revalidating disk failed

2015-03-24 Thread Fam Zheng
If the disk can't read capacity, we should return an error. Signed-off-by: Fam Zheng f...@redhat.com --- block/partition-generic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/partition-generic.c b/block/partition-generic.c index 0d9e5f9..1e60d7d 100644

[PATCH 0/3] Fix return code for ioctl( BLKRRPART ) if device is down

2015-03-24 Thread Fam Zheng
command through the stack, so that the ioctl could fail with -EIO. Fam Zheng (3): block: Return error in rescan_partitions if revalidating disk failed sd: Return error in sd_revalidate_disk if read capacity failed sd: Return -EIO if read capacity failed block/partition-generic.c | 6

[PATCH 2/3] sd: Return error in sd_revalidate_disk if read capacity failed

2015-03-24 Thread Fam Zheng
necessary. Signed-off-by: Fam Zheng f...@redhat.com --- drivers/scsi/sd.c | 18 +++--- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 6b78476..7e5ca3b 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -113,7 +113,7

Re: [PATCH 1/3] scsi: serialize -rescan against -remove

2015-01-29 Thread Fam Zheng
On Fri, 01/30 00:11, Paolo Bonzini wrote: On 29/01/2015 00:00, Christoph Hellwig wrote: Lock the device embedded in the scsi_device to protect against concurrent calls to -remove. Signed-off-by: Christoph Hellwig h...@lst.de I wonder if this makes this problem:

[PATCH v4] virtio-scsi: Fix the race condition in virtscsi_handle_event

2015-01-07 Thread Fam Zheng
. I'm able to reproduce it by repeatedly plugging and unplugging a scsi disk with the same lun number. To fix this, a single thread workqueue (local to the module) is added, which makes the scan work serialized. With this change, the panic goes away. Signed-off-by: Fam Zheng f...@redhat.com --- v4

Re: [PATCH v2] virtio-scsi: Fix the race condition in virtscsi_handle_event

2015-01-06 Thread Fam Zheng
On Tue, 01/06 11:35, Michael S. Tsirkin wrote: On Tue, Jan 06, 2015 at 03:33:36PM +0800, Fam Zheng wrote: There is a race condition in virtscsi_handle_event, when many device hotplug/unplug events flush in quickly. The scsi_remove_device in virtscsi_handle_transport_reset may trigger

[PATCH v3] virtio-scsi: Fix the race condition in virtscsi_handle_event

2015-01-06 Thread Fam Zheng
. I'm able to reproduce it by repeatedly plugging and unplugging a scsi disk with the same lun number. To fix this, a single thread workqueue (local to the module) is added, which makes the scan work serialized. With this change, the panic goes away. Signed-off-by: Fam Zheng f...@redhat.com --- v3

Re: [PATCH v3] virtio-scsi: Fix the race condition in virtscsi_handle_event

2015-01-06 Thread Fam Zheng
On Tue, 01/06 16:54, Michael S. Tsirkin wrote: On Tue, Jan 06, 2015 at 09:25:05PM +0800, Fam Zheng wrote: There is a race condition in virtscsi_handle_event, when many device hotplug/unplug events flush in quickly. The scsi_remove_device in virtscsi_handle_transport_reset may trigger

[PATCH v2] virtio-scsi: Fix the race condition in virtscsi_handle_event

2015-01-05 Thread Fam Zheng
. I'm able to reproduce it by repeatedly plugging and unplugging a scsi disk with the same lun number. To make is safe, a single thread workqueue local to the module is added which runs the scan work. With this change, the panic goes away. Signed-off-by: Fam Zheng f...@redhat.com --- v2: Use

Re: [PATCH] virtio-scsi: Fix the race condition in virtscsi_handle_event

2015-01-05 Thread Fam Zheng
On Tue, 01/06 00:10, Michael S. Tsirkin wrote: On Mon, Jan 05, 2015 at 11:48:47AM -0800, Venkatesh Srinivas wrote: On Sun, Jan 4, 2015 at 10:04 PM, Fam Zheng f...@redhat.com wrote: There is a race condition in virtscsi_handle_event, when many device hotplug/unplug events flush

[PATCH] virtio-scsi: Fix the race condition in virtscsi_handle_event

2015-01-04 Thread Fam Zheng
-by: Fam Zheng f...@redhat.com --- drivers/scsi/virtio_scsi.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index c52bb5d..7f194d4 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -110,6 +110,9 @@ struct

[PATCH v2] virtio-scsi: Skip setting affinity on uninitialized vq

2014-04-13 Thread Fam Zheng
] Kernel Offset: 0x0 from 0x8100 (relocation range: 0x8000-0x9fff) [0.475068] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0009 Signed-off-by: Fam Zheng f...@redhat.com Acked-by: Paolo Bonzini pbonz...@redhat.com Cc: sta

[PATCH] virtio-scsi: Skip setting affinity on uninitialized vq

2014-04-11 Thread Fam Zheng
] Kernel Offset: 0x0 from 0x8100 (relocation range: 0x8000-0x9fff) [0.475068] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0009 Signed-off-by: Fam Zheng f...@redhat.com --- drivers/scsi/virtio_scsi.c | 6 +- 1 file

[PATCH v2] scsi: Change sense buffer size to 252

2014-03-14 Thread Fam Zheng
According to SPC-4, section 4.5.2.1, 252 is the limit of sense data. So increase the values. Tested by hacking QEMU to fake virtio-scsi request sense len to 252. Without this patch the driver stops working immediately when it gets the request. Signed-off-by: Fam Zheng f...@redhat.com

[PATCH] virtio-scsi: Change sense buffer size to 252

2014-03-06 Thread Fam Zheng
According to SPC-4, section 4.5.2.1, 252 is the limit of sense data. So increase the value. Signed-off-by: Fam Zheng f...@redhat.com --- include/linux/virtio_scsi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/virtio_scsi.h b/include/linux/virtio_scsi.h index

Re: [PATCH] virtio-scsi: Change sense buffer size to 252

2014-03-06 Thread Fam Zheng
On Thu, 03/06 11:09, Paolo Bonzini wrote: Il 06/03/2014 09:47, Fam Zheng ha scritto: According to SPC-4, section 4.5.2.1, 252 is the limit of sense data. So increase the value. Signed-off-by: Fam Zheng f...@redhat.com --- include/linux/virtio_scsi.h | 2 +- 1 file changed, 1 insertion

Re: [PATCH] virtio-scsi: Change sense buffer size to 252

2014-03-06 Thread Fam Zheng
On Thu, 03/06 12:55, Paolo Bonzini wrote: Il 06/03/2014 12:22, Hannes Reinecke ha scritto: On 03/06/2014 11:09 AM, Paolo Bonzini wrote: Il 06/03/2014 09:47, Fam Zheng ha scritto: According to SPC-4, section 4.5.2.1, 252 is the limit of sense data. So increase the value. Signed-off-by: Fam