Commit Graph

14 Commits

Author SHA1 Message Date
Kir Kolyshkin a4d8f720a2 Format sources with gofumpt
gofumpt is a superset of gofmt, enabling some more code formatting
rules.

This commit is brought to you by

	gofumpt -w .

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-05-26 16:17:31 -07:00
Nalin Dahyabhai 06d2818bc7 drivers/quota.openDir() log errno if C.opendir() fails
If C.opendir() fails, include errno along with the path of the directory
that we failed to open.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2023-05-04 16:57:31 -04:00
Nalin Dahyabhai d10c03bc3d Extend driver.ListLayers()
Implement ListLayers() for the aufs, btrfs, and devicemapper drivers,
along with a unit test for them.
Stop filtering out directories with names that aren't 64-hex chars in
vfs and overlay ListLayers() implementations, which is more a convention
than a hard rule.
Have layerStore.Wipe() try to remove remaining listed layers after it
removes the layers that the layerStore knew of.
Close() a dangling ReadCloser in NaiveCreateFromTemplate.
Switch from using plain defer to using t.Cleanup() to handle deleting
layers that tests create, have the addManyLayers() test function do so
as well.
Remove vfs.CopyDir, which near as I can tell isn't referenced anywhere.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2023-04-12 16:05:09 -04:00
Peter Hunt~ 891593970a quota: add ClearQuota function to prevent leak
Signed-off-by: Peter Hunt~ <pehunt@redhat.com>
2022-12-12 13:15:24 -05:00
Sascha Grunert aa0d39469a
Recreate missing backingFsBlockDev on setting xfs project quota
There is the rare case that something removed the backingFsBlockDev,
which usually points to
`/var/lib/containers/storage/overlay/backingFsBlockDev`. In that case,
all `SetQuota` operations would fail on overlay layer creation.

We now work around that error by recreating the backingFsBlockDev.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2022-11-07 10:13:27 +01:00
Miloslav Trmač b8f4b5f2d3 Use os.ReadDir instead of ioutil.ReadDir
That is frequently an optimization, because it avoids
a per-item lstat().

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-09-12 16:31:38 +02:00
Daniel J Walsh 3f8c0dc0de
Wrap errors properly with fmt.Errorf
Also returned errors should not begine with a capatalized errors.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-07-12 13:26:10 -04:00
Nalin Dahyabhai 99ef926c0d drivers/quota.makeBackingFsDev(): use mknod+rename
Use mknod() followed by rename() to create the "backingFsBlockDev"
device, instead of unlink() followed by mknod(), to remove the window
where the node won't exist if we're just going to end up replacing it
with an identical device node.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2022-07-05 12:17:54 -04:00
Daniel J Walsh 5c30b53cf6
Fix handling of quota on volumes
This patch fixes the handling of inodes and sizes, currently if
user sets indoes and sizes together, quota is only set on sizes.

Second problem with quota is that we have to have unigue projectids
for each directory. Originally container/storage only did quota on
rootfs, now we want to support it on volumes as well. We need to be
able to get unigue projectids for these two different parent
directories. The added function, attempts to maintain at least 10,000
unigue id's based on the inode of the parent directory. I know that this
is not perfect and we have a potential for overlay.  If you have a
better algorythm, I would love to use it.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-07-30 05:56:23 -04:00
Daniel J Walsh 0c7d87718f
Add inode support to quota
quota for overlay also supports setting the maximum number of
inodes. OpenShift would like to be able to set this to control the
number of inodes added to an image or to a volume.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-07-26 06:29:40 -04:00
Peter Hunt 327a85fe55 drivers/quota: add GetDiskUsage endpoint
that queries xfs_quota, rather than going the route of walking the file path

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2021-01-28 11:57:53 -05:00
Nalin Dahyabhai ba598e19f2 Disable cgo-requiring bits when cgo is not enabled
Adjust build tags in drivers and pkg so that builds with CGO_ENABLED=0
won't fail outright.  This ends up disabling btrfs (which uses kernel
headers), ostree (which uses libostree), overlayfs (which uses C headers
to define fs_disk_quota_t), and devicemapper (which uses libdevmapper
and loopback) by default.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-08-05 13:42:50 -04:00
Giuseppe Scrivano a7a6b097c7
quota: add build tag to disable it
change backported from Moby.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-06-27 12:54:46 +02:00
Daniel J Walsh ca5ce1cfa2 Add moby quota driver into containers/storage
Need this driver to get overlay quota on xfs support

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-09-26 20:45:15 +00:00