2 --- linux-2.4.18/fs/jbd/checkpoint.c~jbd-commit-tricks Mon Jul 28 13:52:05 2003
3 +++ linux-2.4.18-alexey/fs/jbd/checkpoint.c Mon Jul 28 14:03:59 2003
4 @@ -77,19 +77,23 @@ static int __try_to_free_cp_buf(struct j
5 * to wait for a checkpoint to free up some space in the log.
8 -void log_wait_for_space(journal_t *journal, int nblocks)
9 +void log_wait_for_space(journal_t *journal)
13 + nblocks = jbd_space_needed(journal);
14 while (log_space_left(journal) < nblocks) {
15 if (journal->j_flags & JFS_ABORT)
17 unlock_journal(journal);
18 down(&journal->j_checkpoint_sem);
19 lock_journal(journal);
20 + nblocks = jbd_space_needed(journal);
22 /* Test again, another process may have checkpointed
23 * while we were waiting for the checkpoint lock */
24 if (log_space_left(journal) < nblocks) {
25 - log_do_checkpoint(journal, nblocks);
26 + log_do_checkpoint(journal);
28 up(&journal->j_checkpoint_sem);
30 @@ -260,8 +264,7 @@ static int __flush_buffer(journal_t *jou
31 * The journal should be locked before calling this function.
34 -/* @@@ `nblocks' is unused. Should it be used? */
35 -int log_do_checkpoint (journal_t *journal, int nblocks)
36 +int log_do_checkpoint (journal_t *journal)
38 transaction_t *transaction, *last_transaction, *next_transaction;
40 @@ -315,6 +318,8 @@ repeat:
41 retry = __flush_buffer(journal, jh, bhs, &batch_count,
43 } while (jh != last_jh && !retry);
44 + if (journal->j_checkpoint_transactions != transaction)
47 __flush_batch(bhs, &batch_count);
49 @@ -328,6 +333,8 @@ repeat:
51 cleanup_ret = __cleanup_transaction(journal, transaction);
52 J_ASSERT(drop_count != 0 || cleanup_ret != 0);
53 + if (journal->j_checkpoint_transactions != transaction)
55 goto repeat; /* __cleanup may have dropped lock */
56 } while (transaction != last_transaction);
58 --- linux-2.4.18/fs/jbd/journal.c~jbd-commit-tricks Mon Jul 28 13:52:05 2003
59 +++ linux-2.4.18-alexey/fs/jbd/journal.c Mon Jul 28 14:03:59 2003
60 @@ -1115,7 +1115,7 @@ void journal_destroy (journal_t *journal
61 /* Force any old transactions to disk */
62 lock_journal(journal);
63 while (journal->j_checkpoint_transactions != NULL)
64 - log_do_checkpoint(journal, 1);
65 + log_do_checkpoint(journal);
67 J_ASSERT(journal->j_running_transaction == NULL);
68 J_ASSERT(journal->j_committing_transaction == NULL);
69 @@ -1302,7 +1302,7 @@ int journal_flush (journal_t *journal)
70 /* ...and flush everything in the log out to disk. */
71 lock_journal(journal);
72 while (!err && journal->j_checkpoint_transactions != NULL)
73 - err = log_do_checkpoint(journal, journal->j_maxlen);
74 + err = log_do_checkpoint(journal);
75 cleanup_journal_tail(journal);
77 /* Finally, mark the journal as really needing no recovery.
78 --- linux-2.4.18/fs/jbd/transaction.c~jbd-commit-tricks Mon Jul 28 13:52:05 2003
79 +++ linux-2.4.18-alexey/fs/jbd/transaction.c Mon Jul 28 14:03:59 2003
80 @@ -182,14 +182,9 @@ repeat_locked:
81 * Also, this test is inconsitent with the matching one in
84 - needed = journal->j_max_transaction_buffers;
85 - if (journal->j_committing_transaction)
86 - needed += journal->j_committing_transaction->
87 - t_outstanding_credits;
89 - if (log_space_left(journal) < needed) {
90 + if (log_space_left(journal) < jbd_space_needed(journal)) {
91 jbd_debug(2, "Handle %p waiting for checkpoint...\n", handle);
92 - log_wait_for_space(journal, needed);
93 + log_wait_for_space(journal);
97 --- linux-2.4.18/include/linux/jbd.h~jbd-commit-tricks Mon Jul 28 13:52:17 2003
98 +++ linux-2.4.18-alexey/include/linux/jbd.h Mon Jul 28 14:03:59 2003
99 @@ -740,9 +740,9 @@ extern void journal_brelse_array(stru
100 extern int log_space_left (journal_t *); /* Called with journal locked */
101 extern tid_t log_start_commit (journal_t *, transaction_t *);
102 extern void log_wait_commit (journal_t *, tid_t);
103 -extern int log_do_checkpoint (journal_t *, int);
104 +extern int log_do_checkpoint (journal_t *);
106 -extern void log_wait_for_space(journal_t *, int nblocks);
107 +extern void log_wait_for_space(journal_t *);
108 extern void __journal_drop_transaction(journal_t *, transaction_t *);
109 extern int cleanup_journal_tail(journal_t *);
111 @@ -815,6 +815,19 @@ static inline int tid_geq(tid_t x, tid_t
114 extern int journal_blocks_per_page(struct inode *inode);
117 + * Return the minimum number of blocks which must be free in the journal
118 + * before a new transaction may be started. Must be called under j_state_lock.
120 +static inline int jbd_space_needed(journal_t *journal)
122 + int nblocks = journal->j_max_transaction_buffers;
123 + if (journal->j_committing_transaction)
124 + nblocks += journal->j_committing_transaction->
125 + t_outstanding_credits;
130 * Definitions which augment the buffer_head layer