xfs: kill xfs_read_buf()
authorDave Chinner <dchinner@redhat.com>
Mon, 23 Apr 2012 05:58:55 +0000 (15:58 +1000)
committerBen Myers <bpm@sgi.com>
Mon, 14 May 2012 21:20:51 +0000 (16:20 -0500)
xfs_read_buf() is effectively the same as xfs_trans_read_buf() when called
outside a transaction context. The error handling is slightly different in that
xfs_read_buf stales the errored buffer it gets back, but there is probably good
reason for xfs_trans_read_buf() for doing this.

Hence update xfs_trans_read_buf() to the same error handling as xfs_read_buf(),
and convert all the callers of xfs_read_buf() to use the former function. We can
then remove xfs_read_buf().

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
fs/xfs/xfs_attr.c
fs/xfs/xfs_fsops.c
fs/xfs/xfs_log_recover.c
fs/xfs/xfs_rw.c
fs/xfs/xfs_rw.h
fs/xfs/xfs_trans_buf.c

index c8ef9a9c312bc5d42fe484369d11b9272073c76d..ad85bed99de8a8de990ca3dcff03d61407a0202b 100644 (file)
@@ -1987,8 +1987,8 @@ xfs_attr_rmtval_get(xfs_da_args_t *args)
                               (map[i].br_startblock != HOLESTARTBLOCK));
                        dblkno = XFS_FSB_TO_DADDR(mp, map[i].br_startblock);
                        blkcnt = XFS_FSB_TO_BB(mp, map[i].br_blockcount);
-                       error = xfs_read_buf(mp, mp->m_ddev_targp, dblkno,
-                                            blkcnt, XBF_DONT_BLOCK, &bp);
+                       error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp,
+                                                  dblkno, blkcnt, 0, &bp);
                        if (error)
                                return(error);
 
index 874d39883dab6cd08e3145d41e26328f88eaffad..e9f5bc0eea92af2ca6c73598c2ab2d608597c966 100644 (file)
@@ -402,7 +402,7 @@ xfs_growfs_data_private(
 
        /* update secondary superblocks. */
        for (agno = 1; agno < nagcount; agno++) {
-               error = xfs_read_buf(mp, mp->m_ddev_targp,
+               error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp,
                                  XFS_AGB_TO_DADDR(mp, agno, XFS_SB_BLOCK(mp)),
                                  XFS_FSS_TO_BB(mp, 1), 0, &bp);
                if (error) {
index 0d9bdb6bace45c91a22efb924abb92590f81ac04..c8ee0fc49042ec83a9db198afd04f7d41dd3d7f8 100644 (file)
@@ -2539,14 +2539,11 @@ xlog_recover_dquot_pass2(
                return XFS_ERROR(EIO);
        ASSERT(dq_f->qlf_len == 1);
 
-       error = xfs_read_buf(mp, mp->m_ddev_targp,
-                            dq_f->qlf_blkno,
-                            XFS_FSB_TO_BB(mp, dq_f->qlf_len),
-                            0, &bp);
-       if (error) {
-               xfs_buf_ioerror_alert(bp, "xlog_recover_do..(read#3)");
+       error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, dq_f->qlf_blkno,
+                                  XFS_FSB_TO_BB(mp, dq_f->qlf_len), 0, &bp);
+       if (error)
                return error;
-       }
+
        ASSERT(bp);
        ddq = (xfs_disk_dquot_t *)xfs_buf_offset(bp, dq_f->qlf_boffset);
 
index 2ce97758f4c7177bf8202b644e7a7dc9ceadc708..3c2488a111655030e29790d7fbf7bbd289f667a7 100644 (file)
@@ -91,56 +91,6 @@ xfs_do_force_shutdown(
        }
 }
 
-/*
- * This isn't an absolute requirement, but it is
- * just a good idea to call xfs_read_buf instead of
- * directly doing a read_buf call. For one, we shouldn't
- * be doing this disk read if we are in SHUTDOWN state anyway,
- * so this stops that from happening. Secondly, this does all
- * the error checking stuff and the brelse if appropriate for
- * the caller, so the code can be a little leaner.
- */
-
-int
-xfs_read_buf(
-       struct xfs_mount *mp,
-       xfs_buftarg_t    *target,
-       xfs_daddr_t      blkno,
-       int              len,
-       uint             flags,
-       xfs_buf_t        **bpp)
-{
-       xfs_buf_t        *bp;
-       int              error;
-
-       if (!flags)
-               flags = XBF_MAPPED;
-
-       bp = xfs_buf_read(target, blkno, len, flags);
-       if (!bp)
-               return XFS_ERROR(EIO);
-       error = bp->b_error;
-       if (!error && !XFS_FORCED_SHUTDOWN(mp)) {
-               *bpp = bp;
-       } else {
-               *bpp = NULL;
-               if (error) {
-                       xfs_buf_ioerror_alert(bp, __func__);
-               } else {
-                       error = XFS_ERROR(EIO);
-               }
-               if (bp) {
-                       XFS_BUF_UNDONE(bp);
-                       xfs_buf_stale(bp);
-                       /*
-                        * brelse clears B_ERROR and b_error
-                        */
-                       xfs_buf_relse(bp);
-               }
-       }
-       return (error);
-}
-
 /*
  * helper function to extract extent size hint from inode
  */
index bbdb9ad6a4ba7b836d3720539db02c093bcc3ca0..967b3a4b76ab4068aec5336e4c4ba44eb4761b36 100644 (file)
@@ -39,9 +39,6 @@ xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb)
 /*
  * Prototypes for functions in xfs_rw.c.
  */
-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 xfs_extlen_t xfs_get_extsz_hint(struct xfs_inode *ip);
 
 #endif /* __XFS_RW_H__ */
index f9cb7ee04dae70f1c7442e534cdb6b8018f42791..5e4cf617e56cffdbf378512fc47cc0a967394f2a 100644 (file)
@@ -274,6 +274,8 @@ xfs_trans_read_buf(
        xfs_buf_log_item_t      *bip;
        int                     error;
 
+       *bpp = NULL;
+
        if (flags == 0)
                flags = XBF_MAPPED;
 
@@ -289,6 +291,8 @@ xfs_trans_read_buf(
                if (bp->b_error) {
                        error = bp->b_error;
                        xfs_buf_ioerror_alert(bp, __func__);
+                       XFS_BUF_UNDONE(bp);
+                       xfs_buf_stale(bp);
                        xfs_buf_relse(bp);
                        return error;
                }