configured there. If they are not present then no quota is set on that
directory (although one may still be configured on a parent directory).
+The value of ``ceph.quota.max_bytes`` must be aligned to 4MB if greater
+than or equal to 4MB, otherwise it must be aligned to 4KB.
+
To set a quota, set the extended attribute on a CephFS directory with a
value::
- setfattr -n ceph.quota.max_bytes -v 100000000 /some/dir # 100 MB
+ setfattr -n ceph.quota.max_bytes -v 104857600 /some/dir # 100 MB
setfattr -n ceph.quota.max_files -v 10000 /some/dir # 10,000 files
``ceph.quota.max_bytes`` can also be set using human-friendly units::
$ getfattr -n ceph.quota.max_bytes /some/dir
# file: dir1/
- ceph.quota.max_bytes="100000000"
+ ceph.quota.max_bytes="104857600"
$
$ getfattr -n ceph.quota.max_files /some/dir
# file: dir1/
#define CEPH_FS_ONDISK_MAGIC "ceph fs volume v011"
#define MAX_MDS 0x100
+#define CEPH_4M_BLOCK_SHIFT 22
+#define CEPH_4M_BLOCK_SIZE (1 << CEPH_4M_BLOCK_SHIFT) // 4MB
+#define CEPH_4K_BLOCK_SHIFT 12
+#define CEPH_4K_BLOCK_SIZE (1 << CEPH_4K_BLOCK_SHIFT) // 4KB
+
+#define IS_ALIGNED(x, a) (((x) & (int64_t(a) - 1)) == 0)
+
BOOST_STRONG_TYPEDEF(uint64_t, mds_gid_t)
extern const mds_gid_t MDS_GID_NONE;
return r;
}
} else if (name == "quota.max_bytes") {
+ /*
+ * The "quota.max_bytes" must be aligned to 4MB if greater than or
+ * equal to 4MB, otherwise must be aligned to 4KB.
+ */
string cast_err;
int64_t q = strict_iec_cast<int64_t>(value, &cast_err);
- if(!cast_err.empty()) {
+ if(!cast_err.empty() ||
+ (!IS_ALIGNED(q, CEPH_4M_BLOCK_SIZE) &&
+ (q < CEPH_4M_BLOCK_SIZE && !IS_ALIGNED(q, CEPH_4K_BLOCK_SIZE)))) {
dout(10) << __func__ << ": failed to parse quota.max_bytes: "
- << cast_err << dendl;
+ << cast_err << dendl;
return -CEPHFS_EINVAL;
}
quota->max_bytes = q;