aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2
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
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')
-rw-r--r--fs/gfs2/incore.h1
-rw-r--r--fs/gfs2/lops.c68
-rw-r--r--fs/gfs2/lops.h7
-rw-r--r--fs/gfs2/trans.c92
4 files changed, 84 insertions, 84 deletions
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index c373a24fedd9..5d129ab89733 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -52,7 +52,6 @@ struct gfs2_log_header_host {
52 */ 52 */
53 53
54struct gfs2_log_operations { 54struct gfs2_log_operations {
55 void (*lo_add) (struct gfs2_sbd *sdp, struct gfs2_bufdata *bd);
56 void (*lo_before_commit) (struct gfs2_sbd *sdp); 55 void (*lo_before_commit) (struct gfs2_sbd *sdp);
57 void (*lo_after_commit) (struct gfs2_sbd *sdp, struct gfs2_ail *ai); 56 void (*lo_after_commit) (struct gfs2_sbd *sdp, struct gfs2_ail *ai);
58 void (*lo_before_scan) (struct gfs2_jdesc *jd, 57 void (*lo_before_scan) (struct gfs2_jdesc *jd,
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index 9c8074223461..a5055977a214 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -37,7 +37,7 @@
37 * 37 *
38 * The log lock must be held when calling this function 38 * The log lock must be held when calling this function
39 */ 39 */
40static void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh) 40void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh)
41{ 41{
42 struct gfs2_bufdata *bd; 42 struct gfs2_bufdata *bd;
43 43
@@ -388,32 +388,6 @@ static struct page *gfs2_get_log_desc(struct gfs2_sbd *sdp, u32 ld_type,
388 return page; 388 return page;
389} 389}
390 390
391static void buf_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
392{
393 struct gfs2_meta_header *mh;
394 struct gfs2_trans *tr;
395
396 tr = current->journal_info;
397 tr->tr_touched = 1;
398 if (!list_empty(&bd->bd_list))
399 return;
400 set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
401 set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags);
402 mh = (struct gfs2_meta_header *)bd->bd_bh->b_data;
403 if (unlikely(mh->mh_magic != cpu_to_be32(GFS2_MAGIC))) {
404 printk(KERN_ERR
405 "Attempting to add uninitialised block to journal (inplace block=%lld)\n",
406 (unsigned long long)bd->bd_bh->b_blocknr);
407 BUG();
408 }
409 gfs2_pin(sdp, bd->bd_bh);
410 mh->__pad0 = cpu_to_be64(0);
411 mh->mh_jid = cpu_to_be32(sdp->sd_jdesc->jd_jid);
412 sdp->sd_log_num_buf++;
413 list_add(&bd->bd_list, &sdp->sd_log_le_buf);
414 tr->tr_num_buf_new++;
415}
416
417static void gfs2_check_magic(struct buffer_head *bh) 391static void gfs2_check_magic(struct buffer_head *bh)
418{ 392{
419 void *kaddr; 393 void *kaddr;
@@ -735,44 +709,6 @@ static void revoke_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
735} 709}
736 710
737/** 711/**
738 * databuf_lo_add - Add a databuf to the transaction.
739 *
740 * This is used in two distinct cases:
741 * i) In ordered write mode
742 * We put the data buffer on a list so that we can ensure that its
743 * synced to disk at the right time
744 * ii) In journaled data mode
745 * We need to journal the data block in the same way as metadata in
746 * the functions above. The difference is that here we have a tag
747 * which is two __be64's being the block number (as per meta data)
748 * and a flag which says whether the data block needs escaping or
749 * not. This means we need a new log entry for each 251 or so data
750 * blocks, which isn't an enormous overhead but twice as much as
751 * for normal metadata blocks.
752 */
753static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
754{
755 struct gfs2_trans *tr = current->journal_info;
756 struct address_space *mapping = bd->bd_bh->b_page->mapping;
757 struct gfs2_inode *ip = GFS2_I(mapping->host);
758
759 if (tr)
760 tr->tr_touched = 1;
761 if (!list_empty(&bd->bd_list))
762 return;
763 set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
764 set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags);
765 if (gfs2_is_jdata(ip)) {
766 gfs2_pin(sdp, bd->bd_bh);
767 tr->tr_num_databuf_new++;
768 sdp->sd_log_num_databuf++;
769 list_add_tail(&bd->bd_list, &sdp->sd_log_le_databuf);
770 } else {
771 list_add_tail(&bd->bd_list, &sdp->sd_log_le_ordered);
772 }
773}
774
775/**
776 * databuf_lo_before_commit - Scan the data buffers, writing as we go 712 * databuf_lo_before_commit - Scan the data buffers, writing as we go
777 * 713 *
778 */ 714 */
@@ -871,7 +807,6 @@ static void databuf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
871 807
872 808
873const struct gfs2_log_operations gfs2_buf_lops = { 809const struct gfs2_log_operations gfs2_buf_lops = {
874 .lo_add = buf_lo_add,
875 .lo_before_commit = buf_lo_before_commit, 810 .lo_before_commit = buf_lo_before_commit,
876 .lo_after_commit = buf_lo_after_commit, 811 .lo_after_commit = buf_lo_after_commit,
877 .lo_before_scan = buf_lo_before_scan, 812 .lo_before_scan = buf_lo_before_scan,
@@ -894,7 +829,6 @@ const struct gfs2_log_operations gfs2_rg_lops = {
894}; 829};
895 830
896const struct gfs2_log_operations gfs2_databuf_lops = { 831const struct gfs2_log_operations gfs2_databuf_lops = {
897 .lo_add = databuf_lo_add,
898 .lo_before_commit = databuf_lo_before_commit, 832 .lo_before_commit = databuf_lo_before_commit,
899 .lo_after_commit = databuf_lo_after_commit, 833 .lo_after_commit = databuf_lo_after_commit,
900 .lo_scan_elements = databuf_lo_scan_elements, 834 .lo_scan_elements = databuf_lo_scan_elements,
diff --git a/fs/gfs2/lops.h b/fs/gfs2/lops.h
index 954a330585f4..d85b3767ee08 100644
--- a/fs/gfs2/lops.h
+++ b/fs/gfs2/lops.h
@@ -29,6 +29,7 @@ extern const struct gfs2_log_operations gfs2_databuf_lops;
29extern const struct gfs2_log_operations *gfs2_log_ops[]; 29extern const struct gfs2_log_operations *gfs2_log_ops[];
30extern void gfs2_log_write_page(struct gfs2_sbd *sdp, struct page *page); 30extern void gfs2_log_write_page(struct gfs2_sbd *sdp, struct page *page);
31extern void gfs2_log_flush_bio(struct gfs2_sbd *sdp, int rw); 31extern void gfs2_log_flush_bio(struct gfs2_sbd *sdp, int rw);
32extern void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh);
32 33
33static inline unsigned int buf_limit(struct gfs2_sbd *sdp) 34static inline unsigned int buf_limit(struct gfs2_sbd *sdp)
34{ 35{
@@ -53,12 +54,6 @@ static inline void lops_init_le(struct gfs2_bufdata *bd,
53 bd->bd_ops = lops; 54 bd->bd_ops = lops;
54} 55}
55 56
56static inline void lops_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
57{
58 if (bd->bd_ops->lo_add)
59 bd->bd_ops->lo_add(sdp, bd);
60}
61
62static inline void lops_before_commit(struct gfs2_sbd *sdp) 57static inline void lops_before_commit(struct gfs2_sbd *sdp)
63{ 58{
64 int x; 59 int x;
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)