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>
31 * gfs2_pin - Pin a buffer in memory
32 * @sdp: The superblock
33 * @bh: The buffer to be pinned
35 * The log lock must be held when calling this function
37 static void gfs2_pin(struct gfs2_sbd
*sdp
, struct buffer_head
*bh
)
39 struct gfs2_bufdata
*bd
;
41 gfs2_assert_withdraw(sdp
, test_bit(SDF_JOURNAL_LIVE
, &sdp
->sd_flags
));
43 clear_buffer_dirty(bh
);
44 if (test_set_buffer_pinned(bh
))
45 gfs2_assert_withdraw(sdp
, 0);
46 if (!buffer_uptodate(bh
))
47 gfs2_io_error_bh(sdp
, bh
);
49 /* If this buffer is in the AIL and it has already been written
50 * to in-place disk block, remove it from the AIL.
53 list_move(&bd
->bd_ail_st_list
, &bd
->bd_ail
->ai_ail2_list
);
58 * gfs2_unpin - Unpin a buffer
59 * @sdp: the filesystem the buffer belongs to
60 * @bh: The buffer to unpin
65 static void gfs2_unpin(struct gfs2_sbd
*sdp
, struct buffer_head
*bh
,
68 struct gfs2_bufdata
*bd
= bh
->b_private
;
70 gfs2_assert_withdraw(sdp
, buffer_uptodate(bh
));
72 if (!buffer_pinned(bh
))
73 gfs2_assert_withdraw(sdp
, 0);
76 mark_buffer_dirty(bh
);
77 clear_buffer_pinned(bh
);
81 list_del(&bd
->bd_ail_st_list
);
84 struct gfs2_glock
*gl
= bd
->bd_gl
;
85 list_add(&bd
->bd_ail_gl_list
, &gl
->gl_ail_list
);
86 atomic_inc(&gl
->gl_ail_count
);
89 list_add(&bd
->bd_ail_st_list
, &ai
->ai_ail1_list
);
95 static inline struct gfs2_log_descriptor
*bh_log_desc(struct buffer_head
*bh
)
97 return (struct gfs2_log_descriptor
*)bh
->b_data
;
100 static inline __be64
*bh_log_ptr(struct buffer_head
*bh
)
102 struct gfs2_log_descriptor
*ld
= bh_log_desc(bh
);
103 return (__force __be64
*)(ld
+ 1);
106 static inline __be64
*bh_ptr_end(struct buffer_head
*bh
)
108 return (__force __be64
*)(bh
->b_data
+ bh
->b_size
);
112 static struct buffer_head
*gfs2_get_log_desc(struct gfs2_sbd
*sdp
, u32 ld_type
)
114 struct buffer_head
*bh
= gfs2_log_get_buf(sdp
);
115 struct gfs2_log_descriptor
*ld
= bh_log_desc(bh
);
116 ld
->ld_header
.mh_magic
= cpu_to_be32(GFS2_MAGIC
);
117 ld
->ld_header
.mh_type
= cpu_to_be32(GFS2_METATYPE_LD
);
118 ld
->ld_header
.mh_format
= cpu_to_be32(GFS2_FORMAT_LD
);
119 ld
->ld_type
= cpu_to_be32(ld_type
);
123 memset(ld
->ld_reserved
, 0, sizeof(ld
->ld_reserved
));
127 static void __glock_lo_add(struct gfs2_sbd
*sdp
, struct gfs2_log_element
*le
)
129 struct gfs2_glock
*gl
;
130 struct gfs2_trans
*tr
= current
->journal_info
;
134 gl
= container_of(le
, struct gfs2_glock
, gl_le
);
135 if (gfs2_assert_withdraw(sdp
, gfs2_glock_is_held_excl(gl
)))
138 if (!list_empty(&le
->le_list
))
142 set_bit(GLF_DIRTY
, &gl
->gl_flags
);
143 sdp
->sd_log_num_gl
++;
144 list_add(&le
->le_list
, &sdp
->sd_log_le_gl
);
147 static void glock_lo_add(struct gfs2_sbd
*sdp
, struct gfs2_log_element
*le
)
150 __glock_lo_add(sdp
, le
);
151 gfs2_log_unlock(sdp
);
154 static void glock_lo_after_commit(struct gfs2_sbd
*sdp
, struct gfs2_ail
*ai
)
156 struct list_head
*head
= &sdp
->sd_log_le_gl
;
157 struct gfs2_glock
*gl
;
159 while (!list_empty(head
)) {
160 gl
= list_entry(head
->next
, struct gfs2_glock
, gl_le
.le_list
);
161 list_del_init(&gl
->gl_le
.le_list
);
162 sdp
->sd_log_num_gl
--;
164 gfs2_assert_withdraw(sdp
, gfs2_glock_is_held_excl(gl
));
167 gfs2_assert_warn(sdp
, !sdp
->sd_log_num_gl
);
170 static void buf_lo_add(struct gfs2_sbd
*sdp
, struct gfs2_log_element
*le
)
172 struct gfs2_bufdata
*bd
= container_of(le
, struct gfs2_bufdata
, bd_le
);
173 struct gfs2_trans
*tr
;
175 lock_buffer(bd
->bd_bh
);
177 if (!list_empty(&bd
->bd_list_tr
))
179 tr
= current
->journal_info
;
182 list_add(&bd
->bd_list_tr
, &tr
->tr_list_buf
);
183 if (!list_empty(&le
->le_list
))
185 __glock_lo_add(sdp
, &bd
->bd_gl
->gl_le
);
186 gfs2_meta_check(sdp
, bd
->bd_bh
);
187 gfs2_pin(sdp
, bd
->bd_bh
);
188 sdp
->sd_log_num_buf
++;
189 list_add(&le
->le_list
, &sdp
->sd_log_le_buf
);
190 tr
->tr_num_buf_new
++;
192 gfs2_log_unlock(sdp
);
193 unlock_buffer(bd
->bd_bh
);
196 static void buf_lo_incore_commit(struct gfs2_sbd
*sdp
, struct gfs2_trans
*tr
)
198 struct list_head
*head
= &tr
->tr_list_buf
;
199 struct gfs2_bufdata
*bd
;
202 while (!list_empty(head
)) {
203 bd
= list_entry(head
->next
, struct gfs2_bufdata
, bd_list_tr
);
204 list_del_init(&bd
->bd_list_tr
);
207 gfs2_log_unlock(sdp
);
208 gfs2_assert_warn(sdp
, !tr
->tr_num_buf
);
211 static void buf_lo_before_commit(struct gfs2_sbd
*sdp
)
213 struct buffer_head
*bh
;
214 struct gfs2_log_descriptor
*ld
;
215 struct gfs2_bufdata
*bd1
= NULL
, *bd2
;
222 limit
= buf_limit(sdp
);
223 /* for 4k blocks, limit = 503 */
226 total
= sdp
->sd_log_num_buf
;
227 bd1
= bd2
= list_prepare_entry(bd1
, &sdp
->sd_log_le_buf
, bd_le
.le_list
);
232 gfs2_log_unlock(sdp
);
233 bh
= gfs2_get_log_desc(sdp
, GFS2_LOG_DESC_METADATA
);
235 ld
= bh_log_desc(bh
);
236 ptr
= bh_log_ptr(bh
);
237 ld
->ld_length
= cpu_to_be32(num
+ 1);
238 ld
->ld_data1
= cpu_to_be32(num
);
241 list_for_each_entry_continue(bd1
, &sdp
->sd_log_le_buf
,
243 *ptr
++ = cpu_to_be64(bd1
->bd_bh
->b_blocknr
);
248 gfs2_log_unlock(sdp
);
249 submit_bh(WRITE
, bh
);
253 list_for_each_entry_continue(bd2
, &sdp
->sd_log_le_buf
,
256 gfs2_log_unlock(sdp
);
257 lock_buffer(bd2
->bd_bh
);
258 bh
= gfs2_log_fake_buf(sdp
, bd2
->bd_bh
);
259 submit_bh(WRITE
, bh
);
268 gfs2_log_unlock(sdp
);
271 static void buf_lo_after_commit(struct gfs2_sbd
*sdp
, struct gfs2_ail
*ai
)
273 struct list_head
*head
= &sdp
->sd_log_le_buf
;
274 struct gfs2_bufdata
*bd
;
276 while (!list_empty(head
)) {
277 bd
= list_entry(head
->next
, struct gfs2_bufdata
, bd_le
.le_list
);
278 list_del_init(&bd
->bd_le
.le_list
);
279 sdp
->sd_log_num_buf
--;
281 gfs2_unpin(sdp
, bd
->bd_bh
, ai
);
283 gfs2_assert_warn(sdp
, !sdp
->sd_log_num_buf
);
286 static void buf_lo_before_scan(struct gfs2_jdesc
*jd
,
287 struct gfs2_log_header_host
*head
, int pass
)
289 struct gfs2_sbd
*sdp
= GFS2_SB(jd
->jd_inode
);
294 sdp
->sd_found_blocks
= 0;
295 sdp
->sd_replayed_blocks
= 0;
298 static int buf_lo_scan_elements(struct gfs2_jdesc
*jd
, unsigned int start
,
299 struct gfs2_log_descriptor
*ld
, __be64
*ptr
,
302 struct gfs2_inode
*ip
= GFS2_I(jd
->jd_inode
);
303 struct gfs2_sbd
*sdp
= GFS2_SB(jd
->jd_inode
);
304 struct gfs2_glock
*gl
= ip
->i_gl
;
305 unsigned int blks
= be32_to_cpu(ld
->ld_data1
);
306 struct buffer_head
*bh_log
, *bh_ip
;
310 if (pass
!= 1 || be32_to_cpu(ld
->ld_type
) != GFS2_LOG_DESC_METADATA
)
313 gfs2_replay_incr_blk(sdp
, &start
);
315 for (; blks
; gfs2_replay_incr_blk(sdp
, &start
), blks
--) {
316 blkno
= be64_to_cpu(*ptr
++);
318 sdp
->sd_found_blocks
++;
320 if (gfs2_revoke_check(sdp
, blkno
, start
))
323 error
= gfs2_replay_read_block(jd
, start
, &bh_log
);
327 bh_ip
= gfs2_meta_new(gl
, blkno
);
328 memcpy(bh_ip
->b_data
, bh_log
->b_data
, bh_log
->b_size
);
330 if (gfs2_meta_check(sdp
, bh_ip
))
333 mark_buffer_dirty(bh_ip
);
341 sdp
->sd_replayed_blocks
++;
347 static void buf_lo_after_scan(struct gfs2_jdesc
*jd
, int error
, int pass
)
349 struct gfs2_inode
*ip
= GFS2_I(jd
->jd_inode
);
350 struct gfs2_sbd
*sdp
= GFS2_SB(jd
->jd_inode
);
353 gfs2_meta_sync(ip
->i_gl
);
359 gfs2_meta_sync(ip
->i_gl
);
361 fs_info(sdp
, "jid=%u: Replayed %u of %u blocks\n",
362 jd
->jd_jid
, sdp
->sd_replayed_blocks
, sdp
->sd_found_blocks
);
365 static void revoke_lo_add(struct gfs2_sbd
*sdp
, struct gfs2_log_element
*le
)
367 struct gfs2_trans
*tr
;
369 tr
= current
->journal_info
;
372 sdp
->sd_log_num_revoke
++;
373 list_add(&le
->le_list
, &sdp
->sd_log_le_revoke
);
376 static void revoke_lo_before_commit(struct gfs2_sbd
*sdp
)
378 struct gfs2_log_descriptor
*ld
;
379 struct gfs2_meta_header
*mh
;
380 struct buffer_head
*bh
;
382 struct list_head
*head
= &sdp
->sd_log_le_revoke
;
383 struct gfs2_bufdata
*bd
;
385 if (!sdp
->sd_log_num_revoke
)
388 bh
= gfs2_get_log_desc(sdp
, GFS2_LOG_DESC_REVOKE
);
389 ld
= bh_log_desc(bh
);
390 ld
->ld_length
= cpu_to_be32(gfs2_struct2blk(sdp
, sdp
->sd_log_num_revoke
,
392 ld
->ld_data1
= cpu_to_be32(sdp
->sd_log_num_revoke
);
393 offset
= sizeof(struct gfs2_log_descriptor
);
395 while (!list_empty(head
)) {
396 bd
= list_entry(head
->next
, struct gfs2_bufdata
, bd_le
.le_list
);
397 list_del_init(&bd
->bd_le
.le_list
);
398 sdp
->sd_log_num_revoke
--;
400 if (offset
+ sizeof(u64
) > sdp
->sd_sb
.sb_bsize
) {
401 submit_bh(WRITE
, bh
);
403 bh
= gfs2_log_get_buf(sdp
);
404 mh
= (struct gfs2_meta_header
*)bh
->b_data
;
405 mh
->mh_magic
= cpu_to_be32(GFS2_MAGIC
);
406 mh
->mh_type
= cpu_to_be32(GFS2_METATYPE_LB
);
407 mh
->mh_format
= cpu_to_be32(GFS2_FORMAT_LB
);
408 offset
= sizeof(struct gfs2_meta_header
);
411 *(__be64
*)(bh
->b_data
+ offset
) = cpu_to_be64(bd
->bd_blkno
);
412 kmem_cache_free(gfs2_bufdata_cachep
, bd
);
414 offset
+= sizeof(u64
);
416 gfs2_assert_withdraw(sdp
, !sdp
->sd_log_num_revoke
);
418 submit_bh(WRITE
, bh
);
421 static void revoke_lo_before_scan(struct gfs2_jdesc
*jd
,
422 struct gfs2_log_header_host
*head
, int pass
)
424 struct gfs2_sbd
*sdp
= GFS2_SB(jd
->jd_inode
);
429 sdp
->sd_found_revokes
= 0;
430 sdp
->sd_replay_tail
= head
->lh_tail
;
433 static int revoke_lo_scan_elements(struct gfs2_jdesc
*jd
, unsigned int start
,
434 struct gfs2_log_descriptor
*ld
, __be64
*ptr
,
437 struct gfs2_sbd
*sdp
= GFS2_SB(jd
->jd_inode
);
438 unsigned int blks
= be32_to_cpu(ld
->ld_length
);
439 unsigned int revokes
= be32_to_cpu(ld
->ld_data1
);
440 struct buffer_head
*bh
;
446 if (pass
!= 0 || be32_to_cpu(ld
->ld_type
) != GFS2_LOG_DESC_REVOKE
)
449 offset
= sizeof(struct gfs2_log_descriptor
);
451 for (; blks
; gfs2_replay_incr_blk(sdp
, &start
), blks
--) {
452 error
= gfs2_replay_read_block(jd
, start
, &bh
);
457 gfs2_metatype_check(sdp
, bh
, GFS2_METATYPE_LB
);
459 while (offset
+ sizeof(u64
) <= sdp
->sd_sb
.sb_bsize
) {
460 blkno
= be64_to_cpu(*(__be64
*)(bh
->b_data
+ offset
));
462 error
= gfs2_revoke_add(sdp
, blkno
, start
);
466 sdp
->sd_found_revokes
++;
470 offset
+= sizeof(u64
);
474 offset
= sizeof(struct gfs2_meta_header
);
481 static void revoke_lo_after_scan(struct gfs2_jdesc
*jd
, int error
, int pass
)
483 struct gfs2_sbd
*sdp
= GFS2_SB(jd
->jd_inode
);
486 gfs2_revoke_clean(sdp
);
492 fs_info(sdp
, "jid=%u: Found %u revoke tags\n",
493 jd
->jd_jid
, sdp
->sd_found_revokes
);
495 gfs2_revoke_clean(sdp
);
498 static void rg_lo_add(struct gfs2_sbd
*sdp
, struct gfs2_log_element
*le
)
500 struct gfs2_rgrpd
*rgd
;
501 struct gfs2_trans
*tr
= current
->journal_info
;
505 rgd
= container_of(le
, struct gfs2_rgrpd
, rd_le
);
508 if (!list_empty(&le
->le_list
)){
509 gfs2_log_unlock(sdp
);
512 gfs2_rgrp_bh_hold(rgd
);
513 sdp
->sd_log_num_rg
++;
514 list_add(&le
->le_list
, &sdp
->sd_log_le_rg
);
515 gfs2_log_unlock(sdp
);
518 static void rg_lo_after_commit(struct gfs2_sbd
*sdp
, struct gfs2_ail
*ai
)
520 struct list_head
*head
= &sdp
->sd_log_le_rg
;
521 struct gfs2_rgrpd
*rgd
;
523 while (!list_empty(head
)) {
524 rgd
= list_entry(head
->next
, struct gfs2_rgrpd
, rd_le
.le_list
);
525 list_del_init(&rgd
->rd_le
.le_list
);
526 sdp
->sd_log_num_rg
--;
528 gfs2_rgrp_repolish_clones(rgd
);
529 gfs2_rgrp_bh_put(rgd
);
531 gfs2_assert_warn(sdp
, !sdp
->sd_log_num_rg
);
535 * databuf_lo_add - Add a databuf to the transaction.
537 * This is used in two distinct cases:
538 * i) In ordered write mode
539 * We put the data buffer on a list so that we can ensure that its
540 * synced to disk at the right time
541 * ii) In journaled data mode
542 * We need to journal the data block in the same way as metadata in
543 * the functions above. The difference is that here we have a tag
544 * which is two __be64's being the block number (as per meta data)
545 * and a flag which says whether the data block needs escaping or
546 * not. This means we need a new log entry for each 251 or so data
547 * blocks, which isn't an enormous overhead but twice as much as
548 * for normal metadata blocks.
550 static void databuf_lo_add(struct gfs2_sbd
*sdp
, struct gfs2_log_element
*le
)
552 struct gfs2_bufdata
*bd
= container_of(le
, struct gfs2_bufdata
, bd_le
);
553 struct gfs2_trans
*tr
= current
->journal_info
;
554 struct address_space
*mapping
= bd
->bd_bh
->b_page
->mapping
;
555 struct gfs2_inode
*ip
= GFS2_I(mapping
->host
);
557 lock_buffer(bd
->bd_bh
);
559 if (!list_empty(&bd
->bd_list_tr
))
562 if (gfs2_is_jdata(ip
)) {
564 list_add(&bd
->bd_list_tr
, &tr
->tr_list_buf
);
566 if (!list_empty(&le
->le_list
))
569 __glock_lo_add(sdp
, &bd
->bd_gl
->gl_le
);
570 if (gfs2_is_jdata(ip
)) {
571 gfs2_pin(sdp
, bd
->bd_bh
);
572 tr
->tr_num_databuf_new
++;
573 sdp
->sd_log_num_databuf
++;
574 list_add(&le
->le_list
, &sdp
->sd_log_le_databuf
);
576 list_add(&le
->le_list
, &sdp
->sd_log_le_ordered
);
579 gfs2_log_unlock(sdp
);
580 unlock_buffer(bd
->bd_bh
);
583 static void gfs2_check_magic(struct buffer_head
*bh
)
588 clear_buffer_escaped(bh
);
589 kaddr
= kmap_atomic(bh
->b_page
, KM_USER0
);
590 ptr
= kaddr
+ bh_offset(bh
);
591 if (*ptr
== cpu_to_be32(GFS2_MAGIC
))
592 set_buffer_escaped(bh
);
593 kunmap_atomic(kaddr
, KM_USER0
);
596 static void gfs2_write_blocks(struct gfs2_sbd
*sdp
, struct buffer_head
*bh
,
597 struct list_head
*list
, struct list_head
*done
,
600 struct buffer_head
*bh1
;
601 struct gfs2_log_descriptor
*ld
;
602 struct gfs2_bufdata
*bd
;
608 ld
= bh_log_desc(bh
);
609 ld
->ld_length
= cpu_to_be32(n
+ 1);
610 ld
->ld_data1
= cpu_to_be32(n
);
612 ptr
= bh_log_ptr(bh
);
615 submit_bh(WRITE
, bh
);
617 while(!list_empty(list
)) {
618 bd
= list_entry(list
->next
, struct gfs2_bufdata
, bd_le
.le_list
);
619 list_move_tail(&bd
->bd_le
.le_list
, done
);
621 while (be64_to_cpu(*ptr
) != bd
->bd_bh
->b_blocknr
) {
622 gfs2_log_incr_head(sdp
);
625 gfs2_log_unlock(sdp
);
626 lock_buffer(bd
->bd_bh
);
627 if (buffer_escaped(bd
->bd_bh
)) {
629 bh1
= gfs2_log_get_buf(sdp
);
630 kaddr
= kmap_atomic(bd
->bd_bh
->b_page
, KM_USER0
);
631 memcpy(bh1
->b_data
, kaddr
+ bh_offset(bd
->bd_bh
),
633 kunmap_atomic(kaddr
, KM_USER0
);
634 *(__be32
*)bh1
->b_data
= 0;
635 clear_buffer_escaped(bd
->bd_bh
);
636 unlock_buffer(bd
->bd_bh
);
639 bh1
= gfs2_log_fake_buf(sdp
, bd
->bd_bh
);
641 submit_bh(WRITE
, bh1
);
645 gfs2_log_unlock(sdp
);
650 * databuf_lo_before_commit - Scan the data buffers, writing as we go
654 static void databuf_lo_before_commit(struct gfs2_sbd
*sdp
)
656 struct gfs2_bufdata
*bd
= NULL
;
657 struct buffer_head
*bh
= NULL
;
659 __be64
*ptr
= NULL
, *end
= NULL
;
660 LIST_HEAD(processed
);
661 LIST_HEAD(in_progress
);
664 while (!list_empty(&sdp
->sd_log_le_databuf
)) {
666 gfs2_log_unlock(sdp
);
667 gfs2_write_blocks(sdp
, bh
, &in_progress
, &processed
, n
);
669 bh
= gfs2_get_log_desc(sdp
, GFS2_LOG_DESC_JDATA
);
670 ptr
= bh_log_ptr(bh
);
671 end
= bh_ptr_end(bh
) - 1;
675 bd
= list_entry(sdp
->sd_log_le_databuf
.next
, struct gfs2_bufdata
, bd_le
.le_list
);
676 list_move_tail(&bd
->bd_le
.le_list
, &in_progress
);
677 gfs2_check_magic(bd
->bd_bh
);
678 *ptr
++ = cpu_to_be64(bd
->bd_bh
->b_blocknr
);
679 *ptr
++ = cpu_to_be64(buffer_escaped(bh
) ? 1 : 0);
682 gfs2_log_unlock(sdp
);
683 gfs2_write_blocks(sdp
, bh
, &in_progress
, &processed
, n
);
685 list_splice(&processed
, &sdp
->sd_log_le_databuf
);
686 gfs2_log_unlock(sdp
);
689 static int databuf_lo_scan_elements(struct gfs2_jdesc
*jd
, unsigned int start
,
690 struct gfs2_log_descriptor
*ld
,
691 __be64
*ptr
, int pass
)
693 struct gfs2_inode
*ip
= GFS2_I(jd
->jd_inode
);
694 struct gfs2_sbd
*sdp
= GFS2_SB(jd
->jd_inode
);
695 struct gfs2_glock
*gl
= ip
->i_gl
;
696 unsigned int blks
= be32_to_cpu(ld
->ld_data1
);
697 struct buffer_head
*bh_log
, *bh_ip
;
702 if (pass
!= 1 || be32_to_cpu(ld
->ld_type
) != GFS2_LOG_DESC_JDATA
)
705 gfs2_replay_incr_blk(sdp
, &start
);
706 for (; blks
; gfs2_replay_incr_blk(sdp
, &start
), blks
--) {
707 blkno
= be64_to_cpu(*ptr
++);
708 esc
= be64_to_cpu(*ptr
++);
710 sdp
->sd_found_blocks
++;
712 if (gfs2_revoke_check(sdp
, blkno
, start
))
715 error
= gfs2_replay_read_block(jd
, start
, &bh_log
);
719 bh_ip
= gfs2_meta_new(gl
, blkno
);
720 memcpy(bh_ip
->b_data
, bh_log
->b_data
, bh_log
->b_size
);
724 __be32
*eptr
= (__be32
*)bh_ip
->b_data
;
725 *eptr
= cpu_to_be32(GFS2_MAGIC
);
727 mark_buffer_dirty(bh_ip
);
734 sdp
->sd_replayed_blocks
++;
740 /* FIXME: sort out accounting for log blocks etc. */
742 static void databuf_lo_after_scan(struct gfs2_jdesc
*jd
, int error
, int pass
)
744 struct gfs2_inode
*ip
= GFS2_I(jd
->jd_inode
);
745 struct gfs2_sbd
*sdp
= GFS2_SB(jd
->jd_inode
);
748 gfs2_meta_sync(ip
->i_gl
);
755 gfs2_meta_sync(ip
->i_gl
);
757 fs_info(sdp
, "jid=%u: Replayed %u of %u data blocks\n",
758 jd
->jd_jid
, sdp
->sd_replayed_blocks
, sdp
->sd_found_blocks
);
761 static void databuf_lo_after_commit(struct gfs2_sbd
*sdp
, struct gfs2_ail
*ai
)
763 struct list_head
*head
= &sdp
->sd_log_le_databuf
;
764 struct gfs2_bufdata
*bd
;
766 while (!list_empty(head
)) {
767 bd
= list_entry(head
->next
, struct gfs2_bufdata
, bd_le
.le_list
);
768 list_del_init(&bd
->bd_le
.le_list
);
769 sdp
->sd_log_num_databuf
--;
770 gfs2_unpin(sdp
, bd
->bd_bh
, ai
);
772 gfs2_assert_warn(sdp
, !sdp
->sd_log_num_databuf
);
776 const struct gfs2_log_operations gfs2_glock_lops
= {
777 .lo_add
= glock_lo_add
,
778 .lo_after_commit
= glock_lo_after_commit
,
782 const struct gfs2_log_operations gfs2_buf_lops
= {
783 .lo_add
= buf_lo_add
,
784 .lo_incore_commit
= buf_lo_incore_commit
,
785 .lo_before_commit
= buf_lo_before_commit
,
786 .lo_after_commit
= buf_lo_after_commit
,
787 .lo_before_scan
= buf_lo_before_scan
,
788 .lo_scan_elements
= buf_lo_scan_elements
,
789 .lo_after_scan
= buf_lo_after_scan
,
793 const struct gfs2_log_operations gfs2_revoke_lops
= {
794 .lo_add
= revoke_lo_add
,
795 .lo_before_commit
= revoke_lo_before_commit
,
796 .lo_before_scan
= revoke_lo_before_scan
,
797 .lo_scan_elements
= revoke_lo_scan_elements
,
798 .lo_after_scan
= revoke_lo_after_scan
,
802 const struct gfs2_log_operations gfs2_rg_lops
= {
804 .lo_after_commit
= rg_lo_after_commit
,
808 const struct gfs2_log_operations gfs2_databuf_lops
= {
809 .lo_add
= databuf_lo_add
,
810 .lo_incore_commit
= buf_lo_incore_commit
,
811 .lo_before_commit
= databuf_lo_before_commit
,
812 .lo_after_commit
= databuf_lo_after_commit
,
813 .lo_scan_elements
= databuf_lo_scan_elements
,
814 .lo_after_scan
= databuf_lo_after_scan
,
815 .lo_name
= "databuf",
818 const struct gfs2_log_operations
*gfs2_log_ops
[] = {