aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2012-10-15 05:57:02 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2012-11-07 08:31:07 -0500
commit8eae1ca0034cce78a24738087a32adb1ddb66aa7 (patch)
treef43287fa4232a5fdcf78eb74a004ec986c261807 /fs/gfs2
parent0e4a43ed08e2f44aa7b96aa95d0a540d675483e1 (diff)
GFS2: Review bug traps in glops.c
Two of the bug traps here could really be warnings. The others are converted from BUG() to GLOCK_BUG_ON() since we'll most likely need to know the glock state in order to debug any issues which arise. As a result of this, __dump_glock has to be renamed and is no longer static. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/glock.c10
-rw-r--r--fs/gfs2/glock.h54
-rw-r--r--fs/gfs2/glops.c10
3 files changed, 36 insertions, 38 deletions
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index e6c2fd53cab2..e543871ec82f 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -55,8 +55,6 @@ struct gfs2_glock_iter {
55 55
56typedef void (*glock_examiner) (struct gfs2_glock * gl); 56typedef void (*glock_examiner) (struct gfs2_glock * gl);
57 57
58static int __dump_glock(struct seq_file *seq, const struct gfs2_glock *gl);
59#define GLOCK_BUG_ON(gl,x) do { if (unlikely(x)) { __dump_glock(NULL, gl); BUG(); } } while(0)
60static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int target); 58static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int target);
61 59
62static struct dentry *gfs2_root; 60static struct dentry *gfs2_root;
@@ -1013,7 +1011,7 @@ trap_recursive:
1013 printk(KERN_ERR "pid: %d\n", pid_nr(gh->gh_owner_pid)); 1011 printk(KERN_ERR "pid: %d\n", pid_nr(gh->gh_owner_pid));
1014 printk(KERN_ERR "lock type: %d req lock state : %d\n", 1012 printk(KERN_ERR "lock type: %d req lock state : %d\n",
1015 gh->gh_gl->gl_name.ln_type, gh->gh_state); 1013 gh->gh_gl->gl_name.ln_type, gh->gh_state);
1016 __dump_glock(NULL, gl); 1014 gfs2_dump_glock(NULL, gl);
1017 BUG(); 1015 BUG();
1018} 1016}
1019 1017
@@ -1508,7 +1506,7 @@ static int dump_glock(struct seq_file *seq, struct gfs2_glock *gl)
1508{ 1506{
1509 int ret; 1507 int ret;
1510 spin_lock(&gl->gl_spin); 1508 spin_lock(&gl->gl_spin);
1511 ret = __dump_glock(seq, gl); 1509 ret = gfs2_dump_glock(seq, gl);
1512 spin_unlock(&gl->gl_spin); 1510 spin_unlock(&gl->gl_spin);
1513 return ret; 1511 return ret;
1514} 1512}
@@ -1655,7 +1653,7 @@ static const char *gflags2str(char *buf, const struct gfs2_glock *gl)
1655} 1653}
1656 1654
1657/** 1655/**
1658 * __dump_glock - print information about a glock 1656 * gfs2_dump_glock - print information about a glock
1659 * @seq: The seq_file struct 1657 * @seq: The seq_file struct
1660 * @gl: the glock 1658 * @gl: the glock
1661 * 1659 *
@@ -1672,7 +1670,7 @@ static const char *gflags2str(char *buf, const struct gfs2_glock *gl)
1672 * Returns: 0 on success, -ENOBUFS when we run out of space 1670 * Returns: 0 on success, -ENOBUFS when we run out of space
1673 */ 1671 */
1674 1672
1675static int __dump_glock(struct seq_file *seq, const struct gfs2_glock *gl) 1673int gfs2_dump_glock(struct seq_file *seq, const struct gfs2_glock *gl)
1676{ 1674{
1677 const struct gfs2_glock_operations *glops = gl->gl_ops; 1675 const struct gfs2_glock_operations *glops = gl->gl_ops;
1678 unsigned long long dtime; 1676 unsigned long long dtime;
diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h
index 307ac31df781..fd580b7861d5 100644
--- a/fs/gfs2/glock.h
+++ b/fs/gfs2/glock.h
@@ -178,33 +178,33 @@ static inline struct address_space *gfs2_glock2aspace(struct gfs2_glock *gl)
178 return NULL; 178 return NULL;
179} 179}
180 180
181int gfs2_glock_get(struct gfs2_sbd *sdp, 181extern int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
182 u64 number, const struct gfs2_glock_operations *glops, 182 const struct gfs2_glock_operations *glops,
183 int create, struct gfs2_glock **glp); 183 int create, struct gfs2_glock **glp);
184void gfs2_glock_hold(struct gfs2_glock *gl); 184extern void gfs2_glock_hold(struct gfs2_glock *gl);
185void gfs2_glock_put_nolock(struct gfs2_glock *gl); 185extern void gfs2_glock_put_nolock(struct gfs2_glock *gl);
186void gfs2_glock_put(struct gfs2_glock *gl); 186extern void gfs2_glock_put(struct gfs2_glock *gl);
187void gfs2_holder_init(struct gfs2_glock *gl, unsigned int state, unsigned flags, 187extern void gfs2_holder_init(struct gfs2_glock *gl, unsigned int state,
188 struct gfs2_holder *gh); 188 unsigned flags, struct gfs2_holder *gh);
189void gfs2_holder_reinit(unsigned int state, unsigned flags, 189extern void gfs2_holder_reinit(unsigned int state, unsigned flags,
190 struct gfs2_holder *gh); 190 struct gfs2_holder *gh);
191void gfs2_holder_uninit(struct gfs2_holder *gh); 191extern void gfs2_holder_uninit(struct gfs2_holder *gh);
192int gfs2_glock_nq(struct gfs2_holder *gh); 192extern int gfs2_glock_nq(struct gfs2_holder *gh);
193int gfs2_glock_poll(struct gfs2_holder *gh); 193extern int gfs2_glock_poll(struct gfs2_holder *gh);
194int gfs2_glock_wait(struct gfs2_holder *gh); 194extern int gfs2_glock_wait(struct gfs2_holder *gh);
195void gfs2_glock_dq(struct gfs2_holder *gh); 195extern void gfs2_glock_dq(struct gfs2_holder *gh);
196void gfs2_glock_dq_wait(struct gfs2_holder *gh); 196extern void gfs2_glock_dq_wait(struct gfs2_holder *gh);
197 197extern void gfs2_glock_dq_uninit(struct gfs2_holder *gh);
198void gfs2_glock_dq_uninit(struct gfs2_holder *gh); 198extern int gfs2_glock_nq_num(struct gfs2_sbd *sdp, u64 number,
199int gfs2_glock_nq_num(struct gfs2_sbd *sdp, 199 const struct gfs2_glock_operations *glops,
200 u64 number, const struct gfs2_glock_operations *glops, 200 unsigned int state, int flags,
201 unsigned int state, int flags, struct gfs2_holder *gh); 201 struct gfs2_holder *gh);
202 202extern int gfs2_glock_nq_m(unsigned int num_gh, struct gfs2_holder *ghs);
203int gfs2_glock_nq_m(unsigned int num_gh, struct gfs2_holder *ghs); 203extern void gfs2_glock_dq_m(unsigned int num_gh, struct gfs2_holder *ghs);
204void gfs2_glock_dq_m(unsigned int num_gh, struct gfs2_holder *ghs); 204extern void gfs2_glock_dq_uninit_m(unsigned int num_gh, struct gfs2_holder *ghs);
205void gfs2_glock_dq_uninit_m(unsigned int num_gh, struct gfs2_holder *ghs); 205extern int gfs2_dump_glock(struct seq_file *seq, const struct gfs2_glock *gl);
206 206#define GLOCK_BUG_ON(gl,x) do { if (unlikely(x)) { gfs2_dump_glock(NULL, gl); BUG(); } } while(0)
207__printf(2, 3) 207extern __printf(2, 3)
208void gfs2_print_dbg(struct seq_file *seq, const char *fmt, ...); 208void gfs2_print_dbg(struct seq_file *seq, const char *fmt, ...);
209 209
210/** 210/**
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index 32cc4fde975c..0a3e7c7e26c1 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -74,7 +74,7 @@ static void __gfs2_ail_flush(struct gfs2_glock *gl, bool fsync)
74 74
75 gfs2_trans_add_revoke(sdp, bd); 75 gfs2_trans_add_revoke(sdp, bd);
76 } 76 }
77 BUG_ON(!fsync && atomic_read(&gl->gl_ail_count)); 77 GLOCK_BUG_ON(gl, !fsync && atomic_read(&gl->gl_ail_count));
78 spin_unlock(&sdp->sd_ail_lock); 78 spin_unlock(&sdp->sd_ail_lock);
79 gfs2_log_unlock(sdp); 79 gfs2_log_unlock(sdp);
80} 80}
@@ -96,7 +96,7 @@ static void gfs2_ail_empty_gl(struct gfs2_glock *gl)
96 tr.tr_ip = (unsigned long)__builtin_return_address(0); 96 tr.tr_ip = (unsigned long)__builtin_return_address(0);
97 sb_start_intwrite(sdp->sd_vfs); 97 sb_start_intwrite(sdp->sd_vfs);
98 gfs2_log_reserve(sdp, tr.tr_reserved); 98 gfs2_log_reserve(sdp, tr.tr_reserved);
99 BUG_ON(current->journal_info); 99 WARN_ON_ONCE(current->journal_info);
100 current->journal_info = &tr; 100 current->journal_info = &tr;
101 101
102 __gfs2_ail_flush(gl, 0); 102 __gfs2_ail_flush(gl, 0);
@@ -139,7 +139,7 @@ static void rgrp_go_sync(struct gfs2_glock *gl)
139 139
140 if (!test_and_clear_bit(GLF_DIRTY, &gl->gl_flags)) 140 if (!test_and_clear_bit(GLF_DIRTY, &gl->gl_flags))
141 return; 141 return;
142 BUG_ON(gl->gl_state != LM_ST_EXCLUSIVE); 142 GLOCK_BUG_ON(gl, gl->gl_state != LM_ST_EXCLUSIVE);
143 143
144 gfs2_log_flush(gl->gl_sbd, gl); 144 gfs2_log_flush(gl->gl_sbd, gl);
145 filemap_fdatawrite(metamapping); 145 filemap_fdatawrite(metamapping);
@@ -168,7 +168,7 @@ static void rgrp_go_inval(struct gfs2_glock *gl, int flags)
168{ 168{
169 struct address_space *mapping = gfs2_glock2aspace(gl); 169 struct address_space *mapping = gfs2_glock2aspace(gl);
170 170
171 BUG_ON(!(flags & DIO_METADATA)); 171 WARN_ON_ONCE(!(flags & DIO_METADATA));
172 gfs2_assert_withdraw(gl->gl_sbd, !atomic_read(&gl->gl_ail_count)); 172 gfs2_assert_withdraw(gl->gl_sbd, !atomic_read(&gl->gl_ail_count));
173 truncate_inode_pages(mapping, 0); 173 truncate_inode_pages(mapping, 0);
174 174
@@ -197,7 +197,7 @@ static void inode_go_sync(struct gfs2_glock *gl)
197 if (!test_and_clear_bit(GLF_DIRTY, &gl->gl_flags)) 197 if (!test_and_clear_bit(GLF_DIRTY, &gl->gl_flags))
198 return; 198 return;
199 199
200 BUG_ON(gl->gl_state != LM_ST_EXCLUSIVE); 200 GLOCK_BUG_ON(gl, gl->gl_state != LM_ST_EXCLUSIVE);
201 201
202 gfs2_log_flush(gl->gl_sbd, gl); 202 gfs2_log_flush(gl->gl_sbd, gl);
203 filemap_fdatawrite(metamapping); 203 filemap_fdatawrite(metamapping);