1. 15 3月, 2018 1 次提交
  2. 25 8月, 2017 1 次提交
  3. 13 7月, 2017 1 次提交
  4. 27 6月, 2017 1 次提交
    • P
      scsi: virtio_scsi: let host do exception handling · e72c9a2a
      Paolo Bonzini 提交于
      virtio_scsi tries to do exception handling after the default 30 seconds
      timeout expires.  However, it's better to let the host control the
      timeout, otherwise with a heavy I/O load it is likely that an abort will
      also timeout.  This leads to fatal errors like filesystems going
      offline.
      
      Disable the 'sd' timeout and allow the host to do exception handling,
      following the precedent of the storvsc driver.
      
      Hannes has a proposal to introduce timeouts in virtio, but this provides
      an immediate solution for stable kernels too.
      
      [mkp: fixed typo]
      Reported-by: NDouglas Miller <dougmill@linux.vnet.ibm.com>
      Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
      Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: linux-scsi@vger.kernel.org
      Cc: stable@vger.kernel.org
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      e72c9a2a
  5. 13 6月, 2017 1 次提交
  6. 03 5月, 2017 1 次提交
  7. 20 4月, 2017 1 次提交
    • D
      scsi: virtio_scsi: Always try to read VPD pages · 25d1d50e
      David Gibson 提交于
      Passed through SCSI targets may have transfer limits which come from the
      host SCSI controller or something on the host side other than the target
      itself.
      
      To make this work properly, the hypervisor can adjust the target's VPD
      information to advertise these limits.  But for that to work, the guest
      has to look at the VPD pages, which we won't do by default if it is an
      SPC-2 device, even if it does actually support it.
      
      This adds a workaround to address this, forcing devices attached to a
      virtio-scsi controller to always check the VPD pages.  This is modelled
      on a similar workaround for the storvsc (Hyper-V) SCSI controller,
      although that exists for slightly different reasons.
      
      A specific case which causes this is a volume from IBM's IPR RAID
      controller (which presents as an SPC-2 device, although it does support
      VPD) passed through with qemu's 'scsi-block' device.
      
      [mkp: fixed typo]
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Acked-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      25d1d50e
  8. 28 2月, 2017 2 次提交
  9. 21 1月, 2017 1 次提交
    • E
      scsi: virtio_scsi: Reject commands when virtqueue is broken · 773c7220
      Eric Farman 提交于
      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) command, which
      immediately fails (and is retried a couple of times) because the device
      has been removed.  Later, the removal of the controller sees two CRWs
      presented, but there's no further indication of the removal from the
      guest viewpoint.
      
       [   17.217458] sd 0:0:0:0: [sda] Synchronizing SCSI cache
       [   17.219257] sd 0:0:0:0: [sda] Synchronize Cache(10) failed: Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
       [   21.449400] crw_info : CRW reports slct=0, oflw=0, chn=1, rsc=3, anc=0, erc=4, rsid=2
       [   21.449406] crw_info : CRW reports slct=0, oflw=0, chn=0, rsc=3, anc=0, erc=4, rsid=0
      
      However, on s390, the SCSI disks can be removed "by surprise" when an
      entire controller (host) is removed and all associated disks are removed
      via the loop in scsi_forget_host.  The same call to sd_sync_cache is
      made, but because the controller has already been removed, the
      Synchronize Cache(10) command is neither issued (and then failed) nor
      rejected.
      
      That the I/O isn't returned means the guest cannot have other devices
      added nor removed, and other tasks (such as shutdown or reboot) issued
      by the guest will not complete either.  The virtio ring has already been
      marked as broken (via virtio_break_device in virtio_ccw_remove), but we
      still attempt to queue the command only to have it remain there.  The
      calling sequence provides a bit of distinction for us:
      
        virtscsi_queuecommand()
         -> virtscsi_kick_cmd()
          -> virtscsi_add_cmd()
           -> virtqueue_add_sgs()
            -> virtqueue_add()
               if success
                 return 0
               elseif vq->broken or vring_mapping_error()
                 return -EIO
               else
                 return -ENOSPC
      
      A return of ENOSPC is generally a temporary condition, so returning
      "host busy" from virtscsi_queuecommand makes sense here, to have it
      redriven in a moment or two.  But the EIO return code is more of a
      permanent error and so it would be wise to return the I/O itself and
      allow the calling thread to finish gracefully.  The result is these four
      kernel messages in the guest (the fourth one does not occur prior to
      this patch):
      
       [   22.921562] crw_info : CRW reports slct=0, oflw=0, chn=1, rsc=3, anc=0, erc=4, rsid=2
       [   22.921580] crw_info : CRW reports slct=0, oflw=0, chn=0, rsc=3, anc=0, erc=4, rsid=0
       [   22.921978] sd 0:0:0:0: [sda] Synchronizing SCSI cache
       [   22.921993] sd 0:0:0:0: [sda] Synchronize Cache(10) failed: Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
      
      I opted to fill in the same response data that is returned from the more
      graceful device detach, where the disk device is removed prior to the
      controller device.
      Signed-off-by: NEric Farman <farman@linux.vnet.ibm.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      773c7220
  10. 20 9月, 2016 1 次提交
    • S
      virtio scsi: Convert to hotplug state machine · 8904f5a5
      Sebastian Andrzej Siewior 提交于
      Install the callbacks via the state machine. It uses the multi instance
      infrastructure of the hotplug code to handle each interface.
      
      virtscsi_set_affinity() is removed from virtscsi_init() because
      virtscsi_cpu_notif_add() (the function which registers the instance) is invoked
      right after it and the cpuhp_state_add_instance() functions invokes the startup
      callback on all online CPUs.
      
      The same thing can not be applied virtscsi_cpu_notif_remove() because
      virtscsi_remove_vqs() invokes virtscsi_set_affinity() with affinity = false as
      argument but the old CPU_DEAD state invoked the function with affinity = true
      (which does not match the DEAD callback).
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
      Cc: linux-scsi@vger.kernel.org
      Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: virtualization@lists.linux-foundation.org
      Cc: rt@linutronix.de
      Link: http://lkml.kernel.org/r/20160906170457.32393-11-bigeasy@linutronix.deSigned-off-by: NThomas Gleixner <tglx@linutronix.de>
      8904f5a5
  11. 15 9月, 2016 1 次提交
  12. 07 7月, 2015 1 次提交
  13. 26 5月, 2015 1 次提交
  14. 21 1月, 2015 1 次提交
  15. 09 12月, 2014 2 次提交
  16. 24 11月, 2014 2 次提交
  17. 20 11月, 2014 1 次提交
  18. 12 11月, 2014 1 次提交
    • C
      scsi: don't set tagging state from scsi_adjust_queue_depth · c8b09f6f
      Christoph Hellwig 提交于
      Remove the tagged argument from scsi_adjust_queue_depth, and just let it
      handle the queue depth.  For most drivers those two are fairly separate,
      given that most modern drivers don't care about the SCSI "tagged" status
      of a command at all, and many old drivers allow queuing of multiple
      untagged commands in the driver.
      
      Instead we start out with the ->simple_tags flag set before calling
      ->slave_configure, which is how all drivers actually looking at
      ->simple_tags except for one worke anyway.  The one other case looks
      broken, but I've kept the behavior as-is for now.
      
      Except for that we only change ->simple_tags from the ->change_queue_type,
      and when rejecting a tag message in a single driver, so keeping this
      churn out of scsi_adjust_queue_depth is a clear win.
      
      Now that the usage of scsi_adjust_queue_depth is more obvious we can
      also remove all the trivial instances in ->slave_alloc or ->slave_configure
      that just set it to the cmd_per_lun default.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NMike Christie <michaelc@cs.wisc.edu>
      Reviewed-by: NHannes Reinecke <hare@suse.de>
      Reviewed-by: NMartin K. Petersen <martin.petersen@oracle.com>
      c8b09f6f
  19. 15 10月, 2014 5 次提交
  20. 26 7月, 2014 2 次提交
  21. 25 6月, 2014 2 次提交
  22. 03 6月, 2014 1 次提交
    • N
      virtio-scsi: Enable DIF/DIX modes in SCSI host LLD · e6dc783a
      Nicholas Bellinger 提交于
      This patch updates virtscsi_probe() to setup necessary Scsi_Host
      level protection resources. (currently hardcoded to 1)
      
      It changes virtscsi_add_cmd() to attach outgoing / incoming
      protection SGLs preceeding the data payload, and is using the
      new virtio_scsi_cmd_req_pi->pi_bytes[out,in] field to signal
      to signal to vhost/scsi bytes to expect for protection data.
      
      (Add missing #include <linux/blkdev.h> for blk_integrity - sfr + nab)
      Acked-by: NPaolo Bonzini <pbonzini@redhat.com>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Sagi Grimberg <sagig@dev.mellanox.co.il>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      e6dc783a
  23. 21 5月, 2014 1 次提交
    • R
      virtio_scsi: don't call virtqueue_add_sgs(... GFP_NOIO) holding spinlock. · c77fba9a
      Rusty Russell 提交于
      This triggers every time we do a SCSI abort:
      
      virtscsi_tmf -> virtscsi_kick_cmd (grab lock and call) -> virtscsi_add_cmd
      	-> virtqueue_add_sgs (GFP_NOIO)
      
      Logs look like this:
       sd 0:0:0:0: [sda] abort
       BUG: sleeping function called from invalid context at mm/slub.c:966
       in_atomic(): 1, irqs_disabled(): 1, pid: 6, name: kworker/u2:0
       3 locks held by kworker/u2:0/6:
        #0:  ("scsi_tmf_%d"shost->host_no){......}, at: [<c0153180>] process_one_work+0xe0/0x3d0
        #1:  ((&(&cmd->abort_work)->work)){......}, at: [<c0153180>] process_one_work+0xe0/0x3d0
        #2:  (&(&virtscsi_vq->vq_lock)->rlock){......}, at: [<c043f508>] virtscsi_kick_cmd+0x18/0x1b0
       CPU: 0 PID: 6 Comm: kworker/u2:0 Not tainted 3.15.0-rc5+ #110
       Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.7.5-rc1-0-gb1d4dc9-20140515_140003-nilsson.home.kraxel.org 04/01/2014
       Workqueue: scsi_tmf_0 scmd_eh_abort_handler
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      Acked-by: NPaolo Bonzini <pbonzini@redhat.com>
      c77fba9a
  24. 20 5月, 2014 2 次提交
  25. 29 4月, 2014 1 次提交
    • F
      [SCSI] virtio-scsi: Skip setting affinity on uninitialized vq · 0c8482ac
      Fam Zheng 提交于
      virtscsi_init calls virtscsi_remove_vqs on err, even before initializing
      the vqs. The latter calls virtscsi_set_affinity, so let's check the
      pointer there before setting affinity on it.
      
      This fixes a panic when setting device's num_queues=2 on RHEL 6.5:
      
      qemu-system-x86_64 ... \
      -device virtio-scsi-pci,id=scsi0,addr=0x13,...,num_queues=2 \
      -drive file=/stor/vm/dummy.raw,id=drive-scsi-disk,... \
      -device scsi-hd,drive=drive-scsi-disk,...
      
      [    0.354734] scsi0 : Virtio SCSI HBA
      [    0.379504] BUG: unable to handle kernel NULL pointer dereference at 0000000000000020
      [    0.380141] IP: [<ffffffff814741ef>] __virtscsi_set_affinity+0x4f/0x120
      [    0.380141] PGD 0
      [    0.380141] Oops: 0000 [#1] SMP
      [    0.380141] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.14.0+ #5
      [    0.380141] Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2007
      [    0.380141] task: ffff88003c9f0000 ti: ffff88003c9f8000 task.ti: ffff88003c9f8000
      [    0.380141] RIP: 0010:[<ffffffff814741ef>]  [<ffffffff814741ef>] __virtscsi_set_affinity+0x4f/0x120
      [    0.380141] RSP: 0000:ffff88003c9f9c08  EFLAGS: 00010256
      [    0.380141] RAX: 0000000000000000 RBX: ffff88003c3a9d40 RCX: 0000000000001070
      [    0.380141] RDX: 0000000000000002 RSI: 0000000000000000 RDI: 0000000000000000
      [    0.380141] RBP: ffff88003c9f9c28 R08: 00000000000136c0 R09: ffff88003c801c00
      [    0.380141] R10: ffffffff81475229 R11: 0000000000000008 R12: 0000000000000000
      [    0.380141] R13: ffffffff81cc7ca8 R14: ffff88003cac3d40 R15: ffff88003cac37a0
      [    0.380141] FS:  0000000000000000(0000) GS:ffff88003e400000(0000) knlGS:0000000000000000
      [    0.380141] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
      [    0.380141] CR2: 0000000000000020 CR3: 0000000001c0e000 CR4: 00000000000006f0
      [    0.380141] Stack:
      [    0.380141]  ffff88003c3a9d40 0000000000000000 ffff88003cac3d80 ffff88003cac3d40
      [    0.380141]  ffff88003c9f9c48 ffffffff814742e8 ffff88003c26d000 ffff88003c26d000
      [    0.380141]  ffff88003c9f9c68 ffffffff81474321 ffff88003c26d000 ffff88003c3a9d40
      [    0.380141] Call Trace:
      [    0.380141]  [<ffffffff814742e8>] virtscsi_set_affinity+0x28/0x40
      [    0.380141]  [<ffffffff81474321>] virtscsi_remove_vqs+0x21/0x50
      [    0.380141]  [<ffffffff81475231>] virtscsi_init+0x91/0x240
      [    0.380141]  [<ffffffff81365290>] ? vp_get+0x50/0x70
      [    0.380141]  [<ffffffff81475544>] virtscsi_probe+0xf4/0x280
      [    0.380141]  [<ffffffff81363ea5>] virtio_dev_probe+0xe5/0x140
      [    0.380141]  [<ffffffff8144c669>] driver_probe_device+0x89/0x230
      [    0.380141]  [<ffffffff8144c8ab>] __driver_attach+0x9b/0xa0
      [    0.380141]  [<ffffffff8144c810>] ? driver_probe_device+0x230/0x230
      [    0.380141]  [<ffffffff8144c810>] ? driver_probe_device+0x230/0x230
      [    0.380141]  [<ffffffff8144ac1c>] bus_for_each_dev+0x8c/0xb0
      [    0.380141]  [<ffffffff8144c499>] driver_attach+0x19/0x20
      [    0.380141]  [<ffffffff8144bf28>] bus_add_driver+0x198/0x220
      [    0.380141]  [<ffffffff8144ce9f>] driver_register+0x5f/0xf0
      [    0.380141]  [<ffffffff81d27c91>] ? spi_transport_init+0x79/0x79
      [    0.380141]  [<ffffffff8136403b>] register_virtio_driver+0x1b/0x30
      [    0.380141]  [<ffffffff81d27d19>] init+0x88/0xd6
      [    0.380141]  [<ffffffff81d27c18>] ? scsi_init_procfs+0x5b/0x5b
      [    0.380141]  [<ffffffff81ce88a7>] do_one_initcall+0x7f/0x10a
      [    0.380141]  [<ffffffff81ce8aa7>] kernel_init_freeable+0x14a/0x1de
      [    0.380141]  [<ffffffff81ce8b3b>] ? kernel_init_freeable+0x1de/0x1de
      [    0.380141]  [<ffffffff817dec20>] ? rest_init+0x80/0x80
      [    0.380141]  [<ffffffff817dec29>] kernel_init+0x9/0xf0
      [    0.380141]  [<ffffffff817e68fc>] ret_from_fork+0x7c/0xb0
      [    0.380141]  [<ffffffff817dec20>] ? rest_init+0x80/0x80
      [    0.380141] RIP  [<ffffffff814741ef>] __virtscsi_set_affinity+0x4f/0x120
      [    0.380141]  RSP <ffff88003c9f9c08>
      [    0.380141] CR2: 0000000000000020
      [    0.380141] ---[ end trace 8074b70c3d5e1d73 ]---
      [    0.475018] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000009
      [    0.475018]
      [    0.475068] Kernel Offset: 0x0 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffff9fffffff)
      [    0.475068] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000009
      
      [jejb: checkpatch fixes]
      Signed-off-by: NFam Zheng <famz@redhat.com>
      Acked-by: NPaolo Bonzini <pbonzini@redhat.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NJames Bottomley <JBottomley@Parallels.com>
      0c8482ac
  26. 16 1月, 2014 1 次提交
  27. 11 11月, 2013 1 次提交
  28. 17 10月, 2013 1 次提交
  29. 23 9月, 2013 1 次提交
  30. 01 8月, 2013 1 次提交
    • A
      virtio-scsi: Fix virtqueue affinity setup · aa52aeea
      Asias He 提交于
      vscsi->num_queues counts the number of request virtqueue which does not
      include the control and event virtqueue. It is wrong to subtract
      VIRTIO_SCSI_VQ_BASE from vscsi->num_queues.
      
      This patch fixes the following panic.
      
      (qemu) device_del scsi0
      
       BUG: unable to handle kernel NULL pointer dereference at 0000000000000020
       IP: [<ffffffff8179b29f>] __virtscsi_set_affinity+0x6f/0x120
       PGD 0
       Oops: 0000 [#1] SMP
       Modules linked in:
       CPU: 0 PID: 659 Comm: kworker/0:1 Not tainted 3.11.0-rc2+ #1172
       Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
       Workqueue: kacpi_hotplug _handle_hotplug_event_func
       task: ffff88007bee1cc0 ti: ffff88007bfe4000 task.ti: ffff88007bfe4000
       RIP: 0010:[<ffffffff8179b29f>]  [<ffffffff8179b29f>] __virtscsi_set_affinity+0x6f/0x120
       RSP: 0018:ffff88007bfe5a38  EFLAGS: 00010202
       RAX: 0000000000000010 RBX: ffff880077fd0d28 RCX: 0000000000000050
       RDX: 0000000000000000 RSI: 0000000000000246 RDI: 0000000000000000
       RBP: ffff88007bfe5a58 R08: ffff880077f6ff00 R09: 0000000000000001
       R10: ffffffff8143e673 R11: 0000000000000001 R12: 0000000000000001
       R13: ffff880077fd0800 R14: 0000000000000000 R15: ffff88007bf489b0
       FS:  0000000000000000(0000) GS:ffff88007ea00000(0000) knlGS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
       CR2: 0000000000000020 CR3: 0000000079f8b000 CR4: 00000000000006f0
       Stack:
        ffff880077fd0d28 0000000000000000 ffff880077fd0800 0000000000000008
        ffff88007bfe5a78 ffffffff8179b37d ffff88007bccc800 ffff88007bccc800
        ffff88007bfe5a98 ffffffff8179b3b6 ffff88007bccc800 ffff880077fd0d28
       Call Trace:
        [<ffffffff8179b37d>] virtscsi_set_affinity+0x2d/0x40
        [<ffffffff8179b3b6>] virtscsi_remove_vqs+0x26/0x50
        [<ffffffff8179c7d2>] virtscsi_remove+0x82/0xa0
        [<ffffffff814cb6b2>] virtio_dev_remove+0x22/0x70
        [<ffffffff8167ca49>] __device_release_driver+0x69/0xd0
        [<ffffffff8167cb9d>] device_release_driver+0x2d/0x40
        [<ffffffff8167bb96>] bus_remove_device+0x116/0x150
        [<ffffffff81679936>] device_del+0x126/0x1e0
        [<ffffffff81679a06>] device_unregister+0x16/0x30
        [<ffffffff814cb889>] unregister_virtio_device+0x19/0x30
        [<ffffffff814cdad6>] virtio_pci_remove+0x36/0x80
        [<ffffffff81464ae7>] pci_device_remove+0x37/0x70
        [<ffffffff8167ca49>] __device_release_driver+0x69/0xd0
        [<ffffffff8167cb9d>] device_release_driver+0x2d/0x40
        [<ffffffff8167bb96>] bus_remove_device+0x116/0x150
        [<ffffffff81679936>] device_del+0x126/0x1e0
        [<ffffffff8145edfc>] pci_stop_bus_device+0x9c/0xb0
        [<ffffffff8145f036>] pci_stop_and_remove_bus_device+0x16/0x30
        [<ffffffff81474a9e>] acpiphp_disable_slot+0x8e/0x150
        [<ffffffff81474f6a>] hotplug_event_func+0xba/0x1a0
        [<ffffffff814906c8>] ? acpi_os_release_object+0xe/0x12
        [<ffffffff81475911>] _handle_hotplug_event_func+0x31/0x70
        [<ffffffff810b5333>] process_one_work+0x183/0x500
        [<ffffffff810b66e2>] worker_thread+0x122/0x400
        [<ffffffff810b65c0>] ? manage_workers+0x2d0/0x2d0
        [<ffffffff810bc5de>] kthread+0xce/0xe0
        [<ffffffff810bc510>] ? kthread_freezable_should_stop+0x70/0x70
        [<ffffffff81ca045c>] ret_from_fork+0x7c/0xb0
        [<ffffffff810bc510>] ? kthread_freezable_should_stop+0x70/0x70
       Code: 01 00 00 00 74 59 45 31 e4 83 bb c8 01 00 00 02 74 46 66 2e 0f 1f 84 00 00 00 00 00 49 63 c4 48 c1 e0 04 48 8b bc 0
      3 10 02 00 00 <48> 8b 47 20 48 8b 80 d0 01 00 00 48 8b 40 50 48 85 c0 74 07 be
       RIP  [<ffffffff8179b29f>] __virtscsi_set_affinity+0x6f/0x120
        RSP <ffff88007bfe5a38>
       CR2: 0000000000000020
       ---[ end trace 99679331a3775f48 ]---
      
      CC: stable@vger.kernel.org
      Signed-off-by: NAsias He <asias@redhat.com>
      Reviewed-by: NWanlong Gao <gaowanlong@cn.fujitsu.com>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      aa52aeea