Skip to content

Commit

Permalink
free the cluster cluster context if no longer used by any bdev
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Indenbaum <[email protected]>
  • Loading branch information
Alexander Indenbaum committed Feb 18, 2024
1 parent 4f5e2e7 commit dd09294
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion control/grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,30 @@ def _put_cluster(self, name: str) -> None:
if name in self.clusters[anagrp]:
self.clusters[anagrp][name] -= 1
assert self.clusters[anagrp][name] >= 0
# free the cluster cluster context if no longer used by any bdev
if self.clusters[anagrp][name] == 0:
ret = rpc_bdev.bdev_rbd_unregister_cluster(
self.spdk_rpc_client,
name = name
)
self.logger.info(f"Free cluster {name=} {ret=}")
assert ret
self.clusters[anagrp].pop(name)
return
assert False # we should find the cluster in our state

def _alloc_cluster_name(self, anagrp: int) -> str:
"""Allocates a new cluster name for ana group"""
x = 0
while True:
name = f"cluster_context_{anagrp}_{x}"
if name not in self.clusters[anagrp]:
return name
x += 1

def _alloc_cluster(self, anagrp: int) -> str:
"""Allocates a new Rados cluster context"""
name = f"cluster_context_{anagrp}_{len(self.clusters[anagrp])}"
name = self._alloc_cluster_name(anagrp)
nonce = rpc_bdev.bdev_rbd_register_cluster(
self.spdk_rpc_client,
name = name,
Expand Down

0 comments on commit dd09294

Please sign in to comment.