From patchwork Fri Oct 16 16:18:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 7418831 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 DA4409F302 for ; Fri, 16 Oct 2015 16:19:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 88A7320A13 for ; Fri, 16 Oct 2015 16:19:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9610320A02 for ; Fri, 16 Oct 2015 16:19:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932675AbbJPQTW (ORCPT ); Fri, 16 Oct 2015 12:19:22 -0400 Received: from mx2.suse.de ([195.135.220.15]:34593 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932665AbbJPQTV (ORCPT ); Fri, 16 Oct 2015 12:19:21 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E2E4EAABE for ; Fri, 16 Oct 2015 16:19:18 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 3CC90DA8E4; Fri, 16 Oct 2015 18:18:09 +0200 (CEST) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH 7/8] btrfs-progs: balance: enhance the limit fiter with range Date: Fri, 16 Oct 2015 18:18:09 +0200 Message-Id: <11f6aeccaa3e2432807b3985eda10743d1531a92.1445011409.git.dsterba@suse.com> X-Mailer: git-send-email 2.6.1 In-Reply-To: References: Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 We can do more with the balance filer. Enhance it so we can specify also the minimum number of block groups to process. The 'limit' filter now accepts a range (a..b, can be partial) and needs kernel support. The 'limit=value' filter is equivalent to 'limit=..value' but works on older kernels as well. The min/max values are 32bit, unlike the single-value limit which is 64bit. Signed-off-by: David Sterba --- cmds-balance.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cmds-balance.c b/cmds-balance.c index 148039bdc503..05d48651b0b7 100644 --- a/cmds-balance.c +++ b/cmds-balance.c @@ -304,11 +304,19 @@ static int parse_filters(char *filters, struct btrfs_balance_args *args) return 1; } if (parse_u64(value, &args->limit)) { - fprintf(stderr, "Invalid limit argument: %s\n", - value); - return 1; + if (parse_range_u32(value, &args->limit_min, + &args->limit_max)) { + fprintf(stderr, + "Invalid limit argument: %s\n", + value); + return 1; + } + args->flags &= ~BTRFS_BALANCE_ARGS_LIMIT; + args->flags |= BTRFS_BALANCE_ARGS_LIMITS; + } else { + args->flags &= ~BTRFS_BALANCE_ARGS_LIMITS; + args->flags |= BTRFS_BALANCE_ARGS_LIMIT; } - args->flags |= BTRFS_BALANCE_ARGS_LIMIT; } else { fprintf(stderr, "Unrecognized balance option '%s'\n", this_char);