From patchwork Sun Dec 12 14:33:08 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Itaru Kitayama X-Patchwork-Id: 400892 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBCEXGOZ023363 for ; Sun, 12 Dec 2010 14:33:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753329Ab0LLOdN (ORCPT ); Sun, 12 Dec 2010 09:33:13 -0500 Received: from irs1ma.bb4u.ne.jp ([202.229.9.180]:51694 "HELO irs1m.bias.ne.jp" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with SMTP id S1753286Ab0LLOdN (ORCPT ); Sun, 12 Dec 2010 09:33:13 -0500 Received: (qmail 22875 invoked from network); 12 Dec 2010 14:33:09 -0000 Received: from unknown (HELO prime) (58.89.220.250) by 0 with SMTP; Sun, 12 Dec 2010 23:33:09 +0900 Date: Sun, 12 Dec 2010 23:33:08 +0900 From: Itaru Kitayama To: linux-btrfs@vger.kernel.org Subject: [PATCH] Btrfs: pick the correct metadata allocation size on small devices Message-Id: <20101212233308.4b2aff4a.kitayama@cl.bb4u.ne.jp> X-Mailer: Sylpheed 3.0.2 (GTK+ 2.20.1; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Sun, 12 Dec 2010 14:33:16 +0000 (UTC) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 8c26441..54ab490 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -3241,6 +3241,8 @@ static int should_alloc_chunk(struct btrfs_root *root, struct btrfs_space_info *sinfo, u64 alloc_bytes) { u64 num_bytes = sinfo->total_bytes - sinfo->bytes_readonly; + u64 total_rw_bytes = root->fs_info->fs_devices->total_rw_bytes; + u64 max_chunk_size; u64 thresh; if (sinfo->bytes_used + sinfo->bytes_reserved + @@ -3251,8 +3253,9 @@ static int should_alloc_chunk(struct btrfs_root *root, alloc_bytes < div_factor(num_bytes, 8)) return 0; + max_chunk_size = min(256 * 1024 * 1024, div_factor(total_rw_bytes, 1)); thresh = btrfs_super_total_bytes(&root->fs_info->super_copy); - thresh = max_t(u64, 256 * 1024 * 1024, div_factor_fine(thresh, 5)); + thresh = max_t(u64, max_chunk_size, div_factor_fine(thresh, 5)); if (num_bytes > thresh && sinfo->bytes_used < div_factor(num_bytes, 3)) return 0;