mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 06:10:22 +00:00
rbd: use rbdVolume.open() for metadata operations
Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
7a18e68a6e
commit
63c458bd63
@ -1007,14 +1007,9 @@ func resizeRBDImage(rbdVol *rbdVolume, cr *util.Credentials) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (rv *rbdVolume) GetMetadata(key string) (string, error) {
|
func (rv *rbdVolume) GetMetadata(key string) (string, error) {
|
||||||
ioctx, err := rv.conn.GetIoctx(rv.Pool)
|
image, err := rv.open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.Wrapf(err, "failed to get ioctx for %q", rv.RbdImageName)
|
return "", err
|
||||||
}
|
|
||||||
|
|
||||||
image, err := librbd.OpenImage(ioctx, rv.RbdImageName, librbd.NoSnapshot)
|
|
||||||
if err != nil {
|
|
||||||
return "", errors.Wrapf(err, "could not open image %q", rv.RbdImageName)
|
|
||||||
}
|
}
|
||||||
defer image.Close()
|
defer image.Close()
|
||||||
|
|
||||||
@ -1022,14 +1017,9 @@ func (rv *rbdVolume) GetMetadata(key string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (rv *rbdVolume) SetMetadata(key, value string) error {
|
func (rv *rbdVolume) SetMetadata(key, value string) error {
|
||||||
ioctx, err := rv.conn.GetIoctx(rv.Pool)
|
image, err := rv.open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "failed to get ioctx for %q", rv.RbdImageName)
|
return err
|
||||||
}
|
|
||||||
|
|
||||||
image, err := librbd.OpenImage(ioctx, rv.RbdImageName, librbd.NoSnapshot)
|
|
||||||
if err != nil {
|
|
||||||
return errors.Wrapf(err, "could not open image %q", rv.RbdImageName)
|
|
||||||
}
|
}
|
||||||
defer image.Close()
|
defer image.Close()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user