From patchwork Thu Oct 9 04:05:29 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Theodore Ts'o X-Patchwork-Id: 3449 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id A1227DDF0A for ; Thu, 9 Oct 2008 15:06:34 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751499AbYJIEGT (ORCPT ); Thu, 9 Oct 2008 00:06:19 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751435AbYJIEGS (ORCPT ); Thu, 9 Oct 2008 00:06:18 -0400 Received: from www.church-of-our-saviour.org ([69.25.196.31]:54454 "EHLO thunker.thunk.org" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757252AbYJIEGF (ORCPT ); Thu, 9 Oct 2008 00:06:05 -0400 Received: from root (helo=closure.thunk.org) by thunker.thunk.org with local-esmtp (Exim 4.50 #1 (Debian)) id 1Knmmp-0006C3-GW; Thu, 09 Oct 2008 00:06:03 -0400 Received: from tytso by closure.thunk.org with local (Exim 4.69) (envelope-from ) id 1Knmmn-0006Xz-Sb; Thu, 09 Oct 2008 00:06:01 -0400 From: Theodore Ts'o To: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Aneesh Kumar K.V" , Mingming Cao , "Theodore Ts'o" Subject: [PATCH 11/42] ext4: Fix ext4 nomballoc allocator for ENOSPC Date: Thu, 9 Oct 2008 00:05:29 -0400 Message-Id: <1223525160-9887-12-git-send-email-tytso@mit.edu> X-Mailer: git-send-email 1.5.6.1.205.ge2c7.dirty In-Reply-To: <1223525160-9887-11-git-send-email-tytso@mit.edu> References: <1223525160-9887-1-git-send-email-tytso@mit.edu> <1223525160-9887-2-git-send-email-tytso@mit.edu> <1223525160-9887-3-git-send-email-tytso@mit.edu> <1223525160-9887-4-git-send-email-tytso@mit.edu> <1223525160-9887-5-git-send-email-tytso@mit.edu> <1223525160-9887-6-git-send-email-tytso@mit.edu> <1223525160-9887-7-git-send-email-tytso@mit.edu> <1223525160-9887-8-git-send-email-tytso@mit.edu> <1223525160-9887-9-git-send-email-tytso@mit.edu> <1223525160-9887-10-git-send-email-tytso@mit.edu> <1223525160-9887-11-git-send-email-tytso@mit.edu> X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@mit.edu X-SA-Exim-Scanned: No (on thunker.thunk.org); SAEximRunCond expanded to false Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Aneesh Kumar K.V We run into ENOSPC error on nonmballoc ext4, even when there is free blocks on the filesystem. The patch includes two changes: a) Set reservation to NULL if we trying to allocate near group_target_block from the goal group if the free block in the group is less than windows. This should give us a better chance to allocate near group_target_block. This also ensures that if we are not allocating near group_target_block then we don't trun off reservation. This should enable us to allocate with reservation from other groups that have large free blocks count. b) we don't need to check the window size if the block reservation is off. Signed-off-by: Aneesh Kumar K.V Signed-off-by: Mingming Cao Signed-off-by: "Theodore Ts'o" --- fs/ext4/balloc.c | 18 ++++++++++-------- 1 files changed, 10 insertions(+), 8 deletions(-) diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index e4274aa..87b660b 100644 --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c @@ -1804,15 +1804,17 @@ retry_alloc: goto io_error; free_blocks = le16_to_cpu(gdp->bg_free_blocks_count); - /* - * if there is not enough free blocks to make a new resevation - * turn off reservation for this allocation - */ - if (my_rsv && (free_blocks < windowsz) - && (rsv_is_empty(&my_rsv->rsv_window))) - my_rsv = NULL; if (free_blocks > 0) { + /* + * try to allocate with group target block + * in the goal group. If we have low free_blocks + * count turn off reservation + */ + if (my_rsv && (free_blocks < windowsz) + && (rsv_is_empty(&my_rsv->rsv_window))) + my_rsv = NULL; + bitmap_bh = ext4_read_block_bitmap(sb, group_no); if (!bitmap_bh) goto io_error; @@ -1845,7 +1847,7 @@ retry_alloc: * free blocks is less than half of the reservation * window size. */ - if (free_blocks <= (windowsz/2)) + if (my_rsv && (free_blocks <= (windowsz/2))) continue; brelse(bitmap_bh);