From: Dmitry Monakhov <dmonakhov@openvz.org>
To: linux-ext4@vger.kernel.org
Cc: jack@suse.cz, Dmitry Monakhov <dmonakhov@openvz.org>
Subject: [PATCH 4/5] jbd: optimize journal_force_commit
Date: Sun, 14 Apr 2013 23:01:36 +0400 [thread overview]
Message-ID: <1365966097-8968-4-git-send-email-dmonakhov@openvz.org> (raw)
In-Reply-To: <1365966097-8968-1-git-send-email-dmonakhov@openvz.org>
Current implementation of journal_force_commit() is suboptimal because
result in empty and useless commits. But callers just want to force and wait
any unfinished commits. We already has journal_force_commit_nested()
which does exactly what we want, except we are guaranteed that we do not hold
journal transaction open.
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
fs/jbd/journal.c | 53 ++++++++++++++++++++++++++++++++++++++-----------
fs/jbd/transaction.c | 23 ---------------------
2 files changed, 41 insertions(+), 35 deletions(-)
diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
index 81cc7ea..82eaec4 100644
--- a/fs/jbd/journal.c
+++ b/fs/jbd/journal.c
@@ -482,24 +482,23 @@ int log_start_commit(journal_t *journal, tid_t tid)
}
/*
- * Force and wait upon a commit if the calling process is not within
- * transaction. This is used for forcing out undo-protected data which contains
- * bitmaps, when the fs is running out of space.
- *
- * We can only force the running transaction if we don't have an active handle;
- * otherwise, we will deadlock.
- *
- * Returns true if a transaction was started.
+ * Force and wait any uncommitted transactions. We can only force the running
+ * transaction if we don't have an active handle, otherwise, we will deadlock.
*/
-int journal_force_commit_nested(journal_t *journal)
+static int __journal_force_commit(journal_t *journal, int nested, int *progress)
{
transaction_t *transaction = NULL;
tid_t tid;
+ int ret = 0;
+
+ J_ASSERT(!current->journal_info || nested);
+ if (progress)
+ *progress = 0;
spin_lock(&journal->j_state_lock);
if (journal->j_running_transaction && !current->journal_info) {
transaction = journal->j_running_transaction;
- __log_start_commit(journal, transaction->t_tid);
+ ret = __log_start_commit(journal, transaction->t_tid);
} else if (journal->j_committing_transaction)
transaction = journal->j_committing_transaction;
@@ -510,8 +509,38 @@ int journal_force_commit_nested(journal_t *journal)
tid = transaction->t_tid;
spin_unlock(&journal->j_state_lock);
- log_wait_commit(journal, tid);
- return 1;
+ if (!ret)
+ ret = log_wait_commit(journal, tid);
+ if (!ret && progress)
+ *progress = 1;
+
+ return ret;
+}
+
+/**
+ * Force and wait upon a commit if the calling process is not within
+ * transaction. This is used for forcing out undo-protected data which contains
+ * bitmaps, when the fs is running out of space.
+ *
+ * @journal: journal to force
+ * Returns true if progress was made.
+ */
+int journal_force_commit_nested(journal_t *journal)
+{
+ int progress;
+
+ __journal_force_commit(journal, 1, &progress);
+ return progress;
+}
+
+/**
+ * int journal_force_commit() - force any uncommitted transactions
+ * @journal: journal to force
+ *
+ */
+int journal_force_commit(journal_t *journal)
+{
+ return __journal_force_commit(journal, 0, NULL);
}
/*
diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c
index 071d690..d3b9a13 100644
--- a/fs/jbd/transaction.c
+++ b/fs/jbd/transaction.c
@@ -1483,29 +1483,6 @@ int journal_stop(handle_t *handle)
return err;
}
-/**
- * int journal_force_commit() - force any uncommitted transactions
- * @journal: journal to force
- *
- * For synchronous operations: force any uncommitted transactions
- * to disk. May seem kludgy, but it reuses all the handle batching
- * code in a very simple manner.
- */
-int journal_force_commit(journal_t *journal)
-{
- handle_t *handle;
- int ret;
-
- handle = journal_start(journal, 1);
- if (IS_ERR(handle)) {
- ret = PTR_ERR(handle);
- } else {
- handle->h_sync = 1;
- ret = journal_stop(handle);
- }
- return ret;
-}
next prev parent reply other threads:[~2013-04-14 19:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-14 19:01 [PATCH 1/5] ext4: convert write_begin methods to stable_page_writes semantics Dmitry Monakhov
2013-04-14 19:01 ` [PATCH 2/5] jbd2: optimize jbd2_journal_force_commit Dmitry Monakhov
2013-04-15 12:29 ` Jan Kara
2013-04-17 7:39 ` Dmitry Monakhov
2013-04-18 18:07 ` Jan Kara
2013-04-22 8:11 ` Dmitry Monakhov
2013-04-23 8:51 ` Jan Kara
2013-08-28 18:33 ` Theodore Ts'o
2013-04-14 19:01 ` [PATCH 3/5] ext4: fix data integrity for ext4_sync_fs Dmitry Monakhov
2013-04-15 13:59 ` Jan Kara
2013-04-14 19:01 ` Dmitry Monakhov [this message]
2013-04-14 19:01 ` [PATCH 5/5] ext3: " Dmitry Monakhov
2013-04-15 12:01 ` [PATCH 1/5] ext4: convert write_begin methods to stable_page_writes semantics Jan Kara
2013-04-22 12:36 ` Zheng Liu
2013-08-28 18:32 ` Theodore Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1365966097-8968-4-git-send-email-dmonakhov@openvz.org \
--to=dmonakhov@openvz.org \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).