xfs: clean up xfs_ioerror_alert
authorChristoph Hellwig <hch@infradead.org>
Mon, 10 Oct 2011 16:52:49 +0000 (16:52 +0000)
committerAlex Elder <aelder@sgi.com>
Wed, 12 Oct 2011 02:15:10 +0000 (21:15 -0500)
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>
fs/xfs/xfs_buf.c
fs/xfs/xfs_buf.h
fs/xfs/xfs_log.c
fs/xfs/xfs_log_recover.c
fs/xfs/xfs_mount.c
fs/xfs/xfs_rw.c
fs/xfs/xfs_rw.h
fs/xfs/xfs_trans_buf.c
fs/xfs/xfs_vnodeops.c

index 1f24ee5..0a767fc 100644 (file)
@@ -1004,6 +1004,17 @@ xfs_buf_ioerror(
        trace_xfs_buf_ioerror(bp, error, _RET_IP_);
 }
 
+void
+xfs_buf_ioerror_alert(
+       struct xfs_buf          *bp,
+       const char              *func)
+{
+       xfs_alert(bp->b_target->bt_mount,
+"metadata I/O error: block 0x%llx (\"%s\") error %d buf count %zd",
+               (__uint64_t)XFS_BUF_ADDR(bp), func,
+               bp->b_error, XFS_BUF_COUNT(bp));
+}
+
 int
 xfs_bwrite(
        struct xfs_buf          *bp)
index 26b9094..357a337 100644 (file)
@@ -205,6 +205,7 @@ extern int xfs_bdstrat_cb(struct xfs_buf *);
 
 extern void xfs_buf_ioend(xfs_buf_t *, int);
 extern void xfs_buf_ioerror(xfs_buf_t *, int);
