From patchwork Thu Oct 9 04:05:50 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: 3466 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 C22BADDEE7 for ; Thu, 9 Oct 2008 15:07:29 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757940AbYJIEHX (ORCPT ); Thu, 9 Oct 2008 00:07:23 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757731AbYJIEHW (ORCPT ); Thu, 9 Oct 2008 00:07:22 -0400 Received: from www.church-of-our-saviour.org ([69.25.196.31]:54522 "EHLO thunker.thunk.org" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757612AbYJIEGN (ORCPT ); Thu, 9 Oct 2008 00:06:13 -0400 Received: from root (helo=closure.thunk.org) by thunker.thunk.org with local-esmtp (Exim 4.50 #1 (Debian)) id 1Knmmr-0006C4-JV; Thu, 09 Oct 2008 00:06:07 -0400 Received: from tytso by closure.thunk.org with local (Exim 4.69) (envelope-from ) id 1Knmmq-0006bW-8Z; Thu, 09 Oct 2008 00:06:04 -0400 From: Theodore Ts'o To: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Duane Griffin , Sami Liedes , Andrew Morton , "Theodore Ts'o" Subject: [PATCH 32/42] jbd2: abort instead of waiting for nonexistent transaction Date: Thu, 9 Oct 2008 00:05:50 -0400 Message-Id: <1223525160-9887-33-git-send-email-tytso@mit.edu> X-Mailer: git-send-email 1.5.6.1.205.ge2c7.dirty In-Reply-To: <1223525160-9887-32-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> <1223525160-9887-12-git-send-email-tytso@mit.edu> <1223525160-9887-13-git-send-email-tytso@mit.edu> <1223525160-9887-14-git-send-email-tytso@mit.edu> <1223525160-9887-15-git-send-email-tytso@mit.edu> <1223525160-9887-16-git-send-email-tytso@mit.edu> <1223525160-9887-17-git-send-email-tytso@mit.edu> <1223525160-9887-18-git-send-email-tytso@mit.edu> <1223525160-9887-19-git-send-email-tytso@mit.edu> <1223525160-9887-20-git-send-email-tytso@mit.edu> <1223525160-9887-21-git-send-email-tytso@mit.edu> <1223525160-9887-22-git-send-email-tytso@mit.edu> <1223525160-9887-23-git-send-email-tytso@mit.edu> <1223525160-9887-24-git-send-email-tytso@mit.edu> <1223525160-9887-25-git-send-email-tytso@mit.edu> <1223525160-9887-26-git-send-email-tytso@mit.edu> <1223525160-9887-27-git-send-email-tytso@mit.edu> <1223525160-9887-28-git-send-email-tytso@mit.edu> <1223525160-9887-29-git-send-email-tytso@mit.edu> <1223525160-9887-30-git-send-email-tytso@mit.edu> <1223525160-9887-31-git-send-email-tytso@mit.edu> <1223525160-9887-32-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: Duane Griffin The __jbd2_log_wait_for_space function sits in a loop checkpointing transactions until there is sufficient space free in the journal. However, if there are no transactions to be processed (e.g. because the free space calculation is wrong due to a corrupted filesystem) it will never progress. Check for space being required when no transactions are outstanding and abort the journal instead of endlessly looping. This patch fixes the bug reported by Sami Liedes at: http://bugzilla.kernel.org/show_bug.cgi?id=10976 Signed-off-by: Duane Griffin Cc: Sami Liedes Cc: Signed-off-by: Andrew Morton Signed-off-by: "Theodore Ts'o" --- fs/jbd2/checkpoint.c | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-) diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c index 91389c8..af4651b 100644 --- a/fs/jbd2/checkpoint.c +++ b/fs/jbd2/checkpoint.c @@ -126,14 +126,29 @@ void __jbd2_log_wait_for_space(journal_t *journal) /* * Test again, another process may have checkpointed while we - * were waiting for the checkpoint lock + * were waiting for the checkpoint lock. If there are no + * outstanding transactions there is nothing to checkpoint and + * we can't make progress. Abort the journal in this case. */ spin_lock(&journal->j_state_lock); + spin_lock(&journal->j_list_lock); nblocks = jbd_space_needed(journal); if (__jbd2_log_space_left(journal) < nblocks) { + int chkpt = journal->j_checkpoint_transactions != NULL; + + spin_unlock(&journal->j_list_lock); spin_unlock(&journal->j_state_lock); - jbd2_log_do_checkpoint(journal); + if (chkpt) { + jbd2_log_do_checkpoint(journal); + } else { + printk(KERN_ERR "%s: no transactions\n", + __func__); + jbd2_journal_abort(journal, 0); + } + spin_lock(&journal->j_state_lock); + } else { + spin_unlock(&journal->j_list_lock); } mutex_unlock(&journal->j_checkpoint_mutex); }