From patchwork Wed Jun 24 14:21:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrik Lundquist X-Patchwork-Id: 6668271 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 49C459F1C1 for ; Wed, 24 Jun 2015 14:23:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 421E220666 for ; Wed, 24 Jun 2015 14:23:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6DA2920160 for ; Wed, 24 Jun 2015 14:23:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753025AbbFXOWX (ORCPT ); Wed, 24 Jun 2015 10:22:23 -0400 Received: from mail-la0-f50.google.com ([209.85.215.50]:34410 "EHLO mail-la0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752527AbbFXOWW (ORCPT ); Wed, 24 Jun 2015 10:22:22 -0400 Received: by lagx9 with SMTP id x9so27062821lag.1 for ; Wed, 24 Jun 2015 07:22:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=MXp41H2TPSOovvHjxyCaxsU6PL81Ujpx7Irg1fN49qM=; b=rIU4FToBqutiVvETSazn7t63WZNA6qtOedYBMOs6zcTHmtVpb3UTZaTs/s2oWkNivm 30vjD1Zln8ZMznzHaVSa5cipouAQMn5s3c8RW32fuEgpztpC7c542LBASEpRby3BEjAi JRJu/s56+LBOI3SdDEeZv7vozAeTps7HvwQ5JW0IZQ9FCu/BEEMTZop5DsqCAkoBH/z6 p4jhtpJXwL19YA1dbIL8SdJTVlyQh1hrxGccxYPe84iAsNam8dNTbp9jOGnwyIEpFPtC QyBUfN89Vcysf9iY1AwJCXcz7rsLu6bvcK7EapATx4lRoVjNXQmI1xbLeAm3EFmlwa0F Yd5A== X-Received: by 10.112.198.74 with SMTP id ja10mr40434828lbc.19.1435155741309; Wed, 24 Jun 2015 07:22:21 -0700 (PDT) Received: from nas.localdomain (c83-253-102-83.bredband.comhem.se. [83.253.102.83]) by mx.google.com with ESMTPSA id x10sm2335706laa.32.2015.06.24.07.22.20 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 Jun 2015 07:22:20 -0700 (PDT) From: Patrik Lundquist To: linux-btrfs@vger.kernel.org Cc: Patrik Lundquist Subject: [PATCH] btrfs-progs: Fix defrag threshold overflow Date: Wed, 24 Jun 2015 16:21:06 +0200 Message-Id: <1435155666-11214-1-git-send-email-patrik.lundquist@gmail.com> X-Mailer: git-send-email 2.1.4 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP btrfs fi defrag -t 1T overflows the u32 thresh variable and default, instead of max, threshold is used. Signed-off-by: Patrik Lundquist --- cmds-filesystem.c | 4 ++-- 1 file 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;