[JBD] Handle j_commit_interval == 0

From: Herbert Xu
Date: Sat Nov 29 2003 - 04:27:23 EST


Hi:

After the laptop mode patch was merged, it is now possible for
j_commit_interval to be zero. Unfortunately jbd doesn't handle
this situation very well.

This patch makes it do the sensible thing.

Cheers,
--
Debian GNU/Linux 3.0 is out! ( http://www.debian.org/ )
Email: Herbert Xu ~{PmV>HI~} <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Index: kernel-source-2.4/fs/jbd/journal.c
===================================================================
RCS file: /home/gondolin/herbert/src/CVS/debian/kernel-source-2.4/fs/jbd/journal.c,v
retrieving revision 1.1.1.9
diff -u -r1.1.1.9 journal.c
--- kernel-source-2.4/fs/jbd/journal.c 29 Nov 2003 06:39:14 -0000 1.1.1.9
+++ kernel-source-2.4/fs/jbd/journal.c 29 Nov 2003 09:20:32 -0000
@@ -253,6 +253,7 @@

/* Were we woken up by a commit wakeup event? */
if ((transaction = journal->j_running_transaction) != NULL &&
+ journal->j_commit_interval &&
time_after_eq(jiffies, transaction->t_expires)) {
journal->j_commit_request = transaction->t_tid;
jbd_debug(1, "woke because of timeout\n");
Index: kernel-source-2.4/fs/jbd/transaction.c
===================================================================
RCS file: /home/gondolin/herbert/src/CVS/debian/kernel-source-2.4/fs/jbd/transaction.c,v
retrieving revision 1.1.1.6
diff -u -r1.1.1.6 transaction.c
--- kernel-source-2.4/fs/jbd/transaction.c 28 Nov 2003 18:26:21 -0000 1.1.1.6
+++ kernel-source-2.4/fs/jbd/transaction.c 29 Nov 2003 06:59:58 -0000
@@ -60,10 +60,12 @@
INIT_LIST_HEAD(&transaction->t_jcb);

/* Set up the commit timer for the new transaction. */
- J_ASSERT (!journal->j_commit_timer_active);
- journal->j_commit_timer_active = 1;
- journal->j_commit_timer->expires = transaction->t_expires;
- add_timer(journal->j_commit_timer);
+ if (journal->j_commit_interval) {
+ J_ASSERT (!journal->j_commit_timer_active);
+ journal->j_commit_timer_active = 1;
+ journal->j_commit_timer->expires = transaction->t_expires;
+ add_timer(journal->j_commit_timer);
+ }

J_ASSERT (journal->j_running_transaction == NULL);
journal->j_running_transaction = transaction;
@@ -1465,7 +1467,8 @@
if (handle->h_sync ||
transaction->t_outstanding_credits >
journal->j_max_transaction_buffers ||
- time_after_eq(jiffies, transaction->t_expires)) {
+ (journal->j_commit_interval &&
+ time_after_eq(jiffies, transaction->t_expires))) {
/* Do this even for aborted journals: an abort still
* completes the commit thread, it just doesn't write
* anything to disk. */