暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

聊聊Lustre Quota

166


作者时间QQ技术交流群
perrynzhou@gmail.com2023/02/29672152841



Quota
设计思路




  • lustre整体分为master
    slave
    ,其中master
    是负责全局的quota
    分配和追踪运行在MDT上;slave
    负责后端mdt
    ost
    后端文件系统的hard quota
    的统计和上报,运行在MDT和所有的OST上。


Quota
设置核心链路

  • Quota Master





// 这个qmt_hdls定义了quota的请求处理函数
struct qmt_handlers qmt_hdls = {
/* quota request handlers */
.qmth_quotactl = qmt_quotactl,
.qmth_dqacq = qmt_dqacq,
/******忽略******/
};

  • Quota Slave







// quota slave端的核心数据结构
struct qsd_instance;

// slave端的核心函数
struct qsd_instance *qsd_init(const struct lu_env *, char *, struct dt_device *,struct proc_dir_entry *, bool is_md, bool excl);
int qsd_prepare(const struct lu_env *, struct qsd_instance *);
int qsd_start(const struct lu_env *, struct qsd_instance *);
void qsd_fini(const struct lu_env *, struct qsd_instance *);
int qsd_op_begin(const struct lu_env *, struct qsd_instance *,
struct lquota_trans *, struct lquota_id_info *,
enum osd_quota_local_flags *);
void qsd_op_end(const struct lu_env *, struct qsd_instance *,
struct lquota_trans *);
void qsd_op_adjust(const struct lu_env *, struct qsd_instance *,
union lquota_id *, int);
int qsd_transfer(const struct lu_env *env, struct qsd_instance *qsd,
struct lquota_trans *trans, unsigned int qtype,
u64 orig_id, u64 new_id, u64 bspace,
struct lquota_id_info *qi);


Lustre quota
设置





quota
启用

  • quota
    取值范围


// osd-ldiskfs.{fsname}-OST{index}.quota_slave.enabled取值范围
// 参数必须在mgs端进行设置

* u - 仅对⽤户启⽤强制配额
* g - 仅对组启⽤强制配额
* p - 仅对项⽬启⽤强制配额
* ugp - 启⽤所有⽤户、组和项⽬的强制配额
* none - 禁⽤所有⽤户、组和项⽬的强制配额。

  • MDT
    端启用inode
    限制


// 查看quota参数
[root@CentOS-Lustre-MDS ~]$ lctl list_param *.*.*.* |grep quota|grep -v dt|grep -v md|grep enable
osd-ldiskfs.bigfs-MDT0000.quota_slave.enabled

// 查看默认的mdt上的quota限制
[root@CentOS-Lustre-MDS ~]$ lctl get_param osd-ldiskfs.bigfs-MDT0000.quota_slave.enabled
osd-ldiskfs.bigfs-MDT0000.quota_slave.enabled=none

// 查看启用后的参数值
[root@CentOS-Lustre-MDS ~]$ lctl conf_param bigfs.quota.mdt=ugp
[root@CentOS-Lustre-MDS ~]$ sync
[root@CentOS-Lustre-MDS ~]$ lctl get_param osd-ldiskfs.bigfs-MDT0000.quota_slave.enabled
osd-ldiskfs.bigfs-MDT0000.quota_slave.enabled=ugp
  • OST


// 查看ost端的quota
[root@CentOS-Lustre-OSS ~]$ lctl get_param osd-ldiskfs.bigfs-OST*.quota_slave.enabled
osd-ldiskfs.bigfs-OST0001.quota_slave.enabled=none
osd-ldiskfs.bigfs-OST0002.quota_slave.enabled=none


// 在mgs端启用quota
[root@CentOS-Lustre-MDS ~]$ lctl conf_param bigfs.quota.ost=ugp
[root@CentOS-Lustre-MDS ~]$ sync

// 查看启用后的参数值
[root@CentOS-Lustre-OSS ~]$ lctl get_param osd-ldiskfs.bigfs-OST*.quota_slave.enabled
osd-ldiskfs.bigfs-OST0001.quota_slave.enabled=ugp
osd-ldiskfs.bigfs-OST0002.quota_slave.enabled=ugp


Quota
设置

  • 设置quota


// 设置语法
// lfs setquota {-u|--user|-g|--group|-p|--project} username|groupname [-b block-softlimit] [-B block_hardlimit] [-i inode_softlimit] 5 [-I inode_hardlimit] mount_point

// 设置示例
// 说明: perrynzhou在整个/bigfs空间内,用户在MDT端inode的软限制(-i 10000)是10000,硬限制(-I 11000)是11000;在OST上限制的Block软限制是307200个,硬限制是309200个
[root@centos-lustre-client ~]$ lfs setquota -u perrynzhou -b 307200 -B 309200 -i 10000 -I 11000 bigfs

// 单个目录设置quota
lfs project -s -p 1 -r bigfs/quota_dir2
lfs setquota -p 1 -b 42800 -B 42800 -i 409600 -I 409600 bigfs

  • 清除quota


// 语法规则:lctl conf_param fsname.quota.ost|mdt=u|g|p|ugp|none


// mdt管理的是inode配额
// ost管理的是块配额
$ lctl conf_param bigfs.quota.ost=ugp
$ lctl conf_param bigfs.quota.mdt=ugp


// 这里会清除整个文件系统的quota信息
[root@CentOS-Lustre-MDS ~]$ lctl conf_param bigfs.quota.ost=none
[root@CentOS-Lustre-MDS ~]$ lctl conf_param bigfs.quota.mdt=none


Quota
查看


[root@CentOS-Lustre-MDS ~]$ lctl get_param osd-*.*.quota_slave.limit*
osd-ldiskfs.bigfs-MDT0000.quota_slave.limit_group=
global_index_copy:
- id: 0
limits: { hard: 0, soft: 0, granted: 0, time: 604800 }
osd-ldiskfs.bigfs-MDT0000.quota_slave.limit_project=
global_index_copy:
- id: 0
limits: { hard: 0, soft: 0, granted: 0, time: 604800 }
- id: 1
limits: { hard: 409600, soft: 409600, granted: 0, time: 0 }
osd-ldiskfs.bigfs-MDT0000.quota_slave.limit_user=
global_index_copy:
- id: 0
limits: { hard: 0, soft: 0, granted: 0, time: 604800 }
- id: 1000
limits: { hard: 22000, soft: 20000, granted: 0, time: 0 }


文章转载自存储内核技术交流,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论