Skip to content

Commit

Permalink
Unlock OMAP on exit.
Browse files Browse the repository at this point in the history
Fixes #598

Signed-off-by: Gil Bregman <[email protected]>
  • Loading branch information
gbregman committed Aug 29, 2024
1 parent 2d77886 commit bbd9e4b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 4 additions & 3 deletions control/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def __init__(self, config: GatewayConfig):
self.group_id = 0
self.monitor_client = '/usr/bin/ceph-nvmeof-monitor-client'
self.omap_state = None
self.omap_lock = None

self.name = self.config.get("gateway", "name")
if not self.name:
Expand Down Expand Up @@ -120,7 +121,7 @@ def __exit__(self, exc_type, exc_value, traceback):
self._stop_discovery()

if self.omap_state:
self.omap_state.cleanup_omap()
self.omap_state.cleanup_omap(self.omap_lock)
self.omap_state = None

if logger:
Expand Down Expand Up @@ -172,8 +173,8 @@ def serve(self):

# Register service implementation with server
gateway_state = GatewayStateHandler(self.config, local_state, omap_state, self.gateway_rpc_caller, f"gateway-{self.name}")
omap_lock = OmapLock(omap_state, gateway_state, self.rpc_lock)
self.gateway_rpc = GatewayService(self.config, gateway_state, self.rpc_lock, omap_lock, self.group_id, self.spdk_rpc_client, self.ceph_utils)
self.omap_lock = OmapLock(omap_state, gateway_state, self.rpc_lock)
self.gateway_rpc = GatewayService(self.config, gateway_state, self.rpc_lock, self.omap_lock, self.group_id, self.spdk_rpc_client, self.ceph_utils)
self.server = self._grpc_server(self._gateway_address())
pb2_grpc.add_GatewayServicer_to_server(self.gateway_rpc, self.server)

Expand Down
7 changes: 6 additions & 1 deletion control/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ def _watcher_callback(notify_id, notifier_id, watch_id, data):
else:
self.logger.info(f"Watch already exists.")

def cleanup_omap(self):
def cleanup_omap(self, omap_lock = None):
self.logger.info(f"Cleanup OMAP on exit ({self.id_text})")
if self.watch:
try:
Expand All @@ -552,6 +552,11 @@ def cleanup_omap(self):
self.watch = None
except Exception:
pass
if omap_lock and omap_lock.omap_file_lock_duration > 0:
try:
omap_lock.unlock_omap()
except Exceprion:
pass
if self.ioctx:
try:
self.ioctx.close()
Expand Down

0 comments on commit bbd9e4b

Please sign in to comment.