Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use size in MiBs, not bytes, in namespace_resize gRRPC call #686

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading