]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/volumes: prevent negative subvolume size
authorJos Collin <jcollin@redhat.com>
Sun, 1 Sep 2019 16:07:21 +0000 (21:37 +0530)
committerRamana Raja <rraja@redhat.com>
Fri, 20 Sep 2019 09:36:24 +0000 (15:06 +0530)
Fixes: https://tracker.ceph.com/issues/41617
Signed-off-by: Jos Collin <jcollin@redhat.com>
(cherry picked from commit 8a1249626b56f345e20f1a7058aa70da9fb82576)

src/pybind/mgr/volumes/fs/subvolume.py

index 4789bd1338160d3c150a543c6e825dae2866b8da..ed3314ac5257c82c417993d651e438562842ddae 100644 (file)
@@ -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)