Skip to content

Commit cb94eb0

Browse files
JoePerchesswhiteho
authored andcommitted
GFS2: Convert gfs2_lm_withdraw to use fs_err
vprintk use is not prefixed by a KERN_<LEVEL>, so emit these messages at KERN_ERR level. Using %pV can save some code and allow fs_err to be used, so do it. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
1 parent 8382e26 commit cb94eb0

3 files changed

Lines changed: 46 additions & 50 deletions

File tree

‎fs/gfs2/sys.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,8 @@ static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
140140
if (simple_strtol(buf, NULL, 0) != 1)
141141
return -EINVAL;
142142

143-
gfs2_lm_withdraw(sdp,
144-
"GFS2: fsid=%s: withdrawing from cluster at user's request\n",
145-
sdp->sd_fsname);
143+
gfs2_lm_withdraw(sdp, "withdrawing from cluster at user's request\n");
144+
146145
return len;
147146
}
148147

‎fs/gfs2/util.c‎

Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,24 @@ void gfs2_assert_i(struct gfs2_sbd *sdp)
3535
fs_emerg(sdp, "fatal assertion failed\n");
3636
}
3737

38-
int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...)
38+
int gfs2_lm_withdraw(struct gfs2_sbd *sdp, const char *fmt, ...)
3939
{
4040
struct lm_lockstruct *ls = &sdp->sd_lockstruct;
4141
const struct lm_lockops *lm = ls->ls_ops;
4242
va_list args;
43+
struct va_format vaf;
4344

4445
if (sdp->sd_args.ar_errors == GFS2_ERRORS_WITHDRAW &&
4546
test_and_set_bit(SDF_SHUTDOWN, &sdp->sd_flags))
4647
return 0;
4748

4849
va_start(args, fmt);
49-
vprintk(fmt, args);
50+
51+
vaf.fmt = fmt;
52+
vaf.va = &args;
53+
54+
fs_err(sdp, "%pV", &vaf);
55+
5056
va_end(args);
5157

5258
if (sdp->sd_args.ar_errors == GFS2_ERRORS_WITHDRAW) {
@@ -83,10 +89,9 @@ int gfs2_assert_withdraw_i(struct gfs2_sbd *sdp, char *assertion,
8389
{
8490
int me;
8591
me = gfs2_lm_withdraw(sdp,
86-
"GFS2: fsid=%s: fatal: assertion \"%s\" failed\n"
87-
"GFS2: fsid=%s: function = %s, file = %s, line = %u\n",
88-
sdp->sd_fsname, assertion,
89-
sdp->sd_fsname, function, file, line);
92+
"fatal: assertion \"%s\" failed\n"
93+
" function = %s, file = %s, line = %u\n",
94+
assertion, function, file, line);
9095
dump_stack();
9196
return (me) ? -1 : -2;
9297
}
@@ -136,10 +141,8 @@ int gfs2_consist_i(struct gfs2_sbd *sdp, int cluster_wide, const char *function,
136141
{
137142
int rv;
138143
rv = gfs2_lm_withdraw(sdp,
139-
"GFS2: fsid=%s: fatal: filesystem consistency error\n"
140-
"GFS2: fsid=%s: function = %s, file = %s, line = %u\n",
141-
sdp->sd_fsname,
142-
sdp->sd_fsname, function, file, line);
144+
"fatal: filesystem consistency error - function = %s, file = %s, line = %u\n",
145+
function, file, line);
143146
return rv;
144147
}
145148

@@ -155,13 +158,12 @@ int gfs2_consist_inode_i(struct gfs2_inode *ip, int cluster_wide,
155158
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
156159
int rv;
157160
rv = gfs2_lm_withdraw(sdp,
158-
"GFS2: fsid=%s: fatal: filesystem consistency error\n"
159-
"GFS2: fsid=%s: inode = %llu %llu\n"
160-
"GFS2: fsid=%s: function = %s, file = %s, line = %u\n",
161-
sdp->sd_fsname,
162-
sdp->sd_fsname, (unsigned long long)ip->i_no_formal_ino,
163-
(unsigned long long)ip->i_no_addr,
164-
sdp->sd_fsname, function, file, line);
161+
"fatal: filesystem consistency error\n"
162+
" inode = %llu %llu\n"
163+
" function = %s, file = %s, line = %u\n",
164+
(unsigned long long)ip->i_no_formal_ino,
165+
(unsigned long long)ip->i_no_addr,
166+
function, file, line);
165167
return rv;
166168
}
167169

@@ -177,12 +179,11 @@ int gfs2_consist_rgrpd_i(struct gfs2_rgrpd *rgd, int cluster_wide,
177179
struct gfs2_sbd *sdp = rgd->rd_sbd;
178180
int rv;
179181
rv = gfs2_lm_withdraw(sdp,
180-
"GFS2: fsid=%s: fatal: filesystem consistency error\n"
181-
"GFS2: fsid=%s: RG = %llu\n"
182-
"GFS2: fsid=%s: function = %s, file = %s, line = %u\n",
183-
sdp->sd_fsname,
184-
sdp->sd_fsname, (unsigned long long)rgd->rd_addr,
185-
sdp->sd_fsname, function, file, line);
182+
"fatal: filesystem consistency error\n"
183+
" RG = %llu\n"
184+
" function = %s, file = %s, line = %u\n",
185+
(unsigned long long)rgd->rd_addr,
186+
function, file, line);
186187
return rv;
187188
}
188189

