From: David Sterba Date: Mon, 7 Nov 2016 12:02:00 +0000 (+0100) Subject: btrfs-progs: fix search tree v2 ioctl detection X-Git-Tag: upstream/4.16.1~1038 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3934ba255d520daab8217d5e7419a8193c680a68;p=platform%2Fupstream%2Fbtrfs-progs.git btrfs-progs: fix search tree v2 ioctl detection The result of the test applies per-filesystem, so we can't simply cache it. The function hasn't been used yet. Signed-off-by: David Sterba --- diff --git a/utils.c b/utils.c index 01d9586..6ddfbf9 100644 --- a/utils.c +++ b/utils.c @@ -3825,6 +3825,10 @@ u64 get_partition_size(const char *dev) return result; } +/* + * Check if the BTRFS_IOC_TREE_SEARCH_V2 ioctl is supported on a given + * filesystem, opened at fd + */ int btrfs_tree_search2_ioctl_supported(int fd) { struct btrfs_ioctl_search_args_v2 *args2; @@ -3832,10 +3836,6 @@ int btrfs_tree_search2_ioctl_supported(int fd) int args2_size = 1024; char args2_buf[args2_size]; int ret; - static int v2_supported = -1; - - if (v2_supported != -1) - return v2_supported; args2 = (struct btrfs_ioctl_search_args_v2 *)args2_buf; sk = &(args2->key); @@ -3856,13 +3856,10 @@ int btrfs_tree_search2_ioctl_supported(int fd) args2->buf_size = args2_size - sizeof(struct btrfs_ioctl_search_args_v2); ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH_V2, args2); if (ret == -EOPNOTSUPP) - v2_supported = 0; + return 0; else if (ret == 0) - v2_supported = 1; - else - return ret; - - return v2_supported; + return 1; + return ret; } int btrfs_check_nodesize(u32 nodesize, u32 sectorsize, u64 features)