aboutsummaryrefslogtreecommitdiffstats
path: root/cmds-filesystem.c
diff options
context:
space:
mode:
authorPatrik Lundquist <patrik.lundquist@gmail.com>2015-06-24 16:21:06 +0200
committerDavid Sterba <dsterba@suse.cz>2015-06-25 19:32:28 +0200
commit96cfbbf0ea9fce7ecaa9e03964474f407f6e76ab (patch)
treedcb6457f4babe77cc7e66eed3d2019edbfe1fb73 /cmds-filesystem.c
parentce63aed165688343b6cf6c6124a834b395a15291 (diff)
downloadbtrfs-progs-96cfbbf0ea9fce7ecaa9e03964474f407f6e76ab.tar.gz
btrfs-progs-96cfbbf0ea9fce7ecaa9e03964474f407f6e76ab.tar.xz
btrfs-progs-96cfbbf0ea9fce7ecaa9e03964474f407f6e76ab.zip
btrfs-progs: fix defrag threshold overflow
btrfs fi defrag -t 1T overflows the u32 thresh variable and default, instead of max, threshold is used. Signed-off-by: Patrik Lundquist <patrik.lundquist@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'cmds-filesystem.c')
-rw-r--r--cmds-filesystem.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index 530f815..72bb45b 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -1127,7 +1127,7 @@ static int cmd_defrag(int argc, char **argv)
int flush = 0;
u64 start = 0;
u64 len = (u64)-1;
- u32 thresh = 0;
+ u64 thresh = 0;
int i;
int recursive = 0;
int ret = 0;
@@ -1186,7 +1186,7 @@ static int cmd_defrag(int argc, char **argv)
memset(&defrag_global_range, 0, sizeof(range));
defrag_global_range.start = start;
defrag_global_range.len = len;
- defrag_global_range.extent_thresh = thresh;
+ defrag_global_range.extent_thresh = thresh > (u32)-1 ? (u32)-1 : (u32)thresh;
if (compress_type) {
defrag_global_range.flags |= BTRFS_DEFRAG_RANGE_COMPRESS;
defrag_global_range.compress_type = compress_type;