@@ -198,12 +199,11 @@ int gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
198199
{
199200
int me;
200201
me = gfs2_lm_withdraw(sdp,
201-
"GFS2: fsid=%s: fatal: invalid metadata block\n"
202-
"GFS2: fsid=%s: bh = %llu (%s)\n"
203-
"GFS2: fsid=%s: function = %s, file = %s, line = %u\n",
204-
sdp->sd_fsname,
205-
sdp->sd_fsname, (unsigned long long)bh->b_blocknr, type,
206-
sdp->sd_fsname, function, file, line);
202+
"fatal: invalid metadata block\n"
203+
" bh = %llu (%s)\n"
204+
" function = %s, file = %s, line = %u\n",
205+
(unsigned long long)bh->b_blocknr, type,
206+
function, file, line);
207207
return (me) ? -1 : -2;
208208
}
209209

@@ -219,12 +219,11 @@ int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
219219
{
220220
int me;
221221
me = gfs2_lm_withdraw(sdp,
222-
"GFS2: fsid=%s: fatal: invalid metadata block\n"
223-
"GFS2: fsid=%s: bh = %llu (type: exp=%u, found=%u)\n"
224-
"GFS2: fsid=%s: function = %s, file = %s, line = %u\n",
225-
sdp->sd_fsname,
226-
sdp->sd_fsname, (unsigned long long)bh->b_blocknr, type, t,
227-
sdp->sd_fsname, function, file, line);
222+
"fatal: invalid metadata block\n"
223+
" bh = %llu (type: exp=%u, found=%u)\n"
224+
" function = %s, file = %s, line = %u\n",
225+
(unsigned long long)bh->b_blocknr, type, t,
226+
function, file, line);
228227
return (me) ? -1 : -2;
229228
}
230229

@@ -239,10 +238,9 @@ int gfs2_io_error_i(struct gfs2_sbd *sdp, const char *function, char *file,
239238
{
240239
int rv;
241240
rv = gfs2_lm_withdraw(sdp,
242-
"GFS2: fsid=%s: fatal: I/O error\n"
243-
"GFS2: fsid=%s: function = %s, file = %s, line = %u\n",
244-
sdp->sd_fsname,
245-
sdp->sd_fsname, function, file, line);
241+
"fatal: I/O error\n"
242+
" function = %s, file = %s, line = %u\n",
243+
function, file, line);
246244
return rv;
247245
}
248246

@@ -257,12 +255,11 @@ int gfs2_io_error_bh_i(struct gfs2_sbd *sdp, struct buffer_head *bh,
257255
{
258256
int rv;
259257
rv = gfs2_lm_withdraw(sdp,
260-
"GFS2: fsid=%s: fatal: I/O error\n"
261-
"GFS2: fsid=%s: block = %llu\n"
262-
"GFS2: fsid=%s: function = %s, file = %s, line = %u\n",
263-
sdp->sd_fsname,
264-
sdp->sd_fsname, (unsigned long long)bh->b_blocknr,
265-
sdp->sd_fsname, function, file, line);
258+
"fatal: I/O error\n"
259+
" block = %llu\n"
260+
" function = %s, file = %s, line = %u\n",
261+
(unsigned long long)bh->b_blocknr,
262+
function, file, line);
266263
return rv;
267264
}
268265

‎fs/gfs2/util.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static inline unsigned int gfs2_tune_get_i(struct gfs2_tune *gt,
165165
#define gfs2_tune_get(sdp, field) \
166166
gfs2_tune_get_i(&(sdp)->sd_tune, &(sdp)->sd_tune.field)
167167

168-
int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...);
168+
__printf(2, 3)
169+
int gfs2_lm_withdraw(struct gfs2_sbd *sdp, const char *fmt, ...);
169170

170171
#endif /* __UTIL_DOT_H__ */
171-

0 commit comments

Comments
 (0)