diff options
author | Dave Chinner <dchinner@redhat.com> | 2012-04-23 01:58:55 -0400 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2012-05-14 17:20:51 -0400 |
commit | 7ca790a507a9288ebedab90a8e40b9afa8e4e949 (patch) | |
tree | 70ad7655655e3f5e021b3c80f5c102f4399bbd68 /fs/xfs | |
parent | a8acad70731e7d0585f25f33f8a009176f001f70 (diff) |
xfs: kill xfs_read_buf()
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>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/xfs_attr.c | 4 | ||||
-rw-r--r-- | fs/xfs/xfs_fsops.c | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_log_recover.c | 11 | ||||
-rw-r--r-- | fs/xfs/xfs_rw.c | 50 | ||||
-rw-r--r-- | fs/xfs/xfs_rw.h | 3 | ||||
-rw-r--r-- | fs/xfs/xfs_trans_buf.c | 4 |
6 files changed, 11 insertions, 63 deletions
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c index c8ef9a9c312b..ad85bed99de8 100644 --- a/fs/xfs/xfs_attr.c +++ b/fs/xfs/xfs_attr.c | |||
@@ -1987,8 +1987,8 @@ xfs_attr_rmtval_get(xfs_da_args_t *args) | |||
1987 | (map[i].br_startblock != HOLESTARTBLOCK)); | 1987 | (map[i].br_startblock != HOLESTARTBLOCK)); |
1988 | dblkno = XFS_FSB_TO_DADDR(mp, map[i].br_startblock); | 1988 | dblkno = XFS_FSB_TO_DADDR(mp, map[i].br_startblock); |
1989 | blkcnt = XFS_FSB_TO_BB(mp, map[i].br_blockcount); | 1989 | blkcnt = XFS_FSB_TO_BB(mp, map[i].br_blockcount); |
1990 | error = xfs_read_buf(mp, mp->m_ddev_targp, dblkno, | 1990 | error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, |
1991 | blkcnt, XBF_DONT_BLOCK, &bp); | 1991 | dblkno, blkcnt, 0, &bp); |
1992 | if (error) | 1992 | if (error) |
1993 | return(error); | 1993 | return(error); |
1994 | 1994 | ||
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index 874d39883dab..e9f5bc0eea92 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c | |||
@@ -402,7 +402,7 @@ xfs_growfs_data_private( | |||
402 | 402 | ||
403 | /* update secondary superblocks. */ | 403 | /* update secondary superblocks. */ |
404 | for (agno = 1; agno < nagcount; agno++) { | 404 | for (agno = 1; agno < nagcount; agno++) { |
405 | error = xfs_read_buf(mp, mp->m_ddev_targp, | 405 | error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, |
406 | XFS_AGB_TO_DADDR(mp, agno, XFS_SB_BLOCK(mp)), | 406 | XFS_AGB_TO_DADDR(mp, agno, XFS_SB_BLOCK(mp)), |
407 | XFS_FSS_TO_BB(mp, 1), 0, &bp); | 407 | XFS_FSS_TO_BB(mp, 1), 0, &bp); |
408 | if (error) { | 408 | if (error) { |
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 0d9bdb6bace4..c8ee0fc49042 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c | |||
@@ -2539,14 +2539,11 @@ xlog_recover_dquot_pass2( | |||
2539 | return XFS_ERROR(EIO); | 2539 | return XFS_ERROR(EIO); |
2540 | ASSERT(dq_f->qlf_len == 1); | 2540 | ASSERT(dq_f->qlf_len == 1); |
2541 | 2541 | ||
2542 | error = xfs_read_buf(mp, mp->m_ddev_targp, | 2542 | error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, dq_f->qlf_blkno, |
2543 | dq_f->qlf_blkno, | 2543 | XFS_FSB_TO_BB(mp, dq_f->qlf_len), 0, &bp); |
2544 | XFS_FSB_TO_BB(mp, dq_f->qlf_len), | 2544 | if (error) |
2545 | 0, &bp); | ||
2546 | if (error) { | ||
2547 | xfs_buf_ioerror_alert(bp, "xlog_recover_do..(read#3)"); | ||
2548 | return error; | 2545 | return error; |
2549 | } | 2546 | |
2550 | ASSERT(bp); | 2547 | ASSERT(bp); |
2551 | ddq = (xfs_disk_dquot_t *)xfs_buf_offset(bp, dq_f->qlf_boffset); | 2548 | ddq = (xfs_disk_dquot_t *)xfs_buf_offset(bp, dq_f->qlf_boffset); |
2552 | 2549 | ||
diff --git a/fs/xfs/xfs_rw.c b/fs/xfs/xfs_rw.c index 2ce97758f4c7..3c2488a11165 100644 --- a/fs/xfs/xfs_rw.c +++ b/fs/xfs/xfs_rw.c | |||
@@ -92,56 +92,6 @@ xfs_do_force_shutdown( | |||
92 | } | 92 | } |
93 | 93 | ||
94 | /* | 94 | /* |
95 | * This isn't an absolute requirement, but it is | ||
96 | * just a good idea to call xfs_read_buf instead of | ||
97 | * directly doing a read_buf call. For one, we shouldn't | ||
98 | * be doing this disk read if we are in SHUTDOWN state anyway, | ||
99 | * so this stops that from happening. Secondly, this does all | ||
100 | * the error checking stuff and the brelse if appropriate for | ||
101 | * the caller, so the code can be a little leaner. | ||
102 | */ | ||
103 | |||
104 | int | ||
105 | xfs_read_buf( | ||
106 | struct xfs_mount *mp, | ||
107 | xfs_buftarg_t *target, | ||
108 | xfs_daddr_t blkno, | ||
109 | int len, | ||
110 | uint flags, | ||
111 | xfs_buf_t **bpp) | ||
112 | { | ||
113 | xfs_buf_t *bp; | ||
114 | int error; | ||
115 | |||
116 | if (!flags) | ||
117 | flags = XBF_MAPPED; | ||
118 | |||
119 | bp = xfs_buf_read(target, blkno, len, flags); | ||
120 | if (!bp) | ||
121 | return XFS_ERROR(EIO); | ||
122 | error = bp->b_error; | ||
123 | if (!error && !XFS_FORCED_SHUTDOWN(mp)) { | ||
124 | *bpp = bp; | ||
125 | } else { | ||
126 | *bpp = NULL; | ||
127 | if (error) { | ||
128 | xfs_buf_ioerror_alert(bp, __func__); | ||
129 | } else { | ||
130 | error = XFS_ERROR(EIO); | ||
131 | } | ||
132 | if (bp) { | ||
133 | XFS_BUF_UNDONE(bp); | ||
134 | xfs_buf_stale(bp); | ||
135 | /* | ||
136 | * brelse clears B_ERROR and b_error | ||
137 | */ | ||
138 | xfs_buf_relse(bp); | ||
139 | } | ||
140 | } | ||
141 | return (error); | ||
142 | } | ||
143 | |||
144 | /* | ||
145 | * helper function to extract extent size hint from inode | 95 | * helper function to extract extent size hint from inode |
146 | */ | 96 | */ |
147 | xfs_extlen_t | 97 | xfs_extlen_t |
diff --git a/fs/xfs/xfs_rw.h b/fs/xfs/xfs_rw.h index bbdb9ad6a4ba..967b3a4b76ab 100644 --- a/fs/xfs/xfs_rw.h +++ b/fs/xfs/xfs_rw.h | |||
@@ -39,9 +39,6 @@ xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb) | |||
39 | /* | 39 | /* |
40 | * Prototypes for functions in xfs_rw.c. | 40 | * Prototypes for functions in xfs_rw.c. |
41 | */ | 41 | */ |
42 | extern int xfs_read_buf(struct xfs_mount *mp, xfs_buftarg_t *btp, | ||
43 | xfs_daddr_t blkno, int len, uint flags, | ||
44 | struct xfs_buf **bpp); | ||
45 | extern xfs_extlen_t xfs_get_extsz_hint(struct xfs_inode *ip); | 42 | extern xfs_extlen_t xfs_get_extsz_hint(struct xfs_inode *ip); |
46 | 43 | ||
47 | #endif /* __XFS_RW_H__ */ | 44 | #endif /* __XFS_RW_H__ */ |
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c index f9cb7ee04dae..5e4cf617e56c 100644 --- a/fs/xfs/xfs_trans_buf.c +++ b/fs/xfs/xfs_trans_buf.c | |||
@@ -274,6 +274,8 @@ xfs_trans_read_buf( | |||
274 | xfs_buf_log_item_t *bip; | 274 | xfs_buf_log_item_t *bip; |
275 | int error; | 275 | int error; |
276 | 276 | ||
277 | *bpp = NULL; | ||
278 | |||
277 | if (flags == 0) | 279 | if (flags == 0) |
278 | flags = XBF_MAPPED; | 280 | flags = XBF_MAPPED; |
279 | 281 | ||
@@ -289,6 +291,8 @@ xfs_trans_read_buf( | |||
289 | if (bp->b_error) { | 291 | if (bp->b_error) { |
290 | error = bp->b_error; | 292 | error = bp->b_error; |
291 | xfs_buf_ioerror_alert(bp, __func__); | 293 | xfs_buf_ioerror_alert(bp, __func__); |
294 | XFS_BUF_UNDONE(bp); | ||
295 | xfs_buf_stale(bp); | ||
292 | xfs_buf_relse(bp); | 296 | xfs_buf_relse(bp); |
293 | return error; | 297 | return error; |
294 | } | 298 | } |