blob: fe369bd9e10c7ee907620d81e7960d5a77417134 [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 Whitehouse5c676f62006-02-27 17:23:27 -050015#include <linux/gfs2_ondisk.h>
Steven Whitehousec969f582009-04-07 14:13:01 +010016#include <linux/bio.h>
17#include <linux/fs.h>
David Teiglandb3b94fa2006-01-16 16:50:04 +000018
19#include "gfs2.h"
Steven Whitehouse5c676f62006-02-27 17:23:27 -050020#include "incore.h"
Robert Peterson2332c442007-06-18 14:50:20 -050021#include "inode.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000022#include "glock.h"
23#include "log.h"
24#include "lops.h"
25#include "meta_io.h"
26#include "recovery.h"
27#include "rgrp.h"
28#include "trans.h"
Steven Whitehouse5c676f62006-02-27 17:23:27 -050029#include "util.h"
Steven Whitehouse63997772009-06-12 08:49:20 +010030#include "trace_gfs2.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000031
Steven Whitehouse9b9107a2007-08-27 13:54:05 +010032/**
33 * gfs2_pin - Pin a buffer in memory
34 * @sdp: The superblock
35 * @bh: The buffer to be pinned
36 *
37 * The log lock must be held when calling this function
38 */
39static void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh)
40{
41 struct gfs2_bufdata *bd;
42
Steven Whitehouse29687a22011-03-30 16:33:25 +010043 BUG_ON(!current->journal_info);
Steven Whitehouse9b9107a2007-08-27 13:54:05 +010044
45 clear_buffer_dirty(bh);
46 if (test_set_buffer_pinned(bh))
47 gfs2_assert_withdraw(sdp, 0);
48 if (!buffer_uptodate(bh))
49 gfs2_io_error_bh(sdp, bh);
50 bd = bh->b_private;
51 /* If this buffer is in the AIL and it has already been written
52 * to in-place disk block, remove it from the AIL.
53 */
Steven Whitehousec618e872011-03-14 12:40:29 +000054 spin_lock(&sdp->sd_ail_lock);
Steven Whitehouse9b9107a2007-08-27 13:54:05 +010055 if (bd->bd_ail)
56 list_move(&bd->bd_ail_st_list, &bd->bd_ail->ai_ail2_list);
Steven Whitehousec618e872011-03-14 12:40:29 +000057 spin_unlock(&sdp->sd_ail_lock);
Steven Whitehouse9b9107a2007-08-27 13:54:05 +010058 get_bh(bh);
Benjamin Marzinski5e687ea2010-05-04 14:29:16 -050059 atomic_inc(&sdp->sd_log_pinned);
Steven Whitehouse63997772009-06-12 08:49:20 +010060 trace_gfs2_pin(bd, 1);
Steven Whitehouse9b9107a2007-08-27 13:54:05 +010061}
62
Bob Peterson7c9ca622011-08-31 09:53:19 +010063static bool buffer_is_rgrp(const struct gfs2_bufdata *bd)
64{
65 return bd->bd_gl->gl_name.ln_type == LM_TYPE_RGRP;
66}
67
68static void maybe_release_space(struct gfs2_bufdata *bd)
69{
70 struct gfs2_glock *gl = bd->bd_gl;
71 struct gfs2_sbd *sdp = gl->gl_sbd;
72 struct gfs2_rgrpd *rgd = gl->gl_object;
73 unsigned int index = bd->bd_bh->b_blocknr - gl->gl_name.ln_number;
74 struct gfs2_bitmap *bi = rgd->rd_bits + index;
75
76 if (bi->bi_clone == 0)
77 return;
78 if (sdp->sd_args.ar_discard)
Steven Whitehouse66fc0612012-02-08 12:58:32 +000079 gfs2_rgrp_send_discards(sdp, rgd->rd_data0, bd->bd_bh, bi, 1, NULL);
Bob Peterson7c9ca622011-08-31 09:53:19 +010080 memcpy(bi->bi_clone + bi->bi_offset,
81 bd->bd_bh->b_data + bi->bi_offset, bi->bi_len);
82 clear_bit(GBF_FULL, &bi->bi_flags);
83 rgd->rd_free_clone = rgd->rd_free;
84}
85
Steven Whitehouse9b9107a2007-08-27 13:54:05 +010086/**
87 * gfs2_unpin - Unpin a buffer
88 * @sdp: the filesystem the buffer belongs to
89 * @bh: The buffer to unpin
90 * @ai:
Steven Whitehouse29687a22011-03-30 16:33:25 +010091 * @flags: The inode dirty flags
Steven Whitehouse9b9107a2007-08-27 13:54:05 +010092 *
93 */
94
95static void gfs2_unpin(struct gfs2_sbd *sdp, struct buffer_head *bh,
96 struct gfs2_ail *ai)
97{
98 struct gfs2_bufdata *bd = bh->b_private;
99
Steven Whitehouse29687a22011-03-30 16:33:25 +0100100 BUG_ON(!buffer_uptodate(bh));
101 BUG_ON(!buffer_pinned(bh));
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100102
103 lock_buffer(bh);
104 mark_buffer_dirty(bh);
105 clear_buffer_pinned(bh);
106
Bob Peterson7c9ca622011-08-31 09:53:19 +0100107 if (buffer_is_rgrp(bd))
108 maybe_release_space(bd);
109
Dave Chinnerd6a079e2011-03-11 11:52:25 +0000110 spin_lock(&sdp->sd_ail_lock);
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100111 if (bd->bd_ail) {
112 list_del(&bd->bd_ail_st_list);
113 brelse(bh);
114 } else {
115 struct gfs2_glock *gl = bd->bd_gl;
116 list_add(&bd->bd_ail_gl_list, &gl->gl_ail_list);
117 atomic_inc(&gl->gl_ail_count);
118 }
119 bd->bd_ail = ai;
120 list_add(&bd->bd_ail_st_list, &ai->ai_ail1_list);
Dave Chinnerd6a079e2011-03-11 11:52:25 +0000121 spin_unlock(&sdp->sd_ail_lock);
122
Steven Whitehouse29687a22011-03-30 16:33:25 +0100123 clear_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
Steven Whitehouse63997772009-06-12 08:49:20 +0100124 trace_gfs2_pin(bd, 0);
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100125 unlock_buffer(bh);
Benjamin Marzinski5e687ea2010-05-04 14:29:16 -0500126 atomic_dec(&sdp->sd_log_pinned);
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100127}
128
Steven Whitehouse16615be2007-09-17 10:59:52 +0100129
130static inline struct gfs2_log_descriptor *bh_log_desc(struct buffer_head *bh)
131{
132 return (struct gfs2_log_descriptor *)bh->b_data;
133}
134
135static inline __be64 *bh_log_ptr(struct buffer_head *bh)
136{
137 struct gfs2_log_descriptor *ld = bh_log_desc(bh);
138 return (__force __be64 *)(ld + 1);
139}
140
141static inline __be64 *bh_ptr_end(struct buffer_head *bh)
142{
143 return (__force __be64 *)(bh->b_data + bh->b_size);
144}
145
Steven Whitehouse47ac5532012-02-03 15:21:59 +0000146/**
147 * gfs2_log_write_endio - End of I/O for a log buffer
148 * @bh: The buffer head
149 * @uptodate: I/O Status
150 *
151 */
152
153static void gfs2_log_write_endio(struct buffer_head *bh, int uptodate)
154{
155 struct gfs2_sbd *sdp = bh->b_private;
156 bh->b_private = NULL;
157
158 end_buffer_write_sync(bh, uptodate);
159 if (atomic_dec_and_test(&sdp->sd_log_in_flight))
160 wake_up(&sdp->sd_log_flush_wait);
161}
162
163/**
164 * gfs2_log_get_buf - Get and initialize a buffer to use for log control data
165 * @sdp: The GFS2 superblock
166 *
167 * tReturns: the buffer_head
168 */
169
170static struct buffer_head *gfs2_log_get_buf(struct gfs2_sbd *sdp)
171{
172 u64 blkno = gfs2_log_bmap(sdp, sdp->sd_log_flush_head);
173 struct buffer_head *bh;
174
175 bh = sb_getblk(sdp->sd_vfs, blkno);
176 lock_buffer(bh);
177 memset(bh->b_data, 0, bh->b_size);
178 set_buffer_uptodate(bh);
179 clear_buffer_dirty(bh);
180 gfs2_log_incr_head(sdp);
181 atomic_inc(&sdp->sd_log_in_flight);
182 bh->b_private = sdp;
183 bh->b_end_io = gfs2_log_write_endio;
184
185 return bh;
186}
187
188/**
189 * gfs2_fake_write_endio -
190 * @bh: The buffer head
191 * @uptodate: The I/O Status
192 *
193 */
194
195static void gfs2_fake_write_endio(struct buffer_head *bh, int uptodate)
196{
197 struct buffer_head *real_bh = bh->b_private;
198 struct gfs2_bufdata *bd = real_bh->b_private;
199 struct gfs2_sbd *sdp = bd->bd_gl->gl_sbd;
200
201 end_buffer_write_sync(bh, uptodate);
202 free_buffer_head(bh);
203 unlock_buffer(real_bh);
204 brelse(real_bh);
205 if (atomic_dec_and_test(&sdp->sd_log_in_flight))
206 wake_up(&sdp->sd_log_flush_wait);
207}
208
209/**
210 * gfs2_log_fake_buf - Build a fake buffer head to write metadata buffer to log
211 * @sdp: the filesystem
212 * @data: the data the buffer_head should point to
213 *
214 * Returns: the log buffer descriptor
215 */
216
217static struct buffer_head *gfs2_log_fake_buf(struct gfs2_sbd *sdp,
218 struct buffer_head *real)
219{
220 u64 blkno = gfs2_log_bmap(sdp, sdp->sd_log_flush_head);
221 struct buffer_head *bh;
222
223 bh = alloc_buffer_head(GFP_NOFS | __GFP_NOFAIL);
224 atomic_set(&bh->b_count, 1);
225 bh->b_state = (1 << BH_Mapped) | (1 << BH_Uptodate) | (1 << BH_Lock);
226 set_bh_page(bh, real->b_page, bh_offset(real));
227 bh->b_blocknr = blkno;
228 bh->b_size = sdp->sd_sb.sb_bsize;
229 bh->b_bdev = sdp->sd_vfs->s_bdev;
230 bh->b_private = real;
231 bh->b_end_io = gfs2_fake_write_endio;
232
233 gfs2_log_incr_head(sdp);
234 atomic_inc(&sdp->sd_log_in_flight);
235
236 return bh;
237}
Steven Whitehouse16615be2007-09-17 10:59:52 +0100238
239static struct buffer_head *gfs2_get_log_desc(struct gfs2_sbd *sdp, u32 ld_type)
240{
241 struct buffer_head *bh = gfs2_log_get_buf(sdp);
242 struct gfs2_log_descriptor *ld = bh_log_desc(bh);
243 ld->ld_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
244 ld->ld_header.mh_type = cpu_to_be32(GFS2_METATYPE_LD);
245 ld->ld_header.mh_format = cpu_to_be32(GFS2_FORMAT_LD);
246 ld->ld_type = cpu_to_be32(ld_type);
247 ld->ld_length = 0;
248 ld->ld_data1 = 0;
249 ld->ld_data2 = 0;
250 memset(ld->ld_reserved, 0, sizeof(ld->ld_reserved));
251 return bh;
252}
253
David Teiglandb3b94fa2006-01-16 16:50:04 +0000254static void buf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
255{
256 struct gfs2_bufdata *bd = container_of(le, struct gfs2_bufdata, bd_le);
Steven Whitehouse0ab7d132009-11-06 16:20:51 +0000257 struct gfs2_meta_header *mh;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000258 struct gfs2_trans *tr;
259
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100260 lock_buffer(bd->bd_bh);
Steven Whitehouse8bd95722007-01-25 10:04:20 +0000261 gfs2_log_lock(sdp);
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100262 if (!list_empty(&bd->bd_list_tr))
263 goto out;
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500264 tr = current->journal_info;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000265 tr->tr_touched = 1;
266 tr->tr_num_buf++;
267 list_add(&bd->bd_list_tr, &tr->tr_list_buf);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000268 if (!list_empty(&le->le_list))
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100269 goto out;
Steven Whitehouse2bcd6102007-11-08 14:25:12 +0000270 set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
271 set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000272 gfs2_meta_check(sdp, bd->bd_bh);
Steven Whitehousea98ab222006-01-18 13:38:44 +0000273 gfs2_pin(sdp, bd->bd_bh);
Steven Whitehouse0ab7d132009-11-06 16:20:51 +0000274 mh = (struct gfs2_meta_header *)bd->bd_bh->b_data;
275 mh->__pad0 = cpu_to_be64(0);
276 mh->mh_jid = cpu_to_be32(sdp->sd_jdesc->jd_jid);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000277 sdp->sd_log_num_buf++;
278 list_add(&le->le_list, &sdp->sd_log_le_buf);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000279 tr->tr_num_buf_new++;
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100280out:
281 gfs2_log_unlock(sdp);
282 unlock_buffer(bd->bd_bh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000283}
284
David Teiglandb3b94fa2006-01-16 16:50:04 +0000285static void buf_lo_before_commit(struct gfs2_sbd *sdp)
286{
287 struct buffer_head *bh;
288 struct gfs2_log_descriptor *ld;
289 struct gfs2_bufdata *bd1 = NULL, *bd2;
Bob Peterson905d2ae2007-07-24 14:05:31 -0500290 unsigned int total;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000291 unsigned int limit;
292 unsigned int num;
293 unsigned n;
294 __be64 *ptr;
295
Robert Peterson2332c442007-06-18 14:50:20 -0500296 limit = buf_limit(sdp);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000297 /* for 4k blocks, limit = 503 */
298
Bob Peterson905d2ae2007-07-24 14:05:31 -0500299 gfs2_log_lock(sdp);
300 total = sdp->sd_log_num_buf;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000301 bd1 = bd2 = list_prepare_entry(bd1, &sdp->sd_log_le_buf, bd_le.le_list);
302 while(total) {
303 num = total;
304 if (total > limit)
305 num = limit;
Bob Peterson905d2ae2007-07-24 14:05:31 -0500306 gfs2_log_unlock(sdp);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100307 bh = gfs2_get_log_desc(sdp, GFS2_LOG_DESC_METADATA);
Bob Peterson905d2ae2007-07-24 14:05:31 -0500308 gfs2_log_lock(sdp);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100309 ld = bh_log_desc(bh);
310 ptr = bh_log_ptr(bh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000311 ld->ld_length = cpu_to_be32(num + 1);
312 ld->ld_data1 = cpu_to_be32(num);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000313
314 n = 0;
Steven Whitehouse568f4c92006-02-27 12:00:42 -0500315 list_for_each_entry_continue(bd1, &sdp->sd_log_le_buf,
316 bd_le.le_list) {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000317 *ptr++ = cpu_to_be64(bd1->bd_bh->b_blocknr);
318 if (++n >= num)
319 break;
320 }
321
Bob Peterson905d2ae2007-07-24 14:05:31 -0500322 gfs2_log_unlock(sdp);
Jens Axboe721a9602011-03-09 11:56:30 +0100323 submit_bh(WRITE_SYNC, bh);
Bob Peterson905d2ae2007-07-24 14:05:31 -0500324 gfs2_log_lock(sdp);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000325
326 n = 0;
Steven Whitehouse568f4c92006-02-27 12:00:42 -0500327 list_for_each_entry_continue(bd2, &sdp->sd_log_le_buf,
328 bd_le.le_list) {
Steven Whitehouse16615be2007-09-17 10:59:52 +0100329 get_bh(bd2->bd_bh);
Bob Peterson905d2ae2007-07-24 14:05:31 -0500330 gfs2_log_unlock(sdp);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100331 lock_buffer(bd2->bd_bh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000332 bh = gfs2_log_fake_buf(sdp, bd2->bd_bh);
Jens Axboe721a9602011-03-09 11:56:30 +0100333 submit_bh(WRITE_SYNC, bh);
Bob Peterson905d2ae2007-07-24 14:05:31 -0500334 gfs2_log_lock(sdp);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000335 if (++n >= num)
336 break;
337 }
338
Bob Peterson905d2ae2007-07-24 14:05:31 -0500339 BUG_ON(total < num);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000340 total -= num;
341 }
Bob Peterson905d2ae2007-07-24 14:05:31 -0500342 gfs2_log_unlock(sdp);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000343}
344
345static void buf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
346{
347 struct list_head *head = &sdp->sd_log_le_buf;
348 struct gfs2_bufdata *bd;
349
350 while (!list_empty(head)) {
351 bd = list_entry(head->next, struct gfs2_bufdata, bd_le.le_list);
352 list_del_init(&bd->bd_le.le_list);
353 sdp->sd_log_num_buf--;
354
Steven Whitehousea98ab222006-01-18 13:38:44 +0000355 gfs2_unpin(sdp, bd->bd_bh, ai);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000356 }
357 gfs2_assert_warn(sdp, !sdp->sd_log_num_buf);
358}
359
360static void buf_lo_before_scan(struct gfs2_jdesc *jd,
Al Viro55167622006-10-13 21:47:13 -0400361 struct gfs2_log_header_host *head, int pass)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000362{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400363 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000364
365 if (pass != 0)
366 return;
367
368 sdp->sd_found_blocks = 0;
369 sdp->sd_replayed_blocks = 0;
370}
371
372static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
373 struct gfs2_log_descriptor *ld, __be64 *ptr,
374 int pass)
375{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400376 struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
377 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500378 struct gfs2_glock *gl = ip->i_gl;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000379 unsigned int blks = be32_to_cpu(ld->ld_data1);
380 struct buffer_head *bh_log, *bh_ip;
Steven Whitehousecd915492006-09-04 12:49:07 -0400381 u64 blkno;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000382 int error = 0;
383
384 if (pass != 1 || be32_to_cpu(ld->ld_type) != GFS2_LOG_DESC_METADATA)
385 return 0;
386
387 gfs2_replay_incr_blk(sdp, &start);
388
389 for (; blks; gfs2_replay_incr_blk(sdp, &start), blks--) {
390 blkno = be64_to_cpu(*ptr++);
391
392 sdp->sd_found_blocks++;
393
394 if (gfs2_revoke_check(sdp, blkno, start))
395 continue;
396
397 error = gfs2_replay_read_block(jd, start, &bh_log);
Steven Whitehouse82ffa512006-09-04 14:47:06 -0400398 if (error)
399 return error;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000400
401 bh_ip = gfs2_meta_new(gl, blkno);
402 memcpy(bh_ip->b_data, bh_log->b_data, bh_log->b_size);
403
404 if (gfs2_meta_check(sdp, bh_ip))
405 error = -EIO;
406 else
407 mark_buffer_dirty(bh_ip);
408
409 brelse(bh_log);
410 brelse(bh_ip);
411
412 if (error)
413 break;
414
415 sdp->sd_replayed_blocks++;
416 }
417
418 return error;
419}
420
421static void buf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
422{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400423 struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
424 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000425
426 if (error) {
Steven Whitehouse7276b3b2006-09-21 17:05:23 -0400427 gfs2_meta_sync(ip->i_gl);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000428 return;
429 }
430 if (pass != 1)
431 return;
432
Steven Whitehouse7276b3b2006-09-21 17:05:23 -0400433 gfs2_meta_sync(ip->i_gl);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000434
435 fs_info(sdp, "jid=%u: Replayed %u of %u blocks\n",
436 jd->jd_jid, sdp->sd_replayed_blocks, sdp->sd_found_blocks);
437}
438
439static void revoke_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
440{
Steven Whitehousef42ab082011-04-14 16:50:31 +0100441 struct gfs2_bufdata *bd = container_of(le, struct gfs2_bufdata, bd_le);
442 struct gfs2_glock *gl = bd->bd_gl;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000443 struct gfs2_trans *tr;
444
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500445 tr = current->journal_info;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000446 tr->tr_touched = 1;
447 tr->tr_num_revoke++;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000448 sdp->sd_log_num_revoke++;
Steven Whitehousef42ab082011-04-14 16:50:31 +0100449 atomic_inc(&gl->gl_revokes);
450 set_bit(GLF_LFLUSH, &gl->gl_flags);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000451 list_add(&le->le_list, &sdp->sd_log_le_revoke);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000452}
453
454static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
455{
456 struct gfs2_log_descriptor *ld;
457 struct gfs2_meta_header *mh;
458 struct buffer_head *bh;
459 unsigned int offset;
460 struct list_head *head = &sdp->sd_log_le_revoke;
Steven Whitehouse82e86082007-09-02 15:39:43 +0100461 struct gfs2_bufdata *bd;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000462
463 if (!sdp->sd_log_num_revoke)
464 return;
465
Steven Whitehouse16615be2007-09-17 10:59:52 +0100466 bh = gfs2_get_log_desc(sdp, GFS2_LOG_DESC_REVOKE);
467 ld = bh_log_desc(bh);
Steven Whitehouse568f4c92006-02-27 12:00:42 -0500468 ld->ld_length = cpu_to_be32(gfs2_struct2blk(sdp, sdp->sd_log_num_revoke,
Steven Whitehousecd915492006-09-04 12:49:07 -0400469 sizeof(u64)));
David Teiglandb3b94fa2006-01-16 16:50:04 +0000470 ld->ld_data1 = cpu_to_be32(sdp->sd_log_num_revoke);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000471 offset = sizeof(struct gfs2_log_descriptor);
472
Steven Whitehousef42ab082011-04-14 16:50:31 +0100473 list_for_each_entry(bd, head, bd_le.le_list) {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000474 sdp->sd_log_num_revoke--;
475
Steven Whitehousecd915492006-09-04 12:49:07 -0400476 if (offset + sizeof(u64) > sdp->sd_sb.sb_bsize) {
Jens Axboe721a9602011-03-09 11:56:30 +0100477 submit_bh(WRITE_SYNC, bh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000478
479 bh = gfs2_log_get_buf(sdp);
480 mh = (struct gfs2_meta_header *)bh->b_data;
481 mh->mh_magic = cpu_to_be32(GFS2_MAGIC);
Steven Whitehousee3167de2006-03-30 15:46:23 -0500482 mh->mh_type = cpu_to_be32(GFS2_METATYPE_LB);
483 mh->mh_format = cpu_to_be32(GFS2_FORMAT_LB);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000484 offset = sizeof(struct gfs2_meta_header);
485 }
486
Steven Whitehouse82e86082007-09-02 15:39:43 +0100487 *(__be64 *)(bh->b_data + offset) = cpu_to_be64(bd->bd_blkno);
Steven Whitehousecd915492006-09-04 12:49:07 -0400488 offset += sizeof(u64);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000489 }
490 gfs2_assert_withdraw(sdp, !sdp->sd_log_num_revoke);
491
Jens Axboe721a9602011-03-09 11:56:30 +0100492 submit_bh(WRITE_SYNC, bh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000493}
494
Steven Whitehousef42ab082011-04-14 16:50:31 +0100495static void revoke_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
496{
497 struct list_head *head = &sdp->sd_log_le_revoke;
498 struct gfs2_bufdata *bd;
499 struct gfs2_glock *gl;
500
501 while (!list_empty(head)) {
502 bd = list_entry(head->next, struct gfs2_bufdata, bd_le.le_list);
503 list_del_init(&bd->bd_le.le_list);
504 gl = bd->bd_gl;
505 atomic_dec(&gl->gl_revokes);
506 clear_bit(GLF_LFLUSH, &gl->gl_flags);
507 kmem_cache_free(gfs2_bufdata_cachep, bd);
508 }
509}
510
David Teiglandb3b94fa2006-01-16 16:50:04 +0000511static void revoke_lo_before_scan(struct gfs2_jdesc *jd,
Al Viro55167622006-10-13 21:47:13 -0400512 struct gfs2_log_header_host *head, int pass)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000513{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400514 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000515
516 if (pass != 0)
517 return;
518
519 sdp->sd_found_revokes = 0;
520 sdp->sd_replay_tail = head->lh_tail;
521}
522
523static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
524 struct gfs2_log_descriptor *ld, __be64 *ptr,
525 int pass)
526{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400527 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000528 unsigned int blks = be32_to_cpu(ld->ld_length);
529 unsigned int revokes = be32_to_cpu(ld->ld_data1);
530 struct buffer_head *bh;
531 unsigned int offset;
Steven Whitehousecd915492006-09-04 12:49:07 -0400532 u64 blkno;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000533 int first = 1;
534 int error;
535
536 if (pass != 0 || be32_to_cpu(ld->ld_type) != GFS2_LOG_DESC_REVOKE)
537 return 0;
538
539 offset = sizeof(struct gfs2_log_descriptor);
540
541 for (; blks; gfs2_replay_incr_blk(sdp, &start), blks--) {
542 error = gfs2_replay_read_block(jd, start, &bh);
543 if (error)
544 return error;
545
546 if (!first)
547 gfs2_metatype_check(sdp, bh, GFS2_METATYPE_LB);
548
Steven Whitehousecd915492006-09-04 12:49:07 -0400549 while (offset + sizeof(u64) <= sdp->sd_sb.sb_bsize) {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000550 blkno = be64_to_cpu(*(__be64 *)(bh->b_data + offset));
551
552 error = gfs2_revoke_add(sdp, blkno, start);
Bob Peterson3ad62e82008-01-28 16:35:13 -0600553 if (error < 0) {
554 brelse(bh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000555 return error;
Bob Peterson3ad62e82008-01-28 16:35:13 -0600556 }
David Teiglandb3b94fa2006-01-16 16:50:04 +0000557 else if (error)
558 sdp->sd_found_revokes++;
559
560 if (!--revokes)
561 break;
Steven Whitehousecd915492006-09-04 12:49:07 -0400562 offset += sizeof(u64);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000563 }
564
565 brelse(bh);
566 offset = sizeof(struct gfs2_meta_header);
567 first = 0;
568 }
569
570 return 0;
571}
572
573static void revoke_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
574{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400575 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000576
577 if (error) {
578 gfs2_revoke_clean(sdp);
579 return;
580 }
581 if (pass != 1)
582 return;
583
584 fs_info(sdp, "jid=%u: Found %u revoke tags\n",
585 jd->jd_jid, sdp->sd_found_revokes);
586
587 gfs2_revoke_clean(sdp);
588}
589
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000590/**
591 * databuf_lo_add - Add a databuf to the transaction.
592 *
593 * This is used in two distinct cases:
594 * i) In ordered write mode
595 * We put the data buffer on a list so that we can ensure that its
596 * synced to disk at the right time
597 * ii) In journaled data mode
598 * We need to journal the data block in the same way as metadata in
599 * the functions above. The difference is that here we have a tag
600 * which is two __be64's being the block number (as per meta data)
601 * and a flag which says whether the data block needs escaping or
602 * not. This means we need a new log entry for each 251 or so data
603 * blocks, which isn't an enormous overhead but twice as much as
604 * for normal metadata blocks.
605 */
David Teiglandb3b94fa2006-01-16 16:50:04 +0000606static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
607{
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000608 struct gfs2_bufdata *bd = container_of(le, struct gfs2_bufdata, bd_le);
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500609 struct gfs2_trans *tr = current->journal_info;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000610 struct address_space *mapping = bd->bd_bh->b_page->mapping;
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400611 struct gfs2_inode *ip = GFS2_I(mapping->host);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000612
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100613 lock_buffer(bd->bd_bh);
Steven Whitehouse8bd95722007-01-25 10:04:20 +0000614 gfs2_log_lock(sdp);
Steven Whitehouse9ff8ec32007-09-28 13:49:05 +0100615 if (tr) {
616 if (!list_empty(&bd->bd_list_tr))
617 goto out;
618 tr->tr_touched = 1;
619 if (gfs2_is_jdata(ip)) {
620 tr->tr_num_buf++;
621 list_add(&bd->bd_list_tr, &tr->tr_list_buf);
622 }
Robert Peterson773ed1a2007-06-20 08:34:06 -0500623 }
Robert Peterson2332c442007-06-18 14:50:20 -0500624 if (!list_empty(&le->le_list))
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100625 goto out;
Robert Peterson2332c442007-06-18 14:50:20 -0500626
Steven Whitehouse2bcd6102007-11-08 14:25:12 +0000627 set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
628 set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags);
Robert Peterson2332c442007-06-18 14:50:20 -0500629 if (gfs2_is_jdata(ip)) {
Robert Peterson2332c442007-06-18 14:50:20 -0500630 gfs2_pin(sdp, bd->bd_bh);
631 tr->tr_num_databuf_new++;
Steven Whitehoused7b616e2007-09-02 10:48:13 +0100632 sdp->sd_log_num_databuf++;
Dave Chinnere5884632010-02-05 16:45:25 +1100633 list_add_tail(&le->le_list, &sdp->sd_log_le_databuf);
Steven Whitehoused7b616e2007-09-02 10:48:13 +0100634 } else {
Dave Chinnere5884632010-02-05 16:45:25 +1100635 list_add_tail(&le->le_list, &sdp->sd_log_le_ordered);
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100636 }
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100637out:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000638 gfs2_log_unlock(sdp);
Steven Whitehouse9b9107a2007-08-27 13:54:05 +0100639 unlock_buffer(bd->bd_bh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000640}
641
Steven Whitehouse16615be2007-09-17 10:59:52 +0100642static void gfs2_check_magic(struct buffer_head *bh)
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000643{
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000644 void *kaddr;
645 __be32 *ptr;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000646
Steven Whitehouse16615be2007-09-17 10:59:52 +0100647 clear_buffer_escaped(bh);
648 kaddr = kmap_atomic(bh->b_page, KM_USER0);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000649 ptr = kaddr + bh_offset(bh);
650 if (*ptr == cpu_to_be32(GFS2_MAGIC))
Steven Whitehouse16615be2007-09-17 10:59:52 +0100651 set_buffer_escaped(bh);
Russell Cattelanc312c4f2006-10-12 09:23:41 -0400652 kunmap_atomic(kaddr, KM_USER0);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100653}
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000654
Steven Whitehouse16615be2007-09-17 10:59:52 +0100655static void gfs2_write_blocks(struct gfs2_sbd *sdp, struct buffer_head *bh,
656 struct list_head *list, struct list_head *done,
657 unsigned int n)
658{
659 struct buffer_head *bh1;
660 struct gfs2_log_descriptor *ld;
661 struct gfs2_bufdata *bd;
662 __be64 *ptr;
663
664 if (!bh)
665 return;
666
667 ld = bh_log_desc(bh);
668 ld->ld_length = cpu_to_be32(n + 1);
669 ld->ld_data1 = cpu_to_be32(n);
670
671 ptr = bh_log_ptr(bh);
672
673 get_bh(bh);
Jens Axboe721a9602011-03-09 11:56:30 +0100674 submit_bh(WRITE_SYNC, bh);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100675 gfs2_log_lock(sdp);
676 while(!list_empty(list)) {
677 bd = list_entry(list->next, struct gfs2_bufdata, bd_le.le_list);
678 list_move_tail(&bd->bd_le.le_list, done);
679 get_bh(bd->bd_bh);
680 while (be64_to_cpu(*ptr) != bd->bd_bh->b_blocknr) {
681 gfs2_log_incr_head(sdp);
682 ptr += 2;
683 }
684 gfs2_log_unlock(sdp);
685 lock_buffer(bd->bd_bh);
686 if (buffer_escaped(bd->bd_bh)) {
687 void *kaddr;
688 bh1 = gfs2_log_get_buf(sdp);
689 kaddr = kmap_atomic(bd->bd_bh->b_page, KM_USER0);
690 memcpy(bh1->b_data, kaddr + bh_offset(bd->bd_bh),
691 bh1->b_size);
692 kunmap_atomic(kaddr, KM_USER0);
693 *(__be32 *)bh1->b_data = 0;
694 clear_buffer_escaped(bd->bd_bh);
695 unlock_buffer(bd->bd_bh);
696 brelse(bd->bd_bh);
697 } else {
698 bh1 = gfs2_log_fake_buf(sdp, bd->bd_bh);
699 }
Jens Axboe721a9602011-03-09 11:56:30 +0100700 submit_bh(WRITE_SYNC, bh1);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100701 gfs2_log_lock(sdp);
702 ptr += 2;
703 }
704 gfs2_log_unlock(sdp);
705 brelse(bh);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000706}
707
708/**
709 * databuf_lo_before_commit - Scan the data buffers, writing as we go
710 *
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000711 */
Steven Whitehoused7b616e2007-09-02 10:48:13 +0100712
David Teiglandb3b94fa2006-01-16 16:50:04 +0000713static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
714{
Steven Whitehouse16615be2007-09-17 10:59:52 +0100715 struct gfs2_bufdata *bd = NULL;
716 struct buffer_head *bh = NULL;
717 unsigned int n = 0;
718 __be64 *ptr = NULL, *end = NULL;
719 LIST_HEAD(processed);
720 LIST_HEAD(in_progress);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000721
Steven Whitehousef55ab262006-02-21 12:51:39 +0000722 gfs2_log_lock(sdp);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100723 while (!list_empty(&sdp->sd_log_le_databuf)) {
724 if (ptr == end) {
Steven Whitehousef55ab262006-02-21 12:51:39 +0000725 gfs2_log_unlock(sdp);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100726 gfs2_write_blocks(sdp, bh, &in_progress, &processed, n);
727 n = 0;
728 bh = gfs2_get_log_desc(sdp, GFS2_LOG_DESC_JDATA);
729 ptr = bh_log_ptr(bh);
730 end = bh_ptr_end(bh) - 1;
Steven Whitehousef55ab262006-02-21 12:51:39 +0000731 gfs2_log_lock(sdp);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100732 continue;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000733 }
Steven Whitehouse16615be2007-09-17 10:59:52 +0100734 bd = list_entry(sdp->sd_log_le_databuf.next, struct gfs2_bufdata, bd_le.le_list);
735 list_move_tail(&bd->bd_le.le_list, &in_progress);
736 gfs2_check_magic(bd->bd_bh);
737 *ptr++ = cpu_to_be64(bd->bd_bh->b_blocknr);
738 *ptr++ = cpu_to_be64(buffer_escaped(bh) ? 1 : 0);
739 n++;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000740 }
Steven Whitehousef55ab262006-02-21 12:51:39 +0000741 gfs2_log_unlock(sdp);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100742 gfs2_write_blocks(sdp, bh, &in_progress, &processed, n);
743 gfs2_log_lock(sdp);
744 list_splice(&processed, &sdp->sd_log_le_databuf);
745 gfs2_log_unlock(sdp);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000746}
747
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000748static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
749 struct gfs2_log_descriptor *ld,
750 __be64 *ptr, int pass)
751{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400752 struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
753 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500754 struct gfs2_glock *gl = ip->i_gl;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000755 unsigned int blks = be32_to_cpu(ld->ld_data1);
756 struct buffer_head *bh_log, *bh_ip;
Steven Whitehousecd915492006-09-04 12:49:07 -0400757 u64 blkno;
758 u64 esc;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000759 int error = 0;
760
761 if (pass != 1 || be32_to_cpu(ld->ld_type) != GFS2_LOG_DESC_JDATA)
762 return 0;
763
764 gfs2_replay_incr_blk(sdp, &start);
765 for (; blks; gfs2_replay_incr_blk(sdp, &start), blks--) {
766 blkno = be64_to_cpu(*ptr++);
767 esc = be64_to_cpu(*ptr++);
768
769 sdp->sd_found_blocks++;
770
771 if (gfs2_revoke_check(sdp, blkno, start))
772 continue;
773
774 error = gfs2_replay_read_block(jd, start, &bh_log);
775 if (error)
776 return error;
777
778 bh_ip = gfs2_meta_new(gl, blkno);
779 memcpy(bh_ip->b_data, bh_log->b_data, bh_log->b_size);
780
781 /* Unescape */
782 if (esc) {
783 __be32 *eptr = (__be32 *)bh_ip->b_data;
784 *eptr = cpu_to_be32(GFS2_MAGIC);
785 }
786 mark_buffer_dirty(bh_ip);
787
788 brelse(bh_log);
789 brelse(bh_ip);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000790
791 sdp->sd_replayed_blocks++;
792 }
793
794 return error;
795}
796
797/* FIXME: sort out accounting for log blocks etc. */
798
799static void databuf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
800{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400801 struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
802 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000803
804 if (error) {
Steven Whitehouse7276b3b2006-09-21 17:05:23 -0400805 gfs2_meta_sync(ip->i_gl);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000806 return;
807 }
808 if (pass != 1)
809 return;
810
811 /* data sync? */
Steven Whitehouse7276b3b2006-09-21 17:05:23 -0400812 gfs2_meta_sync(ip->i_gl);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000813
814 fs_info(sdp, "jid=%u: Replayed %u of %u data blocks\n",
815 jd->jd_jid, sdp->sd_replayed_blocks, sdp->sd_found_blocks);
816}
817
818static void databuf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
819{
820 struct list_head *head = &sdp->sd_log_le_databuf;
821 struct gfs2_bufdata *bd;
822
823 while (!list_empty(head)) {
824 bd = list_entry(head->next, struct gfs2_bufdata, bd_le.le_list);
Steven Whitehouseb8e1aab2006-08-22 16:25:50 -0400825 list_del_init(&bd->bd_le.le_list);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000826 sdp->sd_log_num_databuf--;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000827 gfs2_unpin(sdp, bd->bd_bh, ai);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000828 }
829 gfs2_assert_warn(sdp, !sdp->sd_log_num_databuf);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000830}
831
832
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400833const struct gfs2_log_operations gfs2_buf_lops = {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000834 .lo_add = buf_lo_add,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000835 .lo_before_commit = buf_lo_before_commit,
836 .lo_after_commit = buf_lo_after_commit,
837 .lo_before_scan = buf_lo_before_scan,
838 .lo_scan_elements = buf_lo_scan_elements,
839 .lo_after_scan = buf_lo_after_scan,
Steven Whitehouseea67eed2006-09-05 10:53:09 -0400840 .lo_name = "buf",
David Teiglandb3b94fa2006-01-16 16:50:04 +0000841};
842
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400843const struct gfs2_log_operations gfs2_revoke_lops = {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000844 .lo_add = revoke_lo_add,
845 .lo_before_commit = revoke_lo_before_commit,
Steven Whitehousef42ab082011-04-14 16:50:31 +0100846 .lo_after_commit = revoke_lo_after_commit,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000847 .lo_before_scan = revoke_lo_before_scan,
848 .lo_scan_elements = revoke_lo_scan_elements,
849 .lo_after_scan = revoke_lo_after_scan,
Steven Whitehouseea67eed2006-09-05 10:53:09 -0400850 .lo_name = "revoke",
David Teiglandb3b94fa2006-01-16 16:50:04 +0000851};
852
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400853const struct gfs2_log_operations gfs2_rg_lops = {
Steven Whitehouseea67eed2006-09-05 10:53:09 -0400854 .lo_name = "rg",
David Teiglandb3b94fa2006-01-16 16:50:04 +0000855};
856
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400857const struct gfs2_log_operations gfs2_databuf_lops = {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000858 .lo_add = databuf_lo_add,
859 .lo_before_commit = databuf_lo_before_commit,
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000860 .lo_after_commit = databuf_lo_after_commit,
861 .lo_scan_elements = databuf_lo_scan_elements,
862 .lo_after_scan = databuf_lo_after_scan,
Steven Whitehouseea67eed2006-09-05 10:53:09 -0400863 .lo_name = "databuf",
David Teiglandb3b94fa2006-01-16 16:50:04 +0000864};
865
Steven Whitehouseb09e5932006-04-07 11:17:32 -0400866const struct gfs2_log_operations *gfs2_log_ops[] = {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000867 &gfs2_databuf_lops,
Steven Whitehouse16615be2007-09-17 10:59:52 +0100868 &gfs2_buf_lops,
869 &gfs2_rg_lops,
870 &gfs2_revoke_lops,
Steven Whitehouseea67eed2006-09-05 10:53:09 -0400871 NULL,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000872};
873