1. 02 9月, 2020 1 次提交
  2. 24 3月, 2019 1 次提交
    • F
      scsi: virtio_scsi: don't send sc payload with tmfs · bd8a0e65
      Felipe Franciosi 提交于
      commit 3722e6a52174d7c3a00e6f5efd006ca093f346c1 upstream.
      
      The virtio scsi spec defines struct virtio_scsi_ctrl_tmf as a set of
      device-readable records and a single device-writable response entry:
      
          struct virtio_scsi_ctrl_tmf
          {
              // Device-readable part
              le32 type;
              le32 subtype;
              u8 lun[8];
              le64 id;
              // Device-writable part
              u8 response;
          }
      
      The above should be organised as two descriptor entries (or potentially
      more if using VIRTIO_F_ANY_LAYOUT), but without any extra data after "le64
      id" or after "u8 response".
      
      The Linux driver doesn't respect that, with virtscsi_abort() and
      virtscsi_device_reset() setting cmd->sc before calling virtscsi_tmf().  It
      results in the original scsi command payload (or writable buffers) added to
      the tmf.
      
      This fixes the problem by leaving cmd->sc zeroed out, which makes
      virtscsi_kick_cmd() add the tmf to the control vq without any payload.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NFelipe Franciosi <felipe@nutanix.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bd8a0e65
  3. 27 7月, 2018 1 次提交
  4. 13 6月, 2018 1 次提交
    • K
      treewide: kmalloc() -> kmalloc_array() · 6da2ec56
      Kees Cook 提交于
      The kmalloc() function has a 2-factor argument form, kmalloc_array(). This
      patch replaces cases of:
      
              kmalloc(a * b, gfp)
      
      with:
              kmalloc_array(a * b, gfp)
      
      as well as handling cases of:
      
              kmalloc(a * b * c, gfp)
      
      with:
      
              kmalloc(array3_size(a, b, c), gfp)
      
      as it's slightly less ugly than:
      
              kmalloc_array(array_size(a, b), c, gfp)
      
      This does, however, attempt to ignore constant size factors like:
      
              kmalloc(4 * 1024, gfp)
      
      though any constants defined via macros get caught up in the conversion.
      
      Any factors with a sizeof() of "unsigned char", "char", and "u8" were
      dropped, since they're redundant.
      
      The tools/ directory was manually excluded, since it has its own
      implementation of kmalloc().
      
      The Coccinelle script used for this was:
      
      // Fix redundant parens around sizeof().
      @@
      type TYPE;
      expression THING, E;
      @@
      
      (
        kmalloc(
      -	(sizeof(TYPE)) * E
      +	sizeof(TYPE) * E
        , ...)
      |
        kmalloc(
      -	(sizeof(THING)) * E
      +	sizeof(THING) * E
        , ...)
      )
      
      // Drop single-byte sizes and redundant parens.
      @@
      expression COUNT;
      typedef u8;
      typedef __u8;
      @@
      
      (
        kmalloc(
      -	sizeof(u8) * (COUNT)
      +	COUNT
        , ...)
      |
        kmalloc(
      -	sizeof(__u8) * (COUNT)
      +	COUNT
        , ...)
      |
        kmalloc(
      -	sizeof(char) * (COUNT)
      +	COUNT
        , ...)
      |
        kmalloc(
      -	sizeof(unsigned char) * (COUNT)
      +	COUNT
        , ...)
      |
        kmalloc(
      -	sizeof(u8) * COUNT
      +	COUNT
        , ...)
      |
        kmalloc(
      -	sizeof(__u8) * COUNT
      +	COUNT
        , ...)
      |
        kmalloc(
      -	sizeof(char) * COUNT
      +	COUNT
        , ...)
      |
        kmalloc(
      -	sizeof(unsigned char) * COUNT
      +	COUNT
        , ...)
      )
      
      // 2-factor product with sizeof(type/expression) and identifier or constant.
      @@
      type TYPE;
      expression THING;
      identifier COUNT_ID;
      constant COUNT_CONST;
      @@
      
      (
      - kmalloc
      + kmalloc_array
        (
      -	sizeof(TYPE) * (COUNT_ID)
      +	COUNT_ID, sizeof(TYPE)
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	sizeof(TYPE) * COUNT_ID
      +	COUNT_ID, sizeof(TYPE)
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	sizeof(TYPE) * (COUNT_CONST)
      +	COUNT_CONST, sizeof(TYPE)
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	sizeof(TYPE) * COUNT_CONST
      +	COUNT_CONST, sizeof(TYPE)
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	sizeof(THING) * (COUNT_ID)
      +	COUNT_ID, sizeof(THING)
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	sizeof(THING) * COUNT_ID
      +	COUNT_ID, sizeof(THING)
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	sizeof(THING) * (COUNT_CONST)
      +	COUNT_CONST, sizeof(THING)
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	sizeof(THING) * COUNT_CONST
      +	COUNT_CONST, sizeof(THING)
        , ...)
      )
      
      // 2-factor product, only identifiers.
      @@
      identifier SIZE, COUNT;
      @@
      
      - kmalloc
      + kmalloc_array
        (
      -	SIZE * COUNT
      +	COUNT, SIZE
        , ...)
      
      // 3-factor product with 1 sizeof(type) or sizeof(expression), with
      // redundant parens removed.
      @@
      expression THING;
      identifier STRIDE, COUNT;
      type TYPE;
      @@
      
      (
        kmalloc(
      -	sizeof(TYPE) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kmalloc(
      -	sizeof(TYPE) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kmalloc(
      -	sizeof(TYPE) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kmalloc(
      -	sizeof(TYPE) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kmalloc(
      -	sizeof(THING) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        kmalloc(
      -	sizeof(THING) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        kmalloc(
      -	sizeof(THING) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        kmalloc(
      -	sizeof(THING) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      )
      
      // 3-factor product with 2 sizeof(variable), with redundant parens removed.
      @@
      expression THING1, THING2;
      identifier COUNT;
      type TYPE1, TYPE2;
      @@
      
      (
        kmalloc(
      -	sizeof(TYPE1) * sizeof(TYPE2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        kmalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        kmalloc(
      -	sizeof(THING1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        kmalloc(
      -	sizeof(THING1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        kmalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      |
        kmalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      )
      
      // 3-factor product, only identifiers, with redundant parens removed.
      @@
      identifier STRIDE, SIZE, COUNT;
      @@
      
      (
        kmalloc(
      -	(COUNT) * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kmalloc(
      -	COUNT * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kmalloc(
      -	COUNT * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kmalloc(
      -	(COUNT) * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kmalloc(
      -	COUNT * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kmalloc(
      -	(COUNT) * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kmalloc(
      -	(COUNT) * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kmalloc(
      -	COUNT * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      )
      
      // Any remaining multi-factor products, first at least 3-factor products,
      // when they're not all constants...
      @@
      expression E1, E2, E3;
      constant C1, C2, C3;
      @@
      
      (
        kmalloc(C1 * C2 * C3, ...)
      |
        kmalloc(
      -	(E1) * E2 * E3
      +	array3_size(E1, E2, E3)
        , ...)
      |
        kmalloc(
      -	(E1) * (E2) * E3
      +	array3_size(E1, E2, E3)
        , ...)
      |
        kmalloc(
      -	(E1) * (E2) * (E3)
      +	array3_size(E1, E2, E3)
        , ...)
      |
        kmalloc(
      -	E1 * E2 * E3
      +	array3_size(E1, E2, E3)
        , ...)
      )
      
      // And then all remaining 2 factors products when they're not all constants,
      // keeping sizeof() as the second factor argument.
      @@
      expression THING, E1, E2;
      type TYPE;
      constant C1, C2, C3;
      @@
      
      (
        kmalloc(sizeof(THING) * C2, ...)
      |
        kmalloc(sizeof(TYPE) * C2, ...)
      |
        kmalloc(C1 * C2 * C3, ...)
      |
        kmalloc(C1 * C2, ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	sizeof(TYPE) * (E2)
      +	E2, sizeof(TYPE)
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	sizeof(TYPE) * E2
      +	E2, sizeof(TYPE)
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	sizeof(THING) * (E2)
      +	E2, sizeof(THING)
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	sizeof(THING) * E2
      +	E2, sizeof(THING)
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	(E1) * E2
      +	E1, E2
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	(E1) * (E2)
      +	E1, E2
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	E1 * E2
      +	E1, E2
        , ...)
      )
      Signed-off-by: NKees Cook <keescook@chromium.org>
      6da2ec56
  5. 15 3月, 2018 2 次提交
    • M
      scsi: virtio_scsi: unify scsi_host_template · c3506df8
      Ming Lei 提交于
      Now that virtio_scsi uses blk-mq exclusively, we can remove the
      scsi_host_template and associated plumbing for the legacy I/O path.
      
      [mkp: commit desc]
      
      Cc: Omar Sandoval <osandov@fb.com>,
      Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
      Cc: James Bottomley <james.bottomley@hansenpartnership.com>,
      Cc: Christoph Hellwig <hch@lst.de>,
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Mike Snitzer <snitzer@redhat.com>
      Cc: Laurence Oberman <loberman@redhat.com>
      Cc: Hannes Reinecke <hare@suse.de>
      Signed-off-by: NMing Lei <ming.lei@redhat.com>
      Suggested-by: Christoph Hellwig <hch@lst.de>,
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      c3506df8
    • M
      scsi: virtio_scsi: fix IO hang caused by automatic irq vector affinity · b5b6e8c8
      Ming Lei 提交于
      Since commit 84676c1f ("genirq/affinity: assign vectors to all
      possible CPUs") it is possible to end up in a scenario where only
      offline CPUs are mapped to an interrupt vector.
      
      This is only an issue for the legacy I/O path since with blk-mq/scsi-mq
      an I/O can't be submitted to a hardware queue if the queue isn't mapped
      to an online CPU.
      
      Fix this issue by forcing virtio-scsi to use blk-mq.
      
      [mkp: commit desc]
      
      Cc: Omar Sandoval <osandov@fb.com>,
      Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
      Cc: James Bottomley <james.bottomley@hansenpartnership.com>,
      Cc: Christoph Hellwig <hch@lst.de>,
      Cc: Don Brace <don.brace@microsemi.com>
      Cc: Kashyap Desai <kashyap.desai@broadcom.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Mike Snitzer <snitzer@redhat.com>
      Cc: Laurence Oberman <loberman@redhat.com>
      Fixes: 84676c1f ("genirq/affinity: assign vectors to all possible CPUs")
      Signed-off-by: NMing Lei <ming.lei@redhat.com>
      Reviewed-by: NHannes Reinecke <hare@suse.de>
      Acked-by: NPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      b5b6e8c8
  6. 25 8月, 2017 1 次提交
  7. 13 7月, 2017 1 次提交
  8. 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
  9. 13 6月, 2017 1 次提交
  10. 03 5月, 2017 1 次提交
  11. 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
  12. 28 2月, 2017 2 次提交
  13. 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
  14. 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
  15. 15 9月, 2016 1 次提交
  16. 07 7月, 2015 1 次提交
  17. 26 5月, 2015 1 次提交
  18. 21 1月, 2015 1 次提交
  19. 09 12月, 2014 2 次提交
  20. 24 11月, 2014 2 次提交
  21. 20 11月, 2014 1 次提交
  22. 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
  23. 15 10月, 2014 5 次提交
  24. 26 7月, 2014 2 次提交
  25. 25 6月, 2014 2 次提交
  26. 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
  27. 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
  28. 20 5月, 2014 2 次提交
  29. 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