1. 30 Jul, 2021 1 commit
  2. 06 Apr, 2021 1 commit
  3. 30 Mar, 2021 1 commit
  4. 04 Mar, 2021 2 commits
  5. 17 Nov, 2020 1 commit
  6. 06 Oct, 2020 1 commit
  7. 17 Mar, 2020 1 commit
  8. 29 Feb, 2020 1 commit
  9. 30 Oct, 2019 1 commit
  10. 18 Oct, 2019 1 commit
    • Yufen Yu's avatar
      scsi: core: try to get module before removing device · 77c30128
      Yufen Yu authored
      We have a test case like block/001 in blktests, which will create a scsi
      device by loading scsi_debug module and then try to delete the device by
      sysfs interface. At the same time, it may remove the scsi_debug module.
      
      And getting a invalid paging request BUG_ON as following:
      
      [   34.625854] BUG: unable to handle page fault for address: ffffffffa0016bb8
      [   34.629189] Oops: 0000 [#1] SMP PTI
      [   34.629618] CPU: 1 PID: 450 Comm: bash Tainted: G        W         5.4.0-rc3+ #473
      [   34.632524] RIP: 0010:scsi_proc_hostdir_rm+0x5/0xa0
      [   34.643555] CR2: ffffffffa0016bb8 CR3: 000000012cd88000 CR4: 00000000000006e0
      [   34.644545] Call Trace:
      [   34.644907]  scsi_host_dev_release+0x6b/0x1f0
      [   34.645511]  device_release+0x74/0x110
      [   34.646046]  kobject_put+0x116/0x390
      [   34.646559]  put_device+0x17/0x30
      [   34.647041]  scsi_target_dev_release+0x2b/0x40
      [   34.647652]  device_release+0x74/0x110
      [   34.648186]  kobject_put+0x116/0x390
      [   34.648691]  put_device+0x17/0x30
      [   34.649157]  scsi_device_dev_release_usercontext+0x2e8/0x360
      [   34.649953]  execute_in_process_context+0x29/0x80
      [   34.650603]  scsi_device_dev_release+0x20/0x30
      [   34.651221]  device_release+0x74/0x110
      [   34.651732]  kobject_put+0x116/0x390
      [   34.652230]  sysfs_unbreak_active_protection+0x3f/0x50
      [   34.652935]  sdev_store_delete.cold.4+0x71/0x8f
      [   34.653579]  dev_attr_store+0x1b/0x40
      [   34.654103]  sysfs_kf_write+0x3d/0x60
      [   34.654603]  kernfs_fop_write+0x174/0x250
      [   34.655165]  __vfs_write+0x1f/0x60
      [   34.655639]  vfs_write+0xc7/0x280
      [   34.656117]  ksys_write+0x6d/0x140
      [   34.656591]  __x64_sys_write+0x1e/0x30
      [   34.657114]  do_syscall_64+0xb1/0x400
      [   34.657627]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      [   34.658335] RIP: 0033:0x7f156f337130
      
      During deleting scsi target, the scsi_debug module have been removed. Then,
      sdebug_driver_template belonged to the module cannot be accessd, resulting
      in scsi_proc_hostdir_rm() BUG_ON.
      
      To fix the bug, we add scsi_device_get() in sdev_store_delete() to try to
      increase refcount of module, avoiding the module been removed.
      
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20191015130556.18061-1-yuyufen@huawei.com
      
      Signed-off-by: default avatarYufen Yu <yuyufen@huawei.com>
      Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      77c30128
  11. 01 Oct, 2019 2 commits
  12. 20 Jun, 2019 1 commit
    • Bart Van Assche's avatar
      scsi: Restrict user space SCSI device state changes to "running" and "offline" · ac88c1f6
      Bart Van Assche authored
      
      The ability to modify the SCSI device state was introduced by commit
      638127e579a4 ("[PATCH] Fix error handler offline behaviour"; v2.6.12). That
      same commit introduced the following device states:
      
             { SDEV_CREATED, "created" },
             { SDEV_RUNNING, "running" },
             { SDEV_CANCEL,  "cancel"  },
             { SDEV_DEL,     "deleted" },
             { SDEV_QUIESCE, "quiesce" },
             { SDEV_OFFLINE, "offline" },
      
      The SDEV_BLOCK state was introduced later to avoid that an FC cable pull
      would immediately result in an I/O error (commit 1094e682310e; "[PATCH]
      suspending I/Os to a device"; v2.6.12). That same patch introduced the
      ability to set the SDEV_BLOCK state from user space. I'm not sure whether
      that ability was introduced on purpose or accidentally.
      
      Since there is agreement that only writing "running" or "offline" into
      the SCSI sysfs device state attribute makes sense, restrict sysfs writes
      to these values.
      
      This patch makes sure that SDEV_BLOCK is only used for its original
      purpose, namely to allow transport drivers and LLDs to block further
      .queuecommand() calls while transport layer or adapter recovery is in
      progress.
      
      Note: a web search for "/sys/class/scsi_device" AND "device/state"
      revealed several storage configuration guides. The instructions I found
      in these guides tell users to write the value "running" or "offline" in
      the SCSI device state sysfs attribute and no other values.
      
      [mkp: typo]
      
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Ming Lei <ming.lei@redhat.com>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Johannes Thumshirn <jthumshirn@suse.de>
      Cc: James Smart <james.smart@broadcom.com>
      Cc: Ewan D. Milne <emilne@redhat.com>
      Cc: Laurence Oberman <loberman@redhat.com>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      ac88c1f6
  13. 21 May, 2019 2 commits
  14. 28 Mar, 2019 1 commit
  15. 07 Nov, 2018 1 commit
  16. 02 Aug, 2018 1 commit
    • Bart Van Assche's avatar
      scsi: core: Avoid that SCSI device removal through sysfs triggers a deadlock · 0ee223b2
      Bart Van Assche authored
      A long time ago the unfortunate decision was taken to add a self-deletion
      attribute to the sysfs SCSI device directory. That decision was unfortunate
      because self-deletion is really tricky. We can't drop that attribute
      because widely used user space software depends on it, namely the
      rescan-scsi-bus.sh script. Hence this patch that avoids that writing into
      that attribute triggers a deadlock. See also commit 7973cbd9fbd9 ("[PATCH]
      add sysfs attributes to scan and delete scsi_devices").
      
      This patch avoids that self-removal triggers the following deadlock:
      
      ======================================================
      WARNING: possible circular locking dependency detected
      4.18.0-rc2-dbg+ #5 Not tainted
      ------------------------------------------------------
      modprobe/6539 is trying to acquire lock:
      000000008323c4cd (kn->count#202){++++}, at: kernfs_remove_by_name_ns+0x45/0x90
      
      but task is already holding lock:
      00000000a6ec2c69 (&shost->scan_mutex){+.+.}, at: scsi_remove_host+0x21/0x150 [scsi_mod]
      
      which lock already depends on the new lock.
      
      the existing dependency chain (in reverse order) is:
      
      -> #1 (&shost->scan_mutex){+.+.}:
             __mutex_lock+0xfe/0xc70
             mutex_lock_nested+0x1b/0x20
             scsi_remove_device+0x26/0x40 [scsi_mod]
             sdev_store_delete+0x27/0x30 [scsi_mod]
             dev_attr_store+0x3e/0x50
             sysfs_kf_write+0x87/0xa0
             kernfs_fop_write+0x190/0x230
             __vfs_write+0xd2/0x3b0
             vfs_write+0x101/0x270
             ksys_write+0xab/0x120
             __x64_sys_write+0x43/0x50
             do_syscall_64+0x77/0x230
             entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
      -> #0 (kn->count#202){++++}:
             lock_acquire+0xd2/0x260
             __kernfs_remove+0x424/0x4a0
             kernfs_remove_by_name_ns+0x45/0x90
             remove_files.isra.1+0x3a/0x90
             sysfs_remove_group+0x5c/0xc0
             sysfs_remove_groups+0x39/0x60
             device_remove_attrs+0x82/0xb0
             device_del+0x251/0x580
             __scsi_remove_device+0x19f/0x1d0 [scsi_mod]
             scsi_forget_host+0x37/0xb0 [scsi_mod]
             scsi_remove_host+0x9b/0x150 [scsi_mod]
             sdebug_driver_remove+0x4b/0x150 [scsi_debug]
             device_release_driver_internal+0x241/0x360
             device_release_driver+0x12/0x20
             bus_remove_device+0x1bc/0x290
             device_del+0x259/0x580
             device_unregister+0x1a/0x70
             sdebug_remove_adapter+0x8b/0xf0 [scsi_debug]
             scsi_debug_exit+0x76/0xe8 [scsi_debug]
             __x64_sys_delete_module+0x1c1/0x280
             do_syscall_64+0x77/0x230
             entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
      other info that might help us debug this:
      
       Possible unsafe locking scenario:
      
             CPU0                    CPU1
             ----                    ----
        lock(&shost->scan_mutex);
                                     lock(kn->count#202);
                                     lock(&shost->scan_mutex);
        lock(kn->count#202);
      
       *** DEADLOCK ***
      
      2 locks held by modprobe/6539:
       #0: 00000000efaf9298 (&dev->mutex){....}, at: device_release_driver_internal+0x68/0x360
       #1: 00000000a6ec2c69 (&shost->scan_mutex){+.+.}, at: scsi_remove_host+0x21/0x150 [scsi_mod]
      
      stack backtrace:
      CPU: 10 PID: 6539 Comm: modprobe Not tainted 4.18.0-rc2-dbg+ #5
      Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014
      Call Trace:
       dump_stack+0xa4/0xf5
       print_circular_bug.isra.34+0x213/0x221
       __lock_acquire+0x1a7e/0x1b50
       lock_acquire+0xd2/0x260
       __kernfs_remove+0x424/0x4a0
       kernfs_remove_by_name_ns+0x45/0x90
       remove_files.isra.1+0x3a/0x90
       sysfs_remove_group+0x5c/0xc0
       sysfs_remove_groups+0x39/0x60
       device_remove_attrs+0x82/0xb0
       device_del+0x251/0x580
       __scsi_remove_device+0x19f/0x1d0 [scsi_mod]
       scsi_forget_host+0x37/0xb0 [scsi_mod]
       scsi_remove_host+0x9b/0x150 [scsi_mod]
       sdebug_driver_remove+0x4b/0x150 [scsi_debug]
       device_release_driver_internal+0x241/0x360
       device_release_driver+0x12/0x20
       bus_remove_device+0x1bc/0x290
       device_del+0x259/0x580
       device_unregister+0x1a/0x70
       sdebug_remove_adapter+0x8b/0xf0 [scsi_debug]
       scsi_debug_exit+0x76/0xe8 [scsi_debug]
       __x64_sys_delete_module+0x1c1/0x280
       do_syscall_64+0x77/0x230
       entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
      See also https://www.mail-archive.com/linux-scsi@vger.kernel.org/msg54525.html.
      
      Fixes: ac0ece91
      
       ("scsi: use device_remove_file_self() instead of device_schedule_callback()")
      Signed-off-by: default avatarBart Van Assche <bart.vanassche@wdc.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Johannes Thumshirn <jthumshirn@suse.de>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      0ee223b2
  17. 26 Jun, 2018 1 commit
    • Ming Lei's avatar
      scsi: read host_busy via scsi_host_busy() · c84b023a
      Ming Lei authored
      
      No functional change.
      
      Just introduce scsi_host_busy() and replace the direct read of
      scsi_host->host_busy with this new API.
      
      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: Mike Snitzer <snitzer@redhat.com>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Laurence Oberman <loberman@redhat.com>
      Cc: Bart Van Assche <bart.vanassche@wdc.com>
      Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
      Reviewed-by: default avatarBart Van Assche <bart.vanassche@wdc.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      c84b023a
  18. 20 Apr, 2018 2 commits
  19. 13 Mar, 2018 1 commit
    • Christoph Hellwig's avatar
      bsg: split handling of SCSI CDBs vs transport requeues · 17cb960f
      Christoph Hellwig authored
      
      The current BSG design tries to shoe-horn the transport-specific
      passthrough commands into the overall framework for SCSI passthrough
      requests.  This has a couple problems:
      
       - each passthrough queue has to set the QUEUE_FLAG_SCSI_PASSTHROUGH flag
         despite not dealing with SCSI commands at all.  Because of that these
         queues could also incorrectly accept SCSI commands from in-kernel
         users or through the legacy SCSI_IOCTL_SEND_COMMAND ioctl.
       - the real SCSI bsg queues also incorrectly accept bsg requests of the
         BSG_SUB_PROTOCOL_SCSI_TRANSPORT type
       - the bsg transport code is almost unredable because it tries to reuse
         different SCSI concepts for its own purpose.
      
      This patch instead adds a new bsg_ops structure to handle the two cases
      differently, and thus solves all of the above problems.  Another side
      effect is that the bsg-lib queues also don't need to embedd a
      struct scsi_request anymore.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
      Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      17cb960f
  20. 15 Feb, 2018 1 commit
  21. 19 Dec, 2017 1 commit
  22. 15 Dec, 2017 1 commit
  23. 08 Dec, 2017 1 commit
  24. 17 Oct, 2017 1 commit
  25. 06 Oct, 2017 1 commit
  26. 25 Sep, 2017 1 commit
  27. 30 Aug, 2017 1 commit
    • Bart Van Assche's avatar
      scsi: Rework handling of scsi_device.vpd_pg8[03] · ccf1e004
      Bart Van Assche authored
      Introduce struct scsi_vpd for the VPD page length, data and the RCU head
      that will be used to free the VPD data. Use kfree_rcu() instead of
      kfree() to free VPD data. Move the VPD buffer pointer check inside the
      RCU read lock in the sysfs code. Only annotate pointers that are shared
      across threads with __rcu. Use rcu_dereference() when dereferencing an
      RCU pointer. This patch suppresses about twenty sparse complaints about
      the vpd_pg8[03] pointers. This patch also fixes a race condition, namely
      that updating of the VPD pointers and length variables in struct
      scsi_device was not atomic with reference to the code reading these
      variables. See also "Does the update code tolerate concurrent accesses?"
      in Documentation/RCU/checklist.txt.
      
      Fixes: commit 09e2b0b1
      
       ("scsi: rescan VPD attributes")
      Signed-off-by: default avatarBart Van Assche <bart.vanassche@wdc.com>
      Acked-by: default avatarHannes Reinecke <hare@suse.de>
      Reviewed-by: default avatarShane Seymour <shane.seymour@hpe.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Johannes Thumshirn <jthumshirn@suse.de>
      Cc: Shane Seymour <shane.seymour@hpe.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      ccf1e004
  28. 25 Aug, 2017 2 commits
  29. 01 Jul, 2017 1 commit
    • Ewan D. Milne's avatar
      scsi: Add STARGET_CREATED_REMOVE state to scsi_target_state · f9279c96
      Ewan D. Milne authored
      The addition of the STARGET_REMOVE state had the side effect of
      introducing a race condition that can cause a crash.
      
      scsi_target_reap_ref_release() checks the starget->state to
      see if it still in STARGET_CREATED, and if so, skips calling
      transport_remove_device() and device_del(), because the starget->state
      is only set to STARGET_RUNNING after scsi_target_add() has called
      device_add() and transport_add_device().
      
      However, if an rport loss occurs while a target is being scanned,
      it can happen that scsi_remove_target() will be called while the
      starget is still in the STARGET_CREATED state.  In this case, the
      starget->state will be set to STARGET_REMOVE, and as a result,
      scsi_target_reap_ref_release() will take the wrong path.  The end
      result is a panic:
      
      [ 1255.356653] Oops: 0000 [#1] SMP
      [ 1255.360154] Modules linked in: x86_pkg_temp_thermal kvm_intel kvm irqbypass crc32c_intel ghash_clmulni_i
      [ 1255.393234] CPU: 5 PID: 149 Comm: kworker/u96:4 Tainted: G        W       4.11.0+ #8
      [ 1255.401879] Hardware name: Dell Inc. PowerEdge R320/08VT7V, BIOS 2.0.22 11/19/2013
      [ 1255.410327] Workqueue: scsi_wq_6 fc_scsi_scan_rport [scsi_transport_fc]
      [ 1255.417720] task: ffff88060ca8c8c0 task.stack: ffffc900048a8000
      [ 1255.424331] RIP: 0010:kernfs_find_ns+0x13/0xc0
      [ 1255.429287] RSP: 0018:ffffc900048abbf0 EFLAGS: 00010246
      [ 1255.435123] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
      [ 1255.443083] RDX: 0000000000000000 RSI: ffffffff8188d659 RDI: 0000000000000000
      [ 1255.451043] RBP: ffffc900048abc10 R08: 0000000000000000 R09: 0000012433fe0025
      [ 1255.459005] R10: 0000000025e5a4b5 R11: 0000000025e5a4b5 R12: ffffffff8188d659
      [ 1255.466972] R13: 0000000000000000 R14: ffff8805f55e5088 R15: 0000000000000000
      [ 1255.474931] FS:  0000000000000000(0000) GS:ffff880616b40000(0000) knlGS:0000000000000000
      [ 1255.483959] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [ 1255.490370] CR2: 0000000000000068 CR3: 0000000001c09000 CR4: 00000000000406e0
      [ 1255.498332] Call Trace:
      [ 1255.501058]  kernfs_find_and_get_ns+0x31/0x60
      [ 1255.505916]  sysfs_unmerge_group+0x1d/0x60
      [ 1255.510498]  dpm_sysfs_remove+0x22/0x60
      [ 1255.514783]  device_del+0xf4/0x2e0
      [ 1255.518577]  ? device_remove_file+0x19/0x20
      [ 1255.523241]  attribute_container_class_device_del+0x1a/0x20
      [ 1255.529457]  transport_remove_classdev+0x4e/0x60
      [ 1255.534607]  ? transport_add_class_device+0x40/0x40
      [ 1255.540046]  attribute_container_device_trigger+0xb0/0xc0
      [ 1255.546069]  transport_remove_device+0x15/0x20
      [ 1255.551025]  scsi_target_reap_ref_release+0x25/0x40
      [ 1255.556467]  scsi_target_reap+0x2e/0x40
      [ 1255.560744]  __scsi_scan_target+0xaa/0x5b0
      [ 1255.565312]  scsi_scan_target+0xec/0x100
      [ 1255.569689]  fc_scsi_scan_rport+0xb1/0xc0 [scsi_transport_fc]
      [ 1255.576099]  process_one_work+0x14b/0x390
      [ 1255.580569]  worker_thread+0x4b/0x390
      [ 1255.584651]  kthread+0x109/0x140
      [ 1255.588251]  ? rescuer_thread+0x330/0x330
      [ 1255.592730]  ? kthread_park+0x60/0x60
      [ 1255.596815]  ret_from_fork+0x29/0x40
      [ 1255.600801] Code: 24 08 48 83 42 40 01 5b 41 5c 5d c3 66 66 66 2e 0f 1f 84 00 00 00 00 00 66 66 66 66 90
      [ 1255.621876] RIP: kernfs_find_ns+0x13/0xc0 RSP: ffffc900048abbf0
      [ 1255.628479] CR2: 0000000000000068
      [ 1255.632756] ---[ end trace 34a69ba0477d036f ]---
      
      Fix this by adding another scsi_target state STARGET_CREATED_REMOVE
      to distinguish this case.
      
      Fixes: f05795d3
      
       ("scsi: Add intermediate STARGET_REMOVE state to scsi_target_state")
      Reported-by: default avatarDavid Jeffery <djeffery@redhat.com>
      Signed-off-by: default avatarEwan D. Milne <emilne@redhat.com>
      Cc: <stable@vger.kernel.org>
      Reviewed-by: default avatarLaurence Oberman <loberman@redhat.com>
      Tested-by: default avatarLaurence Oberman <loberman@redhat.com>
      Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      f9279c96
  30. 13 Jun, 2017 2 commits
    • Bart Van Assche's avatar
      scsi: Make __scsi_remove_device go straight from BLOCKED to DEL · 255ee932
      Bart Van Assche authored
      
      If a device is blocked, make __scsi_remove_device() cause it to
      transition to the DEL state. This means that all the commands issued in
      .shutdown() will error in the mid-layer, thus making the removal proceed
      without being stopped.
      
      This patch is a slightly modified version of a patch from James
      Bottomley. This patch avoids that the following lockup occurs:
      
      Call Trace:
       schedule+0x35/0x80
       schedule_timeout+0x237/0x2d0
       io_schedule_timeout+0xa6/0x110
       wait_for_completion_io+0xa3/0x110
       blk_execute_rq+0xdf/0x120
       scsi_execute+0xce/0x150 [scsi_mod]
       scsi_execute_req_flags+0x8f/0xf0 [scsi_mod]
       sd_sync_cache+0xa9/0x190 [sd_mod]
       sd_shutdown+0x6a/0x100 [sd_mod]
       sd_remove+0x64/0xc0 [sd_mod]
       __device_release_driver+0x8d/0x120
       device_release_driver+0x1e/0x30
       bus_remove_device+0xf9/0x170
       device_del+0x127/0x240
       __scsi_remove_device+0xc1/0xd0 [scsi_mod]
       scsi_forget_host+0x57/0x60 [scsi_mod]
       scsi_remove_host+0x72/0x110 [scsi_mod]
       srp_remove_work+0x8b/0x200 [ib_srp]
      Reported-by: default avatarIsrael Rukshin <israelr@mellanox.com>
      Signed-off-by: default avatarBart Van Assche <bart.vanassche@sandisk.com>
      Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
      Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
      Cc: Israel Rukshin <israelr@mellanox.com>
      Cc: Max Gurtovoy <maxg@mellanox.com>
      Cc: Benjamin Block <bblock@linux.vnet.ibm.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      255ee932
    • Bart Van Assche's avatar
      scsi: Protect SCSI device state changes with a mutex · 0db6ca8a
      Bart Van Assche authored
      
      Serializing SCSI device state changes avoids that two state changes can
      occur concurrently, e.g. the state changes in scsi_target_block() and
      __scsi_remove_device(). This serialization is essential to make patch
      "Make __scsi_remove_device go straight from BLOCKED to DEL" work
      reliably.
      
      Enable this mechanism for all scsi_target_*block() callers but not for
      the scsi_internal_device_unblock() calls from the mpt3sas driver because
      that driver can call scsi_internal_device_unblock() from atomic context.
      Signed-off-by: default avatarBart Van Assche <bart.vanassche@sandisk.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.com>
      Cc: Johannes Thumshirn <jthumshirn@suse.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      0db6ca8a
  31. 14 Dec, 2016 1 commit
    • Wei Fang's avatar
      scsi: avoid a permanent stop of the scsi device's request queue · d2a14525
      Wei Fang authored
      
      A race between scanning and fc_remote_port_delete() may result in a
      permanent stop if the device gets blocked before scsi_sysfs_add_sdev()
      and unblocked after.  The reason is that blocking a device sets both the
      SDEV_BLOCKED state and the QUEUE_FLAG_STOPPED.  However,
      scsi_sysfs_add_sdev() unconditionally sets SDEV_RUNNING which causes the
      device to be ignored by scsi_target_unblock() and thus never have its
      QUEUE_FLAG_STOPPED cleared leading to a device which is apparently
      running but has a stopped queue.
      
      We actually have two places where SDEV_RUNNING is set: once in
      scsi_add_lun() which respects the blocked flag and once in
      scsi_sysfs_add_sdev() which doesn't.  Since the second set is entirely
      spurious, simply remove it to fix the problem.
      
      Cc: <stable@vger.kernel.org>
      Reported-by: default avatarZengxi Chen <chenzengxi@huawei.com>
      Signed-off-by: default avatarWei Fang <fangwei1@huawei.com>
      Reviewed-by: default avatarEwan D. Milne <emilne@redhat.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      d2a14525
  32. 15 Apr, 2016 2 commits
  33. 11 Apr, 2016 1 commit