OSDN Git Service

xfs: kill xfs_buf_geterror()
authorDave Chinner <dchinner@redhat.com>
Fri, 6 Jun 2014 06:02:12 +0000 (16:02 +1000)
committerDave Chinner <david@fromorbit.com>
Fri, 6 Jun 2014 06:02:12 +0000 (16:02 +1000)
Most of the callers are just calling ASSERT(!xfs_buf_geterror())
which means they are checking for bp->b_error == 0. If bp is null in
this case, we will assert fail, and hence it's no different in
result to oopsing because of a null bp. In some cases, errors have
already been checked for or the function returning the buffer can't
return a buffer with an error, so it's just a redundant assert.
Either way, the assert can either be removed.

The other two non-assert callers can just test for a buffer and
error properly.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/xfs_alloc.c
fs/xfs/xfs_btree.c
fs/xfs/xfs_buf.h
fs/xfs/xfs_buf_item.c
fs/xfs/xfs_dquot.c
fs/xfs/xfs_ialloc.c
fs/xfs/xfs_log.c
fs/xfs/xfs_rtbitmap.c

index c1cf6a3..077c341 100644 (file)
@@ -541,7 +541,6 @@ xfs_alloc_read_agfl(
                        XFS_FSS_TO_BB(mp, 1), 0, &bp, &xfs_agfl_buf_ops);
        if (error)
                return error;
-       ASSERT(!xfs_buf_geterror(bp));
        xfs_buf_set_ref(bp, XFS_AGFL_REF);
        *bpp = bp;
        return 0;
index e80d59f..22707ad 100644 (file)
@@ -552,14 +552,11 @@ xfs_btree_get_bufl(
        xfs_fsblock_t   fsbno,          /* file system block number */
        uint            lock)           /* lock flags for get_buf */
 {
-       xfs_buf_t       *bp;            /* buffer pointer (return value) */
        xfs_daddr_t             d;              /* real disk block address */
 
        ASSERT(fsbno != NULLFSBLOCK);
        d = XFS_FSB_TO_DADDR(mp, fsbno);
-       bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock);
-       ASSERT(!xfs_buf_geterror(bp));
-       return bp;
+       return xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock);
 }
 
 /*
@@ -574,15 +571,12 @@ xfs_btree_get_bufs(
        xfs_agblock_t   agbno,          /* allocation group block number */
        uint            lock)           /* lock flags for get_buf */
 {
-       xfs_buf_t       *bp;            /* buffer pointer (return value) */
        xfs_daddr_t             d;              /* real disk block address */
 
        ASSERT(agno != NULLAGNUMBER);
        ASSERT(agbno != NULLAGBLOCK);
        d = XFS_AGB_TO_DADDR(mp, agno, agbno);
-       bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock);
-       ASSERT(!xfs_buf_geterror(bp));
-       return bp;
+       return xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock);
 }
 
 /*
@@ -722,7 +716,6 @@ xfs_btree_read_bufl(
                                   mp->m_bsize, lock, &bp, ops);
        if (error)
                return error;
-       ASSERT(!xfs_buf_geterror(bp));
        if (bp)
                xfs_buf_set_ref(bp, refval);
        *bpp = bp;
@@ -1178,7 +1171,6 @@ xfs_btree_read_buf_block(
        if (error)
                return error;
 
-       ASSERT(!xfs_buf_geterror(*bpp));
        xfs_btree_set_refs(cur, *bpp);
        *block = XFS_BUF_TO_BLOCK(*bpp);
        return 0;
index b8a3abf..a999a39 100644 (file)
@@ -298,11 +298,6 @@ extern void xfs_buf_iomove(xfs_buf_t *, size_t, size_t, void *,
 
 extern int xfs_bioerror_relse(struct xfs_buf *);
 
-static inline int xfs_buf_geterror(xfs_buf_t *bp)
-{
-       return bp ? bp->b_error : ENOMEM;
-}
-
 /* Buffer Utility Routines */
 extern xfs_caddr_t xfs_buf_offset(xfs_buf_t *, size_t);
 
index 8752821..941f6e9 100644 (file)
@@ -1053,7 +1053,7 @@ xfs_buf_iodone_callbacks(
        static ulong            lasttime;
        static xfs_buftarg_t    *lasttarg;
 
-       if (likely(!xfs_buf_geterror(bp)))
+       if (likely(!bp->b_error))
                goto do_callbacks;
 
        /*
index 868b19f..8867d02 100644 (file)
@@ -353,10 +353,10 @@ xfs_qm_dqalloc(
                               dqp->q_blkno,
                               mp->m_quotainfo->qi_dqchunklen,
                               0);
-
-       error = xfs_buf_geterror(bp);
-       if (error)
+       if (!bp) {
+               error = ENOMEM;
                goto error1;
+       }
        bp->b_ops = &xfs_dquot_buf_ops;
 
        /*
index 8f711db..c254b1c 100644 (file)
@@ -1640,7 +1640,6 @@ xfs_read_agi(
        if (error)
                return error;
 
-       ASSERT(!xfs_buf_geterror(*bpp));
        xfs_buf_set_ref(*bpp, XFS_AGI_REF);
        return 0;
 }
index a5f8bd9..ae871df 100644 (file)
@@ -1165,7 +1165,7 @@ xlog_iodone(xfs_buf_t *bp)
        /*
         * Race to shutdown the filesystem if we see an error.
         */
-       if (XFS_TEST_ERROR((xfs_buf_geterror(bp)), l->l_mp,
+       if (XFS_TEST_ERROR(bp->b_error, l->l_mp,
                        XFS_ERRTAG_IODONE_IOERR, XFS_RANDOM_IODONE_IOERR)) {
                xfs_buf_ioerror_alert(bp, __func__);
                xfs_buf_stale(bp);
index b1f2fe8..f4dd697 100644 (file)
@@ -74,7 +74,6 @@ xfs_rtbuf_get(
                                   mp->m_bsize, 0, &bp, NULL);
        if (error)
                return error;
-       ASSERT(!xfs_buf_geterror(bp));
        *bpp = bp;
        return 0;
 }