]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tmpfiles: deal with kernel errno change if quota is not enabled
authorLennart Poettering <lennart@poettering.net>
Tue, 26 May 2020 10:52:57 +0000 (12:52 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 26 May 2020 19:36:29 +0000 (21:36 +0200)
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
src/basic/btrfs-util.c
src/tmpfiles/tmpfiles.c

index 17ee474f7332bdaf0d054623680519dc255fe646..71e1bc92eb7bfb4690e8f33f318e7cc1569a1d24 100644 (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);
index e9453d39351d329f355ee65c18e7220ad26841e0..a69411f1759f26f3254c1177b565dea169aa76f5 100644 (file)
@@ -1625,7 +1625,7 @@ static int create_subvolume(Item *i, const char *path) {
                         log_debug_errno(r, "Couldn't adjust quota for subvolume \"%s\" (unsupported fs or dir not a subvolume): %m", i->path);
                 else if (r == -EROFS)
                         log_debug_errno(r, "Couldn't adjust quota for subvolume \"%s\" (fs is read-only).", i->path);
-                else if (r == -ENOPROTOOPT)
+                else if (r == -ENOTCONN)
                         log_debug_errno(r, "Couldn't adjust quota for subvolume \"%s\" (quota support is disabled).", i->path);
                 else if (r < 0)
                         q = log_error_errno(r, "Failed to adjust quota for subvolume \"%s\": %m", i->path);