Skip to content

Commit b6958cd

Browse files
committed
Support xfs default quota
1 parent 0ff3cc3 commit b6958cd

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/index.mjs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ const {
6868
configUpdatePassword,
6969
configLinger,
7070
configUserDiskQuota,
71-
xfsDefaultDiskUserQuota,
7271
} = parseConfig(config);
7372
console.timeLog("parseConfig");
7473

@@ -99,9 +98,6 @@ console.time("getDiskQuota");
9998
const diskQuota = await getDiskQuota(diskQuotaPaths);
10099
console.timeLog("getDiskQuota");
101100

102-
// TODO: implement setting xfs default quota
103-
console.log(xfsDefaultDiskUserQuota['/var/lib/cluster'])
104-
105101
// =====================================================
106102
// Calculate changes
107103
// =====================================================

src/utils.mjs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,17 @@ export function parseConfig(config) {
115115
// convert to object of the form { <uid>: { ...quotaConfig } }
116116
(v) => Object.fromEntries(v.map((x) => [x[1], x[2]]))
117117
);
118-
const xfsDefaultDiskUserQuota = Object.fromEntries(config.xfs_default_user_quota.map(normalizeDiskQuota).map((d) => {
119-
const { path, ...quotaConfig } = d
120-
return [path, quotaConfig];
121-
}));
118+
// XFS disk quota is implemented as a quota on the root user. The root user is not constrained by quotas.
119+
for (const quota of config.xfs_default_user_quota) {
120+
const { path, ...quotaConfig } = normalizeDiskQuota(quota);
121+
if (!(path in configUserDiskQuota)) {
122+
configUserDiskQuota[path] = {};
123+
}
124+
if ('0' in configUserDiskQuota[path]) {
125+
throw new ValueError(`The root user (uid 0) already has a configured quota for path ${path}! This is the same as setting the xfs_default_user_quota property.`)
126+
}
127+
configUserDiskQuota[path]['0'] = quotaConfig;
128+
}
122129

123130
const configUsers = config.users.reduce((out, u) => {
124131
const {
@@ -145,7 +152,6 @@ export function parseConfig(config) {
145152
configUpdatePassword,
146153
configLinger,
147154
configUserDiskQuota,
148-
xfsDefaultDiskUserQuota,
149155
};
150156
}
151157

0 commit comments

Comments
 (0)