Skip to content

Commit 901796a

Browse files
Christoph HellwigAlex Elder
authored andcommitted
xfs: clean up xfs_ioerror_alert
Instead of passing the block number and mount structure explicitly get them off the bp and fix make the argument order more natural. Also move it to xfs_buf.c and stop printing the device name given that we already get the fs name as part of xfs_alert, and we know what device is operates on because of the caller that gets printed, finally rename it to xfs_buf_ioerror_alert and pass __func__ as argument where it makes sense. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Alex Elder <aelder@sgi.com>
1 parent 4347b9d commit 901796a

9 files changed

Lines changed: 37 additions & 59 deletions

File tree

‎fs/xfs/xfs_buf.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,17 @@ xfs_buf_ioerror(
10041004
trace_xfs_buf_ioerror(bp, error, _RET_IP_);
10051005
}
10061006

1007+
void
1008+
xfs_buf_ioerror_alert(
1009+
struct xfs_buf *bp,
1010+
const char *func)
1011+
{
1012+
xfs_alert(bp->b_target->bt_mount,
1013+
"metadata I/O error: block 0x%llx (\"%s\") error %d buf count %zd",
1014+
(__uint64_t)XFS_BUF_ADDR(bp), func,
1015+
bp->b_error, XFS_BUF_COUNT(bp));
1016+
}
1017+
10071018
int
10081019
xfs_bwrite(
10091020
struct xfs_buf *bp)

‎fs/xfs/xfs_buf.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ extern int xfs_bdstrat_cb(struct xfs_buf *);
205205

