blob: a392e32af480c7cc26919adc5c8f579c46a58851 [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 Whitehousec969f582009-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 if (!list_empty(&bd->bd_list_tr))
Benjamin Marzinski84bd6d12012-11-07 00:38:06 -0600262 return;
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500263 tr = current->journal_info;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000264 tr->tr_touched = 1;
265 tr->tr_num_buf++;
266 list_add(&bd->bd_list_tr, &tr->tr_list_buf);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000267 if (!list_empty(&le->le_list))
Benjamin Marzinski84bd6d12012-11-07 00:38:06 -0600268 return;
Steven Whitehouse2bcd6102007-11-08 14:25:12 +0000269 set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
270 set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000271 gfs2_meta_check(sdp, bd->bd_bh);
Steven Whitehousea98ab222006-01-18 13:38:44 +0000272 gfs2_pin(sdp, bd->bd_bh);
Steven Whitehouse0ab7d132009-11-06 16:20:51 +0000273 mh = (struct gfs2_meta_header *)bd->bd_bh->b_data;
274 mh->__pad0 = cpu_to_be64(0);
275 mh->mh_jid = cpu_to_be32(sdp->sd_jdesc->jd_jid);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000276 sdp->sd_log_num_buf++;
277 list_add(&le->le_list, &sdp->sd_log_le_buf);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000278 tr->tr_num_buf_new++;
279}
280
David Teiglandb3b94fa2006-01-16 16:50:04 +0000281static void buf_lo_before_commit(struct gfs2_sbd *sdp)
282{
283 struct buffer_head *bh;
284 struct gfs2_log_descriptor *ld;
285 struct gfs2_bufdata *bd1 = NULL, *bd2;
Bob Peterson905d2ae2007-07-24 14:05:31 -0500286 unsigned int total;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000287 unsigned int limit;
288 unsigned int num;
289 unsigned n;
290 __be64 *ptr;
291
Robert Peterson2332c442007-06-18 14:50:20 -0500292 limit = buf_limit(sdp);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000293 /* for 4k blocks, limit = 503 */
294
Bob Peterson905d2ae2007-07-24 14:05:31 -0500295 gfs2_log_lock(sdp);
296 total = sdp->sd_log_num_buf;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000297 bd1 = bd2 = list_prepare_entry(bd1, &sdp->sd_log_le_buf, bd_le.le_list);
298 while(total) {
299 num = total;
300 if (total > limit)
301 num = limit;
Bob Peterson905d2ae2007-07-24 14:05:31 -0500302 gfs2_log_unlock(sdp);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100303 bh = gfs2_get_log_desc(sdp, GFS2_LOG_DESC_METADATA);
Bob Peterson905d2ae2007-07-24 14:05:31 -0500304 gfs2_log_lock(sdp);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100305 ld = bh_log_desc(bh);
306 ptr = bh_log_ptr(bh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000307 ld->ld_length = cpu_to_be32(num + 1);
308 ld->ld_data1 = cpu_to_be32(num);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000309
310 n = 0;
Steven Whitehouse568f4c92006-02-27 12:00:42 -0500311 list_for_each_entry_continue(bd1, &sdp->sd_log_le_buf,
312 bd_le.le_list) {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000313 *ptr++ = cpu_to_be64(bd1->bd_bh->b_blocknr);
314 if (++n >= num)
315 break;
316 }
317
Bob Peterson905d2ae2007-07-24 14:05:31 -0500318 gfs2_log_unlock(sdp);
Jens Axboe721a9602011-03-09 11:56:30 +0100319 submit_bh(WRITE_SYNC, bh);
Bob Peterson905d2ae2007-07-24 14:05:31 -0500320 gfs2_log_lock(sdp);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000321
322 n = 0;
Steven Whitehouse568f4c92006-02-27 12:00:42 -0500323 list_for_each_entry_continue(bd2, &sdp->sd_log_le_buf,
324 bd_le.le_list) {
Steven Whitehouse16615be2007-09-17 10:59:52 +0100325 get_bh(bd2->bd_bh);
Bob Peterson905d2ae2007-07-24 14:05:31 -0500326 gfs2_log_unlock(sdp);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100327 lock_buffer(bd2->bd_bh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000328 bh = gfs2_log_fake_buf(sdp, bd2->bd_bh);
Jens Axboe721a9602011-03-09 11:56:30 +0100329 submit_bh(WRITE_SYNC, bh);
Bob Peterson905d2ae2007-07-24 14:05:31 -0500330 gfs2_log_lock(sdp);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000331 if (++n >= num)
332 break;
333 }
334
Bob Peterson905d2ae2007-07-24 14:05:31 -0500335 BUG_ON(total < num);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000336 total -= num;
337 }
Bob Peterson905d2ae2007-07-24 14:05:31 -0500338 gfs2_log_unlock(sdp);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000339}
340
341static void buf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
342{
343 struct list_head *head = &sdp->sd_log_le_buf;
344 struct gfs2_bufdata *bd;
345
346 while (!list_empty(head)) {
347 bd = list_entry(head->next, struct gfs2_bufdata, bd_le.le_list);
348 list_del_init(&bd->bd_le.le_list);
349 sdp->sd_log_num_buf--;
350
Steven Whitehousea98ab222006-01-18 13:38:44 +0000351 gfs2_unpin(sdp, bd->bd_bh, ai);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000352 }
353 gfs2_assert_warn(sdp, !sdp->sd_log_num_buf);
354}
355
356static void buf_lo_before_scan(struct gfs2_jdesc *jd,
Al Viro55167622006-10-13 21:47:13 -0400357 struct gfs2_log_header_host *head, int pass)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000358{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400359 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000360
361 if (pass != 0)
362 return;
363
364 sdp->sd_found_blocks = 0;
365 sdp->sd_replayed_blocks = 0;
366}
367
368static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
369 struct gfs2_log_descriptor *ld, __be64 *ptr,
370 int pass)
371{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400372 struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
373 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500374 struct gfs2_glock *gl = ip->i_gl;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000375 unsigned int blks = be32_to_cpu(ld->ld_data1);
376 struct buffer_head *bh_log, *bh_ip;
Steven Whitehousecd915492006-09-04 12:49:07 -0400377 u64 blkno;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000378 int error = 0;
379
380 if (pass != 1 || be32_to_cpu(ld->ld_type) != GFS2_LOG_DESC_METADATA)
381 return 0;
382
383 gfs2_replay_incr_blk(sdp, &start);
384
385 for (; blks; gfs2_replay_incr_blk(sdp, &start), blks--) {
386 blkno = be64_to_cpu(*ptr++);
387
388 sdp->sd_found_blocks++;
389
390 if (gfs2_revoke_check(sdp, blkno, start))
391 continue;
392
393 error = gfs2_replay_read_block(jd, start, &bh_log);
Steven Whitehouse82ffa512006-09-04 14:47:06 -0400394 if (error)
395 return error;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000396
397 bh_ip = gfs2_meta_new(gl, blkno);
398 memcpy(bh_ip->b_data, bh_log->b_data, bh_log->b_size);
399
400 if (gfs2_meta_check(sdp, bh_ip))
401 error = -EIO;
402 else
403 mark_buffer_dirty(bh_ip);
404
405 brelse(bh_log);
406 brelse(bh_ip);
407
408 if (error)
409 break;
410
411 sdp->sd_replayed_blocks++;
412 }
413
414 return error;
415}
416
417static void buf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
418{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400419 struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
420 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000421
422 if (error) {
Steven Whitehouse7276b3b2006-09-21 17:05:23 -0400423 gfs2_meta_sync(ip->i_gl);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000424 return;
425 }
426 if (pass != 1)
427 return;
428
Steven Whitehouse7276b3b2006-09-21 17:05:23 -0400429 gfs2_meta_sync(ip->i_gl);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000430
431 fs_info(sdp, "jid=%u: Replayed %u of %u blocks\n",
432 jd->jd_jid, sdp->sd_replayed_blocks, sdp->sd_found_blocks);
433}
434
435static void revoke_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
436{
Steven Whitehousef42ab082011-04-14 16:50:31 +0100437 struct gfs2_bufdata *bd = container_of(le, struct gfs2_bufdata, bd_le);
438 struct gfs2_glock *gl = bd->bd_gl;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000439 struct gfs2_trans *tr;
440
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500441 tr = current->journal_info;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000442 tr->tr_touched = 1;
443 tr->tr_num_revoke++;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000444 sdp->sd_log_num_revoke++;
Steven Whitehousef42ab082011-04-14 16:50:31 +0100445 atomic_inc(&gl->gl_revokes);
446 set_bit(GLF_LFLUSH, &gl->gl_flags);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000447 list_add(&le->le_list, &sdp->sd_log_le_revoke);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000448}
449
450static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
451{
452 struct gfs2_log_descriptor *ld;
453 struct gfs2_meta_header *mh;
454 struct buffer_head *bh;
455 unsigned int offset;
456 struct list_head *head = &sdp->sd_log_le_revoke;
Steven Whitehouse82e86082007-09-02 15:39:43 +0100457 struct gfs2_bufdata *bd;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000458
459 if (!sdp->sd_log_num_revoke)
460 return;
461
Steven Whitehouse16615be2007-09-17 10:59:52 +0100462 bh = gfs2_get_log_desc(sdp, GFS2_LOG_DESC_REVOKE);
463 ld = bh_log_desc(bh);
Steven Whitehouse568f4c92006-02-27 12:00:42 -0500464 ld->ld_length = cpu_to_be32(gfs2_struct2blk(sdp, sdp->sd_log_num_revoke,
Steven Whitehousecd915492006-09-04 12:49:07 -0400465 sizeof(u64)));
David Teiglandb3b94fa2006-01-16 16:50:04 +0000466 ld->ld_data1 = cpu_to_be32(sdp->sd_log_num_revoke);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000467 offset = sizeof(struct gfs2_log_descriptor);
468
Steven Whitehousef42ab082011-04-14 16:50:31 +0100469 list_for_each_entry(bd, head, bd_le.le_list) {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000470 sdp->sd_log_num_revoke--;
471
Steven Whitehousecd915492006-09-04 12:49:07 -0400472 if (offset + sizeof(u64) > sdp->sd_sb.sb_bsize) {
Jens Axboe721a9602011-03-09 11:56:30 +0100473 submit_bh(WRITE_SYNC, bh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000474
475 bh = gfs2_log_get_buf(sdp);
476 mh = (struct gfs2_meta_header *)bh->b_data;
477 mh->mh_magic = cpu_to_be32(GFS2_MAGIC);
Steven Whitehousee3167de2006-03-30 15:46:23 -0500478 mh->mh_type = cpu_to_be32(GFS2_METATYPE_LB);
479 mh->mh_format = cpu_to_be32(GFS2_FORMAT_LB);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000480 offset = sizeof(struct gfs2_meta_header);
481 }
482
Steven Whitehouse82e86082007-09-02 15:39:43 +0100483 *(__be64 *)(bh->b_data + offset) = cpu_to_be64(bd->bd_blkno);
Steven Whitehousecd915492006-09-04 12:49:07 -0400484 offset += sizeof(u64);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000485 }
486 gfs2_assert_withdraw(sdp, !sdp->sd_log_num_revoke);
487
Jens Axboe721a9602011-03-09 11:56:30 +0100488 submit_bh(WRITE_SYNC, bh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000489}
490
Steven Whitehousef42ab082011-04-14 16:50:31 +0100491static void revoke_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
492{
493 struct list_head *head = &sdp->sd_log_le_revoke;
494 struct gfs2_bufdata *bd;
495 struct gfs2_glock *gl;
496
497 while (!list_empty(head)) {
498 bd = list_entry(head->next, struct gfs2_bufdata, bd_le.le_list);
499 list_del_init(&bd->bd_le.le_list);
500 gl = bd->bd_gl;
501 atomic_dec(&gl->gl_revokes);
502 clear_bit(GLF_LFLUSH, &gl->gl_flags);
503 kmem_cache_free(gfs2_bufdata_cachep, bd);
504 }
505}
506
David Teiglandb3b94fa2006-01-16 16:50:04 +0000507static void revoke_lo_before_scan(struct gfs2_jdesc *jd,
Al Viro55167622006-10-13 21:47:13 -0400508 struct gfs2_log_header_host *head, int pass)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000509{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400510 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000511
512 if (pass != 0)
513 return;
514
515 sdp->sd_found_revokes = 0;
516 sdp->sd_replay_tail = head->lh_tail;
517}
518
519static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
520 struct gfs2_log_descriptor *ld, __be64 *ptr,
521 int pass)
522{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400523 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000524 unsigned int blks = be32_to_cpu(ld->ld_length);
525 unsigned int revokes = be32_to_cpu(ld->ld_data1);
526 struct buffer_head *bh;
527 unsigned int offset;
Steven Whitehousecd915492006-09-04 12:49:07 -0400528 u64 blkno;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000529 int first = 1;
530 int error;
531
532 if (pass != 0 || be32_to_cpu(ld->ld_type) != GFS2_LOG_DESC_REVOKE)
533 return 0;
534
535 offset = sizeof(struct gfs2_log_descriptor);
536
537 for (; blks; gfs2_replay_incr_blk(sdp, &start), blks--) {
538 error = gfs2_replay_read_block(jd, start, &bh);
539 if (error)
540 return error;
541
542 if (!first)
543 gfs2_metatype_check(sdp, bh, GFS2_METATYPE_LB);
544
Steven Whitehousecd915492006-09-04 12:49:07 -0400545 while (offset + sizeof(u64) <= sdp->sd_sb.sb_bsize) {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000546 blkno = be64_to_cpu(*(__be64 *)(bh->b_data + offset));
547
548 error = gfs2_revoke_add(sdp, blkno, start);
Bob Peterson3ad62e82008-01-28 16:35:13 -0600549 if (error < 0) {
550 brelse(bh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000551 return error;
Bob Peterson3ad62e82008-01-28 16:35:13 -0600552 }
David Teiglandb3b94fa2006-01-16 16:50:04 +0000553 else if (error)
554 sdp->sd_found_revokes++;
555
556 if (!--revokes)
557 break;
Steven Whitehousecd915492006-09-04 12:49:07 -0400558 offset += sizeof(u64);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000559 }
560
561 brelse(bh);
562 offset = sizeof(struct gfs2_meta_header);
563 first = 0;
564 }
565
566 return 0;
567}
568
569static void revoke_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
570{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400571 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000572
573 if (error) {
574 gfs2_revoke_clean(sdp);
575 return;
576 }
577 if (pass != 1)
578 return;
579
580 fs_info(sdp, "jid=%u: Found %u revoke tags\n",
581 jd->jd_jid, sdp->sd_found_revokes);
582
583 gfs2_revoke_clean(sdp);
584}
585
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000586/**
587 * databuf_lo_add - Add a databuf to the transaction.
588 *
589 * This is used in two distinct cases:
590 * i) In ordered write mode
591 * We put the data buffer on a list so that we can ensure that its
592 * synced to disk at the right time
593 * ii) In journaled data mode
594 * We need to journal the data block in the same way as metadata in
595 * the functions above. The difference is that here we have a tag
596 * which is two __be64's being the block number (as per meta data)
597 * and a flag which says whether the data block needs escaping or
598 * not. This means we need a new log entry for each 251 or so data
599 * blocks, which isn't an enormous overhead but twice as much as
600 * for normal metadata blocks.
601 */
David Teiglandb3b94fa2006-01-16 16:50:04 +0000602static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
603{
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000604 struct gfs2_bufdata *bd = container_of(le, struct gfs2_bufdata, bd_le);
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500605 struct gfs2_trans *tr = current->journal_info;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000606 struct address_space *mapping = bd->bd_bh->b_page->mapping;
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400607 struct gfs2_inode *ip = GFS2_I(mapping->host);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000608
Steven Whitehouse9ff8ec32007-09-28 13:49:05 +0100609 if (tr) {
610 if (!list_empty(&bd->bd_list_tr))
Benjamin Marzinski84bd6d12012-11-07 00:38:06 -0600611 return;
Steven Whitehouse9ff8ec32007-09-28 13:49:05 +0100612 tr->tr_touched = 1;
613 if (gfs2_is_jdata(ip)) {
614 tr->tr_num_buf++;
615 list_add(&bd->bd_list_tr, &tr->tr_list_buf);
616 }
Robert Peterson773ed1a2007-06-20 08:34:06 -0500617 }
Robert Peterson2332c442007-06-18 14:50:20 -0500618 if (!list_empty(&le->le_list))
Benjamin Marzinski84bd6d12012-11-07 00:38:06 -0600619 return;
Robert Peterson2332c442007-06-18 14:50:20 -0500620
Steven Whitehouse2bcd6102007-11-08 14:25:12 +0000621 set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
622 set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags);
Robert Peterson2332c442007-06-18 14:50:20 -0500623 if (gfs2_is_jdata(ip)) {
Robert Peterson2332c442007-06-18 14:50:20 -0500624 gfs2_pin(sdp, bd->bd_bh);
625 tr->tr_num_databuf_new++;
Steven Whitehoused7b616e2007-09-02 10:48:13 +0100626 sdp->sd_log_num_databuf++;
Dave Chinnere5884632010-02-05 16:45:25 +1100627 list_add_tail(&le->le_list, &sdp->sd_log_le_databuf);
Steven Whitehoused7b616e2007-09-02 10:48:13 +0100628 } else {
Dave Chinnere5884632010-02-05 16:45:25 +1100629 list_add_tail(&le->le_list, &sdp->sd_log_le_ordered);
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100630 }
David Teiglandb3b94fa2006-01-16 16:50:04 +0000631}
632
Steven Whitehouse16615be2007-09-17 10:59:52 +0100633static void gfs2_check_magic(struct buffer_head *bh)
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000634{
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000635 void *kaddr;
636 __be32 *ptr;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000637
Steven Whitehouse16615be2007-09-17 10:59:52 +0100638 clear_buffer_escaped(bh);
Cong Wangd9349282011-11-25 23:14:30 +0800639 kaddr = kmap_atomic(bh->b_page);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000640 ptr = kaddr + bh_offset(bh);
641 if (*ptr == cpu_to_be32(GFS2_MAGIC))
Steven Whitehouse16615be2007-09-17 10:59:52 +0100642 set_buffer_escaped(bh);
Cong Wangd9349282011-11-25 23:14:30 +0800643 kunmap_atomic(kaddr);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100644}
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000645
Steven Whitehouse16615be2007-09-17 10:59:52 +0100646static void gfs2_write_blocks(struct gfs2_sbd *sdp, struct buffer_head *bh,
647 struct list_head *list, struct list_head *done,
648 unsigned int n)
649{
650 struct buffer_head *bh1;
651 struct gfs2_log_descriptor *ld;
652 struct gfs2_bufdata *bd;
653 __be64 *ptr;
654
655 if (!bh)
656 return;
657
658 ld = bh_log_desc(bh);
659 ld->ld_length = cpu_to_be32(n + 1);
660 ld->ld_data1 = cpu_to_be32(n);
661
662 ptr = bh_log_ptr(bh);
663
664 get_bh(bh);
Jens Axboe721a9602011-03-09 11:56:30 +0100665 submit_bh(WRITE_SYNC, bh);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100666 gfs2_log_lock(sdp);
667 while(!list_empty(list)) {
668 bd = list_entry(list->next, struct gfs2_bufdata, bd_le.le_list);
669 list_move_tail(&bd->bd_le.le_list, done);
670 get_bh(bd->bd_bh);
671 while (be64_to_cpu(*ptr) != bd->bd_bh->b_blocknr) {
672 gfs2_log_incr_head(sdp);
673 ptr += 2;
674 }
675 gfs2_log_unlock(sdp);
676 lock_buffer(bd->bd_bh);
677 if (buffer_escaped(bd->bd_bh)) {
678 void *kaddr;
679 bh1 = gfs2_log_get_buf(sdp);
Cong Wangd9349282011-11-25 23:14:30 +0800680 kaddr = kmap_atomic(bd->bd_bh->b_page);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100681 memcpy(bh1->b_data, kaddr + bh_offset(bd->bd_bh),
682 bh1->b_size);
Cong Wangd9349282011-11-25 23:14:30 +0800683 kunmap_atomic(kaddr);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100684 *(__be32 *)bh1->b_data = 0;
685 clear_buffer_escaped(bd->bd_bh);
686 unlock_buffer(bd->bd_bh);
687 brelse(bd->bd_bh);
688 } else {
689 bh1 = gfs2_log_fake_buf(sdp, bd->bd_bh);
690 }
Jens Axboe721a9602011-03-09 11:56:30 +0100691 submit_bh(WRITE_SYNC, bh1);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100692 gfs2_log_lock(sdp);
693 ptr += 2;
694 }
695 gfs2_log_unlock(sdp);
696 brelse(bh);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000697}
698
699/**
700 * databuf_lo_before_commit - Scan the data buffers, writing as we go
701 *
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000702 */
Steven Whitehoused7b616e2007-09-02 10:48:13 +0100703
David Teiglandb3b94fa2006-01-16 16:50:04 +0000704static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
705{
Steven Whitehouse16615be2007-09-17 10:59:52 +0100706 struct gfs2_bufdata *bd = NULL;
707 struct buffer_head *bh = NULL;
708 unsigned int n = 0;
709 __be64 *ptr = NULL, *end = NULL;
710 LIST_HEAD(processed);
711 LIST_HEAD(in_progress);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000712
Steven Whitehousef55ab262006-02-21 12:51:39 +0000713 gfs2_log_lock(sdp);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100714 while (!list_empty(&sdp->sd_log_le_databuf)) {
715 if (ptr == end) {
Steven Whitehousef55ab262006-02-21 12:51:39 +0000716 gfs2_log_unlock(sdp);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100717 gfs2_write_blocks(sdp, bh, &in_progress, &processed, n);
718 n = 0;
719 bh = gfs2_get_log_desc(sdp, GFS2_LOG_DESC_JDATA);
720 ptr = bh_log_ptr(bh);
721 end = bh_ptr_end(bh) - 1;
Steven Whitehousef55ab262006-02-21 12:51:39 +0000722 gfs2_log_lock(sdp);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100723 continue;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000724 }
Steven Whitehouse16615be2007-09-17 10:59:52 +0100725 bd = list_entry(sdp->sd_log_le_databuf.next, struct gfs2_bufdata, bd_le.le_list);
726 list_move_tail(&bd->bd_le.le_list, &in_progress);
727 gfs2_check_magic(bd->bd_bh);
728 *ptr++ = cpu_to_be64(bd->bd_bh->b_blocknr);
729 *ptr++ = cpu_to_be64(buffer_escaped(bh) ? 1 : 0);
730 n++;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000731 }
Steven Whitehousef55ab262006-02-21 12:51:39 +0000732 gfs2_log_unlock(sdp);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100733 gfs2_write_blocks(sdp, bh, &in_progress, &processed, n);
734 gfs2_log_lock(sdp);
735 list_splice(&processed, &sdp->sd_log_le_databuf);
736 gfs2_log_unlock(sdp);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000737}
738
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000739static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
740 struct gfs2_log_descriptor *ld,
741 __be64 *ptr, int pass)
742{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400743 struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
744 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500745 struct gfs2_glock *gl = ip->i_gl;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000746 unsigned int blks = be32_to_cpu(ld->ld_data1);
747 struct buffer_head *bh_log, *bh_ip;
Steven Whitehousecd915492006-09-04 12:49:07 -0400748 u64 blkno;
749 u64 esc;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000750 int error = 0;
751
752 if (pass != 1 || be32_to_cpu(ld->ld_type) != GFS2_LOG_DESC_JDATA)
753 return 0;
754
755 gfs2_replay_incr_blk(sdp, &start);
756 for (; blks; gfs2_replay_incr_blk(sdp, &start), blks--) {
757 blkno = be64_to_cpu(*ptr++);
758 esc = be64_to_cpu(*ptr++);
759
760 sdp->sd_found_blocks++;
761
762 if (gfs2_revoke_check(sdp, blkno, start))
763 continue;
764
765 error = gfs2_replay_read_block(jd, start, &bh_log);
766 if (error)
767 return error;
768
769 bh_ip = gfs2_meta_new(gl, blkno);
770 memcpy(bh_ip->b_data, bh_log->b_data, bh_log->b_size);
771
772 /* Unescape */
773 if (esc) {
774 __be32 *eptr = (__be32 *)bh_ip->b_data;
775 *eptr = cpu_to_be32(GFS2_MAGIC);
776 }
777 mark_buffer_dirty(bh_ip);
778
779 brelse(bh_log);
780 brelse(bh_ip);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000781
782 sdp->sd_replayed_blocks++;
783 }
784
785 return error;
786}
787
788/* FIXME: sort out accounting for log blocks etc. */
789
790static void databuf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
791{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400792 struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
793 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000794
795 if (error) {
Steven Whitehouse7276b3b2006-09-21 17:05:23 -0400796 gfs2_meta_sync(ip->i_gl);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000797 return;
798 }
799 if (pass != 1)
800 return;
801
802 /* data sync? */
Steven Whitehouse7276b3b2006-09-21 17:05:23 -0400803 gfs2_meta_sync(ip->i_gl);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000804
805 fs_info(sdp, "jid=%u: Replayed %u of %u data blocks\n",
806 jd->jd_jid, sdp->sd_replayed_blocks, sdp->sd_found_blocks);
807}
808
809static void databuf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
810{
811 struct list_head *head = &sdp->sd_log_le_databuf;
812 struct gfs2_bufdata *bd;
813
814 while (!list_empty(head)) {
815 bd = list_entry(head->next, struct gfs2_bufdata, bd_le.le_list);
Steven Whitehouseb8e1aab2006-08-22 16:25:50 -0400816 list_del_init(&bd->bd_le.le_list);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000817 sdp->sd_log_num_databuf--;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000818 gfs2_unpin(sdp, bd->bd_bh, ai);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000819 }
820 gfs2_assert_warn(sdp, !sdp->sd_log_num_databuf);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000821}
822
823
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400824const struct gfs2_log_operations gfs2_buf_lops = {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000825 .lo_add = buf_lo_add,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000826 .lo_before_commit = buf_lo_before_commit,
827 .lo_after_commit = buf_lo_after_commit,
828 .lo_before_scan = buf_lo_before_scan,
829 .lo_scan_elements = buf_lo_scan_elements,
830 .lo_after_scan = buf_lo_after_scan,
Steven Whitehouseea67eed2006-09-05 10:53:09 -0400831 .lo_name = "buf",
David Teiglandb3b94fa2006-01-16 16:50:04 +0000832};
833
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400834const struct gfs2_log_operations gfs2_revoke_lops = {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000835 .lo_add = revoke_lo_add,
836 .lo_before_commit = revoke_lo_before_commit,
Steven Whitehousef42ab082011-04-14 16:50:31 +0100837 .lo_after_commit = revoke_lo_after_commit,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000838 .lo_before_scan = revoke_lo_before_scan,
839 .lo_scan_elements = revoke_lo_scan_elements,
840 .lo_after_scan = revoke_lo_after_scan,
Steven Whitehouseea67eed2006-09-05 10:53:09 -0400841 .lo_name = "revoke",
David Teiglandb3b94fa2006-01-16 16:50:04 +0000842};
843
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400844const struct gfs2_log_operations gfs2_rg_lops = {
Steven Whitehouseea67eed2006-09-05 10:53:09 -0400845 .lo_name = "rg",
David Teiglandb3b94fa2006-01-16 16:50:04 +0000846};
847
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400848const struct gfs2_log_operations gfs2_databuf_lops = {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000849 .lo_add = databuf_lo_add,
850 .lo_before_commit = databuf_lo_before_commit,
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000851 .lo_after_commit = databuf_lo_after_commit,
852 .lo_scan_elements = databuf_lo_scan_elements,
853 .lo_after_scan = databuf_lo_after_scan,
Steven Whitehouseea67eed2006-09-05 10:53:09 -0400854 .lo_name = "databuf",
David Teiglandb3b94fa2006-01-16 16:50:04 +0000855};
856
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400857const struct gfs2_log_operations *gfs2_log_ops[] = {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000858 &gfs2_databuf_lops,
Steven Whitehouse16615be2007-09-17 10:59:52 +0100859 &gfs2_buf_lops,
860 &gfs2_rg_lops,
861 &gfs2_revoke_lops,
Steven Whitehouseea67eed2006-09-05 10:53:09 -0400862 NULL,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000863};
864