diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-11-10 21:37:49 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-11-10 21:37:49 +0100 |
commit | 12ee6186dc4431b8d75f8becb236ec840feedb6e (patch) | |
tree | a45afd6f08fe44a48bdb2cbdffed0783b162233e /src | |
parent | 17afc8f27b7850ca479f0c3720680b90881d8e6e (diff) |
btrfs: when querying quota, make sure we don't choke if quota is disabled
When quota is disabled there's no quota tree on the fs, which results in
the SEARCH ioctl to return ENOENT. Handle this nicely: treat this the
same way as the case where the quota tree is around but doesn't carry
the searched for fields.
Diffstat (limited to 'src')
-rw-r--r-- | src/basic/btrfs-util.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/basic/btrfs-util.c b/src/basic/btrfs-util.c index 4c90bc0c80..661331e8b2 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; @@ -1335,8 +1339,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 +1774,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; |