The following patches were made over Linus tree. The patches fix 3 issues: 1. If a user performs LIO LUN unmapping before the endpoint has been cleared then we can end up trying to free a bogus tmf struct if the TMF is still exucuting when we do the unmap. 2. If vhost_scsi_setup_vq_cmds fails we can leave the tpg->vhost_scsi pointer set and we can end up trying to access a freed struct. 3. Management operations like LUN mapping/unmapping and device addition hang for 30 seconds or up to N minutes depending on the device. The problem is that we use a global mutex to protect the list of tpgs and for accessing the tpg, and to make sure they are flushed. We then hold that mutex during a lot of management operations. So if you are just trying to add another device, it will have to wait on another device if we are in the middle of clearing it's endpoint and it's waiting on hung IO. This patchset fixes up the ordering of how we flush IO and release refcounts and how often the global mutex is used so we don't need to always hold it v2: 1. Added fix for possible use after free and merge with a locking cleanup patch. 2. Added fix for LIO LUN unmap during TMF execution bug. 3. Fixed bug where we needed to hold the tpg mutex instead of the vhost_scsi_mutex when calling vhost_scsi_do_plug.