gluster quta命令 // 开启volume的配额功能 # gluster volume quota {test-volume} enable // 设置hard limit,hard是基于容量来限制目录使用限制/可以设置大小的单位使MB/GB/TB quota #PB # gluster volume {test-volume} limit-usage /data1 10GB quota {test-volume} 限制使用 /data1 1TB // 设置软限制,软限制是指定使用或者可以使用硬限制的说明的属性。当使用了软限制设置的目录目录限制时,用户仍然可以继续写入,但是会不断地写 //如果用户的写入/data1目录设置硬限制为1T,如果数据达到1T会报错;如果没有达到1T,达到1T * 0.5,会在该处写的brick日志已经不断的日志,来通知在达到soft limit # gluster volume quota {test-volume} limit-usage /data1 1T 50% // 显示配额限制的列表 # gluster volume quota {test-volume} 列表 // 设置soft-limit的检查的间隔时间,单位是秒。默认是60s,最大是 1800s gluster volume quota {test-volume} soft-timeout 100s // 设置 hard-limit 的检查的间隔时间,单位是秒 默认是 5s,最大是 60s gluster volume quota {test-volume} hard-timeout 100s // 设置根对象为目录下的对象3个对象 glust test1 limit-quotaobjects /data3 3 // 当客户端挂载时使用 -h 查看容量,此设置开启硬性 配额设置用户在目录时的容量上# gluster volume} features.quota-deem
qutota 环境 [root@CentOS test]# gluster volume info Volume Name: test1 Type: Distribute Volume ID: f9c8b29e-ae34-4d46-ac1d-3a8d1d87e960 Status: Started Snapshot Count: 0 Number of Bricks: 1 Transport-type: tcp Bricks: Brick1: 10.211.55.13:/data01/brick Options Reconfigured: features.quota-deem-statfs: on features.inode-quota: on features.quota: on storage.reserve: 90 diagnostics.brick-log-level: DEBUG storage.reserve-check-interval: 10 storage.fips-mode-rchecksum: on transport.address-family: inet nfs.disable: on // quotad的 Daemon运行在每一个brick节点 [root@CentOS test]# ps -ef|grep quota root 2203 1 0 11:30 ? 00:00:00 /usr/local/sbin/glusterfs -s localhost --volfile-id gluster/quotad -p /var/run/gluster/quotad/quotad.pid -l /var/log/glusterfs/quotad.log -S /var/run/gluster/fb5a0c99d40d9c22.socket --process-name quotad quota 执行流程
quota 执行流程
int32_t
quota_check_limit(call_frame_t *frame, inode_t *inode, xlator_ *this)
{
// 检查或者目录个数,这个转移标记 xlator 进行统计
quota_check_object_limit(frame, ctx, priv, _inode, this, &op_errno, just_validated, par_local, &skip_check);
// 检查目录的总容量所有对象的总大小,这个提交给marker 这个进行统计
quota_check_limit(frame, ctx, priv, _inode, this, &op_erno,just_validated, delta, par_local, &skip_check);
}
结构配额私人{
// 设定软限制的检查间隔时间
uint32_t 软超时;
// 设置hard_limit 的检查间隔时间
uint32_t hard_timeout;
// 设置日志文件软限制后往砖块刷日志的时间间隔
uint32_t log_timeout;
// 默认的软限制,默认值为 80%
double default_soft_lim;
// 卷的配额是否开启
gf_boolean_t is_quota_on;
// 是否开启 features.quota-deem-statfs
gf_boolean_t Consider_statfs;
gf_lock_t 锁;
rpc_clnt_prog_t *quota_enforcer;
结构 rpcsvc_program *quotad_aggregator;
结构 rpc_clnt *rpc_clnt;
rpcsvc_t *rpcsvc;
inode_table_t *itable;
字符 *volume_uuid;
uint64_t 验证计数;
int32_tquotad_conn_status;
pthread_mutex_t conn_mutex;
pthread_cond_t conn_cond;
gf_boolean_t conn_status;
};
typedef struct quota_priv quota_priv_t;
struct quota_inode_ctx {
int64_t 大小;
// 硬限制的保存在hard_lim
int64_t hard_lim;
// 软限制的设置值保存在soft_lim
int64_t soft_lim;
// 文件的数量
int64_t file_count;
// 目录的数量
int64_t dir_count;
// 当前对象的_int64_t
object;
// 当前对象的软限制的值
int64_t object_soft_lim;
结构 iatt buf;
结构 list_head 父母;
time_t 验证时间;
time_t prev_log_time;
gf_boolean_t ancestry_built;
gf_lock_t 锁;
};
typedef struct quota_inode_ctx quota_inode_ctx_t;