4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1998
6 * Copyright 1998 Red Hat corp --- All Rights Reserved
8 * This file is part of the Linux kernel and is made available under
9 * the terms of the GNU General Public License, version 2, or at your
10 * option, any later version, incorporated herein by reference.
12 * Journal commit routines for the generic filesystem journaling code;
13 * part of the ext2fs journaling system.
16 #include <linux/time.h>
18 #include <linux/jbd.h>
19 #include <linux/errno.h>
20 #include <linux/slab.h>
22 #include <linux/pagemap.h>
23 #include <linux/smp_lock.h>
26 * Default IO end handler for temporary BJ_IO buffer_heads.
28 static void journal_end_buffer_io_sync(struct buffer_head *bh, int uptodate)
32 set_buffer_uptodate(bh);
34 clear_buffer_uptodate(bh);
39 * When an ext3-ordered file is truncated, it is possible that many pages are
40 * not sucessfully freed, because they are attached to a committing transaction.
41 * After the transaction commits, these pages are left on the LRU, with no
42 * ->mapping, and with attached buffers. These pages are trivially reclaimable
43 * by the VM, but their apparent absence upsets the VM accounting, and it makes
44 * the numbers in /proc/meminfo look odd.
46 * So here, we have a buffer which has just come off the forget list. Look to
47 * see if we can strip all buffers from the backing page.
49 * Called under lock_journal(), and possibly under journal_datalist_lock. The
50 * caller provided us with a ref against the buffer, and we drop that here.
52 static void release_buffer_page(struct buffer_head *bh)
58 if (atomic_read(&bh->b_count) != 1)
66 /* OK, it's a truncated page */
67 if (TestSetPageLocked(page))
72 try_to_free_buffers(page);
74 page_cache_release(page);
82 * Try to acquire jbd_lock_bh_state() against the buffer, when j_list_lock is
83 * held. For ranking reasons we must trylock. If we lose, schedule away and
84 * return 0. j_list_lock is dropped in this case.
86 static int inverted_lock(journal_t *journal, struct buffer_head *bh)
88 if (!jbd_trylock_bh_state(bh)) {
89 spin_unlock(&journal->j_list_lock);
96 /* Done it all: now write the commit record. We should have
97 * cleaned up our previous buffers by now, so if we are in abort
98 * mode we can now just skip the rest of the journal write
101 * Returns 1 if the journal needs to be aborted or 0 on success
103 static int journal_write_commit_record(journal_t *journal,
104 transaction_t *commit_transaction)
106 struct journal_head *descriptor;
107 struct buffer_head *bh;
109 int barrier_done = 0;
111 if (is_journal_aborted(journal))
114 descriptor = journal_get_descriptor_buffer(journal);
118 bh = jh2bh(descriptor);
120 /* AKPM: buglet - add `i' to tmp! */
121 for (i = 0; i < bh->b_size; i += 512) {
122 journal_header_t *tmp = (journal_header_t*)bh->b_data;
123 tmp->h_magic = cpu_to_be32(JFS_MAGIC_NUMBER);
124 tmp->h_blocktype = cpu_to_be32(JFS_COMMIT_BLOCK);
125 tmp->h_sequence = cpu_to_be32(commit_transaction->t_tid);
128 JBUFFER_TRACE(descriptor, "write commit block");
129 set_buffer_dirty(bh);
130 if (journal->j_flags & JFS_BARRIER) {
131 set_buffer_ordered(bh);
134 ret = sync_dirty_buffer(bh);
135 /* is it possible for another commit to fail at roughly
136 * the same time as this one? If so, we don't want to
137 * trust the barrier flag in the super, but instead want
138 * to remember if we sent a barrier request
140 if (ret == -EOPNOTSUPP && barrier_done) {
141 char b[BDEVNAME_SIZE];
144 "JBD: barrier-based sync failed on %s - "
145 "disabling barriers\n",
146 bdevname(journal->j_dev, b));
147 spin_lock(&journal->j_state_lock);
148 journal->j_flags &= ~JFS_BARRIER;
149 spin_unlock(&journal->j_state_lock);
151 /* And try again, without the barrier */
152 clear_buffer_ordered(bh);
153 set_buffer_uptodate(bh);
154 set_buffer_dirty(bh);
155 ret = sync_dirty_buffer(bh);
157 put_bh(bh); /* One for getblk() */
158 journal_put_journal_head(descriptor);
160 return (ret == -EIO);
164 * journal_commit_transaction
166 * The primary function for committing a transaction to the log. This
167 * function is called by the journal thread to begin a complete commit.
169 void journal_commit_transaction(journal_t *journal)
171 transaction_t *commit_transaction;
172 struct journal_head *jh, *new_jh, *descriptor;
173 struct buffer_head **wbuf = journal->j_wbuf;
177 unsigned long blocknr;
179 journal_header_t *header;
180 journal_block_tag_t *tag = NULL;
187 * First job: lock down the current transaction and wait for
188 * all outstanding updates to complete.
192 spin_lock(&journal->j_list_lock);
193 summarise_journal_usage(journal);
194 spin_unlock(&journal->j_list_lock);
197 /* Do we need to erase the effects of a prior journal_flush? */
198 if (journal->j_flags & JFS_FLUSHED) {
199 jbd_debug(3, "super block updated\n");
200 journal_update_superblock(journal, 1);
202 jbd_debug(3, "superblock not updated\n");
205 J_ASSERT(journal->j_running_transaction != NULL);
206 J_ASSERT(journal->j_committing_transaction == NULL);
208 commit_transaction = journal->j_running_transaction;
209 J_ASSERT(commit_transaction->t_state == T_RUNNING);
211 jbd_debug(1, "JBD: starting commit of transaction %d\n",
212 commit_transaction->t_tid);
214 spin_lock(&journal->j_state_lock);
215 commit_transaction->t_state = T_LOCKED;
217 spin_lock(&commit_transaction->t_handle_lock);
218 while (commit_transaction->t_updates) {
221 prepare_to_wait(&journal->j_wait_updates, &wait,
222 TASK_UNINTERRUPTIBLE);
223 if (commit_transaction->t_updates) {
224 spin_unlock(&commit_transaction->t_handle_lock);
225 spin_unlock(&journal->j_state_lock);
227 spin_lock(&journal->j_state_lock);
228 spin_lock(&commit_transaction->t_handle_lock);
230 finish_wait(&journal->j_wait_updates, &wait);
232 spin_unlock(&commit_transaction->t_handle_lock);
234 J_ASSERT (commit_transaction->t_outstanding_credits <=
235 journal->j_max_transaction_buffers);
238 * First thing we are allowed to do is to discard any remaining
239 * BJ_Reserved buffers. Note, it is _not_ permissible to assume
240 * that there are no such buffers: if a large filesystem
241 * operation like a truncate needs to split itself over multiple
242 * transactions, then it may try to do a journal_restart() while
243 * there are still BJ_Reserved buffers outstanding. These must
244 * be released cleanly from the current transaction.
246 * In this case, the filesystem must still reserve write access
247 * again before modifying the buffer in the new transaction, but
248 * we do not require it to remember exactly which old buffers it
249 * has reserved. This is consistent with the existing behaviour
250 * that multiple journal_get_write_access() calls to the same
251 * buffer are perfectly permissable.
253 while (commit_transaction->t_reserved_list) {
254 jh = commit_transaction->t_reserved_list;
255 JBUFFER_TRACE(jh, "reserved, unused: refile");
257 * A journal_get_undo_access()+journal_release_buffer() may
258 * leave undo-committed data.
260 if (jh->b_committed_data) {
261 struct buffer_head *bh = jh2bh(jh);
263 jbd_lock_bh_state(bh);
264 if (jh->b_committed_data) {
265 kfree(jh->b_committed_data);
266 jh->b_committed_data = NULL;
268 jbd_unlock_bh_state(bh);
270 journal_refile_buffer(journal, jh);
274 * Now try to drop any written-back buffers from the journal's
275 * checkpoint lists. We do this *before* commit because it potentially
278 spin_lock(&journal->j_list_lock);
279 __journal_clean_checkpoint_list(journal);
280 spin_unlock(&journal->j_list_lock);
282 jbd_debug (3, "JBD: commit phase 1\n");
285 * Switch to a new revoke table.
287 journal_switch_revoke_table(journal);
289 commit_transaction->t_state = T_FLUSH;
290 journal->j_committing_transaction = commit_transaction;
291 journal->j_running_transaction = NULL;
292 commit_transaction->t_log_start = journal->j_head;
293 wake_up(&journal->j_wait_transaction_locked);
294 spin_unlock(&journal->j_state_lock);
296 jbd_debug (3, "JBD: commit phase 2\n");
299 * First, drop modified flag: all accesses to the buffers
300 * will be tracked for a new trasaction only -bzzz
302 spin_lock(&journal->j_list_lock);
303 if (commit_transaction->t_buffers) {
304 new_jh = jh = commit_transaction->t_buffers->b_tnext;
306 J_ASSERT_JH(new_jh, new_jh->b_modified == 1 ||
307 new_jh->b_modified == 0);
308 new_jh->b_modified = 0;
309 new_jh = new_jh->b_tnext;
310 } while (new_jh != jh);
312 spin_unlock(&journal->j_list_lock);
315 * Now start flushing things to disk, in the order they appear
316 * on the transaction lists. Data blocks go first.
321 * Whenever we unlock the journal and sleep, things can get added
322 * onto ->t_sync_datalist, so we have to keep looping back to
323 * write_out_data until we *know* that the list is empty.
327 * Cleanup any flushed data buffers from the data list. Even in
328 * abort mode, we want to flush this out as soon as possible.
332 spin_lock(&journal->j_list_lock);
334 while (commit_transaction->t_sync_datalist) {
335 struct buffer_head *bh;
337 jh = commit_transaction->t_sync_datalist;
338 commit_transaction->t_sync_datalist = jh->b_tnext;
340 if (buffer_locked(bh)) {
341 BUFFER_TRACE(bh, "locked");
342 if (!inverted_lock(journal, bh))
344 __journal_temp_unlink_buffer(jh);
345 __journal_file_buffer(jh, commit_transaction,
347 jbd_unlock_bh_state(bh);
348 if (lock_need_resched(&journal->j_list_lock)) {
349 spin_unlock(&journal->j_list_lock);
353 if (buffer_dirty(bh)) {
354 BUFFER_TRACE(bh, "start journal writeout");
357 if (bufs == journal->j_wbufsize) {
358 jbd_debug(2, "submit %d writes\n",
360 spin_unlock(&journal->j_list_lock);
361 ll_rw_block(SWRITE, bufs, wbuf);
362 journal_brelse_array(wbuf, bufs);
367 BUFFER_TRACE(bh, "writeout complete: unfile");
368 if (!inverted_lock(journal, bh))
370 __journal_unfile_buffer(jh);
371 jbd_unlock_bh_state(bh);
372 journal_remove_journal_head(bh);
374 if (lock_need_resched(&journal->j_list_lock)) {
375 spin_unlock(&journal->j_list_lock);
383 spin_unlock(&journal->j_list_lock);
384 ll_rw_block(SWRITE, bufs, wbuf);
385 journal_brelse_array(wbuf, bufs);
386 spin_lock(&journal->j_list_lock);
390 * Wait for all previously submitted IO to complete.
392 while (commit_transaction->t_locked_list) {
393 struct buffer_head *bh;
395 jh = commit_transaction->t_locked_list->b_tprev;
398 if (buffer_locked(bh)) {
399 spin_unlock(&journal->j_list_lock);
401 if (unlikely(!buffer_uptodate(bh)))
403 spin_lock(&journal->j_list_lock);
405 if (!inverted_lock(journal, bh)) {
407 spin_lock(&journal->j_list_lock);
410 if (buffer_jbd(bh) && jh->b_jlist == BJ_Locked) {
411 __journal_unfile_buffer(jh);
412 jbd_unlock_bh_state(bh);
413 journal_remove_journal_head(bh);
416 jbd_unlock_bh_state(bh);
419 cond_resched_lock(&journal->j_list_lock);
421 spin_unlock(&journal->j_list_lock);
424 __journal_abort_hard(journal);
426 journal_write_revoke_records(journal, commit_transaction);
428 jbd_debug(3, "JBD: commit phase 2\n");
431 * If we found any dirty or locked buffers, then we should have
432 * looped back up to the write_out_data label. If there weren't
433 * any then journal_clean_data_list should have wiped the list
434 * clean by now, so check that it is in fact empty.
436 J_ASSERT (commit_transaction->t_sync_datalist == NULL);
438 jbd_debug (3, "JBD: commit phase 3\n");
441 * Way to go: we have now written out all of the data for a
442 * transaction! Now comes the tricky part: we need to write out
443 * metadata. Loop over the transaction's entire buffer list:
445 commit_transaction->t_state = T_COMMIT;
449 while (commit_transaction->t_buffers) {
451 /* Find the next buffer to be journaled... */
453 jh = commit_transaction->t_buffers;
455 /* If we're in abort mode, we just un-journal the buffer and
456 release it for background writing. */
458 if (is_journal_aborted(journal)) {
459 JBUFFER_TRACE(jh, "journal is aborting: refile");
460 journal_refile_buffer(journal, jh);
461 /* If that was the last one, we need to clean up
462 * any descriptor buffers which may have been
463 * already allocated, even if we are now
465 if (!commit_transaction->t_buffers)
466 goto start_journal_io;
470 /* Make sure we have a descriptor block in which to
471 record the metadata buffer. */
474 struct buffer_head *bh;
476 J_ASSERT (bufs == 0);
478 jbd_debug(4, "JBD: get descriptor\n");
480 descriptor = journal_get_descriptor_buffer(journal);
482 __journal_abort_hard(journal);
486 bh = jh2bh(descriptor);
487 jbd_debug(4, "JBD: got buffer %llu (%p)\n",
488 (unsigned long long)bh->b_blocknr, bh->b_data);
489 header = (journal_header_t *)&bh->b_data[0];
490 header->h_magic = cpu_to_be32(JFS_MAGIC_NUMBER);
491 header->h_blocktype = cpu_to_be32(JFS_DESCRIPTOR_BLOCK);
492 header->h_sequence = cpu_to_be32(commit_transaction->t_tid);
494 tagp = &bh->b_data[sizeof(journal_header_t)];
495 space_left = bh->b_size - sizeof(journal_header_t);
497 set_buffer_jwrite(bh);
498 set_buffer_dirty(bh);
501 /* Record it so that we can wait for IO
503 BUFFER_TRACE(bh, "ph3: file as descriptor");
504 journal_file_buffer(descriptor, commit_transaction,
508 /* Where is the buffer to be written? */
510 err = journal_next_log_block(journal, &blocknr);
511 /* If the block mapping failed, just abandon the buffer
512 and repeat this loop: we'll fall into the
513 refile-on-abort condition above. */
515 __journal_abort_hard(journal);
520 * start_this_handle() uses t_outstanding_credits to determine
521 * the free space in the log, but this counter is changed
522 * by journal_next_log_block() also.
524 commit_transaction->t_outstanding_credits--;
526 /* Bump b_count to prevent truncate from stumbling over
527 the shadowed buffer! @@@ This can go if we ever get
528 rid of the BJ_IO/BJ_Shadow pairing of buffers. */
529 atomic_inc(&jh2bh(jh)->b_count);
531 /* Make a temporary IO buffer with which to write it out
532 (this will requeue both the metadata buffer and the
533 temporary IO buffer). new_bh goes on BJ_IO*/
535 set_bit(BH_JWrite, &jh2bh(jh)->b_state);
537 * akpm: journal_write_metadata_buffer() sets
538 * new_bh->b_transaction to commit_transaction.
539 * We need to clean this up before we release new_bh
540 * (which is of type BJ_IO)
542 JBUFFER_TRACE(jh, "ph3: write metadata");
543 flags = journal_write_metadata_buffer(commit_transaction,
544 jh, &new_jh, blocknr);
545 set_bit(BH_JWrite, &jh2bh(new_jh)->b_state);
546 wbuf[bufs++] = jh2bh(new_jh);
548 /* Record the new block's tag in the current descriptor
553 tag_flag |= JFS_FLAG_ESCAPE;
555 tag_flag |= JFS_FLAG_SAME_UUID;
557 tag = (journal_block_tag_t *) tagp;
558 tag->t_blocknr = cpu_to_be32(jh2bh(jh)->b_blocknr);
559 tag->t_flags = cpu_to_be32(tag_flag);
560 tagp += sizeof(journal_block_tag_t);
561 space_left -= sizeof(journal_block_tag_t);
564 memcpy (tagp, journal->j_uuid, 16);
570 /* If there's no more to do, or if the descriptor is full,
573 if (bufs == journal->j_wbufsize ||
574 commit_transaction->t_buffers == NULL ||
575 space_left < sizeof(journal_block_tag_t) + 16) {
577 jbd_debug(4, "JBD: Submit %d IOs\n", bufs);
579 /* Write an end-of-descriptor marker before
580 submitting the IOs. "tag" still points to
581 the last tag we set up. */
583 tag->t_flags |= cpu_to_be32(JFS_FLAG_LAST_TAG);
586 for (i = 0; i < bufs; i++) {
587 struct buffer_head *bh = wbuf[i];
589 clear_buffer_dirty(bh);
590 set_buffer_uptodate(bh);
591 bh->b_end_io = journal_end_buffer_io_sync;
592 submit_bh(WRITE, bh);
596 /* Force a new descriptor to be generated next
597 time round the loop. */
603 /* Lo and behold: we have just managed to send a transaction to
604 the log. Before we can commit it, wait for the IO so far to
605 complete. Control buffers being written are on the
606 transaction's t_log_list queue, and metadata buffers are on
607 the t_iobuf_list queue.
609 Wait for the buffers in reverse order. That way we are
610 less likely to be woken up until all IOs have completed, and
611 so we incur less scheduling load.
614 jbd_debug(3, "JBD: commit phase 4\n");
617 * akpm: these are BJ_IO, and j_list_lock is not needed.
618 * See __journal_try_to_free_buffer.
621 while (commit_transaction->t_iobuf_list != NULL) {
622 struct buffer_head *bh;
624 jh = commit_transaction->t_iobuf_list->b_tprev;
626 if (buffer_locked(bh)) {
633 if (unlikely(!buffer_uptodate(bh)))
636 clear_buffer_jwrite(bh);
638 JBUFFER_TRACE(jh, "ph4: unfile after journal write");
639 journal_unfile_buffer(journal, jh);
642 * ->t_iobuf_list should contain only dummy buffer_heads
643 * which were created by journal_write_metadata_buffer().
645 BUFFER_TRACE(bh, "dumping temporary bh");
646 journal_put_journal_head(jh);
648 J_ASSERT_BH(bh, atomic_read(&bh->b_count) == 0);
649 free_buffer_head(bh);
651 /* We also have to unlock and free the corresponding
653 jh = commit_transaction->t_shadow_list->b_tprev;
655 clear_bit(BH_JWrite, &bh->b_state);
656 J_ASSERT_BH(bh, buffer_jbddirty(bh));
658 /* The metadata is now released for reuse, but we need
659 to remember it against this transaction so that when
660 we finally commit, we can do any checkpointing
662 JBUFFER_TRACE(jh, "file as BJ_Forget");
663 journal_file_buffer(jh, commit_transaction, BJ_Forget);
664 /* Wake up any transactions which were waiting for this
666 wake_up_bit(&bh->b_state, BH_Unshadow);
667 JBUFFER_TRACE(jh, "brelse shadowed buffer");
671 J_ASSERT (commit_transaction->t_shadow_list == NULL);
673 jbd_debug(3, "JBD: commit phase 5\n");
675 /* Here we wait for the revoke record and descriptor record buffers */
677 while (commit_transaction->t_log_list != NULL) {
678 struct buffer_head *bh;
680 jh = commit_transaction->t_log_list->b_tprev;
682 if (buffer_locked(bh)) {
684 goto wait_for_ctlbuf;
687 goto wait_for_ctlbuf;
689 if (unlikely(!buffer_uptodate(bh)))
692 BUFFER_TRACE(bh, "ph5: control buffer writeout done: unfile");
693 clear_buffer_jwrite(bh);
694 journal_unfile_buffer(journal, jh);
695 journal_put_journal_head(jh);
696 __brelse(bh); /* One for getblk */
697 /* AKPM: bforget here */
700 jbd_debug(3, "JBD: commit phase 6\n");
702 if (journal_write_commit_record(journal, commit_transaction))
706 __journal_abort_hard(journal);
708 /* End of a transaction! Finally, we can do checkpoint
709 processing: any buffers committed as a result of this
710 transaction can be removed from any checkpoint list it was on
713 jbd_debug(3, "JBD: commit phase 7\n");
715 J_ASSERT(commit_transaction->t_sync_datalist == NULL);
716 J_ASSERT(commit_transaction->t_buffers == NULL);
717 J_ASSERT(commit_transaction->t_checkpoint_list == NULL);
718 J_ASSERT(commit_transaction->t_iobuf_list == NULL);
719 J_ASSERT(commit_transaction->t_shadow_list == NULL);
720 J_ASSERT(commit_transaction->t_log_list == NULL);
724 * As there are other places (journal_unmap_buffer()) adding buffers
725 * to this list we have to be careful and hold the j_list_lock.
727 spin_lock(&journal->j_list_lock);
728 while (commit_transaction->t_forget) {
729 transaction_t *cp_transaction;
730 struct buffer_head *bh;
732 jh = commit_transaction->t_forget;
733 spin_unlock(&journal->j_list_lock);
735 jbd_lock_bh_state(bh);
736 J_ASSERT_JH(jh, jh->b_transaction == commit_transaction ||
737 jh->b_transaction == journal->j_running_transaction);
740 * If there is undo-protected committed data against
741 * this buffer, then we can remove it now. If it is a
742 * buffer needing such protection, the old frozen_data
743 * field now points to a committed version of the
744 * buffer, so rotate that field to the new committed
747 * Otherwise, we can just throw away the frozen data now.
749 if (jh->b_committed_data) {
750 kfree(jh->b_committed_data);
751 jh->b_committed_data = NULL;
752 if (jh->b_frozen_data) {
753 jh->b_committed_data = jh->b_frozen_data;
754 jh->b_frozen_data = NULL;
756 } else if (jh->b_frozen_data) {
757 kfree(jh->b_frozen_data);
758 jh->b_frozen_data = NULL;
761 spin_lock(&journal->j_list_lock);
762 cp_transaction = jh->b_cp_transaction;
763 if (cp_transaction) {
764 JBUFFER_TRACE(jh, "remove from old cp transaction");
765 __journal_remove_checkpoint(jh);
768 /* Only re-checkpoint the buffer_head if it is marked
769 * dirty. If the buffer was added to the BJ_Forget list
770 * by journal_forget, it may no longer be dirty and
771 * there's no point in keeping a checkpoint record for
774 /* A buffer which has been freed while still being
775 * journaled by a previous transaction may end up still
776 * being dirty here, but we want to avoid writing back
777 * that buffer in the future now that the last use has
778 * been committed. That's not only a performance gain,
779 * it also stops aliasing problems if the buffer is left
780 * behind for writeback and gets reallocated for another
781 * use in a different page. */
782 if (buffer_freed(bh)) {
783 clear_buffer_freed(bh);
784 clear_buffer_jbddirty(bh);
787 if (buffer_jbddirty(bh)) {
788 JBUFFER_TRACE(jh, "add to new checkpointing trans");
789 __journal_insert_checkpoint(jh, commit_transaction);
790 JBUFFER_TRACE(jh, "refile for checkpoint writeback");
791 __journal_refile_buffer(jh);
792 jbd_unlock_bh_state(bh);
794 J_ASSERT_BH(bh, !buffer_dirty(bh));
795 J_ASSERT_JH(jh, jh->b_next_transaction == NULL);
796 __journal_unfile_buffer(jh);
797 jbd_unlock_bh_state(bh);
798 journal_remove_journal_head(bh); /* needs a brelse */
799 release_buffer_page(bh);
801 cond_resched_lock(&journal->j_list_lock);
803 spin_unlock(&journal->j_list_lock);
805 * This is a bit sleazy. We borrow j_list_lock to protect
806 * journal->j_committing_transaction in __journal_remove_checkpoint.
807 * Really, __journal_remove_checkpoint should be using j_state_lock but
808 * it's a bit hassle to hold that across __journal_remove_checkpoint
810 spin_lock(&journal->j_state_lock);
811 spin_lock(&journal->j_list_lock);
813 * Now recheck if some buffers did not get attached to the transaction
814 * while the lock was dropped...
816 if (commit_transaction->t_forget) {
817 spin_unlock(&journal->j_list_lock);
818 spin_unlock(&journal->j_state_lock);
822 /* Done with this transaction! */
824 jbd_debug(3, "JBD: commit phase 8\n");
826 J_ASSERT(commit_transaction->t_state == T_COMMIT);
828 commit_transaction->t_state = T_FINISHED;
829 J_ASSERT(commit_transaction == journal->j_committing_transaction);
830 journal->j_commit_sequence = commit_transaction->t_tid;
831 journal->j_committing_transaction = NULL;
832 spin_unlock(&journal->j_state_lock);
834 if (commit_transaction->t_checkpoint_list == NULL) {
835 __journal_drop_transaction(journal, commit_transaction);
837 if (journal->j_checkpoint_transactions == NULL) {
838 journal->j_checkpoint_transactions = commit_transaction;
839 commit_transaction->t_cpnext = commit_transaction;
840 commit_transaction->t_cpprev = commit_transaction;
842 commit_transaction->t_cpnext =
843 journal->j_checkpoint_transactions;
844 commit_transaction->t_cpprev =
845 commit_transaction->t_cpnext->t_cpprev;
846 commit_transaction->t_cpnext->t_cpprev =
848 commit_transaction->t_cpprev->t_cpnext =
852 spin_unlock(&journal->j_list_lock);
854 jbd_debug(1, "JBD: commit %d complete, head %d\n",
855 journal->j_commit_sequence, journal->j_tail_sequence);
857 wake_up(&journal->j_wait_done_commit);