CA-83745: work-around a race between SR.create and PBD.plug by making PBD.plug more robust
CA-83745: work-around a race between SR.create and PBD.plug by making PBD.plug more robust

The following interleaving appears to be possible:

XenAPI SR.create
  creates PBD
  adds SR to hashtable
  calls SMAPI sr_create
                                          XenAPI PBD.plug
                                            adds SR to hashtable
                                            sets currently_attached to true
  removes SR from hashtable
  calls XenAPI PBD.plug
    no-op since currently_attached = true

-- at this point a PBD is currently_attached = true but the SR is nolonger in the hashtable.

This race window always existed but it has recently been enlarged.

We work around this by unconditionally adding the SR to the hashtable in PBD.plug
irrespective of the value of currently_attached. Since SR.create always ends with
a call to PBD.plug, we gain the property that when the SR.create has finished
the SR must be in the hashtable.

Signed-off-by: David Scott <63c9eb0ea83039690fefa11afe17873ba8278a56@eu.citrix.com>

koushikcgit/xen-api,euanh/xen-api,djs55/xen-api,guard163/xen-api,thomassa/xen-api,salvocambria/xen-api,ravippandey/xen-api,guard163/xen-api,euanh/xen-api,ravippandey/xen-api,jjd27/xen-api,huizh/xen-api,rafalmiel/xen-api,srowe/xen-api,guard163/xen-api,simonjbeaumont/xen-api,cheng--zhang/xen-api,guard163/xen-api,koushikcgit/xen-api,salvocambria/xen-api,robertbreker/xen-api,cheng--zhang/xen-api,thomassa/xen-api,cheng-z/xen-api,thomassa/xen-api,ravippandey/xen-api,agimofcarmen/xen-api,jjd27/xen-api,vasilenkomike/xen-api,rafalmiel/xen-api,vasilenkomike/xen-api,rafalmiel/xen-api,jjd27/xen-api,huizh/xen-api,salvocambria/xen-api,srowe/xen-api,srowe/xen-api,euanh/xen-api,cheng--zhang/xen-api,anoobs/xen-api,rafalmiel/xen-api,cheng-z/xen-api,agimofcarmen/xen-api,rafalmiel/xen-api,thomassa/xen-api,Frezzle/xen-api,agimofcarmen/xen-api,djs55/xen-api,agimofcarmen/xen-api,guard163/xen-api,koushikcgit/xen-api,robertbreker/xen-api,vasilenkomike/xen-api,cheng--zhang/xen-api,koushikcgit/xen-api,koushikcgit/xen-api,robertbreker/xen-api,cheng-z/xen-api,jjd27/xen-api,djs55/xen-api,cheng--zhang/xen-api,euanh/xen-api,anoobs/xen-api,srowe/xen-api,Frezzle/xen-api,cheng-z/xen-api,simonjbeaumont/xen-api,guard163/xen-api,anoobs/xen-api,robertbreker/xen-api,cheng-z/xen-api,huizh/xen-api,Frezzle/xen-api,cheng--zhang/xen-api,Frezzle/xen-api,jjd27/xen-api,huizh/xen-api,salvocambria/xen-api,vasilenkomike/xen-api,vasilenkomike/xen-api,jjd27/xen-api,ravippandey/xen-api,cheng-z/xen-api,simonjbeaumont/xen-api,srowe/xen-api,huizh/xen-api,simonjbeaumont/xen-api,huizh/xen-api,ravippandey/xen-api,djs55/xen-api,anoobs/xen-api,anoobs/xen-api,djs55/xen-api,thomassa/xen-api,euanh/xen-api,agimofcarmen/xen-api,ravippandey/xen-api,djs55/xen-api,salvocambria/xen-api,simonjbeaumont/xen-api,thomassa/xen-api,euanh/xen-api,agimofcarmen/xen-api,Frezzle/xen-api,robertbreker/xen-api,cheng--zhang/xen-api,robertbreker/xen-api,cheng-z/xen-api,rafalmiel/xen-api,salvocambria/xen-api,simonjbeaumont/xen-api,vasilenkomike/xen-api,anoobs/xen-api,koushikcgit/xen-api