206206
extern void xfs_buf_ioend(xfs_buf_t *, int);
207207
extern void xfs_buf_ioerror(xfs_buf_t *, int);
208+
extern void xfs_buf_ioerror_alert(struct xfs_buf *, const char *func);
208209
extern int xfs_buf_iorequest(xfs_buf_t *);
209210
extern int xfs_buf_iowait(xfs_buf_t *);
210211
extern void xfs_buf_iomove(xfs_buf_t *, size_t, size_t, void *,

‎fs/xfs/xfs_log.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ xlog_iodone(xfs_buf_t *bp)
880880
*/
881881
if (XFS_TEST_ERROR((xfs_buf_geterror(bp)), l->l_mp,
882882
XFS_ERRTAG_IODONE_IOERR, XFS_RANDOM_IODONE_IOERR)) {
883-
xfs_ioerror_alert("xlog_iodone", l->l_mp, bp, XFS_BUF_ADDR(bp));
883+
xfs_buf_ioerror_alert(bp, __func__);
884884
xfs_buf_stale(bp);
885885
xfs_force_shutdown(l->l_mp, SHUTDOWN_LOG_IO_ERROR);
886886
/*
@@ -1387,9 +1387,9 @@ xlog_sync(xlog_t *log,
13871387
*/
13881388
XFS_BUF_WRITE(bp);
13891389

1390-
if ((error = xlog_bdstrat(bp))) {
1391-
xfs_ioerror_alert("xlog_sync", log->l_mp, bp,
1392-
XFS_BUF_ADDR(bp));
1390+
error = xlog_bdstrat(bp);
1391+
if (error) {
1392+
xfs_buf_ioerror_alert(bp, "xlog_sync");
13931393
return error;
13941394
}
13951395
if (split) {
@@ -1423,9 +1423,9 @@ xlog_sync(xlog_t *log,
14231423
/* account for internal log which doesn't start at block #0 */
14241424
XFS_BUF_SET_ADDR(bp, XFS_BUF_ADDR(bp) + log->l_logBBstart);
14251425
XFS_BUF_WRITE(bp);
1426-
if ((error = xlog_bdstrat(bp))) {
1427-
xfs_ioerror_alert("xlog_sync (split)", log->l_mp,
1428-
bp, XFS_BUF_ADDR(bp));
1426+
error = xlog_bdstrat(bp);
1427+
if (error) {
1428+
xfs_buf_ioerror_alert(bp, "xlog_sync (split)");
14291429
return error;
14301430
}
14311431
}

‎fs/xfs/xfs_log_recover.c‎

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,7 @@ xlog_bread_noalign(
183183
xfsbdstrat(log->l_mp, bp);
184184
error = xfs_buf_iowait(bp);
185185
if (error)
186-
xfs_ioerror_alert("xlog_bread", log->l_mp,
187-
bp, XFS_BUF_ADDR(bp));
186+
xfs_buf_ioerror_alert(bp, __func__);
188187
return error;
189188
}
190189

@@ -269,10 +268,8 @@ xlog_bwrite(
269268
XFS_BUF_SET_COUNT(bp, BBTOB(nbblks));
270269

271270
error = xfs_bwrite(bp);
272-
if (error) {
273-
xfs_ioerror_alert("xlog_bwrite", log->l_mp,
274-
bp, XFS_BUF_ADDR(bp));
275-
}
271+
if (error)
272+
xfs_buf_ioerror_alert(bp, __func__);
276273
xfs_buf_relse(bp);
277274
return error;
278275
}
@@ -364,9 +361,7 @@ xlog_recover_iodone(
364361
* We're not going to bother about retrying
365362
* this during recovery. One strike!
366363
*/
367-
xfs_ioerror_alert("xlog_recover_iodone",
368-
bp->b_target->bt_mount, bp,
369-
XFS_BUF_ADDR(bp));
364+
xfs_buf_ioerror_alert(bp, __func__);
370365
xfs_force_shutdown(bp->b_target->bt_mount,
371366
SHUTDOWN_META_IO_ERROR);
372367
}
@@ -2138,8 +2133,7 @@ xlog_recover_buffer_pass2(
21382133
return XFS_ERROR(ENOMEM);
21392134
error = bp->b_error;
21402135
if (error) {
2141-
xfs_ioerror_alert("xlog_recover_do..(read#1)", mp,
2142-
bp, buf_f->blf_blkno);
2136+
xfs_buf_ioerror_alert(bp, "xlog_recover_do..(read#1)");
21432137
xfs_buf_relse(bp);
21442138
return error;
21452139
}
@@ -2234,8 +2228,7 @@ xlog_recover_inode_pass2(
22342228
}
22352229
error = bp->b_error;
22362230
if (error) {
2237-
xfs_ioerror_alert("xlog_recover_do..(read#2)", mp,
2238-
bp, in_f->ilf_blkno);
2231+
xfs_buf_ioerror_alert(bp, "xlog_recover_do..(read#2)");
22392232
xfs_buf_relse(bp);
22402233
goto error;
22412234
}
@@ -2542,8 +2535,7 @@ xlog_recover_dquot_pass2(
25422535
XFS_FSB_TO_BB(mp, dq_f->qlf_len),
25432536
0, &bp);
25442537
if (error) {
2545-
xfs_ioerror_alert("xlog_recover_do..(read#3)", mp,
2546-
bp, dq_f->qlf_blkno);
2538+
xfs_buf_ioerror_alert(bp, "xlog_recover_do..(read#3)");
25472539
return error;
25482540
}
25492541
ASSERT(bp);
@@ -3695,8 +3687,7 @@ xlog_do_recover(
36953687
xfsbdstrat(log->l_mp, bp);
36963688
error = xfs_buf_iowait(bp);
36973689
if (error) {
3698-
xfs_ioerror_alert("xlog_do_recover",
3699-
log->l_mp, bp, XFS_BUF_ADDR(bp));
3690+
xfs_buf_ioerror_alert(bp, __func__);
37003691
ASSERT(0);
37013692
xfs_buf_relse(bp);
37023693
return error;

‎fs/xfs/xfs_mount.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,8 +1610,7 @@ xfs_unmountfs_writesb(xfs_mount_t *mp)
16101610
xfsbdstrat(mp, sbp);
16111611
error = xfs_buf_iowait(sbp);
16121612
if (error)
1613-
xfs_ioerror_alert("xfs_unmountfs_writesb",
1614-
mp, sbp, XFS_BUF_ADDR(sbp));
1613+
xfs_buf_ioerror_alert(sbp, __func__);
16151614
xfs_buf_relse(sbp);
16161615
}
16171616
return error;

‎fs/xfs/xfs_rw.c‎

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -91,24 +91,6 @@ xfs_do_force_shutdown(
9191
}
9292
}
9393

94-
/*
95-
* Prints out an ALERT message about I/O error.
96-
*/
97-
void
98-
xfs_ioerror_alert(
99-
char *func,
100-
struct xfs_mount *mp,
101-
xfs_buf_t *bp,
102-
xfs_daddr_t blkno)
103-
{
104-
xfs_alert(mp,
105-
"I/O error occurred: meta-data dev %s block 0x%llx"
106-
" (\"%s\") error %d buf count %zd",
107-
xfs_buf_target_name(bp->b_target),
108-
(__uint64_t)blkno, func,
109-
bp->b_error, XFS_BUF_COUNT(bp));
110-
}
111-
11294
/*
11395
* This isn't an absolute requirement, but it is
11496
* just a good idea to call xfs_read_buf instead of
@@ -143,7 +125,7 @@ xfs_read_buf(
143125
} else {
144126
*bpp = NULL;
145127
if (error) {
146-
xfs_ioerror_alert("xfs_read_buf", mp, bp, XFS_BUF_ADDR(bp));
128+
xfs_buf_ioerror_alert(bp, __func__);
147129
} else {
148130
error = XFS_ERROR(EIO);
149131
}

‎fs/xfs/xfs_rw.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb)
4242
extern int xfs_read_buf(struct xfs_mount *mp, xfs_buftarg_t *btp,
4343
xfs_daddr_t blkno, int len, uint flags,
4444
struct xfs_buf **bpp);
45-
extern void xfs_ioerror_alert(char *func, struct xfs_mount *mp,
46-
xfs_buf_t *bp, xfs_daddr_t blkno);
4745
extern xfs_extlen_t xfs_get_extsz_hint(struct xfs_inode *ip);
4846

4947
#endif /* __XFS_RW_H__ */

‎fs/xfs/xfs_trans_buf.c‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,7 @@ xfs_trans_read_buf(
296296

297297
if (bp->b_error) {
298298
error = bp->b_error;
299-
xfs_ioerror_alert("xfs_trans_read_buf", mp,
300-
bp, blkno);
299+
xfs_buf_ioerror_alert(bp, __func__);
301300
xfs_buf_relse(bp);
302301
return error;
303302
}
@@ -339,8 +338,7 @@ xfs_trans_read_buf(
339338
xfsbdstrat(tp->t_mountp, bp);
340339
error = xfs_buf_iowait(bp);
341340
if (error) {
342-
xfs_ioerror_alert("xfs_trans_read_buf", mp,
343-
bp, blkno);
341+
xfs_buf_ioerror_alert(bp, __func__);
344342
xfs_buf_relse(bp);
345343
/*
346344
* We can gracefully recover from most read
@@ -391,8 +389,7 @@ xfs_trans_read_buf(
391389
error = bp->b_error;
392390
xfs_buf_stale(bp);
393391
XFS_BUF_DONE(bp);
394-
xfs_ioerror_alert("xfs_trans_read_buf", mp,
395-
bp, blkno);
392+
xfs_buf_ioerror_alert(bp, __func__);
396393
if (tp->t_flags & XFS_TRANS_DIRTY)
397394
xfs_force_shutdown(tp->t_mountp, SHUTDOWN_META_IO_ERROR);
398395
xfs_buf_relse(bp);

‎fs/xfs/xfs_vnodeops.c‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ xfs_readlink_bmap(
8787
return XFS_ERROR(ENOMEM);
8888
error = bp->b_error;
8989
if (error) {
90-
xfs_ioerror_alert("xfs_readlink",
91-
ip->i_mount, bp, XFS_BUF_ADDR(bp));
90+
xfs_buf_ioerror_alert(bp, __func__);
9291
xfs_buf_relse(bp);
9392
goto out;
9493
}
@@ -1993,8 +1992,8 @@ xfs_zero_remaining_bytes(
19931992
xfsbdstrat(mp, bp);
19941993
error = xfs_buf_iowait(bp);
19951994
if (error) {
1996-
xfs_ioerror_alert("xfs_zero_remaining_bytes(read)",
1997-
mp, bp, XFS_BUF_ADDR(bp));
1995+
xfs_buf_ioerror_alert(bp,
1996+
"xfs_zero_remaining_bytes(read)");
19981997
break;
19991998
}
20001999
memset(bp->b_addr +
@@ -2006,8 +2005,8 @@ xfs_zero_remaining_bytes(
20062005
xfsbdstrat(mp, bp);
20072006
error = xfs_buf_iowait(bp);
20082007
if (error) {
2009-
xfs_ioerror_alert("xfs_zero_remaining_bytes(write)",
2010-
mp, bp, XFS_BUF_ADDR(bp));
2008+
xfs_buf_ioerror_alert(bp,
2009+
"xfs_zero_remaining_bytes(write)");
20112010
break;
20122011
}
20132012
}

0 commit comments

Comments
 (0)