@@ -73,7 +73,7 @@ unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct,
7373
7474void gfs2_remove_from_ail (struct gfs2_bufdata * bd )
7575{
76- bd -> bd_ail = NULL ;
76+ bd -> bd_tr = NULL ;
7777 list_del_init (& bd -> bd_ail_st_list );
7878 list_del_init (& bd -> bd_ail_gl_list );
7979 atomic_dec (& bd -> bd_gl -> gl_ail_count );
@@ -90,7 +90,7 @@ void gfs2_remove_from_ail(struct gfs2_bufdata *bd)
9090
9191static int gfs2_ail1_start_one (struct gfs2_sbd * sdp ,
9292 struct writeback_control * wbc ,
93- struct gfs2_ail * ai )
93+ struct gfs2_trans * tr )
9494__releases (& sdp - > sd_ail_lock )
9595__acquires (& sdp - > sd_ail_lock )
9696{
@@ -99,15 +99,15 @@ __acquires(&sdp->sd_ail_lock)
9999 struct gfs2_bufdata * bd , * s ;
100100 struct buffer_head * bh ;
101101
102- list_for_each_entry_safe_reverse (bd , s , & ai -> ai_ail1_list , bd_ail_st_list ) {
102+ list_for_each_entry_safe_reverse (bd , s , & tr -> tr_ail1_list , bd_ail_st_list ) {
103103 bh = bd -> bd_bh ;
104104
105- gfs2_assert (sdp , bd -> bd_ail == ai );
105+ gfs2_assert (sdp , bd -> bd_tr == tr );
106106
107107 if (!buffer_busy (bh )) {
108108 if (!buffer_uptodate (bh ))
109109 gfs2_io_error_bh (sdp , bh );
110- list_move (& bd -> bd_ail_st_list , & ai -> ai_ail2_list );
110+ list_move (& bd -> bd_ail_st_list , & tr -> tr_ail2_list );
111111 continue ;
112112 }
113113
@@ -116,7 +116,7 @@ __acquires(&sdp->sd_ail_lock)
116116 if (gl == bd -> bd_gl )
117117 continue ;
118118 gl = bd -> bd_gl ;
119- list_move (& bd -> bd_ail_st_list , & ai -> ai_ail1_list );
119+ list_move (& bd -> bd_ail_st_list , & tr -> tr_ail1_list );
120120 mapping = bh -> b_page -> mapping ;
121121 if (!mapping )
122122 continue ;
@@ -144,15 +144,15 @@ __acquires(&sdp->sd_ail_lock)
144144void gfs2_ail1_flush (struct gfs2_sbd * sdp , struct writeback_control * wbc )
145145{
146146 struct list_head * head = & sdp -> sd_ail1_list ;
147- struct gfs2_ail * ai ;
147+ struct gfs2_trans * tr ;
148148
149149 trace_gfs2_ail_flush (sdp , wbc , 1 );
150150 spin_lock (& sdp -> sd_ail_lock );
151151restart :
152- list_for_each_entry_reverse (ai , head , ai_list ) {
152+ list_for_each_entry_reverse (tr , head , tr_list ) {
153153 if (wbc -> nr_to_write <= 0 )
154154 break ;
155- if (gfs2_ail1_start_one (sdp , wbc , ai ))
155+ if (gfs2_ail1_start_one (sdp , wbc , tr ))
156156 goto restart ;
157157 }
158158 spin_unlock (& sdp -> sd_ail_lock );
@@ -183,20 +183,20 @@ static void gfs2_ail1_start(struct gfs2_sbd *sdp)
183183 *
184184 */
185185
186- static void gfs2_ail1_empty_one (struct gfs2_sbd * sdp , struct gfs2_ail * ai )
186+ static void gfs2_ail1_empty_one (struct gfs2_sbd * sdp , struct gfs2_trans * tr )
187187{
188188 struct gfs2_bufdata * bd , * s ;
189189 struct buffer_head * bh ;
190190
191- list_for_each_entry_safe_reverse (bd , s , & ai -> ai_ail1_list ,
191+ list_for_each_entry_safe_reverse (bd , s , & tr -> tr_ail1_list ,
192192 bd_ail_st_list ) {
193193 bh = bd -> bd_bh ;
194- gfs2_assert (sdp , bd -> bd_ail == ai );
194+ gfs2_assert (sdp , bd -> bd_tr == tr );
195195 if (buffer_busy (bh ))
196196 continue ;
197197 if (!buffer_uptodate (bh ))
198198 gfs2_io_error_bh (sdp , bh );
199- list_move (& bd -> bd_ail_st_list , & ai -> ai_ail2_list );
199+ list_move (& bd -> bd_ail_st_list , & tr -> tr_ail2_list );
200200 }
201201
202202}
@@ -210,14 +210,14 @@ static void gfs2_ail1_empty_one(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
210210
211211static int gfs2_ail1_empty (struct gfs2_sbd * sdp )
212212{
213- struct gfs2_ail * ai , * s ;
213+ struct gfs2_trans * tr , * s ;
214214 int ret ;
215215
216216 spin_lock (& sdp -> sd_ail_lock );
217- list_for_each_entry_safe_reverse (ai , s , & sdp -> sd_ail1_list , ai_list ) {
218- gfs2_ail1_empty_one (sdp , ai );
219- if (list_empty (& ai -> ai_ail1_list ))
220- list_move (& ai -> ai_list , & sdp -> sd_ail2_list );
217+ list_for_each_entry_safe_reverse (tr , s , & sdp -> sd_ail1_list , tr_list ) {
218+ gfs2_ail1_empty_one (sdp , tr );
219+ if (list_empty (& tr -> tr_ail1_list ))
220+ list_move (& tr -> tr_list , & sdp -> sd_ail2_list );
221221 else
222222 break ;
223223 }
@@ -229,13 +229,13 @@ static int gfs2_ail1_empty(struct gfs2_sbd *sdp)
229229
230230static void gfs2_ail1_wait (struct gfs2_sbd * sdp )
231231{
232- struct gfs2_ail * ai ;
232+ struct gfs2_trans * tr ;
233233 struct gfs2_bufdata * bd ;
234234 struct buffer_head * bh ;
235235
236236 spin_lock (& sdp -> sd_ail_lock );
237- list_for_each_entry_reverse (ai , & sdp -> sd_ail1_list , ai_list ) {
238- list_for_each_entry (bd , & ai -> ai_ail1_list , bd_ail_st_list ) {
237+ list_for_each_entry_reverse (tr , & sdp -> sd_ail1_list , tr_list ) {
238+ list_for_each_entry (bd , & tr -> tr_ail1_list , bd_ail_st_list ) {
239239 bh = bd -> bd_bh ;
240240 if (!buffer_locked (bh ))
241241 continue ;
@@ -256,40 +256,40 @@ static void gfs2_ail1_wait(struct gfs2_sbd *sdp)
256256 *
257257 */
258258
259- static void gfs2_ail2_empty_one (struct gfs2_sbd * sdp , struct gfs2_ail * ai )
259+ static void gfs2_ail2_empty_one (struct gfs2_sbd * sdp , struct gfs2_trans * tr )
260260{
261- struct list_head * head = & ai -> ai_ail2_list ;
261+ struct list_head * head = & tr -> tr_ail2_list ;
262262 struct gfs2_bufdata * bd ;
263263
264264 while (!list_empty (head )) {
265265 bd = list_entry (head -> prev , struct gfs2_bufdata ,
266266 bd_ail_st_list );
267- gfs2_assert (sdp , bd -> bd_ail == ai );
267+ gfs2_assert (sdp , bd -> bd_tr == tr );
268268 gfs2_remove_from_ail (bd );
269269 }
270270}
271271
272272static void ail2_empty (struct gfs2_sbd * sdp , unsigned int new_tail )
273273{
274- struct gfs2_ail * ai , * safe ;
274+ struct gfs2_trans * tr , * safe ;
275275 unsigned int old_tail = sdp -> sd_log_tail ;
276276 int wrap = (new_tail < old_tail );
277277 int a , b , rm ;
278278
279279 spin_lock (& sdp -> sd_ail_lock );
280280
281- list_for_each_entry_safe (ai , safe , & sdp -> sd_ail2_list , ai_list ) {
282- a = (old_tail <= ai -> ai_first );
283- b = (ai -> ai_first < new_tail );
281+ list_for_each_entry_safe (tr , safe , & sdp -> sd_ail2_list , tr_list ) {
282+ a = (old_tail <= tr -> tr_first );
283+ b = (tr -> tr_first < new_tail );
284284 rm = (wrap ) ? (a || b ) : (a && b );
285285 if (!rm )
286286 continue ;
287287
288- gfs2_ail2_empty_one (sdp , ai );
289- list_del (& ai -> ai_list );
290- gfs2_assert_warn (sdp , list_empty (& ai -> ai_ail1_list ));
291- gfs2_assert_warn (sdp , list_empty (& ai -> ai_ail2_list ));
292- kfree (ai );
288+ gfs2_ail2_empty_one (sdp , tr );
289+ list_del (& tr -> tr_list );
290+ gfs2_assert_warn (sdp , list_empty (& tr -> tr_ail1_list ));
291+ gfs2_assert_warn (sdp , list_empty (& tr -> tr_ail2_list ));
292+ kfree (tr );
293293 }
294294
295295 spin_unlock (& sdp -> sd_ail_lock );
@@ -435,16 +435,17 @@ static unsigned int calc_reserved(struct gfs2_sbd *sdp)
435435
436436static unsigned int current_tail (struct gfs2_sbd * sdp )
437437{
438- struct gfs2_ail * ai ;
438+ struct gfs2_trans * tr ;
439439 unsigned int tail ;
440440
441441 spin_lock (& sdp -> sd_ail_lock );
442442
443443 if (list_empty (& sdp -> sd_ail1_list )) {
444444 tail = sdp -> sd_log_head ;
445445 } else {
446- ai = list_entry (sdp -> sd_ail1_list .prev , struct gfs2_ail , ai_list );
447- tail = ai -> ai_first ;
446+ tr = list_entry (sdp -> sd_ail1_list .prev , struct gfs2_trans ,
447+ tr_list );
448+ tail = tr -> tr_first ;
448449 }
449450
450451 spin_unlock (& sdp -> sd_ail_lock );
@@ -600,7 +601,7 @@ static void log_write_header(struct gfs2_sbd *sdp, u32 flags)
600601
601602void gfs2_log_flush (struct gfs2_sbd * sdp , struct gfs2_glock * gl )
602603{
603- struct gfs2_ail * ai ;
604+ struct gfs2_trans * tr ;
604605
605606 down_write (& sdp -> sd_log_flush_lock );
606607
@@ -611,9 +612,12 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl)
611612 }
612613 trace_gfs2_log_flush (sdp , 1 );
613614
614- ai = kzalloc (sizeof (struct gfs2_ail ), GFP_NOFS | __GFP_NOFAIL );
615- INIT_LIST_HEAD (& ai -> ai_ail1_list );
616- INIT_LIST_HEAD (& ai -> ai_ail2_list );
615+ tr = sdp -> sd_log_tr ;
616+ if (tr ) {
617+ sdp -> sd_log_tr = NULL ;
618+ INIT_LIST_HEAD (& tr -> tr_ail1_list );
619+ INIT_LIST_HEAD (& tr -> tr_ail2_list );
620+ }
617621
618622 if (sdp -> sd_log_num_buf != sdp -> sd_log_commited_buf ) {
619623 printk (KERN_INFO "GFS2: log buf %u %u\n" , sdp -> sd_log_num_buf ,
@@ -630,7 +634,8 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl)
630634
631635 sdp -> sd_log_flush_head = sdp -> sd_log_head ;
632636 sdp -> sd_log_flush_wrapped = 0 ;
633- ai -> ai_first = sdp -> sd_log_flush_head ;
637+ if (tr )
638+ tr -> tr_first = sdp -> sd_log_flush_head ;
634639
635640 gfs2_ordered_write (sdp );
636641 lops_before_commit (sdp );
@@ -643,7 +648,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl)
643648 trace_gfs2_log_blocks (sdp , -1 );
644649 log_write_header (sdp , 0 );
645650 }
646- lops_after_commit (sdp , ai );
651+ lops_after_commit (sdp , tr );
647652
648653 gfs2_log_lock (sdp );
649654 sdp -> sd_log_head = sdp -> sd_log_flush_head ;
@@ -653,16 +658,16 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl)
653658 sdp -> sd_log_commited_revoke = 0 ;
654659
655660 spin_lock (& sdp -> sd_ail_lock );
656- if (!list_empty (& ai -> ai_ail1_list )) {
657- list_add (& ai -> ai_list , & sdp -> sd_ail1_list );
658- ai = NULL ;
661+ if (tr && !list_empty (& tr -> tr_ail1_list )) {
662+ list_add (& tr -> tr_list , & sdp -> sd_ail1_list );
663+ tr = NULL ;
659664 }
660665 spin_unlock (& sdp -> sd_ail_lock );
661666 gfs2_log_unlock (sdp );
662667 trace_gfs2_log_flush (sdp , 0 );
663668 up_write (& sdp -> sd_log_flush_lock );
664669
665- kfree (ai );
670+ kfree (tr );
666671}
667672
668673static void log_refund (struct gfs2_sbd * sdp , struct gfs2_trans * tr )
@@ -687,6 +692,12 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
687692 sdp -> sd_jdesc -> jd_blocks );
688693 sdp -> sd_log_blks_reserved = reserved ;
689694
695+ if (sdp -> sd_log_tr == NULL &&
696+ (tr -> tr_num_buf_new || tr -> tr_num_databuf_new )) {
697+ gfs2_assert_withdraw (sdp , tr -> tr_t_gh .gh_gl );
698+ sdp -> sd_log_tr = tr ;
699+ tr -> tr_attached = 1 ;
700+ }
690701 gfs2_log_unlock (sdp );
691702}
692703
@@ -708,7 +719,6 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
708719void gfs2_log_commit (struct gfs2_sbd * sdp , struct gfs2_trans * tr )
709720{
710721 log_refund (sdp , tr );
711- up_read (& sdp -> sd_log_flush_lock );
712722
713723 if (atomic_read (& sdp -> sd_log_pinned ) > atomic_read (& sdp -> sd_log_thresh1 ) ||
714724 ((sdp -> sd_jdesc -> jd_blocks - atomic_read (& sdp -> sd_log_blks_free )) >
0 commit comments