+extern void xfs_buf_ioerror_alert(struct xfs_buf *, const char *func);
 extern int xfs_buf_iorequest(xfs_buf_t *);
 extern int xfs_buf_iowait(xfs_buf_t *);
 extern void xfs_buf_iomove(xfs_buf_t *, size_t, size_t, void *,
index 8c9db4e..2758a62 100644 (file)
@@ -880,7 +880,7 @@ xlog_iodone(xfs_buf_t *bp)
         */
        if (XFS_TEST_ERROR((xfs_buf_geterror(bp)), l->l_mp,
                        XFS_ERRTAG_IODONE_IOERR, XFS_RANDOM_IODONE_IOERR)) {
-               xfs_ioerror_alert("xlog_iodone", l->l_mp, bp, XFS_BUF_ADDR(bp));
+               xfs_buf_ioerror_alert(bp, __func__);
                xfs_buf_stale(bp);
                xfs_force_shutdown(l->l_mp, SHUTDOWN_LOG_IO_ERROR);
                /*
@@ -1387,9 +1387,9 @@ xlog_sync(xlog_t          *log,
         */
        XFS_BUF_WRITE(bp);
 
-       if ((error = xlog_bdstrat(bp))) {
-               xfs_ioerror_alert("xlog_sync", log->l_mp, bp,
-                                 XFS_BUF_ADDR(bp));
+       error = xlog_bdstrat(bp);
+       if (error) {
+               xfs_buf_ioerror_alert(bp, "xlog_sync");
                return error;
        }
        if (split) {
@@ -1423,9 +1423,9 @@ xlog_sync(xlog_t          *log,
                /* account for internal log which doesn't start at block #0 */
                XFS_BUF_SET_ADDR(bp, XFS_BUF_ADDR(bp) + log->l_logBBstart);
                XFS_BUF_WRITE(bp);
-               if ((error = xlog_bdstrat(bp))) {
-                       xfs_ioerror_alert("xlog_sync (split)", log->l_mp,
-                                         bp, XFS_BUF_ADDR(bp));
+               error = xlog_bdstrat(bp);
+               if (error) {
+                       xfs_buf_ioerror_alert(bp, "xlog_sync (split)");
                        return error;
                }
        }
index 8f70f34..82ee9db 100644 (file)
@@ -183,8 +183,7 @@ xlog_bread_noalign(
        xfsbdstrat(log->l_mp, bp);
        error = xfs_buf_iowait(bp);
        if (error)
-               xfs_ioerror_alert("xlog_bread", log->l_mp,
-                                 bp, XFS_BUF_ADDR(bp));
+               xfs_buf_ioerror_alert(bp, __func__);
        return error;
 }
 
@@ -269,10 +268,8 @@ xlog_bwrite(
        XFS_BUF_SET_COUNT(bp, BBTOB(nbblks));
 
        error = xfs_bwrite(bp);
-       if (error) {
-               xfs_ioerror_alert("xlog_bwrite", log->l_mp,
-                                 bp, XFS_BUF_ADDR(bp));
-       }
+       if (error)
+               xfs_buf_ioerror_alert(bp, __func__);
        xfs_buf_relse(bp);
        return error;
 }
@@ -364,9 +361,7 @@ xlog_recover_iodone(
                 * We're not going to bother about retrying
                 * this during recovery. One strike!
                 */
-               xfs_ioerror_alert("xlog_recover_iodone",
-                                       bp->b_target->bt_mount, bp,
-                                       XFS_BUF_ADDR(bp));
+               xfs_buf_ioerror_alert(bp, __func__);
                xfs_force_shutdown(bp->b_target->bt_mount,
                                        SHUTDOWN_META_IO_ERROR);
        }
@@ -2138,8 +2133,7 @@ xlog_recover_buffer_pass2(
                return XFS_ERROR(ENOMEM);
        error = bp->b_error;
        if (error) {
-               xfs_ioerror_alert("xlog_recover_do..(read#1)", mp,
-                                 bp, buf_f->blf_blkno);
+               xfs_buf_ioerror_alert(bp, "xlog_recover_do..(read#1)");
                xfs_buf_relse(bp);
                return error;
        }
@@ -2234,8 +2228,7 @@ xlog_recover_inode_pass2(
        }
        error = bp->b_error;
        if (error) {
-               xfs_ioerror_alert("xlog_recover_do..(read#2)", mp,
-                                 bp, in_f->ilf_blkno);
+               xfs_buf_ioerror_alert(bp, "xlog_recover_do..(read#2)");
                xfs_buf_relse(bp);
                goto error;
        }
@@ -2542,8 +2535,7 @@ xlog_recover_dquot_pass2(
                             XFS_FSB_TO_BB(mp, dq_f->qlf_len),
                             0, &bp);
        if (error) {
-               xfs_ioerror_alert("xlog_recover_do..(read#3)", mp,
-                                 bp, dq_f->qlf_blkno);
+               xfs_buf_ioerror_alert(bp, "xlog_recover_do..(read#3)");
                return error;
        }
        ASSERT(bp);
@@ -3695,8 +3687,7 @@ xlog_do_recover(
        xfsbdstrat(log->l_mp, bp);
        error = xfs_buf_iowait(bp);
        if (error) {
-               xfs_ioerror_alert("xlog_do_recover",
-                                 log->l_mp, bp, XFS_BUF_ADDR(bp));
+               xfs_buf_ioerror_alert(bp, __func__);
                ASSERT(0);
                xfs_buf_relse(bp);
                return error;
index e8fe1cb..f3b1cec 100644 (file)
@@ -1610,8 +1610,7 @@ xfs_unmountfs_writesb(xfs_mount_t *mp)
                xfsbdstrat(mp, sbp);
                error = xfs_buf_iowait(sbp);
                if (error)
-                       xfs_ioerror_alert("xfs_unmountfs_writesb",
-                                         mp, sbp, XFS_BUF_ADDR(sbp));
+                       xfs_buf_ioerror_alert(sbp, __func__);
                xfs_buf_relse(sbp);
        }
        return error;
index 86f1928..597d044 100644 (file)
@@ -91,24 +91,6 @@ xfs_do_force_shutdown(
        }
 }
 
-/*
- * Prints out an ALERT message about I/O error.
- */
-void
-xfs_ioerror_alert(
-       char                    *func,
-       struct xfs_mount        *mp,
-       xfs_buf_t               *bp,
-       xfs_daddr_t             blkno)
-{
-       xfs_alert(mp,
-                "I/O error occurred: meta-data dev %s block 0x%llx"
-                "       (\"%s\") error %d buf count %zd",
-               xfs_buf_target_name(bp->b_target),
-               (__uint64_t)blkno, func,
-               bp->b_error, XFS_BUF_COUNT(bp));
-}
-
 /*
  * This isn't an absolute requirement, but it is
  * just a good idea to call xfs_read_buf instead of
@@ -143,7 +125,7 @@ xfs_read_buf(
        } else {
                *bpp = NULL;
                if (error) {
-                       xfs_ioerror_alert("xfs_read_buf", mp, bp, XFS_BUF_ADDR(bp));
+                       xfs_buf_ioerror_alert(bp, __func__);
                } else {
                        error = XFS_ERROR(EIO);
                }
index 11c41ec..bbdb9ad 100644 (file)
@@ -42,8 +42,6 @@ xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb)
 extern int xfs_read_buf(struct xfs_mount *mp, xfs_buftarg_t *btp,
                        xfs_daddr_t blkno, int len, uint flags,
                        struct xfs_buf **bpp);
-extern void xfs_ioerror_alert(char *func, struct xfs_mount *mp,
-                               xfs_buf_t *bp, xfs_daddr_t blkno);
 extern xfs_extlen_t xfs_get_extsz_hint(struct xfs_inode *ip);
 
 #endif /* __XFS_RW_H__ */
index 5bab598..475a4de 100644 (file)
@@ -296,8 +296,7 @@ xfs_trans_read_buf(
 
                if (bp->b_error) {
                        error = bp->b_error;
-                       xfs_ioerror_alert("xfs_trans_read_buf", mp,
-                                         bp, blkno);
+                       xfs_buf_ioerror_alert(bp, __func__);
                        xfs_buf_relse(bp);
                        return error;
                }
@@ -339,8 +338,7 @@ xfs_trans_read_buf(
                        xfsbdstrat(tp->t_mountp, bp);
                        error = xfs_buf_iowait(bp);
                        if (error) {
-                               xfs_ioerror_alert("xfs_trans_read_buf", mp,
-                                                 bp, blkno);
+                               xfs_buf_ioerror_alert(bp, __func__);
                                xfs_buf_relse(bp);
                                /*
                                 * We can gracefully recover from most read
@@ -391,8 +389,7 @@ xfs_trans_read_buf(
                error = bp->b_error;
                xfs_buf_stale(bp);
                XFS_BUF_DONE(bp);
-               xfs_ioerror_alert("xfs_trans_read_buf", mp,
-                                 bp, blkno);
+               xfs_buf_ioerror_alert(bp, __func__);
                if (tp->t_flags & XFS_TRANS_DIRTY)
                        xfs_force_shutdown(tp->t_mountp, SHUTDOWN_META_IO_ERROR);
                xfs_buf_relse(bp);
index fc38f15..4ecf2a5 100644 (file)
@@ -87,8 +87,7 @@ xfs_readlink_bmap(
                        return XFS_ERROR(ENOMEM);
                error = bp->b_error;
                if (error) {
-                       xfs_ioerror_alert("xfs_readlink",
-                                 ip->i_mount, bp, XFS_BUF_ADDR(bp));
+                       xfs_buf_ioerror_alert(bp, __func__);
                        xfs_buf_relse(bp);
                        goto out;
                }
@@ -1993,8 +1992,8 @@ xfs_zero_remaining_bytes(
                xfsbdstrat(mp, bp);
                error = xfs_buf_iowait(bp);
                if (error) {
-                       xfs_ioerror_alert("xfs_zero_remaining_bytes(read)",
-                                         mp, bp, XFS_BUF_ADDR(bp));
+                       xfs_buf_ioerror_alert(bp,
+                                       "xfs_zero_remaining_bytes(read)");
                        break;
                }
                memset(bp->b_addr +
@@ -2006,8 +2005,8 @@ xfs_zero_remaining_bytes(
                xfsbdstrat(mp, bp);
                error = xfs_buf_iowait(bp);
                if (error) {
-                       xfs_ioerror_alert("xfs_zero_remaining_bytes(write)",
-                                         mp, bp, XFS_BUF_ADDR(bp));
+                       xfs_buf_ioerror_alert(bp,
+                                       "xfs_zero_remaining_bytes(write)");
                        break;
                }
        }