cephfs: snapshots honor --setmetadata option

`--setmetadata` is false by default, honoring it
will keep the metadata disabled by default

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
This commit is contained in:
Prasanna Kumar Kalever
2022-07-28 17:56:55 +05:30
committed by mergify[bot]
parent 14d6211d6d
commit 30244bf11b
6 changed files with 35 additions and 32 deletions

View File

@ -91,6 +91,10 @@ func (s *snapshotClient) removeSnapshotMetadata(key string) error {
// SetAllSnapshotMetadata set all the metadata from arg parameters on
// subvolume snapshot.
func (s *snapshotClient) SetAllSnapshotMetadata(parameters map[string]string) error {
if !s.enableMetadata {
return nil
}
for k, v := range parameters {
err := s.setSnapshotMetadata(k, v)
if err != nil {
@ -113,6 +117,10 @@ func (s *snapshotClient) SetAllSnapshotMetadata(parameters map[string]string) er
// UnsetAllSnapshotMetadata unset all the metadata from arg keys on subvolume
// snapshot.
func (s *snapshotClient) UnsetAllSnapshotMetadata(keys []string) error {
if !s.enableMetadata {
return nil
}
for _, key := range keys {
err := s.removeSnapshotMetadata(key)
// TODO: replace string comparison with errno.