Skip to content

Commit

Permalink
Merge pull request #686 from gbregman/devel
Browse files Browse the repository at this point in the history
Use size in MiBs, not bytes, in namespace_resize gRRPC call
  • Loading branch information
gbregman authored May 28, 2024
2 parents d0f45d7 + 7c624c3 commit fb843d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
3 changes: 2 additions & 1 deletion control/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,7 @@ def ns_resize(self, args):
mib = 1024 * 1024
if ns_size % mib:
self.cli.parser.error("size value must be aligned to MiBs")
ns_size //= mib

try:
ret = self.stub.namespace_resize(pb2.namespace_resize_req(subsystem_nqn=args.subsystem, nsid=args.nsid,
Expand All @@ -1396,7 +1397,7 @@ def ns_resize(self, args):
ns_id_str = f"with UUID {args.uuid}"
else:
assert False
sz_str = self.format_size(ns_size)
sz_str = self.format_size(ns_size * mib)
out_func(f"Resizing namespace {ns_id_str} in {args.subsystem} to {sz_str}: Successful")
else:
err_func(f"{ret.error_message}")
Expand Down
11 changes: 3 additions & 8 deletions control/grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def create_bdev(self, anagrp: int, name, uuid, rbd_pool_name, rbd_image_name, bl
def resize_bdev(self, bdev_name, new_size, peer_msg = ""):
"""Resizes a bdev."""

self.logger.info(f"Received request to resize bdev {bdev_name} to {new_size} bytes{peer_msg}")
self.logger.info(f"Received request to resize bdev {bdev_name} to {new_size} MiB{peer_msg}")
rbd_pool_name = None
rbd_image_name = None
bdev_info = self.get_bdev_info(bdev_name, True)
Expand All @@ -372,16 +372,15 @@ def resize_bdev(self, bdev_name, new_size, peer_msg = ""):
if rbd_pool_name and rbd_image_name:
try:
current_size = self.ceph_utils.get_image_size(rbd_pool_name, rbd_image_name)
if current_size > new_size:
if current_size > new_size * 1024 * 1024:
return pb2.req_status(status=errno.EINVAL,
error_message=f"new size {new_size} bytes is smaller than current size {current_size} bytes")
error_message=f"new size {new_size * 1024 * 1024} bytes is smaller than current size {current_size} bytes")
except Exception as ex:
self.logger.warning(f"Error trying to get the size of image {rbd_pool_name}/{rbd_image_name}, won't check size for shrinkage:\n{ex}")
pass

with self.rpc_lock:
try:
new_size //= (1024 * 1024) # spdk wants the size in MiBs
ret = rpc_bdev.bdev_rbd_resize(
self.spdk_rpc_client,
name=bdev_name,
Expand Down Expand Up @@ -1573,10 +1572,6 @@ def namespace_resize(self, request, context=None):
return pb2.req_status(status=errno.EINVAL,
error_message=f"Failure resizing namespace {nsid_msg}on {request.subsystem_nqn}: New size must be positive")

if request.new_size % (1024 * 1024):
return pb2.req_status(status=errno.EINVAL,
error_message=f"Failure resizing namespace {nsid_msg}on {request.subsystem_nqn}: new size must be aligned to MiBs")

find_ret = self.find_namespace_and_bdev_name(request.subsystem_nqn, request.nsid, request.uuid, True, "Failure resizing namespace")
if not find_ret[0]:
errmsg = f"Failure resizing namespace {nsid_msg}on {request.subsystem_nqn}: Can't find namespace"
Expand Down

0 comments on commit fb843d9

Please sign in to comment.