tmpfiles: deal with kernel errno change if quota is not enabled

Old kernels returned EINVAL if quota was off but we tried to manipulate
it anyway. Since
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8a36e408d40606e21cd4e2dd9601004a67b14868
this changed: now ENOTCONN is returned. This of course is a kernel API
compat breakage, but let's not make a fuss and just map EINVAL to
ENOTCONN to make it recognizable the same way everywhere.

Fixes: #15896
This commit is contained in:
Lennart Poettering
2020-05-26 21:36:29 +02:00
parent 548af942b8
commit 4b019d2f2d
2 changed files with 7 additions and 4 deletions
+6 -3
View File
@@ -927,9 +927,12 @@ static int qgroup_create_or_destroy(int fd, bool b, uint64_t qgroupid) {
for (c = 0;; c++) {
if (ioctl(fd, BTRFS_IOC_QGROUP_CREATE, &args) < 0) {
/* If quota is not enabled, we get EINVAL. Turn this into a recognizable error */
if (errno == EINVAL)
return -ENOPROTOOPT;
/* On old kernels if quota is not enabled, we get EINVAL. On newer kernels we get
* ENOTCONN. Let's always convert this to ENOTCONN to make this recognizable
* everywhere the same way. */
if (IN_SET(errno, EINVAL, ENOTCONN))
return -ENOTCONN;
if (errno == EBUSY && c < 10) {
(void) btrfs_quota_scan_wait(fd);