diff options
Diffstat (limited to 'fs/xfs/xfs_buf.c')
-rw-r--r-- | fs/xfs/xfs_buf.c | 69 |
1 files changed, 25 insertions, 44 deletions
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index 172d3cc8f8cb..269b35c084da 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c | |||
@@ -201,14 +201,7 @@ xfs_buf_alloc( | |||
201 | bp->b_length = numblks; | 201 | bp->b_length = numblks; |
202 | bp->b_io_length = numblks; | 202 | bp->b_io_length = numblks; |
203 | bp->b_flags = flags; | 203 | bp->b_flags = flags; |
204 | 204 | bp->b_bn = blkno; | |
205 | /* | ||
206 | * We do not set the block number here in the buffer because we have not | ||
207 | * finished initialising the buffer. We insert the buffer into the cache | ||
208 | * in this state, so this ensures that we are unable to do IO on a | ||
209 | * buffer that hasn't been fully initialised. | ||
210 | */ | ||
211 | bp->b_bn = XFS_BUF_DADDR_NULL; | ||
212 | atomic_set(&bp->b_pin_count, 0); | 205 | atomic_set(&bp->b_pin_count, 0); |
213 | init_waitqueue_head(&bp->b_waiters); | 206 | init_waitqueue_head(&bp->b_waiters); |
214 | 207 | ||
@@ -567,11 +560,6 @@ xfs_buf_get( | |||
567 | if (bp != new_bp) | 560 | if (bp != new_bp) |
568 | xfs_buf_free(new_bp); | 561 | xfs_buf_free(new_bp); |
569 | 562 | ||
570 | /* | ||
571 | * Now we have a workable buffer, fill in the block number so | ||
572 | * that we can do IO on it. | ||
573 | */ | ||
574 | bp->b_bn = blkno; | ||
575 | bp->b_io_length = bp->b_length; | 563 | bp->b_io_length = bp->b_length; |
576 | 564 | ||
577 | found: | 565 | found: |
@@ -772,7 +760,7 @@ xfs_buf_get_uncached( | |||
772 | int error, i; | 760 | int error, i; |
773 | xfs_buf_t *bp; | 761 | xfs_buf_t *bp; |
774 | 762 | ||
775 | bp = xfs_buf_alloc(target, 0, numblks, 0); | 763 | bp = xfs_buf_alloc(target, XFS_BUF_DADDR_NULL, numblks, 0); |
776 | if (unlikely(bp == NULL)) | 764 | if (unlikely(bp == NULL)) |
777 | goto fail; | 765 | goto fail; |
778 | 766 | ||
@@ -1001,27 +989,6 @@ xfs_buf_ioerror_alert( | |||
1001 | (__uint64_t)XFS_BUF_ADDR(bp), func, bp->b_error, bp->b_length); | 989 | (__uint64_t)XFS_BUF_ADDR(bp), func, bp->b_error, bp->b_length); |
1002 | } | 990 | } |
1003 | 991 | ||
1004 | int | ||
1005 | xfs_bwrite( | ||
1006 | struct xfs_buf *bp) | ||
1007 | { | ||
1008 | int error; | ||
1009 | |||
1010 | ASSERT(xfs_buf_islocked(bp)); | ||
1011 | |||
1012 | bp->b_flags |= XBF_WRITE; | ||
1013 | bp->b_flags &= ~(XBF_ASYNC | XBF_READ | _XBF_DELWRI_Q); | ||
1014 | |||
1015 | xfs_bdstrat_cb(bp); | ||
1016 | |||
1017 | error = xfs_buf_iowait(bp); | ||
1018 | if (error) { | ||
1019 | xfs_force_shutdown(bp->b_target->bt_mount, | ||
1020 | SHUTDOWN_META_IO_ERROR); | ||
1021 | } | ||
1022 | return error; | ||
1023 | } | ||
1024 | |||
1025 | /* | 992 | /* |
1026 | * Called when we want to stop a buffer from getting written or read. | 993 | * Called when we want to stop a buffer from getting written or read. |
1027 | * We attach the EIO error, muck with its flags, and call xfs_buf_ioend | 994 | * We attach the EIO error, muck with its flags, and call xfs_buf_ioend |
@@ -1091,14 +1058,7 @@ xfs_bioerror_relse( | |||
1091 | return EIO; | 1058 | return EIO; |
1092 | } | 1059 | } |
1093 | 1060 | ||
1094 | 1061 | STATIC int | |
1095 | /* | ||
1096 | * All xfs metadata buffers except log state machine buffers | ||
1097 | * get this attached as their b_bdstrat callback function. | ||
1098 | * This is so that we can catch a buffer | ||
1099 | * after prematurely unpinning it to forcibly shutdown the filesystem. | ||
1100 | */ | ||
1101 | int | ||
1102 | xfs_bdstrat_cb( | 1062 | xfs_bdstrat_cb( |
1103 | struct xfs_buf *bp) | 1063 | struct xfs_buf *bp) |
1104 | { | 1064 | { |
@@ -1119,6 +1079,27 @@ xfs_bdstrat_cb( | |||
1119 | return 0; | 1079 | return 0; |
1120 | } | 1080 | } |
1121 | 1081 | ||
1082 | int | ||
1083 | xfs_bwrite( | ||
1084 | struct xfs_buf *bp) | ||
1085 | { | ||
1086 | int error; | ||
1087 | |||
1088 | ASSERT(xfs_buf_islocked(bp)); | ||
1089 | |||
1090 | bp->b_flags |= XBF_WRITE; | ||
1091 | bp->b_flags &= ~(XBF_ASYNC | XBF_READ | _XBF_DELWRI_Q); | ||
1092 | |||
1093 | xfs_bdstrat_cb(bp); | ||
1094 | |||
1095 | error = xfs_buf_iowait(bp); | ||
1096 | if (error) { | ||
1097 | xfs_force_shutdown(bp->b_target->bt_mount, | ||
1098 | SHUTDOWN_META_IO_ERROR); | ||
1099 | } | ||
1100 | return error; | ||
1101 | } | ||
1102 | |||
1122 | /* | 1103 | /* |
1123 | * Wrapper around bdstrat so that we can stop data from going to disk in case | 1104 | * Wrapper around bdstrat so that we can stop data from going to disk in case |
1124 | * we are shutting down the filesystem. Typically user data goes thru this | 1105 | * we are shutting down the filesystem. Typically user data goes thru this |
@@ -1255,7 +1236,7 @@ xfs_buf_iorequest( | |||
1255 | */ | 1236 | */ |
1256 | atomic_set(&bp->b_io_remaining, 1); | 1237 | atomic_set(&bp->b_io_remaining, 1); |
1257 | _xfs_buf_ioapply(bp); | 1238 | _xfs_buf_ioapply(bp); |
1258 | _xfs_buf_ioend(bp, 0); | 1239 | _xfs_buf_ioend(bp, 1); |
1259 | 1240 | ||
1260 | xfs_buf_rele(bp); | 1241 | xfs_buf_rele(bp); |
1261 | } | 1242 | } |