From patchwork Thu Jan 31 17:53:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Theodore Ts'o X-Patchwork-Id: 217225 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.180.67]) by ozlabs.org (Postfix) with ESMTP id 2FF472C007B for ; Fri, 1 Feb 2013 04:53:16 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753266Ab3AaRxM (ORCPT ); Thu, 31 Jan 2013 12:53:12 -0500 Received: from li9-11.members.linode.com ([67.18.176.11]:46389 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754891Ab3AaRxL (ORCPT ); Thu, 31 Jan 2013 12:53:11 -0500 Received: from root (helo=closure.thunk.org) by imap.thunk.org with local-esmtp (Exim 4.80) (envelope-from ) id 1U0yJx-00042w-UK; Thu, 31 Jan 2013 17:53:10 +0000 Received: by closure.thunk.org (Postfix, from userid 15806) id 98317325965; Thu, 31 Jan 2013 12:53:08 -0500 (EST) From: Theodore Ts'o To: Ext4 Developers List Cc: Theodore Ts'o Subject: [PATCH 2/3] jbd2: commit as soon as possible after log_start_commit Date: Thu, 31 Jan 2013 12:53:07 -0500 Message-Id: <1359654788-6078-3-git-send-email-tytso@mit.edu> X-Mailer: git-send-email 1.7.12.rc0.22.gcdd159b In-Reply-To: <1359654788-6078-1-git-send-email-tytso@mit.edu> References: <1359654788-6078-1-git-send-email-tytso@mit.edu> X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on imap.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 Once a transaction has been requested to be committed, don't let any other handles start under that transaction, and don't allow any pending transactions to be extended (i.e., in the case of unlink/ftruncate). The idea is once the transaction has had log_start_commit() called on it, at least one thread is blocked waiting for that transaction to commit, and over time, more and more threads will end up getting blocked. In order to avoid high variability in file system operations getting blocked behind the a blocked start_this_handle(), we should try to get the commit started as soon as possible. Signed-off-by: "Theodore Ts'o" --- fs/jbd2/commit.c | 3 ++- fs/jbd2/journal.c | 1 + fs/jbd2/transaction.c | 6 ++++-- include/linux/jbd2.h | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c index 3091d42..fd2ac94 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c @@ -424,7 +424,8 @@ void jbd2_journal_commit_transaction(journal_t *journal) J_ASSERT(journal->j_committing_transaction == NULL); commit_transaction = journal->j_running_transaction; - J_ASSERT(commit_transaction->t_state == T_RUNNING); + J_ASSERT(commit_transaction->t_state == T_REQUESTED || + commit_transaction->t_state == T_RUNNING); trace_jbd2_start_commit(journal, commit_transaction); jbd_debug(1, "JBD2: starting commit of transaction %d\n", diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 1a80e31..c22773b 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -533,6 +533,7 @@ int __jbd2_log_start_commit(journal_t *journal, tid_t target) jbd_debug(1, "JBD2: requesting commit %d/%d\n", journal->j_commit_request, journal->j_commit_sequence); + journal->j_running_transaction->t_state = T_REQUESTED; wake_up(&journal->j_wait_commit); return 1; } else if (!tid_geq(journal->j_commit_request, target)) diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index df9f297..6daff29 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c @@ -224,7 +224,8 @@ repeat: * If the current transaction is locked down for commit, wait for the * lock to be released. */ - if (transaction->t_state == T_LOCKED) { + if ((transaction->t_state == T_LOCKED) || + (transaction->t_state == T_REQUESTED)) { DEFINE_WAIT(wait); prepare_to_wait(&journal->j_wait_transaction_locked, @@ -2179,7 +2180,8 @@ void __jbd2_journal_refile_buffer(struct journal_head *jh) else jlist = BJ_Reserved; __jbd2_journal_file_buffer(jh, jh->b_transaction, jlist); - J_ASSERT_JH(jh, jh->b_transaction->t_state == T_RUNNING); + J_ASSERT_JH(jh, (jh->b_transaction->t_state == T_RUNNING || + jh->b_transaction->t_state == T_REQUESTED)); if (was_dirty) set_buffer_jbddirty(bh); diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h index e30b663..920a8d0 100644 --- a/include/linux/jbd2.h +++ b/include/linux/jbd2.h @@ -493,6 +493,7 @@ struct transaction_s */ enum { T_RUNNING, + T_REQUESTED, T_LOCKED, T_FLUSH, T_COMMIT,