diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2010-11-18 03:49:56 +0000 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2011-10-25 09:18:31 -0400 |
commit | a418b24318723c0a45fe1f1b76b9286baa36c537 (patch) | |
tree | c2a4138d73454235ca1757ed0a8df561f5cb615c /btrfs_cmds.c | |
parent | b8802ae3fa0c70d4cfc3287ed07479925973b0ac (diff) |
Update for lzo support
[Btrfs-Progs][V2] Update for lzo support
- Add incompat flag, otherwise btrfs-progs will report error
when operating on btrfs filesystems mounted with lzo option.
- Update man page.
- Allow to turn on lzo compression for defrag operation:
# btrfs filesystem defragment -c[zlib, lzo] <file>
Note: "-c zlib" will fail, because that's how getopt() works
for optional arguments.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'btrfs_cmds.c')
-rw-r--r-- | btrfs_cmds.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/btrfs_cmds.c b/btrfs_cmds.c index c21a0071..26d4fccd 100644 --- a/btrfs_cmds.c +++ b/btrfs_cmds.c @@ -142,10 +142,21 @@ static u64 parse_size(char *s) return atoll(s) * mult; } +static int parse_compress_type(char *s) +{ + if (strcmp(optarg, "zlib") == 0) + return BTRFS_COMPRESS_ZLIB; + else if (strcmp(optarg, "lzo") == 0) + return BTRFS_COMPRESS_LZO; + else { + fprintf(stderr, "Unknown compress type %s\n", s); + exit(1); + }; +} + int do_defrag(int ac, char **av) { int fd; - int compress = 0; int flush = 0; u64 start = 0; u64 len = (u64)-1; @@ -157,15 +168,18 @@ int do_defrag(int ac, char **av) int fancy_ioctl = 0; struct btrfs_ioctl_defrag_range_args range; int e=0; + int compress_type = BTRFS_COMPRESS_NONE; optind = 1; while(1) { - int c = getopt(ac, av, "vcfs:l:t:"); + int c = getopt(ac, av, "vc::fs:l:t:"); if (c < 0) break; switch(c) { case 'c': - compress = 1; + compress_type = BTRFS_COMPRESS_ZLIB; + if (optarg) + compress_type = parse_compress_type(optarg); fancy_ioctl = 1; break; case 'f': @@ -203,8 +217,10 @@ int do_defrag(int ac, char **av) range.start = start; range.len = len; range.extent_thresh = thresh; - if (compress) + if (compress_type) { range.flags |= BTRFS_DEFRAG_RANGE_COMPRESS; + range.compress_type = compress_type; + } if (flush) range.flags |= BTRFS_DEFRAG_RANGE_START_IO; |