summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-11-11 02:31:29 +0100
committerTom Gundersen <teg@jklm.no>2015-11-11 02:31:29 +0100
commit7042fc14ff2bd30648aea6602c95d3cf6946e7be (patch)
tree9990f79bfe80bb0b9c8c6da94f62d66d5c7da97e /src/basic
parent620b7793fcbb23f6d27d42b0374d3dddb256aa40 (diff)
parentbe6d467c1f9219b2016d556a0a369828d463ca27 (diff)
Merge pull request #1837 from poettering/grabbag2
variety of fixes
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/btrfs-util.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/basic/btrfs-util.c b/src/basic/btrfs-util.c
index 4c90bc0c80..290fabdeff 100644
--- a/src/basic/btrfs-util.c
+++ b/src/basic/btrfs-util.c
@@ -575,8 +575,12 @@ int btrfs_qgroup_get_quota_fd(int fd, uint64_t qgroupid, BtrfsQuotaInfo *ret) {
unsigned i;
args.key.nr_items = 256;
- if (ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args) < 0)
+ if (ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args) < 0) {
+ if (errno == ENOENT) /* quota tree is missing: quota disabled */
+ break;
+
return -errno;
+ }
if (args.key.nr_items <= 0)
break;
@@ -1006,6 +1010,10 @@ 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;
+
if (errno == EBUSY && c < 10) {
(void) btrfs_quota_scan_wait(fd);
continue;
@@ -1335,8 +1343,12 @@ int btrfs_qgroup_copy_limits(int fd, uint64_t old_qgroupid, uint64_t new_qgroupi
unsigned i;
args.key.nr_items = 256;
- if (ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args) < 0)
+ if (ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args) < 0) {
+ if (errno == ENOENT) /* quota tree missing: quota is not enabled, hence nothing to copy */
+ break;
+
return -errno;
+ }
if (args.key.nr_items <= 0)
break;
@@ -1766,8 +1778,12 @@ int btrfs_qgroup_find_parents(int fd, uint64_t qgroupid, uint64_t **ret) {
unsigned i;
args.key.nr_items = 256;
- if (ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args) < 0)
+ if (ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args) < 0) {
+ if (errno == ENOENT) /* quota tree missing: quota is disabled */
+ break;
+
return -errno;
+ }
if (args.key.nr_items <= 0)
break;