]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: accept human readable values for quotas
authordparmar18 <dparmar@redhat.com>
Tue, 13 Dec 2022 11:40:34 +0000 (17:10 +0530)
committerDhairya Parmar <dparmar@redhat.com>
Fri, 8 Sep 2023 10:44:56 +0000 (16:14 +0530)
Quotas are set in bytes for cephfs subvolumes.
This could be simpler if done in a human readable
size like K/Ki, M/Mi, G/Gi or T/Ti

Fixes: https://tracker.ceph.com/issues/55940
Signed-off-by: dparmar18 <dparmar@redhat.com>
(cherry picked from commit 2d43fede1e1322523ec0029960d9ebf70a8f8e84)

src/mds/Server.cc

index bf12cb7e2c8fa9f24be9f6eae1b330aa829351cb..25bf3afd2d80850eb3f35d4ae03d3179087693b5 100644 (file)
@@ -5865,9 +5865,13 @@ int Server::parse_quota_vxattr(string name, string value, quota_info_t *quota)
           return r;
       }
     } else if (name == "quota.max_bytes") {
-      int64_t q = boost::lexical_cast<int64_t>(value);
-      if (q < 0)
+      string cast_err;
+      int64_t q = strict_iec_cast<int64_t>(value, &cast_err);
+      if(!cast_err.empty()) {
+        dout(10) << __func__ << ":  failed to parse quota.max_bytes: "
+        << cast_err << dendl;
         return -CEPHFS_EINVAL;
+      }
       quota->max_bytes = q;
     } else if (name == "quota.max_files") {
       int64_t q = boost::lexical_cast<int64_t>(value);