From patchwork Mon Feb 11 12:33:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 2124211 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id CB8D8DF23E for ; Mon, 11 Feb 2013 12:34:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756936Ab3BKMeS (ORCPT ); Mon, 11 Feb 2013 07:34:18 -0500 Received: from cantor2.suse.de ([195.135.220.15]:56234 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756794Ab3BKMd6 (ORCPT ); Mon, 11 Feb 2013 07:33:58 -0500 Received: from relay2.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 887F0A341E; Mon, 11 Feb 2013 13:33:57 +0100 (CET) Received: by ds.suse.cz (Postfix, from userid 10065) id 22DF0DB432; Mon, 11 Feb 2013 13:33:57 +0100 (CET) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba , Ilya Dryomov Subject: [PATCH] btrfs: accept zero for balance usage filter Date: Mon, 11 Feb 2013 13:33:52 +0100 Message-Id: <1360586032-22973-1-git-send-email-dsterba@suse.cz> X-Mailer: git-send-email 1.8.0.2 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The condition can be relaxed to accept also 0 which will delete unoccupied chunks and does not need space for the actual data relocation. Until there is an automatic empty chunk reclaim, we can use this as a last resort option under enospc. CC: Ilya Dryomov Signed-off-by: David Sterba --- Also needs progs update, but is not required for the kernel side. fs/btrfs/volumes.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 5cbb7f4..fb871d0 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2623,7 +2623,10 @@ static int chunk_usage_filter(struct btrfs_fs_info *fs_info, u64 chunk_offset, user_thresh = div_factor_fine(cache->key.offset, bargs->usage); - if (chunk_used < user_thresh) + pr_debug("btrfs: chunk_used %llu, user_thresh %llu\n", + (unsigned long long)chunk_used, + (unsigned long long)user_thresh); + if (chunk_used <= user_thresh) ret = 0; btrfs_put_block_group(cache);