btrfs-progs: defrag: remove v1 ioctl support

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2017-01-12 15:12:09 +01:00
parent 52f21fc769
commit a595ade0d5
1 changed files with 8 additions and 30 deletions

View File

@ -972,20 +972,6 @@ static const char * const cmd_filesystem_defrag_usage[] = {
NULL NULL
}; };
static int do_defrag(int fd, int fancy_ioctl,
struct btrfs_ioctl_defrag_range_args *range)
{
int ret;
if (!fancy_ioctl)
ret = ioctl(fd, BTRFS_IOC_DEFRAG, NULL);
else
ret = ioctl(fd, BTRFS_IOC_DEFRAG_RANGE, range);
return ret;
}
static int defrag_global_fancy_ioctl;
static struct btrfs_ioctl_defrag_range_args defrag_global_range; static struct btrfs_ioctl_defrag_range_args defrag_global_range;
static int defrag_global_verbose; static int defrag_global_verbose;
static int defrag_global_errors; static int defrag_global_errors;
@ -1004,12 +990,11 @@ static int defrag_callback(const char *fpath, const struct stat *sb,
err = errno; err = errno;
goto error; goto error;
} }
ret = do_defrag(fd, defrag_global_fancy_ioctl, &defrag_global_range); ret = ioctl(fd, BTRFS_IOC_DEFRAG_RANGE, &defrag_global_range);
close(fd); close(fd);
if (ret && errno == ENOTTY && defrag_global_fancy_ioctl) { if (ret && errno == ENOTTY) {
error("defrag range ioctl not " error(
"supported in this kernel, please try " "defrag range ioctl not supported in this kernel version, 2.6.33 and newer is required");
"without any options.");
defrag_global_errors++; defrag_global_errors++;
return ENOTTY; return ENOTTY;
} }
@ -1046,7 +1031,6 @@ static int cmd_filesystem_defrag(int argc, char **argv)
* use the v2 defrag ioctl. * use the v2 defrag ioctl.
*/ */
thresh = 32 * 1024 * 1024; thresh = 32 * 1024 * 1024;
defrag_global_fancy_ioctl = 1;
defrag_global_errors = 0; defrag_global_errors = 0;
defrag_global_verbose = 0; defrag_global_verbose = 0;
@ -1061,22 +1045,18 @@ static int cmd_filesystem_defrag(int argc, char **argv)
compress_type = BTRFS_COMPRESS_ZLIB; compress_type = BTRFS_COMPRESS_ZLIB;
if (optarg) if (optarg)
compress_type = parse_compress_type(optarg); compress_type = parse_compress_type(optarg);
defrag_global_fancy_ioctl = 1;
break; break;
case 'f': case 'f':
flush = 1; flush = 1;
defrag_global_fancy_ioctl = 1;
break; break;
case 'v': case 'v':
defrag_global_verbose = 1; defrag_global_verbose = 1;
break; break;
case 's': case 's':
start = parse_size(optarg); start = parse_size(optarg);
defrag_global_fancy_ioctl = 1;
break; break;
case 'l': case 'l':
len = parse_size(optarg); len = parse_size(optarg);
defrag_global_fancy_ioctl = 1;
break; break;
case 't': case 't':
thresh = parse_size(optarg); thresh = parse_size(optarg);
@ -1086,7 +1066,6 @@ static int cmd_filesystem_defrag(int argc, char **argv)
thresh, (u32)-1); thresh, (u32)-1);
thresh = (u32)-1; thresh = (u32)-1;
} }
defrag_global_fancy_ioctl = 1;
break; break;
case 'r': case 'r':
recursive = 1; recursive = 1;
@ -1176,15 +1155,14 @@ static int cmd_filesystem_defrag(int argc, char **argv)
} else { } else {
if (defrag_global_verbose) if (defrag_global_verbose)
printf("%s\n", argv[i]); printf("%s\n", argv[i]);
ret = do_defrag(fd, defrag_global_fancy_ioctl, ret = ioctl(fd, BTRFS_IOC_DEFRAG_RANGE,
&defrag_global_range); &defrag_global_range);
defrag_err = errno; defrag_err = errno;
} }
close_file_or_dir(fd, dirstream); close_file_or_dir(fd, dirstream);
if (ret && defrag_err == ENOTTY && defrag_global_fancy_ioctl) { if (ret && defrag_err == ENOTTY) {
error("defrag range ioctl not " error(
"supported in this kernel, please try " "defrag range ioctl not supported in this kernel version, 2.6.33 and newer is required");
"without any options.");
defrag_global_errors++; defrag_global_errors++;
break; break;
} }