From 8a1249626b56f345e20f1a7058aa70da9fb82576 Mon Sep 17 00:00:00 2001 From: Jos Collin Date: Sun, 1 Sep 2019 21:37:21 +0530 Subject: [PATCH] mgr/volumes: prevent negative subvolume size Fixes: https://tracker.ceph.com/issues/41617 Signed-off-by: Jos Collin --- src/pybind/mgr/volumes/fs/subvolume.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/volumes/fs/subvolume.py b/src/pybind/mgr/volumes/fs/subvolume.py index 4789bd1338160..ed3314ac5257c 100644 --- a/src/pybind/mgr/volumes/fs/subvolume.py +++ b/src/pybind/mgr/volumes/fs/subvolume.py @@ -77,8 +77,10 @@ class SubVolume(object): try: if size is not None: - self.fs.setxattr(subvolpath, 'ceph.quota.max_bytes', str(size).encode('utf-8'), 0) - + try: + self.fs.setxattr(subvolpath, 'ceph.quota.max_bytes', str(size).encode('utf-8'), 0) + except cephfs.InvalidValue as e: + raise VolumeException(-errno.EINVAL, "Invalid size: '{0}'".format(size)) if pool: try: self.fs.setxattr(subvolpath, 'ceph.dir.layout.pool', pool.encode('utf-8'), 0) -- 2.39.5