blob: 6b1efb594d9084386546d696e8df244f1087022b [file] [log] [blame]
David Teiglandb3b94fa2006-01-16 16:50:04 +00001/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
Steven Whitehouse3a8a9a12006-05-18 15:09:15 -04003 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
David Teiglandb3b94fa2006-01-16 16:50:04 +00004 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
Steven Whitehousee9fc2aa2006-09-01 11:05:15 -04007 * of the GNU General Public License version 2.
David Teiglandb3b94fa2006-01-16 16:50:04 +00008 */
9
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>
Steven Whitehouse75ca61c2012-03-08 12:10:23 +000015#include <linux/mempool.h>
Steven Whitehouse5c676f62006-02-27 17:23:27 -050016#include <linux/gfs2_ondisk.h>
Steven Whitehousec969f58c2009-04-07 14:13:01 +010017#include <linux/bio.h>
18#include <linux/fs.h>
David Teiglandb3b94fa2006-01-16 16:50:04 +000019
20#include "gfs2.h"
Steven Whitehouse5c676f62006-02-27 17:23:27 -050021#include "incore.h"
Robert Peterson2332c442007-06-18 14:50:20 -050022#include "inode.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000023#include "glock.h"
24#include "log.h"
25#include "lops.h"
26#include "meta_io.h"
27#include "recovery.h"
28#include "rgrp.h"
29#include "trans.h"
Steven Whitehouse5c676f62006-02-27 17:23:27 -050030#include "util.h"
Steven Whitehouse63997772009-06-12 08:49:20 +010031#include "trace_gfs2.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000032
Steven Whitehouse9b9107a2007-08-27 13:54:05 +010033/**
34 * gfs2_pin - Pin a buffer in memory
35 * @sdp: The superblock
36 * @bh: The buffer to be pinned
37 *
38 * The log lock must be held when calling this function
39 */
40static void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh)
41{
42 struct gfs2_bufdata *bd;
43
Steven Whitehouse29687a22011-03-30 16:33:25 +010044 BUG_ON(!current->journal_info);
Steven Whitehouse9b9107a2007-08-27 13:54:05 +010045
46 clear_buffer_dirty(bh);
47 if (test_set_buffer_pinned(bh))
48 gfs2_assert_withdraw(sdp, 0);
49 if (!buffer_uptodate(bh))
50 gfs2_io_error_bh(sdp, bh);
51 bd = bh->b_private;
52 /* If this buffer is in the AIL and it has already been written
53 * to in-place disk block, remove it from the AIL.
54 */
Steven Whitehousec618e872011-03-14 12:40:29 +000055 spin_lock(&sdp->sd_ail_lock);
Steven Whitehouse9b9107a2007-08-27 13:54:05 +010056 if (bd->bd_ail)
57 list_move(&bd->bd_ail_st_list, &bd->bd_ail->ai_ail2_list);
Steven Whitehousec618e872011-03-14 12:40:29 +000058 spin_unlock(&sdp->sd_ail_lock);
Steven Whitehouse9b9107a2007-08-27 13:54:05 +010059 get_bh(bh);
Benjamin Marzinski5e687ea2010-05-04 14:29:16 -050060 atomic_inc(&sdp->sd_log_pinned);
Steven Whitehouse63997772009-06-12 08:49:20 +010061 trace_gfs2_pin(bd, 1);
Steven Whitehouse9b9107a2007-08-27 13:54:05 +010062}
63
Bob Peterson7c9ca622011-08-31 09:53:19 +010064static bool buffer_is_rgrp(const struct gfs2_bufdata *bd)
65{
66 return bd->bd_gl->gl_name.ln_type == LM_TYPE_RGRP;
67}
68
69static void maybe_release_space(struct gfs2_bufdata *bd)
70{
71 struct gfs2_glock *gl = bd->bd_gl;
72 struct gfs2_sbd *sdp = gl->gl_sbd;
73 struct gfs2_rgrpd *rgd = gl->gl_object;
74 unsigned int index = bd->bd_bh->b_blocknr - gl->gl_name.ln_number;
75 struct gfs2_bitmap *bi = rgd->rd_bits + index;
76
77 if (bi->bi_clone == 0)
78 return;
79 if (sdp->sd_args.ar_discard)
Steven Whitehouse66fc0612012-02-08 12:58:32 +000080 gfs2_rgrp_send_discards(sdp, rgd->rd_data0, bd->bd_bh, bi, 1, NULL);
Bob Peterson7c9ca622011-08-31 09:53:19 +010081 memcpy(bi->bi_clone + bi->bi_offset,
82 bd->bd_bh->b_data + bi->bi_offset, bi->bi_len);
83 clear_bit(GBF_FULL, &bi->bi_flags);
84 rgd->rd_free_clone = rgd->rd_free;
85}
86
Steven Whitehouse9b9107a2007-08-27 13:54:05 +010087/**
88 * gfs2_unpin - Unpin a buffer
89 * @sdp: the filesystem the buffer belongs to
90 * @bh: The buffer to unpin
91 * @ai:
Steven Whitehouse29687a22011-03-30 16:33:25 +010092 * @flags: The inode dirty flags
Steven Whitehouse9b9107a2007-08-27 13:54:05 +010093 *
94 */
95
96static void gfs2_unpin(struct gfs2_sbd *sdp, struct buffer_head *bh,
97 struct gfs2_ail *ai)
98{
99 struct gfs2_bufdata *bd = bh->b_private;
100
Steven Whitehouse29687a22011-03-30 16:33:25 +0100101 BUG_ON(!buffer_uptodate(bh));
102 BUG_ON(!buffer_pinned(bh));
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100103
104 lock_buffer(bh);
105 mark_buffer_dirty(bh);
106 clear_buffer_pinned(bh);
107
Bob Peterson7c9ca622011-08-31 09:53:19 +0100108 if (buffer_is_rgrp(bd))
109 maybe_release_space(bd);
110
Dave Chinnerd6a079e2011-03-11 11:52:25 +0000111 spin_lock(&sdp->sd_ail_lock);
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100112 if (bd->bd_ail) {
113 list_del(&bd->bd_ail_st_list);
114 brelse(bh);
115 } else {
116 struct gfs2_glock *gl = bd->bd_gl;
117 list_add(&bd->bd_ail_gl_list, &gl->gl_ail_list);
118 atomic_inc(&gl->gl_ail_count);
119 }
120 bd->bd_ail = ai;
121 list_add(&bd->bd_ail_st_list, &ai->ai_ail1_list);
Dave Chinnerd6a079e2011-03-11 11:52:25 +0000122 spin_unlock(&sdp->sd_ail_lock);
123
Steven Whitehouse29687a22011-03-30 16:33:25 +0100124 clear_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
Steven Whitehouse63997772009-06-12 08:49:20 +0100125 trace_gfs2_pin(bd, 0);
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100126 unlock_buffer(bh);
Benjamin Marzinski5e687ea2010-05-04 14:29:16 -0500127 atomic_dec(&sdp->sd_log_pinned);
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100128}
129
Steven Whitehouse16615be2007-09-17 10:59:52 +0100130
131static inline struct gfs2_log_descriptor *bh_log_desc(struct buffer_head *bh)
132{
133 return (struct gfs2_log_descriptor *)bh->b_data;
134}
135
136static inline __be64 *bh_log_ptr(struct buffer_head *bh)
137{
138 struct gfs2_log_descriptor *ld = bh_log_desc(bh);
139 return (__force __be64 *)(ld + 1);
140}
141
142static inline __be64 *bh_ptr_end(struct buffer_head *bh)
143{
144 return (__force __be64 *)(bh->b_data + bh->b_size);
145}
146
Steven Whitehouse47ac5532012-02-03 15:21:59 +0000147/**
148 * gfs2_log_write_endio - End of I/O for a log buffer
149 * @bh: The buffer head
150 * @uptodate: I/O Status
151 *
152 */
153
154static void gfs2_log_write_endio(struct buffer_head *bh, int uptodate)
155{
156 struct gfs2_sbd *sdp = bh->b_private;
157 bh->b_private = NULL;
158
159 end_buffer_write_sync(bh, uptodate);
160 if (atomic_dec_and_test(&sdp->sd_log_in_flight))
161 wake_up(&sdp->sd_log_flush_wait);
162}
163
164/**
165 * gfs2_log_get_buf - Get and initialize a buffer to use for log control data
166 * @sdp: The GFS2 superblock
167 *
168 * tReturns: the buffer_head
169 */
170
171static struct buffer_head *gfs2_log_get_buf(struct gfs2_sbd *sdp)
172{
173 u64 blkno = gfs2_log_bmap(sdp, sdp->sd_log_flush_head);
174 struct buffer_head *bh;
175
176 bh = sb_getblk(sdp->sd_vfs, blkno);
177 lock_buffer(bh);
178 memset(bh->b_data, 0, bh->b_size);
179 set_buffer_uptodate(bh);
180 clear_buffer_dirty(bh);
181 gfs2_log_incr_head(sdp);
182 atomic_inc(&sdp->sd_log_in_flight);
183 bh->b_private = sdp;
184 bh->b_end_io = gfs2_log_write_endio;
185
186 return bh;
187}
188
189/**
190 * gfs2_fake_write_endio -
191 * @bh: The buffer head
192 * @uptodate: The I/O Status
193 *
194 */
195
196static void gfs2_fake_write_endio(struct buffer_head *bh, int uptodate)
197{
198 struct buffer_head *real_bh = bh->b_private;
199 struct gfs2_bufdata *bd = real_bh->b_private;
200 struct gfs2_sbd *sdp = bd->bd_gl->gl_sbd;
201
202 end_buffer_write_sync(bh, uptodate);
Steven Whitehouse75ca61c2012-03-08 12:10:23 +0000203 mempool_free(bh, gfs2_bh_pool);
Steven Whitehouse47ac5532012-02-03 15:21:59 +0000204 unlock_buffer(real_bh);
205 brelse(real_bh);
206 if (atomic_dec_and_test(&sdp->sd_log_in_flight))
207 wake_up(&sdp->sd_log_flush_wait);
208}
209
210/**
211 * gfs2_log_fake_buf - Build a fake buffer head to write metadata buffer to log
212 * @sdp: the filesystem
213 * @data: the data the buffer_head should point to
214 *
215 * Returns: the log buffer descriptor
216 */
217
218static struct buffer_head *gfs2_log_fake_buf(struct gfs2_sbd *sdp,
219 struct buffer_head *real)
220{
221 u64 blkno = gfs2_log_bmap(sdp, sdp->sd_log_flush_head);
222 struct buffer_head *bh;
223
Steven Whitehouse75ca61c2012-03-08 12:10:23 +0000224 bh = mempool_alloc(gfs2_bh_pool, GFP_NOFS);
Steven Whitehouse47ac5532012-02-03 15:21:59 +0000225 atomic_set(&bh->b_count, 1);
226 bh->b_state = (1 << BH_Mapped) | (1 << BH_Uptodate) | (1 << BH_Lock);
227 set_bh_page(bh, real->b_page, bh_offset(real));
228 bh->b_blocknr = blkno;
229 bh->b_size = sdp->sd_sb.sb_bsize;
230 bh->b_bdev = sdp->sd_vfs->s_bdev;
231 bh->b_private = real;
232 bh->b_end_io = gfs2_fake_write_endio;
233
234 gfs2_log_incr_head(sdp);
235 atomic_inc(&sdp->sd_log_in_flight);
236
237 return bh;
238}
Steven Whitehouse16615be2007-09-17 10:59:52 +0100239
240static struct buffer_head *gfs2_get_log_desc(struct gfs2_sbd *sdp, u32 ld_type)
241{
242 struct buffer_head *bh = gfs2_log_get_buf(sdp);
243 struct gfs2_log_descriptor *ld = bh_log_desc(bh);
244 ld->ld_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
245 ld->ld_header.mh_type = cpu_to_be32(GFS2_METATYPE_LD);
246 ld->ld_header.mh_format = cpu_to_be32(GFS2_FORMAT_LD);
247 ld->ld_type = cpu_to_be32(ld_type);
248 ld->ld_length = 0;
249 ld->ld_data1 = 0;
250 ld->ld_data2 = 0;
251 memset(ld->ld_reserved, 0, sizeof(ld->ld_reserved));
252 return bh;
253}
254
David Teiglandb3b94fa2006-01-16 16:50:04 +0000255static void buf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
256{
257 struct gfs2_bufdata *bd = container_of(le, struct gfs2_bufdata, bd_le);
Steven Whitehouse0ab7d132009-11-06 16:20:51 +0000258 struct gfs2_meta_header *mh;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000259 struct gfs2_trans *tr;
260
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100261 lock_buffer(bd->bd_bh);
Steven Whitehouse8bd95722007-01-25 10:04:20 +0000262 gfs2_log_lock(sdp);
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100263 if (!list_empty(&bd->bd_list_tr))
264 goto out;
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500265 tr = current->journal_info;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000266 tr->tr_touched = 1;
267 tr->tr_num_buf++;
268 list_add(&bd->bd_list_tr, &tr->tr_list_buf);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000269 if (!list_empty(&le->le_list))
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100270 goto out;
Steven Whitehouse2bcd6102007-11-08 14:25:12 +0000271 set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
272 set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000273 gfs2_meta_check(sdp, bd->bd_bh);
Steven Whitehousea98ab222006-01-18 13:38:44 +0000274 gfs2_pin(sdp, bd->bd_bh);
Steven Whitehouse0ab7d132009-11-06 16:20:51 +0000275 mh = (struct gfs2_meta_header *)bd->bd_bh->b_data;
276 mh->__pad0 = cpu_to_be64(0);
277 mh->mh_jid = cpu_to_be32(sdp->sd_jdesc->jd_jid);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000278 sdp->sd_log_num_buf++;
279 list_add(&le->le_list, &sdp->sd_log_le_buf);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000280 tr->tr_num_buf_new++;
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100281out:
282 gfs2_log_unlock(sdp);
283 unlock_buffer(bd->bd_bh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000284}
285
David Teiglandb3b94fa2006-01-16 16:50:04 +0000286static void buf_lo_before_commit(struct gfs2_sbd *sdp)
287{
288 struct buffer_head *bh;
289 struct gfs2_log_descriptor *ld;
290 struct gfs2_bufdata *bd1 = NULL, *bd2;
Bob Peterson905d2ae2007-07-24 14:05:31 -0500291 unsigned int total;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000292 unsigned int limit;
293 unsigned int num;
294 unsigned n;
295 __be64 *ptr;
296
Robert Peterson2332c442007-06-18 14:50:20 -0500297 limit = buf_limit(sdp);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000298 /* for 4k blocks, limit = 503 */
299
Bob Peterson905d2ae2007-07-24 14:05:31 -0500300 gfs2_log_lock(sdp);
301 total = sdp->sd_log_num_buf;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000302 bd1 = bd2 = list_prepare_entry(bd1, &sdp->sd_log_le_buf, bd_le.le_list);
303 while(total) {
304 num = total;
305 if (total > limit)
306 num = limit;
Bob Peterson905d2ae2007-07-24 14:05:31 -0500307 gfs2_log_unlock(sdp);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100308 bh = gfs2_get_log_desc(sdp, GFS2_LOG_DESC_METADATA);
Bob Peterson905d2ae2007-07-24 14:05:31 -0500309 gfs2_log_lock(sdp);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100310 ld = bh_log_desc(bh);
311 ptr = bh_log_ptr(bh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000312 ld->ld_length = cpu_to_be32(num + 1);
313 ld->ld_data1 = cpu_to_be32(num);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000314
315 n = 0;
Steven Whitehouse568f4c92006-02-27 12:00:42 -0500316 list_for_each_entry_continue(bd1, &sdp->sd_log_le_buf,
317 bd_le.le_list) {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000318 *ptr++ = cpu_to_be64(bd1->bd_bh->b_blocknr);
319 if (++n >= num)
320 break;
321 }
322
Bob Peterson905d2ae2007-07-24 14:05:31 -0500323 gfs2_log_unlock(sdp);
Jens Axboe721a9602011-03-09 11:56:30 +0100324 submit_bh(WRITE_SYNC, bh);
Bob Peterson905d2ae2007-07-24 14:05:31 -0500325 gfs2_log_lock(sdp);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000326
327 n = 0;
Steven Whitehouse568f4c92006-02-27 12:00:42 -0500328 list_for_each_entry_continue(bd2, &sdp->sd_log_le_buf,
329 bd_le.le_list) {
Steven Whitehouse16615be2007-09-17 10:59:52 +0100330 get_bh(bd2->bd_bh);
Bob Peterson905d2ae2007-07-24 14:05:31 -0500331 gfs2_log_unlock(sdp);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100332 lock_buffer(bd2->bd_bh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000333 bh = gfs2_log_fake_buf(sdp, bd2->bd_bh);
Jens Axboe721a9602011-03-09 11:56:30 +0100334 submit_bh(WRITE_SYNC, bh);
Bob Peterson905d2ae2007-07-24 14:05:31 -0500335 gfs2_log_lock(sdp);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000336 if (++n >= num)
337 break;
338 }
339
Bob Peterson905d2ae2007-07-24 14:05:31 -0500340 BUG_ON(total < num);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000341 total -= num;
342 }
Bob Peterson905d2ae2007-07-24 14:05:31 -0500343 gfs2_log_unlock(sdp);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000344}
345
346static void buf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
347{
348 struct list_head *head = &sdp->sd_log_le_buf;
349 struct gfs2_bufdata *bd;
350
351 while (!list_empty(head)) {
352 bd = list_entry(head->next, struct gfs2_bufdata, bd_le.le_list);
353 list_del_init(&bd->bd_le.le_list);
354 sdp->sd_log_num_buf--;
355
Steven Whitehousea98ab222006-01-18 13:38:44 +0000356 gfs2_unpin(sdp, bd->bd_bh, ai);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000357 }
358 gfs2_assert_warn(sdp, !sdp->sd_log_num_buf);
359}
360
361static void buf_lo_before_scan(struct gfs2_jdesc *jd,
Al Viro55167622006-10-13 21:47:13 -0400362 struct gfs2_log_header_host *head, int pass)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000363{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400364 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000365
366 if (pass != 0)
367 return;
368
369 sdp->sd_found_blocks = 0;
370 sdp->sd_replayed_blocks = 0;
371}
372
373static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
374 struct gfs2_log_descriptor *ld, __be64 *ptr,
375 int pass)
376{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400377 struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
378 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500379 struct gfs2_glock *gl = ip->i_gl;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000380 unsigned int blks = be32_to_cpu(ld->ld_data1);
381 struct buffer_head *bh_log, *bh_ip;
Steven Whitehousecd915492006-09-04 12:49:07 -0400382 u64 blkno;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000383 int error = 0;
384
385 if (pass != 1 || be32_to_cpu(ld->ld_type) != GFS2_LOG_DESC_METADATA)
386 return 0;
387
388 gfs2_replay_incr_blk(sdp, &start);
389
390 for (; blks; gfs2_replay_incr_blk(sdp, &start), blks--) {
391 blkno = be64_to_cpu(*ptr++);
392
393 sdp->sd_found_blocks++;
394
395 if (gfs2_revoke_check(sdp, blkno, start))
396 continue;
397
398 error = gfs2_replay_read_block(jd, start, &bh_log);
Steven Whitehouse82ffa512006-09-04 14:47:06 -0400399 if (error)
400 return error;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000401
402 bh_ip = gfs2_meta_new(gl, blkno);
403 memcpy(bh_ip->b_data, bh_log->b_data, bh_log->b_size);
404
405 if (gfs2_meta_check(sdp, bh_ip))
406 error = -EIO;
407 else
408 mark_buffer_dirty(bh_ip);
409
410 brelse(bh_log);
411 brelse(bh_ip);
412
413 if (error)
414 break;
415
416 sdp->sd_replayed_blocks++;
417 }
418
419 return error;
420}
421
422static void buf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
423{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400424 struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
425 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000426
427 if (error) {
Steven Whitehouse7276b3b2006-09-21 17:05:23 -0400428 gfs2_meta_sync(ip->i_gl);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000429 return;
430 }
431 if (pass != 1)
432 return;
433
Steven Whitehouse7276b3b2006-09-21 17:05:23 -0400434 gfs2_meta_sync(ip->i_gl);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000435
436 fs_info(sdp, "jid=%u: Replayed %u of %u blocks\n",
437 jd->jd_jid, sdp->sd_replayed_blocks, sdp->sd_found_blocks);
438}
439
440static void revoke_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
441{
Steven Whitehousef42ab082011-04-14 16:50:31 +0100442 struct gfs2_bufdata *bd = container_of(le, struct gfs2_bufdata, bd_le);
443 struct gfs2_glock *gl = bd->bd_gl;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000444 struct gfs2_trans *tr;
445
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500446 tr = current->journal_info;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000447 tr->tr_touched = 1;
448 tr->tr_num_revoke++;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000449 sdp->sd_log_num_revoke++;
Steven Whitehousef42ab082011-04-14 16:50:31 +0100450 atomic_inc(&gl->gl_revokes);
451 set_bit(GLF_LFLUSH, &gl->gl_flags);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000452 list_add(&le->le_list, &sdp->sd_log_le_revoke);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000453}
454
455static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
456{
457 struct gfs2_log_descriptor *ld;
458 struct gfs2_meta_header *mh;
459 struct buffer_head *bh;
460 unsigned int offset;
461 struct list_head *head = &sdp->sd_log_le_revoke;
Steven Whitehouse82e86082007-09-02 15:39:43 +0100462 struct gfs2_bufdata *bd;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000463
464 if (!sdp->sd_log_num_revoke)
465 return;
466
Steven Whitehouse16615be2007-09-17 10:59:52 +0100467 bh = gfs2_get_log_desc(sdp, GFS2_LOG_DESC_REVOKE);
468 ld = bh_log_desc(bh);
Steven Whitehouse568f4c92006-02-27 12:00:42 -0500469 ld->ld_length = cpu_to_be32(gfs2_struct2blk(sdp, sdp->sd_log_num_revoke,
Steven Whitehousecd915492006-09-04 12:49:07 -0400470 sizeof(u64)));
David Teiglandb3b94fa2006-01-16 16:50:04 +0000471 ld->ld_data1 = cpu_to_be32(sdp->sd_log_num_revoke);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000472 offset = sizeof(struct gfs2_log_descriptor);
473
Steven Whitehousef42ab082011-04-14 16:50:31 +0100474 list_for_each_entry(bd, head, bd_le.le_list) {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000475 sdp->sd_log_num_revoke--;
476
Steven Whitehousecd915492006-09-04 12:49:07 -0400477 if (offset + sizeof(u64) > sdp->sd_sb.sb_bsize) {
Jens Axboe721a9602011-03-09 11:56:30 +0100478 submit_bh(WRITE_SYNC, bh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000479
480 bh = gfs2_log_get_buf(sdp);
481 mh = (struct gfs2_meta_header *)bh->b_data;
482 mh->mh_magic = cpu_to_be32(GFS2_MAGIC);
Steven Whitehousee3167de2006-03-30 15:46:23 -0500483 mh->mh_type = cpu_to_be32(GFS2_METATYPE_LB);
484 mh->mh_format = cpu_to_be32(GFS2_FORMAT_LB);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000485 offset = sizeof(struct gfs2_meta_header);
486 }
487
Steven Whitehouse82e86082007-09-02 15:39:43 +0100488 *(__be64 *)(bh->b_data + offset) = cpu_to_be64(bd->bd_blkno);
Steven Whitehousecd915492006-09-04 12:49:07 -0400489 offset += sizeof(u64);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000490 }
491 gfs2_assert_withdraw(sdp, !sdp->sd_log_num_revoke);
492
Jens Axboe721a9602011-03-09 11:56:30 +0100493 submit_bh(WRITE_SYNC, bh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000494}
495
Steven Whitehousef42ab082011-04-14 16:50:31 +0100496static void revoke_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
497{
498 struct list_head *head = &sdp->sd_log_le_revoke;
499 struct gfs2_bufdata *bd;
500 struct gfs2_glock *gl;
501
502 while (!list_empty(head)) {
503 bd = list_entry(head->next, struct gfs2_bufdata, bd_le.le_list);
504 list_del_init(&bd->bd_le.le_list);
505 gl = bd->bd_gl;
506 atomic_dec(&gl->gl_revokes);
507 clear_bit(GLF_LFLUSH, &gl->gl_flags);
508 kmem_cache_free(gfs2_bufdata_cachep, bd);
509 }
510}
511
David Teiglandb3b94fa2006-01-16 16:50:04 +0000512static void revoke_lo_before_scan(struct gfs2_jdesc *jd,
Al Viro55167622006-10-13 21:47:13 -0400513 struct gfs2_log_header_host *head, int pass)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000514{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400515 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000516
517 if (pass != 0)
518 return;
519
520 sdp->sd_found_revokes = 0;
521 sdp->sd_replay_tail = head->lh_tail;
522}
523
524static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
525 struct gfs2_log_descriptor *ld, __be64 *ptr,
526 int pass)
527{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400528 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000529 unsigned int blks = be32_to_cpu(ld->ld_length);
530 unsigned int revokes = be32_to_cpu(ld->ld_data1);
531 struct buffer_head *bh;
532 unsigned int offset;
Steven Whitehousecd915492006-09-04 12:49:07 -0400533 u64 blkno;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000534 int first = 1;
535 int error;
536
537 if (pass != 0 || be32_to_cpu(ld->ld_type) != GFS2_LOG_DESC_REVOKE)
538 return 0;
539
540 offset = sizeof(struct gfs2_log_descriptor);
541
542 for (; blks; gfs2_replay_incr_blk(sdp, &start), blks--) {
543 error = gfs2_replay_read_block(jd, start, &bh);
544 if (error)
545 return error;
546
547 if (!first)
548 gfs2_metatype_check(sdp, bh, GFS2_METATYPE_LB);
549
Steven Whitehousecd915492006-09-04 12:49:07 -0400550 while (offset + sizeof(u64) <= sdp->sd_sb.sb_bsize) {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000551 blkno = be64_to_cpu(*(__be64 *)(bh->b_data + offset));
552
553 error = gfs2_revoke_add(sdp, blkno, start);
Bob Peterson3ad62e82008-01-28 16:35:13 -0600554 if (error < 0) {
555 brelse(bh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000556 return error;
Bob Peterson3ad62e82008-01-28 16:35:13 -0600557 }
David Teiglandb3b94fa2006-01-16 16:50:04 +0000558 else if (error)
559 sdp->sd_found_revokes++;
560
561 if (!--revokes)
562 break;
Steven Whitehousecd915492006-09-04 12:49:07 -0400563 offset += sizeof(u64);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000564 }
565
566 brelse(bh);
567 offset = sizeof(struct gfs2_meta_header);
568 first = 0;
569 }
570
571 return 0;
572}
573
574static void revoke_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
575{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400576 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000577
578 if (error) {
579 gfs2_revoke_clean(sdp);
580 return;
581 }
582 if (pass != 1)
583 return;
584
585 fs_info(sdp, "jid=%u: Found %u revoke tags\n",
586 jd->jd_jid, sdp->sd_found_revokes);
587
588 gfs2_revoke_clean(sdp);
589}
590
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000591/**
592 * databuf_lo_add - Add a databuf to the transaction.
593 *
594 * This is used in two distinct cases:
595 * i) In ordered write mode
596 * We put the data buffer on a list so that we can ensure that its
597 * synced to disk at the right time
598 * ii) In journaled data mode
599 * We need to journal the data block in the same way as metadata in
600 * the functions above. The difference is that here we have a tag
601 * which is two __be64's being the block number (as per meta data)
602 * and a flag which says whether the data block needs escaping or
603 * not. This means we need a new log entry for each 251 or so data
604 * blocks, which isn't an enormous overhead but twice as much as
605 * for normal metadata blocks.
606 */
David Teiglandb3b94fa2006-01-16 16:50:04 +0000607static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
608{
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000609 struct gfs2_bufdata *bd = container_of(le, struct gfs2_bufdata, bd_le);
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500610 struct gfs2_trans *tr = current->journal_info;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000611 struct address_space *mapping = bd->bd_bh->b_page->mapping;
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400612 struct gfs2_inode *ip = GFS2_I(mapping->host);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000613
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100614 lock_buffer(bd->bd_bh);
Steven Whitehouse8bd95722007-01-25 10:04:20 +0000615 gfs2_log_lock(sdp);
Steven Whitehouse9ff8ec32007-09-28 13:49:05 +0100616 if (tr) {
617 if (!list_empty(&bd->bd_list_tr))
618 goto out;
619 tr->tr_touched = 1;
620 if (gfs2_is_jdata(ip)) {
621 tr->tr_num_buf++;
622 list_add(&bd->bd_list_tr, &tr->tr_list_buf);
623 }
Robert Peterson773ed1a2007-06-20 08:34:06 -0500624 }
Robert Peterson2332c442007-06-18 14:50:20 -0500625 if (!list_empty(&le->le_list))
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100626 goto out;
Robert Peterson2332c442007-06-18 14:50:20 -0500627
Steven Whitehouse2bcd6102007-11-08 14:25:12 +0000628 set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
629 set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags);
Robert Peterson2332c442007-06-18 14:50:20 -0500630 if (gfs2_is_jdata(ip)) {
Robert Peterson2332c442007-06-18 14:50:20 -0500631 gfs2_pin(sdp, bd->bd_bh);
632 tr->tr_num_databuf_new++;
Steven Whitehoused7b616e2007-09-02 10:48:13 +0100633 sdp->sd_log_num_databuf++;
Dave Chinnere5884632010-02-05 16:45:25 +1100634 list_add_tail(&le->le_list, &sdp->sd_log_le_databuf);
Steven Whitehoused7b616e2007-09-02 10:48:13 +0100635 } else {
Dave Chinnere5884632010-02-05 16:45:25 +1100636 list_add_tail(&le->le_list, &sdp->sd_log_le_ordered);
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100637 }
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100638out:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000639 gfs2_log_unlock(sdp);
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100640 unlock_buffer(bd->bd_bh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000641}
642
Steven Whitehouse16615be2007-09-17 10:59:52 +0100643static void gfs2_check_magic(struct buffer_head *bh)
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000644{
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000645 void *kaddr;
646 __be32 *ptr;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000647
Steven Whitehouse16615be2007-09-17 10:59:52 +0100648 clear_buffer_escaped(bh);
Cong Wangd9349282011-11-25 23:14:30 +0800649 kaddr = kmap_atomic(bh->b_page);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000650 ptr = kaddr + bh_offset(bh);
651 if (*ptr == cpu_to_be32(GFS2_MAGIC))
Steven Whitehouse16615be2007-09-17 10:59:52 +0100652 set_buffer_escaped(bh);
Cong Wangd9349282011-11-25 23:14:30 +0800653 kunmap_atomic(kaddr);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100654}
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000655
Steven Whitehouse16615be2007-09-17 10:59:52 +0100656static void gfs2_write_blocks(struct gfs2_sbd *sdp, struct buffer_head *bh,
657 struct list_head *list, struct list_head *done,
658 unsigned int n)
659{
660 struct buffer_head *bh1;
661 struct gfs2_log_descriptor *ld;
662 struct gfs2_bufdata *bd;
663 __be64 *ptr;
664
665 if (!bh)
666 return;
667
668 ld = bh_log_desc(bh);
669 ld->ld_length = cpu_to_be32(n + 1);
670 ld->ld_data1 = cpu_to_be32(n);
671
672 ptr = bh_log_ptr(bh);
673
674 get_bh(bh);
Jens Axboe721a9602011-03-09 11:56:30 +0100675 submit_bh(WRITE_SYNC, bh);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100676 gfs2_log_lock(sdp);
677 while(!list_empty(list)) {
678 bd = list_entry(list->next, struct gfs2_bufdata, bd_le.le_list);
679 list_move_tail(&bd->bd_le.le_list, done);
680 get_bh(bd->bd_bh);
681 while (be64_to_cpu(*ptr) != bd->bd_bh->b_blocknr) {
682 gfs2_log_incr_head(sdp);
683 ptr += 2;
684 }
685 gfs2_log_unlock(sdp);
686 lock_buffer(bd->bd_bh);
687 if (buffer_escaped(bd->bd_bh)) {
688 void *kaddr;
689 bh1 = gfs2_log_get_buf(sdp);
Cong Wangd9349282011-11-25 23:14:30 +0800690 kaddr = kmap_atomic(bd->bd_bh->b_page);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100691 memcpy(bh1->b_data, kaddr + bh_offset(bd->bd_bh),
692 bh1->b_size);
Cong Wangd9349282011-11-25 23:14:30 +0800693 kunmap_atomic(kaddr);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100694 *(__be32 *)bh1->b_data = 0;
695 clear_buffer_escaped(bd->bd_bh);
696 unlock_buffer(bd->bd_bh);
697 brelse(bd->bd_bh);
698 } else {
699 bh1 = gfs2_log_fake_buf(sdp, bd->bd_bh);
700 }
Jens Axboe721a9602011-03-09 11:56:30 +0100701 submit_bh(WRITE_SYNC, bh1);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100702 gfs2_log_lock(sdp);
703 ptr += 2;
704 }
705 gfs2_log_unlock(sdp);
706 brelse(bh);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000707}
708
709/**
710 * databuf_lo_before_commit - Scan the data buffers, writing as we go
711 *
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000712 */
Steven Whitehoused7b616e2007-09-02 10:48:13 +0100713
David Teiglandb3b94fa2006-01-16 16:50:04 +0000714static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
715{
Steven Whitehouse16615be2007-09-17 10:59:52 +0100716 struct gfs2_bufdata *bd = NULL;
717 struct buffer_head *bh = NULL;
718 unsigned int n = 0;
719 __be64 *ptr = NULL, *end = NULL;
720 LIST_HEAD(processed);
721 LIST_HEAD(in_progress);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000722
Steven Whitehousef55ab262006-02-21 12:51:39 +0000723 gfs2_log_lock(sdp);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100724 while (!list_empty(&sdp->sd_log_le_databuf)) {
725 if (ptr == end) {
Steven Whitehousef55ab262006-02-21 12:51:39 +0000726 gfs2_log_unlock(sdp);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100727 gfs2_write_blocks(sdp, bh, &in_progress, &processed, n);
728 n = 0;
729 bh = gfs2_get_log_desc(sdp, GFS2_LOG_DESC_JDATA);
730 ptr = bh_log_ptr(bh);
731 end = bh_ptr_end(bh) - 1;
Steven Whitehousef55ab262006-02-21 12:51:39 +0000732 gfs2_log_lock(sdp);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100733 continue;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000734 }
Steven Whitehouse16615be2007-09-17 10:59:52 +0100735 bd = list_entry(sdp->sd_log_le_databuf.next, struct gfs2_bufdata, bd_le.le_list);
736 list_move_tail(&bd->bd_le.le_list, &in_progress);
737 gfs2_check_magic(bd->bd_bh);
738 *ptr++ = cpu_to_be64(bd->bd_bh->b_blocknr);
739 *ptr++ = cpu_to_be64(buffer_escaped(bh) ? 1 : 0);
740 n++;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000741 }
Steven Whitehousef55ab262006-02-21 12:51:39 +0000742 gfs2_log_unlock(sdp);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100743 gfs2_write_blocks(sdp, bh, &in_progress, &processed, n);
744 gfs2_log_lock(sdp);
745 list_splice(&processed, &sdp->sd_log_le_databuf);
746 gfs2_log_unlock(sdp);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000747}
748
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000749static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
750 struct gfs2_log_descriptor *ld,
751 __be64 *ptr, int pass)
752{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400753 struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
754 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500755 struct gfs2_glock *gl = ip->i_gl;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000756 unsigned int blks = be32_to_cpu(ld->ld_data1);
757 struct buffer_head *bh_log, *bh_ip;
Steven Whitehousecd915492006-09-04 12:49:07 -0400758 u64 blkno;
759 u64 esc;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000760 int error = 0;
761
762 if (pass != 1 || be32_to_cpu(ld->ld_type) != GFS2_LOG_DESC_JDATA)
763 return 0;
764
765 gfs2_replay_incr_blk(sdp, &start);
766 for (; blks; gfs2_replay_incr_blk(sdp, &start), blks--) {
767 blkno = be64_to_cpu(*ptr++);
768 esc = be64_to_cpu(*ptr++);
769
770 sdp->sd_found_blocks++;
771
772 if (gfs2_revoke_check(sdp, blkno, start))
773 continue;
774
775 error = gfs2_replay_read_block(jd, start, &bh_log);
776 if (error)
777 return error;
778
779 bh_ip = gfs2_meta_new(gl, blkno);
780 memcpy(bh_ip->b_data, bh_log->b_data, bh_log->b_size);
781
782 /* Unescape */
783 if (esc) {
784 __be32 *eptr = (__be32 *)bh_ip->b_data;
785 *eptr = cpu_to_be32(GFS2_MAGIC);
786 }
787 mark_buffer_dirty(bh_ip);
788
789 brelse(bh_log);
790 brelse(bh_ip);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000791
792 sdp->sd_replayed_blocks++;
793 }
794
795 return error;
796}
797
798/* FIXME: sort out accounting for log blocks etc. */
799
800static void databuf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
801{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400802 struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
803 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000804
805 if (error) {
Steven Whitehouse7276b3b2006-09-21 17:05:23 -0400806 gfs2_meta_sync(ip->i_gl);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000807 return;
808 }
809 if (pass != 1)
810 return;
811
812 /* data sync? */
Steven Whitehouse7276b3b2006-09-21 17:05:23 -0400813 gfs2_meta_sync(ip->i_gl);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000814
815 fs_info(sdp, "jid=%u: Replayed %u of %u data blocks\n",
816 jd->jd_jid, sdp->sd_replayed_blocks, sdp->sd_found_blocks);
817}
818
819static void databuf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
820{
821 struct list_head *head = &sdp->sd_log_le_databuf;
822 struct gfs2_bufdata *bd;
823
824 while (!list_empty(head)) {
825 bd = list_entry(head->next, struct gfs2_bufdata, bd_le.le_list);
Steven Whitehouseb8e1aab2006-08-22 16:25:50 -0400826 list_del_init(&bd->bd_le.le_list);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000827 sdp->sd_log_num_databuf--;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000828 gfs2_unpin(sdp, bd->bd_bh, ai);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000829 }
830 gfs2_assert_warn(sdp, !sdp->sd_log_num_databuf);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000831}
832
833
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400834const struct gfs2_log_operations gfs2_buf_lops = {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000835 .lo_add = buf_lo_add,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000836 .lo_before_commit = buf_lo_before_commit,
837 .lo_after_commit = buf_lo_after_commit,
838 .lo_before_scan = buf_lo_before_scan,
839 .lo_scan_elements = buf_lo_scan_elements,
840 .lo_after_scan = buf_lo_after_scan,
Steven Whitehouseea67eed2006-09-05 10:53:09 -0400841 .lo_name = "buf",
David Teiglandb3b94fa2006-01-16 16:50:04 +0000842};
843
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400844const struct gfs2_log_operations gfs2_revoke_lops = {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000845 .lo_add = revoke_lo_add,
846 .lo_before_commit = revoke_lo_before_commit,
Steven Whitehousef42ab082011-04-14 16:50:31 +0100847 .lo_after_commit = revoke_lo_after_commit,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000848 .lo_before_scan = revoke_lo_before_scan,
849 .lo_scan_elements = revoke_lo_scan_elements,
850 .lo_after_scan = revoke_lo_after_scan,
Steven Whitehouseea67eed2006-09-05 10:53:09 -0400851 .lo_name = "revoke",
David Teiglandb3b94fa2006-01-16 16:50:04 +0000852};
853
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400854const struct gfs2_log_operations gfs2_rg_lops = {
Steven Whitehouseea67eed2006-09-05 10:53:09 -0400855 .lo_name = "rg",
David Teiglandb3b94fa2006-01-16 16:50:04 +0000856};
857
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400858const struct gfs2_log_operations gfs2_databuf_lops = {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000859 .lo_add = databuf_lo_add,
860 .lo_before_commit = databuf_lo_before_commit,
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000861 .lo_after_commit = databuf_lo_after_commit,
862 .lo_scan_elements = databuf_lo_scan_elements,
863 .lo_after_scan = databuf_lo_after_scan,
Steven Whitehouseea67eed2006-09-05 10:53:09 -0400864 .lo_name = "databuf",
David Teiglandb3b94fa2006-01-16 16:50:04 +0000865};
866
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400867const struct gfs2_log_operations *gfs2_log_ops[] = {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000868 &gfs2_databuf_lops,
Steven Whitehouse16615be2007-09-17 10:59:52 +0100869 &gfs2_buf_lops,
870 &gfs2_rg_lops,
871 &gfs2_revoke_lops,
Steven Whitehouseea67eed2006-09-05 10:53:09 -0400872 NULL,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000873};
874