Re: [EXT3/JBD] Periodic journal flush not enough?

From: Andreas Dilger
Date: Fri Mar 26 2004 - 18:56:36 EST


On Mar 27, 2004 10:19 +1100, Herbert Xu wrote:
> I've encountered a problem with the journal flush timer. The problem
> is that when a filesystem is short on space, relying on a timer-based
> flushing mechanism is no longer adequate. For example, on my P4 2GHz
> I can trigger an ENOSPC error by doing
>
> while :; do echo test > a; [ -s a ] || break; rm a; done; echo Out of space
>
> on an ext3 file system with 12Mb of free space using the usual 5s
> journal flush timer.
>
> Of course, when you extend the flushing period as you do with laptop-mode,
> this problem becomes a lot worse.
>
> So would it be possible to have the flushing activated on demand?

I had created a patch a while ago, but never really got any testing on it.
It would be great to get this problem fixed. Patch against a 2.4.x kernel.

--- fs/ext3/balloc.c.orig Fri Jul 25 19:55:34 2003
+++ fs/ext3/balloc.c Tue Sep 2 16:27:51 2003
@@ -547,6 +547,8 @@ int ext3_new_block (handle_t *handle, st
#ifdef EXT3FS_DEBUG
static int goal_hits = 0, goal_attempts = 0;
#endif
+ int tried_commit = 0;
+
*errp = -ENOSPC;
sb = inode->i_sb;
if (!sb) {
@@ -643,6 +645,26 @@ repeat:
}
}

+ /* We can only try to commit the previous transaction, or we will
+ * deadlock because the current op has a transaction handle open.
+ * We also can't restart the current handle in a new transaction as
+ * that might break the atomicity guarantees of this transaction.
+ * Set current handle h_sync to allow it to be committed ASAP. */
+ if (!tried_commit) {
+ journal_t *journal = handle->h_transaction->t_journal;
+ transaction_t *prev_trans = journal->j_committing_transaction;
+
+ if (prev_trans) {
+ tid_t prev_tid = prev_trans->t_tid;
+ log_start_commit(journal, prev_trans);
+ log_wait_commit(journal, prev_tid);
+ }
+ handle->h_sync = 1;
+ tried_commit = 1;
+
+ goto repeat;
+ }
+
/* No space left on the device */
goto out;

Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/