]> git.ipfire.org Git - thirdparty/systemd.git/commit
core: add quota support for State, Cache, and Log exec directories (#35892)
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 8 Jul 2025 00:18:20 +0000 (09:18 +0900)
committerGitHub <noreply@github.com>
Tue, 8 Jul 2025 00:18:20 +0000 (09:18 +0900)
commit3ef791876b9c3562706cdef2105c1e152c35a210
tree759151a9e3d03e83232eb404d86797eebd4adc2b
parentef6b6f31c7007dbe8092b124052fa41947c83d1d
parentc777c05125c0dc7cc07206ea130079c33f92602f
core: add quota support for State, Cache, and Log exec directories (#35892)

Based on https://github.com/systemd/systemd/issues/7820, this adds support for
quota enforcement to State, Cache, and Log exec directories.
* Add new directives, StateDirectoryQuota=, CacheDirectoryQuota=, and
  LogDirectoryQuota=, to define quotas as percentages (hard limits for
  blocks and inodes) or absolute values (hard limits for blocks only).
* Add new directives, StateDirectoryQuotaAccounting=,
  CacheDirectoryQuotaAccounting= and LogDirectoryQuotaAccounting= to keep
  track of storage quotas but not enforce them (effectively just assigning
  a project ID to defined exec directories).

Example:
```
StateDirectory=quotadir
StateDirectoryQuota=1%

Jan 06 22:55:46 abeltran: Storage quotas set for /var/lib/private/quotadir. Block limit = 2639404, inode limit = 671088

root@abeltran:/var/lib/private# lsattr -pR
3153000189 --------------e----P-- ./quotadir

root@abeltran:/var/lib/private# repquota  -P /datadrive
*** Report for project quotas on device /dev/sdc1
Block grace time: 7days; Inode grace time: 7days
                        Block limits                File limits
Project         used    soft    hard  grace    used  soft  hard  grace
----------------------------------------------------------------------
#0        --  213200       0       0           4086     0     0
#3153000189 -- 2639404       0 2639404              2     0 671088
```
src/core/unit.c