From patchwork Fri Jul 24 08:35:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrik Lundquist X-Patchwork-Id: 6857941 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4FB05C05AC for ; Fri, 24 Jul 2015 08:35:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7D7AB205F9 for ; Fri, 24 Jul 2015 08:35:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 57DA220603 for ; Fri, 24 Jul 2015 08:35:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754331AbbGXIfV (ORCPT ); Fri, 24 Jul 2015 04:35:21 -0400 Received: from mail-la0-f54.google.com ([209.85.215.54]:34984 "EHLO mail-la0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754324AbbGXIfT (ORCPT ); Fri, 24 Jul 2015 04:35:19 -0400 Received: by lahh5 with SMTP id h5so9880024lah.2 for ; Fri, 24 Jul 2015 01:35:17 -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=vwlOG5JCCT2G94Cd7r2mE9+UFDd+BK6g2N0pHHPQocs=; b=kTlnEYrA5As2tRRVB6x40KLRsN9+Rt6oEU3clEsq2gqWkIjCD7JXreO1qJTJWd3DT5 nejRPJOVqC/bMnKGbcfaO1SRqCn2v3qU2lnfhJpER7qgXdRxnJAlxnOkdSnO0pBB26gh rcrJCd8MKGY31L14Tbx3xJPV5v+JSXzOn54S1QKgPFyPM6ZYGxPtlINun8AX2NL62s5B stPTzxwjgw44iVaXqaWN4wJt1f1dm9ZaSv65kmr3GCx4FivuLvTlQOZimdecleTc7Fxl JmJaKWqYqsnl1U/TSBk1lO6sa6x1YUVAoDeAXuluBDLn6ZDrmrc9gXW7HDmBbRofh+/j WmXw== X-Received: by 10.112.146.36 with SMTP id sz4mr12719998lbb.54.1437726917208; Fri, 24 Jul 2015 01:35:17 -0700 (PDT) Received: from nas.localdomain (c83-253-102-83.bredband.comhem.se. [83.253.102.83]) by smtp.gmail.com with ESMTPSA id yf5sm1591711lab.1.2015.07.24.01.35.16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Jul 2015 01:35:16 -0700 (PDT) From: Patrik Lundquist To: linux-btrfs@vger.kernel.org Cc: Patrik Lundquist Subject: [PATCH] btrfs-progs: defrag: fix threshold overflow again Date: Fri, 24 Jul 2015 10:35:02 +0200 Message-Id: <1437726902-6458-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.0 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 Commit dedb1ebeee847e3c4d71e14d0c1077887630e44a broke commit 96cfbbf0ea9fce7ecaa9e03964474f407f6e76ab. Casting thresh value greater than (u32)-1 simply truncates bits while desired value is (u32)-1 for max defrag threshold. I.e. "btrfs fi defrag -t 4g" is trimmed/truncated to 0 and "-t 5g" to 1073741824. Also added a missing newline. Signed-off-by: Patrik Lundquist --- cmds-filesystem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmds-filesystem.c b/cmds-filesystem.c index 800aa4d..00a3f78 100644 --- a/cmds-filesystem.c +++ b/cmds-filesystem.c @@ -1172,8 +1172,9 @@ static int cmd_defrag(int argc, char **argv) thresh = parse_size(optarg); if (thresh > (u32)-1) { fprintf(stderr, - "WARNING: target extent size %llu too big, trimmed to %u", + "WARNING: target extent size %llu too big, trimmed to %u\n", thresh, (u32)-1); + thresh = (u32)-1; } defrag_global_fancy_ioctl = 1; break;