2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
7 * of the GNU General Public License version 2.
10 #include <linux/sched.h>
11 #include <linux/slab.h>
12 #include <linux/spinlock.h>
13 #include <linux/completion.h>
14 #include <linux/buffer_head.h>
15 #include <linux/gfs2_ondisk.h>
16 #include <linux/lm_interface.h>
29 static void glock_lo_add(struct gfs2_sbd
*sdp
, struct gfs2_log_element
*le
)
31 struct gfs2_glock
*gl
;
32 struct gfs2_trans
*tr
= current
->journal_info
;
36 gl
= container_of(le
, struct gfs2_glock
, gl_le
);
37 if (gfs2_assert_withdraw(sdp
, gfs2_glock_is_held_excl(gl
)))
41 if (!list_empty(&le
->le_list
)){
46 set_bit(GLF_DIRTY
, &gl
->gl_flags
);
48 list_add(&le
->le_list
, &sdp
->sd_log_le_gl
);
52 static void glock_lo_after_commit(struct gfs2_sbd
*sdp
, struct gfs2_ail
*ai
)
54 struct list_head
*head
= &sdp
->sd_log_le_gl
;
55 struct gfs2_glock
*gl
;
57 while (!list_empty(head
)) {
58 gl
= list_entry(head
->next
, struct gfs2_glock
, gl_le
.le_list
);
59 list_del_init(&gl
->gl_le
.le_list
);
62 gfs2_assert_withdraw(sdp
, gfs2_glock_is_held_excl(gl
));
65 gfs2_assert_warn(sdp
, !sdp
->sd_log_num_gl
);
68 static void buf_lo_add(struct gfs2_sbd
*sdp
, struct gfs2_log_element
*le
)
70 struct gfs2_bufdata
*bd
= container_of(le
, struct gfs2_bufdata
, bd_le
);
71 struct gfs2_trans
*tr
;
74 if (!list_empty(&bd
->bd_list_tr
)) {
78 tr
= current
->journal_info
;
81 list_add(&bd
->bd_list_tr
, &tr
->tr_list_buf
);
84 if (!list_empty(&le
->le_list
))
87 gfs2_trans_add_gl(bd
->bd_gl
);
89 gfs2_meta_check(sdp
, bd
->bd_bh
);
90 gfs2_pin(sdp
, bd
->bd_bh
);
92 sdp
->sd_log_num_buf
++;
93 list_add(&le
->le_list
, &sdp
->sd_log_le_buf
);
99 static void buf_lo_incore_commit(struct gfs2_sbd
*sdp
, struct gfs2_trans
*tr
)
101 struct list_head
*head
= &tr
->tr_list_buf
;
102 struct gfs2_bufdata
*bd
;
105 while (!list_empty(head
)) {
106 bd
= list_entry(head
->next
, struct gfs2_bufdata
, bd_list_tr
);
107 list_del_init(&bd
->bd_list_tr
);
110 gfs2_log_unlock(sdp
);
111 gfs2_assert_warn(sdp
, !tr
->tr_num_buf
);
114 static void buf_lo_before_commit(struct gfs2_sbd
*sdp
)
116 struct buffer_head
*bh
;
117 struct gfs2_log_descriptor
*ld
;
118 struct gfs2_bufdata
*bd1
= NULL
, *bd2
;
119 unsigned int total
= sdp
->sd_log_num_buf
;
120 unsigned int offset
= sizeof(struct gfs2_log_descriptor
);
126 offset
+= sizeof(__be64
) - 1;
127 offset
&= ~(sizeof(__be64
) - 1);
128 limit
= (sdp
->sd_sb
.sb_bsize
- offset
)/sizeof(__be64
);
129 /* for 4k blocks, limit = 503 */
131 bd1
= bd2
= list_prepare_entry(bd1
, &sdp
->sd_log_le_buf
, bd_le
.le_list
);
136 bh
= gfs2_log_get_buf(sdp
);
137 sdp
->sd_log_num_hdrs
++;
138 ld
= (struct gfs2_log_descriptor
*)bh
->b_data
;
139 ptr
= (__be64
*)(bh
->b_data
+ offset
);
140 ld
->ld_header
.mh_magic
= cpu_to_be32(GFS2_MAGIC
);
141 ld
->ld_header
.mh_type
= cpu_to_be32(GFS2_METATYPE_LD
);
142 ld
->ld_header
.mh_format
= cpu_to_be32(GFS2_FORMAT_LD
);
143 ld
->ld_type
= cpu_to_be32(GFS2_LOG_DESC_METADATA
);
144 ld
->ld_length
= cpu_to_be32(num
+ 1);
145 ld
->ld_data1
= cpu_to_be32(num
);
146 ld
->ld_data2
= cpu_to_be32(0);
147 memset(ld
->ld_reserved
, 0, sizeof(ld
->ld_reserved
));
150 list_for_each_entry_continue(bd1
, &sdp
->sd_log_le_buf
,
152 *ptr
++ = cpu_to_be64(bd1
->bd_bh
->b_blocknr
);
157 set_buffer_dirty(bh
);
158 ll_rw_block(WRITE
, 1, &bh
);
161 list_for_each_entry_continue(bd2
, &sdp
->sd_log_le_buf
,
163 bh
= gfs2_log_fake_buf(sdp
, bd2
->bd_bh
);
164 set_buffer_dirty(bh
);
165 ll_rw_block(WRITE
, 1, &bh
);
174 static void buf_lo_after_commit(struct gfs2_sbd
*sdp
, struct gfs2_ail
*ai
)
176 struct list_head
*head
= &sdp
->sd_log_le_buf
;
177 struct gfs2_bufdata
*bd
;
179 while (!list_empty(head
)) {
180 bd
= list_entry(head
->next
, struct gfs2_bufdata
, bd_le
.le_list
);
181 list_del_init(&bd
->bd_le
.le_list
);
182 sdp
->sd_log_num_buf
--;
184 gfs2_unpin(sdp
, bd
->bd_bh
, ai
);
186 gfs2_assert_warn(sdp
, !sdp
->sd_log_num_buf
);
189 static void buf_lo_before_scan(struct gfs2_jdesc
*jd
,
190 struct gfs2_log_header_host
*head
, int pass
)
192 struct gfs2_sbd
*sdp
= GFS2_SB(jd
->jd_inode
);
197 sdp
->sd_found_blocks
= 0;
198 sdp
->sd_replayed_blocks
= 0;
201 static int buf_lo_scan_elements(struct gfs2_jdesc
*jd
, unsigned int start
,
202 struct gfs2_log_descriptor
*ld
, __be64
*ptr
,
205 struct gfs2_inode
*ip
= GFS2_I(jd
->jd_inode
);
206 struct gfs2_sbd
*sdp
= GFS2_SB(jd
->jd_inode
);
207 struct gfs2_glock
*gl
= ip
->i_gl
;
208 unsigned int blks
= be32_to_cpu(ld
->ld_data1
);
209 struct buffer_head
*bh_log
, *bh_ip
;
213 if (pass
!= 1 || be32_to_cpu(ld
->ld_type
) != GFS2_LOG_DESC_METADATA
)
216 gfs2_replay_incr_blk(sdp
, &start
);
218 for (; blks
; gfs2_replay_incr_blk(sdp
, &start
), blks
--) {
219 blkno
= be64_to_cpu(*ptr
++);
221 sdp
->sd_found_blocks
++;
223 if (gfs2_revoke_check(sdp
, blkno
, start
))
226 error
= gfs2_replay_read_block(jd
, start
, &bh_log
);
230 bh_ip
= gfs2_meta_new(gl
, blkno
);
231 memcpy(bh_ip
->b_data
, bh_log
->b_data
, bh_log
->b_size
);
233 if (gfs2_meta_check(sdp
, bh_ip
))
236 mark_buffer_dirty(bh_ip
);
244 sdp
->sd_replayed_blocks
++;
250 static void buf_lo_after_scan(struct gfs2_jdesc
*jd
, int error
, int pass
)
252 struct gfs2_inode
*ip
= GFS2_I(jd
->jd_inode
);
253 struct gfs2_sbd
*sdp
= GFS2_SB(jd
->jd_inode
);
256 gfs2_meta_sync(ip
->i_gl
);
262 gfs2_meta_sync(ip
->i_gl
);
264 fs_info(sdp
, "jid=%u: Replayed %u of %u blocks\n",
265 jd
->jd_jid
, sdp
->sd_replayed_blocks
, sdp
->sd_found_blocks
);
268 static void revoke_lo_add(struct gfs2_sbd
*sdp
, struct gfs2_log_element
*le
)
270 struct gfs2_trans
*tr
;
272 tr
= current
->journal_info
;
277 sdp
->sd_log_num_revoke
++;
278 list_add(&le
->le_list
, &sdp
->sd_log_le_revoke
);
279 gfs2_log_unlock(sdp
);
282 static void revoke_lo_before_commit(struct gfs2_sbd
*sdp
)
284 struct gfs2_log_descriptor
*ld
;
285 struct gfs2_meta_header
*mh
;
286 struct buffer_head
*bh
;
288 struct list_head
*head
= &sdp
->sd_log_le_revoke
;
289 struct gfs2_revoke
*rv
;
291 if (!sdp
->sd_log_num_revoke
)
294 bh
= gfs2_log_get_buf(sdp
);
295 ld
= (struct gfs2_log_descriptor
*)bh
->b_data
;
296 ld
->ld_header
.mh_magic
= cpu_to_be32(GFS2_MAGIC
);
297 ld
->ld_header
.mh_type
= cpu_to_be32(GFS2_METATYPE_LD
);
298 ld
->ld_header
.mh_format
= cpu_to_be32(GFS2_FORMAT_LD
);
299 ld
->ld_type
= cpu_to_be32(GFS2_LOG_DESC_REVOKE
);
300 ld
->ld_length
= cpu_to_be32(gfs2_struct2blk(sdp
, sdp
->sd_log_num_revoke
,
302 ld
->ld_data1
= cpu_to_be32(sdp
->sd_log_num_revoke
);
303 ld
->ld_data2
= cpu_to_be32(0);
304 memset(ld
->ld_reserved
, 0, sizeof(ld
->ld_reserved
));
305 offset
= sizeof(struct gfs2_log_descriptor
);
307 while (!list_empty(head
)) {
308 rv
= list_entry(head
->next
, struct gfs2_revoke
, rv_le
.le_list
);
309 list_del_init(&rv
->rv_le
.le_list
);
310 sdp
->sd_log_num_revoke
--;
312 if (offset
+ sizeof(u64
) > sdp
->sd_sb
.sb_bsize
) {
313 set_buffer_dirty(bh
);
314 ll_rw_block(WRITE
, 1, &bh
);
316 bh
= gfs2_log_get_buf(sdp
);
317 mh
= (struct gfs2_meta_header
*)bh
->b_data
;
318 mh
->mh_magic
= cpu_to_be32(GFS2_MAGIC
);
319 mh
->mh_type
= cpu_to_be32(GFS2_METATYPE_LB
);
320 mh
->mh_format
= cpu_to_be32(GFS2_FORMAT_LB
);
321 offset
= sizeof(struct gfs2_meta_header
);
324 *(__be64
*)(bh
->b_data
+ offset
) = cpu_to_be64(rv
->rv_blkno
);
327 offset
+= sizeof(u64
);
329 gfs2_assert_withdraw(sdp
, !sdp
->sd_log_num_revoke
);
331 set_buffer_dirty(bh
);
332 ll_rw_block(WRITE
, 1, &bh
);
335 static void revoke_lo_before_scan(struct gfs2_jdesc
*jd
,
336 struct gfs2_log_header_host
*head
, int pass
)
338 struct gfs2_sbd
*sdp
= GFS2_SB(jd
->jd_inode
);
343 sdp
->sd_found_revokes
= 0;
344 sdp
->sd_replay_tail
= head
->lh_tail
;
347 static int revoke_lo_scan_elements(struct gfs2_jdesc
*jd
, unsigned int start
,
348 struct gfs2_log_descriptor
*ld
, __be64
*ptr
,
351 struct gfs2_sbd
*sdp
= GFS2_SB(jd
->jd_inode
);
352 unsigned int blks
= be32_to_cpu(ld
->ld_length
);
353 unsigned int revokes
= be32_to_cpu(ld
->ld_data1
);
354 struct buffer_head
*bh
;
360 if (pass
!= 0 || be32_to_cpu(ld
->ld_type
) != GFS2_LOG_DESC_REVOKE
)
363 offset
= sizeof(struct gfs2_log_descriptor
);
365 for (; blks
; gfs2_replay_incr_blk(sdp
, &start
), blks
--) {
366 error
= gfs2_replay_read_block(jd
, start
, &bh
);
371 gfs2_metatype_check(sdp
, bh
, GFS2_METATYPE_LB
);
373 while (offset
+ sizeof(u64
) <= sdp
->sd_sb
.sb_bsize
) {
374 blkno
= be64_to_cpu(*(__be64
*)(bh
->b_data
+ offset
));
376 error
= gfs2_revoke_add(sdp
, blkno
, start
);
380 sdp
->sd_found_revokes
++;
384 offset
+= sizeof(u64
);
388 offset
= sizeof(struct gfs2_meta_header
);
395 static void revoke_lo_after_scan(struct gfs2_jdesc
*jd
, int error
, int pass
)
397 struct gfs2_sbd
*sdp
= GFS2_SB(jd
->jd_inode
);
400 gfs2_revoke_clean(sdp
);
406 fs_info(sdp
, "jid=%u: Found %u revoke tags\n",
407 jd
->jd_jid
, sdp
->sd_found_revokes
);
409 gfs2_revoke_clean(sdp
);
412 static void rg_lo_add(struct gfs2_sbd
*sdp
, struct gfs2_log_element
*le
)
414 struct gfs2_rgrpd
*rgd
;
415 struct gfs2_trans
*tr
= current
->journal_info
;
419 rgd
= container_of(le
, struct gfs2_rgrpd
, rd_le
);
422 if (!list_empty(&le
->le_list
)){
423 gfs2_log_unlock(sdp
);
426 gfs2_rgrp_bh_hold(rgd
);
427 sdp
->sd_log_num_rg
++;
428 list_add(&le
->le_list
, &sdp
->sd_log_le_rg
);
429 gfs2_log_unlock(sdp
);
432 static void rg_lo_after_commit(struct gfs2_sbd
*sdp
, struct gfs2_ail
*ai
)
434 struct list_head
*head
= &sdp
->sd_log_le_rg
;
435 struct gfs2_rgrpd
*rgd
;
437 while (!list_empty(head
)) {
438 rgd
= list_entry(head
->next
, struct gfs2_rgrpd
, rd_le
.le_list
);
439 list_del_init(&rgd
->rd_le
.le_list
);
440 sdp
->sd_log_num_rg
--;
442 gfs2_rgrp_repolish_clones(rgd
);
443 gfs2_rgrp_bh_put(rgd
);
445 gfs2_assert_warn(sdp
, !sdp
->sd_log_num_rg
);
449 * databuf_lo_add - Add a databuf to the transaction.
451 * This is used in two distinct cases:
452 * i) In ordered write mode
453 * We put the data buffer on a list so that we can ensure that its
454 * synced to disk at the right time
455 * ii) In journaled data mode
456 * We need to journal the data block in the same way as metadata in
457 * the functions above. The difference is that here we have a tag
458 * which is two __be64's being the block number (as per meta data)
459 * and a flag which says whether the data block needs escaping or
460 * not. This means we need a new log entry for each 251 or so data
461 * blocks, which isn't an enormous overhead but twice as much as
462 * for normal metadata blocks.
464 static void databuf_lo_add(struct gfs2_sbd
*sdp
, struct gfs2_log_element
*le
)
466 struct gfs2_bufdata
*bd
= container_of(le
, struct gfs2_bufdata
, bd_le
);
467 struct gfs2_trans
*tr
= current
->journal_info
;
468 struct address_space
*mapping
= bd
->bd_bh
->b_page
->mapping
;
469 struct gfs2_inode
*ip
= GFS2_I(mapping
->host
);
473 if (list_empty(&bd
->bd_list_tr
) &&
474 (ip
->i_di
.di_flags
& GFS2_DIF_JDATA
)) {
476 list_add(&bd
->bd_list_tr
, &tr
->tr_list_buf
);
477 gfs2_log_unlock(sdp
);
478 gfs2_pin(sdp
, bd
->bd_bh
);
479 tr
->tr_num_buf_new
++;
481 gfs2_log_unlock(sdp
);
483 gfs2_trans_add_gl(bd
->bd_gl
);
485 if (list_empty(&le
->le_list
)) {
486 if (ip
->i_di
.di_flags
& GFS2_DIF_JDATA
)
487 sdp
->sd_log_num_jdata
++;
488 sdp
->sd_log_num_databuf
++;
489 list_add(&le
->le_list
, &sdp
->sd_log_le_databuf
);
491 gfs2_log_unlock(sdp
);
494 static int gfs2_check_magic(struct buffer_head
*bh
)
496 struct page
*page
= bh
->b_page
;
501 kaddr
= kmap_atomic(page
, KM_USER0
);
502 ptr
= kaddr
+ bh_offset(bh
);
503 if (*ptr
== cpu_to_be32(GFS2_MAGIC
))
505 kunmap_atomic(kaddr
, KM_USER0
);
511 * databuf_lo_before_commit - Scan the data buffers, writing as we go
513 * Here we scan through the lists of buffers and make the assumption
514 * that any buffer thats been pinned is being journaled, and that
515 * any unpinned buffer is an ordered write data buffer and therefore
516 * will be written back rather than journaled.
518 static void databuf_lo_before_commit(struct gfs2_sbd
*sdp
)
521 struct gfs2_bufdata
*bd1
= NULL
, *bd2
, *bdt
;
522 struct buffer_head
*bh
= NULL
,*bh1
= NULL
;
523 unsigned int offset
= sizeof(struct gfs2_log_descriptor
);
524 struct gfs2_log_descriptor
*ld
;
526 unsigned int total_dbuf
= sdp
->sd_log_num_databuf
;
527 unsigned int total_jdata
= sdp
->sd_log_num_jdata
;
531 offset
+= 2*sizeof(__be64
) - 1;
532 offset
&= ~(2*sizeof(__be64
) - 1);
533 limit
= (sdp
->sd_sb
.sb_bsize
- offset
)/sizeof(__be64
);
536 * Start writing ordered buffers, write journaled buffers
537 * into the log along with a header
540 bd2
= bd1
= list_prepare_entry(bd1
, &sdp
->sd_log_le_databuf
,
547 list_for_each_entry_safe_continue(bd1
, bdt
,
548 &sdp
->sd_log_le_databuf
,
550 /* store off the buffer head in a local ptr since
551 * gfs2_bufdata might change when we drop the log lock
555 /* An ordered write buffer */
556 if (bh1
&& !buffer_pinned(bh1
)) {
557 list_move(&bd1
->bd_le
.le_list
, &started
);
560 bd2
= list_prepare_entry(bd2
,
561 &sdp
->sd_log_le_databuf
,
566 if (buffer_dirty(bh1
)) {
569 gfs2_log_unlock(sdp
);
571 ll_rw_block(SWRITE
, 1, &bh1
);
579 } else if (bh1
) { /* A journaled buffer */
581 gfs2_log_unlock(sdp
);
583 bh
= gfs2_log_get_buf(sdp
);
584 sdp
->sd_log_num_hdrs
++;
585 ld
= (struct gfs2_log_descriptor
*)
587 ptr
= (__be64
*)(bh
->b_data
+ offset
);
588 ld
->ld_header
.mh_magic
=
589 cpu_to_be32(GFS2_MAGIC
);
590 ld
->ld_header
.mh_type
=
591 cpu_to_be32(GFS2_METATYPE_LD
);
592 ld
->ld_header
.mh_format
=
593 cpu_to_be32(GFS2_FORMAT_LD
);
595 cpu_to_be32(GFS2_LOG_DESC_JDATA
);
596 ld
->ld_length
= cpu_to_be32(num
+ 1);
597 ld
->ld_data1
= cpu_to_be32(num
);
598 ld
->ld_data2
= cpu_to_be32(0);
599 memset(ld
->ld_reserved
, 0, sizeof(ld
->ld_reserved
));
601 magic
= gfs2_check_magic(bh1
);
602 *ptr
++ = cpu_to_be64(bh1
->b_blocknr
);
603 *ptr
++ = cpu_to_be64((__u64
)magic
);
604 clear_buffer_escaped(bh1
);
605 if (unlikely(magic
!= 0))
606 set_buffer_escaped(bh1
);
612 sdp
->sd_log_num_databuf
--;
613 list_del_init(&bd1
->bd_le
.le_list
);
616 bd2
= list_prepare_entry(bd2
,
617 &sdp
->sd_log_le_databuf
,
620 kmem_cache_free(gfs2_bufdata_cachep
, bd1
);
623 gfs2_log_unlock(sdp
);
625 set_buffer_dirty(bh
);
626 ll_rw_block(WRITE
, 1, &bh
);
631 list_for_each_entry_continue(bd2
, &sdp
->sd_log_le_databuf
,
635 /* copy buffer if it needs escaping */
636 gfs2_log_unlock(sdp
);
637 if (unlikely(buffer_escaped(bd2
->bd_bh
))) {
639 struct page
*page
= bd2
->bd_bh
->b_page
;
640 bh
= gfs2_log_get_buf(sdp
);
641 kaddr
= kmap_atomic(page
, KM_USER0
);
643 kaddr
+ bh_offset(bd2
->bd_bh
),
644 sdp
->sd_sb
.sb_bsize
);
645 kunmap_atomic(kaddr
, KM_USER0
);
646 *(__be32
*)bh
->b_data
= 0;
648 bh
= gfs2_log_fake_buf(sdp
, bd2
->bd_bh
);
650 set_buffer_dirty(bh
);
651 ll_rw_block(WRITE
, 1, &bh
);
660 gfs2_log_unlock(sdp
);
662 /* Wait on all ordered buffers */
663 while (!list_empty(&started
)) {
665 bd1
= list_entry(started
.next
, struct gfs2_bufdata
,
667 list_del_init(&bd1
->bd_le
.le_list
);
668 sdp
->sd_log_num_databuf
--;
671 bh
->b_private
= NULL
;
673 gfs2_log_unlock(sdp
);
677 gfs2_log_unlock(sdp
);
679 kmem_cache_free(gfs2_bufdata_cachep
, bd1
);
682 /* We've removed all the ordered write bufs here, so only jdata left */
683 gfs2_assert_warn(sdp
, sdp
->sd_log_num_databuf
== sdp
->sd_log_num_jdata
);
686 static int databuf_lo_scan_elements(struct gfs2_jdesc
*jd
, unsigned int start
,
687 struct gfs2_log_descriptor
*ld
,
688 __be64
*ptr
, int pass
)
690 struct gfs2_inode
*ip
= GFS2_I(jd
->jd_inode
);
691 struct gfs2_sbd
*sdp
= GFS2_SB(jd
->jd_inode
);
692 struct gfs2_glock
*gl
= ip
->i_gl
;
693 unsigned int blks
= be32_to_cpu(ld
->ld_data1
);
694 struct buffer_head
*bh_log
, *bh_ip
;
699 if (pass
!= 1 || be32_to_cpu(ld
->ld_type
) != GFS2_LOG_DESC_JDATA
)
702 gfs2_replay_incr_blk(sdp
, &start
);
703 for (; blks
; gfs2_replay_incr_blk(sdp
, &start
), blks
--) {
704 blkno
= be64_to_cpu(*ptr
++);
705 esc
= be64_to_cpu(*ptr
++);
707 sdp
->sd_found_blocks
++;
709 if (gfs2_revoke_check(sdp
, blkno
, start
))
712 error
= gfs2_replay_read_block(jd
, start
, &bh_log
);
716 bh_ip
= gfs2_meta_new(gl
, blkno
);
717 memcpy(bh_ip
->b_data
, bh_log
->b_data
, bh_log
->b_size
);
721 __be32
*eptr
= (__be32
*)bh_ip
->b_data
;
722 *eptr
= cpu_to_be32(GFS2_MAGIC
);
724 mark_buffer_dirty(bh_ip
);
731 sdp
->sd_replayed_blocks
++;
737 /* FIXME: sort out accounting for log blocks etc. */
739 static void databuf_lo_after_scan(struct gfs2_jdesc
*jd
, int error
, int pass
)
741 struct gfs2_inode
*ip
= GFS2_I(jd
->jd_inode
);
742 struct gfs2_sbd
*sdp
= GFS2_SB(jd
->jd_inode
);
745 gfs2_meta_sync(ip
->i_gl
);
752 gfs2_meta_sync(ip
->i_gl
);
754 fs_info(sdp
, "jid=%u: Replayed %u of %u data blocks\n",
755 jd
->jd_jid
, sdp
->sd_replayed_blocks
, sdp
->sd_found_blocks
);
758 static void databuf_lo_after_commit(struct gfs2_sbd
*sdp
, struct gfs2_ail
*ai
)
760 struct list_head
*head
= &sdp
->sd_log_le_databuf
;
761 struct gfs2_bufdata
*bd
;
763 while (!list_empty(head
)) {
764 bd
= list_entry(head
->next
, struct gfs2_bufdata
, bd_le
.le_list
);
765 list_del_init(&bd
->bd_le
.le_list
);
766 sdp
->sd_log_num_databuf
--;
767 sdp
->sd_log_num_jdata
--;
768 gfs2_unpin(sdp
, bd
->bd_bh
, ai
);
770 gfs2_assert_warn(sdp
, !sdp
->sd_log_num_databuf
);
771 gfs2_assert_warn(sdp
, !sdp
->sd_log_num_jdata
);
775 const struct gfs2_log_operations gfs2_glock_lops
= {
776 .lo_add
= glock_lo_add
,
777 .lo_after_commit
= glock_lo_after_commit
,
781 const struct gfs2_log_operations gfs2_buf_lops
= {
782 .lo_add
= buf_lo_add
,
783 .lo_incore_commit
= buf_lo_incore_commit
,
784 .lo_before_commit
= buf_lo_before_commit
,
785 .lo_after_commit
= buf_lo_after_commit
,
786 .lo_before_scan
= buf_lo_before_scan
,
787 .lo_scan_elements
= buf_lo_scan_elements
,
788 .lo_after_scan
= buf_lo_after_scan
,
792 const struct gfs2_log_operations gfs2_revoke_lops
= {
793 .lo_add
= revoke_lo_add
,
794 .lo_before_commit
= revoke_lo_before_commit
,
795 .lo_before_scan
= revoke_lo_before_scan
,
796 .lo_scan_elements
= revoke_lo_scan_elements
,
797 .lo_after_scan
= revoke_lo_after_scan
,
801 const struct gfs2_log_operations gfs2_rg_lops
= {
803 .lo_after_commit
= rg_lo_after_commit
,
807 const struct gfs2_log_operations gfs2_databuf_lops
= {
808 .lo_add
= databuf_lo_add
,
809 .lo_incore_commit
= buf_lo_incore_commit
,
810 .lo_before_commit
= databuf_lo_before_commit
,
811 .lo_after_commit
= databuf_lo_after_commit
,
812 .lo_scan_elements
= databuf_lo_scan_elements
,
813 .lo_after_scan
= databuf_lo_after_scan
,
814 .lo_name
= "databuf",
817 const struct gfs2_log_operations
*gfs2_log_ops
[] = {