aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/trans.c
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2012-12-14 07:52:14 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2013-01-29 05:28:28 -0500
commit767f433f346959d6a09b85478eb5db133ab25c6f (patch)
tree876056d7569fcd96fbf8b08163abc00ef0878c66 /fs/gfs2/trans.c
parent350a9b0a7269c6f4b99eca34d0e773c3c2072520 (diff)
GFS2: Copy gfs2_trans_add_bh into new data/meta functions
This patch copies the body of gfs2_trans_add_bh into the two newly added gfs2_trans_add_data and gfs2_trans_add_meta functions. We can then move the .lo_add functions from lops.c into trans.c and call them directly. As a result of this, we no longer need to use the .lo_add functions at all, so that is removed from the log operations structure. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/trans.c')
-rw-r--r--fs/gfs2/trans.c92
1 files changed, 82 insertions, 10 deletions
diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c
index cb795ac754ea..1fbd57eafa48 100644
--- a/fs/gfs2/trans.c
+++ b/fs/gfs2/trans.c
@@ -18,6 +18,7 @@
18#include "gfs2.h" 18#include "gfs2.h"
19#include "incore.h" 19#include "incore.h"
20#include "glock.h" 20#include "glock.h"
21#include "inode.h"
21#include "log.h" 22#include "log.h"
22#include "lops.h" 23#include "lops.h"
23#include "meta_io.h" 24#include "meta_io.h"
@@ -143,15 +144,46 @@ void gfs2_trans_end(struct gfs2_sbd *sdp)
143} 144}
144 145
145/** 146/**
146 * gfs2_trans_add_bh - Add a to-be-modified buffer to the current transaction 147 * databuf_lo_add - Add a databuf to the transaction.
147 * @gl: the glock the buffer belongs to
148 * @bh: The buffer to add
149 * @meta: True in the case of adding metadata
150 * 148 *
149 * This is used in two distinct cases:
150 * i) In ordered write mode
151 * We put the data buffer on a list so that we can ensure that its
152 * synced to disk at the right time
153 * ii) In journaled data mode
154 * We need to journal the data block in the same way as metadata in
155 * the functions above. The difference is that here we have a tag
156 * which is two __be64's being the block number (as per meta data)
157 * and a flag which says whether the data block needs escaping or
158 * not. This means we need a new log entry for each 251 or so data
159 * blocks, which isn't an enormous overhead but twice as much as
160 * for normal metadata blocks.
151 */ 161 */
162static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
163{
164 struct gfs2_trans *tr = current->journal_info;
165 struct address_space *mapping = bd->bd_bh->b_page->mapping;
166 struct gfs2_inode *ip = GFS2_I(mapping->host);
167
168 if (tr)
169 tr->tr_touched = 1;
170 if (!list_empty(&bd->bd_list))
171 return;
172 set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
173 set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags);
174 if (gfs2_is_jdata(ip)) {
175 gfs2_pin(sdp, bd->bd_bh);
176 tr->tr_num_databuf_new++;
177 sdp->sd_log_num_databuf++;
178 list_add_tail(&bd->bd_list, &sdp->sd_log_le_databuf);
179 } else {
180 list_add_tail(&bd->bd_list, &sdp->sd_log_le_ordered);
181 }
182}
152 183
153static void gfs2_trans_add_bh(struct gfs2_glock *gl, struct buffer_head *bh, int meta) 184void gfs2_trans_add_data(struct gfs2_glock *gl, struct buffer_head *bh)
154{ 185{
186
155 struct gfs2_sbd *sdp = gl->gl_sbd; 187 struct gfs2_sbd *sdp = gl->gl_sbd;
156 struct gfs2_bufdata *bd; 188 struct gfs2_bufdata *bd;
157 189
@@ -163,24 +195,64 @@ static void gfs2_trans_add_bh(struct gfs2_glock *gl, struct buffer_head *bh, int
163 else { 195 else {
164 gfs2_log_unlock(sdp); 196 gfs2_log_unlock(sdp);
165 unlock_buffer(bh); 197 unlock_buffer(bh);
166 gfs2_attach_bufdata(gl, bh, meta); 198 gfs2_attach_bufdata(gl, bh, 0);
167 bd = bh->b_private; 199 bd = bh->b_private;
168 lock_buffer(bh); 200 lock_buffer(bh);
169 gfs2_log_lock(sdp); 201 gfs2_log_lock(sdp);
170 } 202 }
171 lops_add(sdp, bd); 203 databuf_lo_add(sdp, bd);
172 gfs2_log_unlock(sdp); 204 gfs2_log_unlock(sdp);
173 unlock_buffer(bh); 205 unlock_buffer(bh);
174} 206}
175 207
176void gfs2_trans_add_data(struct gfs2_glock *gl, struct buffer_head *bh) 208static void meta_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
177{ 209{
178 return gfs2_trans_add_bh(gl, bh, 0); 210 struct gfs2_meta_header *mh;
211 struct gfs2_trans *tr;
212
213 tr = current->journal_info;
214 tr->tr_touched = 1;
215 if (!list_empty(&bd->bd_list))
216 return;
217 set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
218 set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags);
219 mh = (struct gfs2_meta_header *)bd->bd_bh->b_data;
220 if (unlikely(mh->mh_magic != cpu_to_be32(GFS2_MAGIC))) {
221 printk(KERN_ERR
222 "Attempting to add uninitialised block to journal (inplace block=%lld)\n",
223 (unsigned long long)bd->bd_bh->b_blocknr);
224 BUG();
225 }
226 gfs2_pin(sdp, bd->bd_bh);
227 mh->__pad0 = cpu_to_be64(0);
228 mh->mh_jid = cpu_to_be32(sdp->sd_jdesc->jd_jid);
229 sdp->sd_log_num_buf++;
230 list_add(&bd->bd_list, &sdp->sd_log_le_buf);
231 tr->tr_num_buf_new++;
179} 232}
180 233
181void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh) 234void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh)
182{ 235{
183 return gfs2_trans_add_bh(gl, bh, 1); 236
237 struct gfs2_sbd *sdp = gl->gl_sbd;
238 struct gfs2_bufdata *bd;
239
240 lock_buffer(bh);
241 gfs2_log_lock(sdp);
242 bd = bh->b_private;
243 if (bd)
244 gfs2_assert(sdp, bd->bd_gl == gl);
245 else {
246 gfs2_log_unlock(sdp);
247 unlock_buffer(bh);
248 gfs2_attach_bufdata(gl, bh, 1);
249 bd = bh->b_private;
250 lock_buffer(bh);
251 gfs2_log_lock(sdp);
252 }
253 meta_lo_add(sdp, bd);
254 gfs2_log_unlock(sdp);
255 unlock_buffer(bh);
184} 256}
185 257
186void gfs2_trans_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd) 258void gfs2_trans_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)