Skip to contentSkip to conversation

btrfs-progs: Fix defrag threshold overflow

PATCH Applied Patrik Lundquist 2 participants 2 messages Jun 24, 2015 – Jun 25, 2015 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs-progs: Fix defrag threshold overflow

btrfs fi defrag -t 1T overflows the u32 thresh variable and default, instead of max, threshold is used.

---
 cmds-filesystem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
cmds-filesystem.c +2 -2
index 530f815..72bb45b 100644
@@ -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;
Signature · 1 line
2.1.4