aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_log_recover.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2014-10-01 19:05:14 -0400
committerDave Chinner <david@fromorbit.com>2014-10-01 19:05:14 -0400
commit595bff75dce51e0d6d94877b4b6d11b4747a63fd (patch)
tree568f8eaf78e34734a15ebaf3a9865cfc5c1d7581 /fs/xfs/xfs_log_recover.c
parent8b131973d1628f1a0c5a36fe02269d696bbe60a3 (diff)
xfs: introduce xfs_buf_submit[_wait]
There is a lot of cookie-cutter code that looks like: if (shutdown) handle buffer error xfs_buf_iorequest(bp) error = xfs_buf_iowait(bp) if (error) handle buffer error spread through XFS. There's significant complexity now in xfs_buf_iorequest() to specifically handle this sort of synchronous IO pattern, but there's all sorts of nasty surprises in different error handling code dependent on who owns the buffer references and the locks. Pull this pattern into a single helper, where we can hide all the synchronous IO warts and hence make the error handling for all the callers much saner. This removes the need for a special extra reference to protect IO completion processing, as we can now hold a single reference across dispatch and waiting, simplifying the sync IO smeantics and error handling. In doing this, also rename xfs_buf_iorequest to xfs_buf_submit and make it explicitly handle on asynchronous IO. This forces all users to be switched specifically to one interface or the other and removes any ambiguity between how the interfaces are to be used. It also means that xfs_buf_iowait() goes away. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/xfs_log_recover.c')
-rw-r--r--fs/xfs/xfs_log_recover.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 4ba19bf7da1f..980e2968b907 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -193,12 +193,8 @@ xlog_bread_noalign(
193 bp->b_io_length = nbblks; 193 bp->b_io_length = nbblks;
194 bp->b_error = 0; 194 bp->b_error = 0;
195 195
196 if (XFS_FORCED_SHUTDOWN(log->l_mp)) 196 error = xfs_buf_submit_wait(bp);
197 return -EIO; 197 if (error && !XFS_FORCED_SHUTDOWN(log->l_mp))
198
199 xfs_buf_iorequest(bp);
200 error = xfs_buf_iowait(bp);
201 if (error)
202 xfs_buf_ioerror_alert(bp, __func__); 198 xfs_buf_ioerror_alert(bp, __func__);
203 return error; 199 return error;
204} 200}
@@ -378,9 +374,11 @@ xlog_recover_iodone(
378 * We're not going to bother about retrying 374 * We're not going to bother about retrying
379 * this during recovery. One strike! 375 * this during recovery. One strike!
380 */ 376 */
381 xfs_buf_ioerror_alert(bp, __func__); 377 if (!XFS_FORCED_SHUTDOWN(bp->b_target->bt_mount)) {
382 xfs_force_shutdown(bp->b_target->bt_mount, 378 xfs_buf_ioerror_alert(bp, __func__);
383 SHUTDOWN_META_IO_ERROR); 379 xfs_force_shutdown(bp->b_target->bt_mount,
380 SHUTDOWN_META_IO_ERROR);
381 }
384 } 382 }
385 bp->b_iodone = NULL; 383 bp->b_iodone = NULL;
386 xfs_buf_ioend(bp); 384 xfs_buf_ioend(bp);
@@ -4427,16 +4425,12 @@ xlog_do_recover(
4427 XFS_BUF_UNASYNC(bp); 4425 XFS_BUF_UNASYNC(bp);
4428 bp->b_ops = &xfs_sb_buf_ops; 4426 bp->b_ops = &xfs_sb_buf_ops;
4429 4427
4430 if (XFS_FORCED_SHUTDOWN(log->l_mp)) { 4428 error = xfs_buf_submit_wait(bp);
4431 xfs_buf_relse(bp);
4432 return -EIO;
4433 }
4434
4435 xfs_buf_iorequest(bp);
4436 error = xfs_buf_iowait(bp);
4437 if (error) { 4429 if (error) {
4438 xfs_buf_ioerror_alert(bp, __func__); 4430 if (!XFS_FORCED_SHUTDOWN(log->l_mp)) {
4439 ASSERT(0); 4431 xfs_buf_ioerror_alert(bp, __func__);
4432 ASSERT(0);
4433 }
4440 xfs_buf_relse(bp); 4434 xfs_buf_relse(bp);
4441 return error; 4435 return error;
4442 } 4436 }