@@ -369,7 +369,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
369369{
370370 struct transaction_stats_s stats ;
371371 transaction_t * commit_transaction ;
372- struct journal_head * jh , * new_jh , * descriptor ;
372+ struct journal_head * jh , * descriptor ;
373373 struct buffer_head * * wbuf = journal -> j_wbuf ;
374374 int bufs ;
375375 int flags ;
@@ -393,6 +393,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
393393 tid_t first_tid ;
394394 int update_tail ;
395395 int csum_size = 0 ;
396+ LIST_HEAD (io_bufs );
396397
397398 if (JBD2_HAS_INCOMPAT_FEATURE (journal , JBD2_FEATURE_INCOMPAT_CSUM_V2 ))
398399 csum_size = sizeof (struct jbd2_journal_block_tail );
@@ -659,29 +660,22 @@ void jbd2_journal_commit_transaction(journal_t *journal)
659660
660661 /* Bump b_count to prevent truncate from stumbling over
661662 the shadowed buffer! @@@ This can go if we ever get
662- rid of the BJ_IO/BJ_Shadow pairing of buffers. */
663+ rid of the shadow pairing of buffers. */
663664 atomic_inc (& jh2bh (jh )-> b_count );
664665
665- /* Make a temporary IO buffer with which to write it out
666- (this will requeue both the metadata buffer and the
667- temporary IO buffer). new_bh goes on BJ_IO*/
668-
669- set_bit (BH_JWrite , & jh2bh (jh )-> b_state );
670666 /*
671- * akpm: jbd2_journal_write_metadata_buffer() sets
672- * new_bh->b_transaction to commit_transaction.
673- * We need to clean this up before we release new_bh
674- * (which is of type BJ_IO)
667+ * Make a temporary IO buffer with which to write it out
668+ * (this will requeue the metadata buffer to BJ_Shadow).
675669 */
670+ set_bit (BH_JWrite , & jh2bh (jh )-> b_state );
676671 JBUFFER_TRACE (jh , "ph3: write metadata" );
677672 flags = jbd2_journal_write_metadata_buffer (commit_transaction ,
678- jh , & new_jh , blocknr );
673+ jh , & wbuf [ bufs ] , blocknr );
679674 if (flags < 0 ) {
680675 jbd2_journal_abort (journal , flags );
681676 continue ;
682677 }
683- set_bit (BH_JWrite , & jh2bh (new_jh )-> b_state );
684- wbuf [bufs ++ ] = jh2bh (new_jh );
678+ jbd2_file_log_bh (& io_bufs , wbuf [bufs ]);
685679
686680 /* Record the new block's tag in the current descriptor
687681 buffer */
@@ -695,10 +689,11 @@ void jbd2_journal_commit_transaction(journal_t *journal)
695689 tag = (journal_block_tag_t * ) tagp ;
696690 write_tag_block (tag_bytes , tag , jh2bh (jh )-> b_blocknr );
697691 tag -> t_flags = cpu_to_be16 (tag_flag );
698- jbd2_block_tag_csum_set (journal , tag , jh2bh ( new_jh ) ,
692+ jbd2_block_tag_csum_set (journal , tag , wbuf [ bufs ] ,
699693 commit_transaction -> t_tid );
700694 tagp += tag_bytes ;
701695 space_left -= tag_bytes ;
696+ bufs ++ ;
702697
703698 if (first_tag ) {
704699 memcpy (tagp , journal -> j_uuid , 16 );
@@ -810,7 +805,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
810805 the log. Before we can commit it, wait for the IO so far to
811806 complete. Control buffers being written are on the
812807 transaction's t_log_list queue, and metadata buffers are on
813- the t_iobuf_list queue .
808+ the io_bufs list .
814809
815810 Wait for the buffers in reverse order. That way we are
816811 less likely to be woken up until all IOs have completed, and
@@ -819,46 +814,31 @@ void jbd2_journal_commit_transaction(journal_t *journal)
819814
820815 jbd_debug (3 , "JBD2: commit phase 3\n" );
821816
822- /*
823- * akpm: these are BJ_IO, and j_list_lock is not needed.
824- * See __journal_try_to_free_buffer.
825- */
826- wait_for_iobuf :
827- while (commit_transaction -> t_iobuf_list != NULL ) {
828- struct buffer_head * bh ;
817+ while (!list_empty (& io_bufs )) {
818+ struct buffer_head * bh = list_entry (io_bufs .prev ,
819+ struct buffer_head ,
820+ b_assoc_buffers );
829821
830- jh = commit_transaction -> t_iobuf_list -> b_tprev ;
831- bh = jh2bh (jh );
832- if (buffer_locked (bh )) {
833- wait_on_buffer (bh );
834- goto wait_for_iobuf ;
835- }
836- if (cond_resched ())
837- goto wait_for_iobuf ;
822+ wait_on_buffer (bh );
823+ cond_resched ();
838824
839825 if (unlikely (!buffer_uptodate (bh )))
840826 err = - EIO ;
841-
842- clear_buffer_jwrite (bh );
843-
844- JBUFFER_TRACE (jh , "ph4: unfile after journal write" );
845- jbd2_journal_unfile_buffer (journal , jh );
827+ jbd2_unfile_log_bh (bh );
846828
847829 /*
848- * ->t_iobuf_list should contain only dummy buffer_heads
849- * which were created by jbd2_journal_write_metadata_buffer().
830+ * The list contains temporary buffer heads created by
831+ * jbd2_journal_write_metadata_buffer().
850832 */
851833 BUFFER_TRACE (bh , "dumping temporary bh" );
852- jbd2_journal_put_journal_head (jh );
853834 __brelse (bh );
854835 J_ASSERT_BH (bh , atomic_read (& bh -> b_count ) == 0 );
855836 free_buffer_head (bh );
856837
857- /* We also have to unlock and free the corresponding
858- shadowed buffer */
838+ /* We also have to refile the corresponding shadowed buffer */
859839 jh = commit_transaction -> t_shadow_list -> b_tprev ;
860840 bh = jh2bh (jh );
861- clear_bit ( BH_JWrite , & bh -> b_state );
841+ clear_buffer_jwrite ( bh );
862842 J_ASSERT_BH (bh , buffer_jbddirty (bh ));
863843
864844 /* The metadata is now released for reuse, but we need
@@ -953,7 +933,6 @@ void jbd2_journal_commit_transaction(journal_t *journal)
953933 J_ASSERT (list_empty (& commit_transaction -> t_inode_list ));
954934 J_ASSERT (commit_transaction -> t_buffers == NULL );
955935 J_ASSERT (commit_transaction -> t_checkpoint_list == NULL );
956- J_ASSERT (commit_transaction -> t_iobuf_list == NULL );
957936 J_ASSERT (commit_transaction -> t_shadow_list == NULL );
958937 J_ASSERT (commit_transaction -> t_log_list == NULL );
959938
0 commit comments