mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +00:00
rbd: prevent re-use of destroyed resources
When an `.Destroy()` is called on an rbdImage (or rbdVolume or rbdSnapshot), the IOContext, Connection and other attributes are invalid. When using a destroyed resource that points to an object that was allocated through librbd, the process most likely ends with a panic. Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
parent
f1379e4cc4
commit
8c252d58ea
@ -390,15 +390,19 @@ func (ri *rbdImage) Connect(cr *util.Credentials) error {
|
|||||||
func (ri *rbdImage) Destroy(ctx context.Context) {
|
func (ri *rbdImage) Destroy(ctx context.Context) {
|
||||||
if ri.ioctx != nil {
|
if ri.ioctx != nil {
|
||||||
ri.ioctx.Destroy()
|
ri.ioctx.Destroy()
|
||||||
|
ri.ioctx = nil
|
||||||
}
|
}
|
||||||
if ri.conn != nil {
|
if ri.conn != nil {
|
||||||
ri.conn.Destroy()
|
ri.conn.Destroy()
|
||||||
|
ri.conn = nil
|
||||||
}
|
}
|
||||||
if ri.isBlockEncrypted() {
|
if ri.isBlockEncrypted() {
|
||||||
ri.blockEncryption.Destroy()
|
ri.blockEncryption.Destroy()
|
||||||
|
ri.blockEncryption = nil
|
||||||
}
|
}
|
||||||
if ri.isFileEncrypted() {
|
if ri.isFileEncrypted() {
|
||||||
ri.fileEncryption.Destroy()
|
ri.fileEncryption.Destroy()
|
||||||
|
ri.fileEncryption = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user