Whamcloud - gitweb
adding 2.6-sles10 target and kernel config files for the sles10 kernel
[fs/lustre-release.git] / lustre / kernel_patches / patches / jbd-commit-tricks.patch
1
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.
6   */
7  
8 -void log_wait_for_space(journal_t *journal, int nblocks)
9 +void log_wait_for_space(journal_t *journal)
10  {
11 +       int nblocks;
12 +
13 +       nblocks = jbd_space_needed(journal);
14         while (log_space_left(journal) < nblocks) {
15                 if (journal->j_flags & JFS_ABORT)
16                         return;
17                 unlock_journal(journal);
18                 down(&journal->j_checkpoint_sem);
19                 lock_journal(journal);
20 +               nblocks = jbd_space_needed(journal);
21                 
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);
27                 }
28                 up(&journal->j_checkpoint_sem);
29         }
30 @@ -260,8 +264,7 @@ static int __flush_buffer(journal_t *jou
31   * The journal should be locked before calling this function.
32   */
33  
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)
37  {
38         transaction_t *transaction, *last_transaction, *next_transaction;
39         int result;
40 @@ -315,6 +318,8 @@ repeat:
41                         retry = __flush_buffer(journal, jh, bhs, &batch_count,
42                                                 &drop_count);
43                 } while (jh != last_jh && !retry);
44 +               if (journal->j_checkpoint_transactions != transaction)
45 +                       goto done;
46                 if (batch_count) {
47                         __flush_batch(bhs, &batch_count);
48                         goto repeat;
49 @@ -328,6 +333,8 @@ repeat:
50                  */
51                 cleanup_ret = __cleanup_transaction(journal, transaction);
52                 J_ASSERT(drop_count != 0 || cleanup_ret != 0);
53 +               if (journal->j_checkpoint_transactions != transaction)
54 +                       goto done;
55                 goto repeat;    /* __cleanup may have dropped lock */
56         } while (transaction != last_transaction);
57  
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);
66  
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);
76  
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
82          * journal_extend().
83          */
84 -       needed = journal->j_max_transaction_buffers;
85 -       if (journal->j_committing_transaction) 
86 -               needed += journal->j_committing_transaction->
87 -                                       t_outstanding_credits;
88 -       
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);
94                 goto repeat_locked;
95         }
96  
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 *);
105  
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 *);
110  
111 @@ -815,6 +815,19 @@ static inline int tid_geq(tid_t x, tid_t
112  }
113  
114  extern int journal_blocks_per_page(struct inode *inode);
115 +
116 +/*
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.
119 + */
120 +static inline int jbd_space_needed(journal_t *journal)
121 +{
122 +       int nblocks = journal->j_max_transaction_buffers;
123 +       if (journal->j_committing_transaction)
124 +               nblocks += journal->j_committing_transaction->
125 +                       t_outstanding_credits;
126 +       return nblocks;
127 +}
128  
129  /*
130   * Definitions which augment the buffer_head layer
131
132 _