diff options
author | Christoph Hellwig <hch@infradead.org> | 2010-01-13 17:17:56 -0500 |
---|---|---|
committer | Alex Elder <aelder@sgi.com> | 2010-01-15 16:35:17 -0500 |
commit | 4e23471a3f3aba885ea70100db47ccacb5f069f6 (patch) | |
tree | 976d7943087e8f49fada9204b6914c84b3c25a31 /fs/xfs/linux-2.6/xfs_buf.c | |
parent | 64e0bc7d2a6609ad265757a600e2a0d93c8adb47 (diff) |
xfs: move more buffer helpers into xfs_buf.c
Move xfsbdstrat and xfs_bdstrat_cb from xfs_lrw.c and xfs_bioerror
and xfs_bioerror_relse from xfs_rw.c into xfs_buf.c. This also
means xfs_bioerror and xfs_bioerror_relse can be marked static now.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_buf.c')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_buf.c | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c index 492465c6e0b4..158fad4550df 100644 --- a/fs/xfs/linux-2.6/xfs_buf.c +++ b/fs/xfs/linux-2.6/xfs_buf.c | |||
@@ -1112,6 +1112,126 @@ xfs_bdwrite( | |||
1112 | xfs_buf_delwri_queue(bp, 1); | 1112 | xfs_buf_delwri_queue(bp, 1); |
1113 | } | 1113 | } |
1114 | 1114 | ||
1115 | /* | ||
1116 | * Called when we want to stop a buffer from getting written or read. | ||
1117 | * We attach the EIO error, muck with its flags, and call biodone | ||
1118 | * so that the proper iodone callbacks get called. | ||
1119 | */ | ||
1120 | STATIC int | ||
1121 | xfs_bioerror( | ||
1122 | xfs_buf_t *bp) | ||
1123 | { | ||
1124 | #ifdef XFSERRORDEBUG | ||
1125 | ASSERT(XFS_BUF_ISREAD(bp) || bp->b_iodone); | ||
1126 | #endif | ||
1127 | |||
1128 | /* | ||
1129 | * No need to wait until the buffer is unpinned, we aren't flushing it. | ||
1130 | */ | ||
1131 | XFS_BUF_ERROR(bp, EIO); | ||
1132 | |||
1133 | /* | ||
1134 | * We're calling biodone, so delete XBF_DONE flag. | ||
1135 | */ | ||
1136 | XFS_BUF_UNREAD(bp); | ||
1137 | XFS_BUF_UNDELAYWRITE(bp); | ||
1138 | XFS_BUF_UNDONE(bp); | ||
1139 | XFS_BUF_STALE(bp); | ||
1140 | |||
1141 | XFS_BUF_CLR_BDSTRAT_FUNC(bp); | ||
1142 | xfs_biodone(bp); | ||
1143 | |||
1144 | return EIO; | ||
1145 | } | ||
1146 | |||
1147 | /* | ||
1148 | * Same as xfs_bioerror, except that we are releasing the buffer | ||
1149 | * here ourselves, and avoiding the biodone call. | ||
1150 | * This is meant for userdata errors; metadata bufs come with | ||
1151 | * iodone functions attached, so that we can track down errors. | ||
1152 | */ | ||
1153 | STATIC int | ||
1154 | xfs_bioerror_relse( | ||
1155 | struct xfs_buf *bp) | ||
1156 | { | ||
1157 | int64_t fl = XFS_BUF_BFLAGS(bp); | ||
1158 | /* | ||
1159 | * No need to wait until the buffer is unpinned. | ||
1160 | * We aren't flushing it. | ||
1161 | * | ||
1162 | * chunkhold expects B_DONE to be set, whether | ||
1163 | * we actually finish the I/O or not. We don't want to | ||
1164 | * change that interface. | ||
1165 | */ | ||
1166 | XFS_BUF_UNREAD(bp); | ||
1167 | XFS_BUF_UNDELAYWRITE(bp); | ||
1168 | XFS_BUF_DONE(bp); | ||
1169 | XFS_BUF_STALE(bp); | ||
1170 | XFS_BUF_CLR_IODONE_FUNC(bp); | ||
1171 | XFS_BUF_CLR_BDSTRAT_FUNC(bp); | ||
1172 | if (!(fl & XFS_B_ASYNC)) { | ||
1173 | /* | ||
1174 | * Mark b_error and B_ERROR _both_. | ||
1175 | * Lot's of chunkcache code assumes that. | ||
1176 | * There's no reason to mark error for | ||
1177 | * ASYNC buffers. | ||
1178 | */ | ||
1179 | XFS_BUF_ERROR(bp, EIO); | ||
1180 | XFS_BUF_FINISH_IOWAIT(bp); | ||
1181 | } else { | ||
1182 | xfs_buf_relse(bp); | ||
1183 | } | ||
1184 | |||
1185 | return EIO; | ||
1186 | } | ||
1187 | |||
1188 | |||
1189 | /* | ||
1190 | * All xfs metadata buffers except log state machine buffers | ||
1191 | * get this attached as their b_bdstrat callback function. | ||
1192 | * This is so that we can catch a buffer | ||
1193 | * after prematurely unpinning it to forcibly shutdown the filesystem. | ||
1194 | */ | ||
1195 | int | ||
1196 | xfs_bdstrat_cb( | ||
1197 | struct xfs_buf *bp) | ||
1198 | { | ||
1199 | if (XFS_FORCED_SHUTDOWN(bp->b_mount)) { | ||
1200 | trace_xfs_bdstrat_shut(bp, _RET_IP_); | ||
1201 | /* | ||
1202 | * Metadata write that didn't get logged but | ||
1203 | * written delayed anyway. These aren't associated | ||
1204 | * with a transaction, and can be ignored. | ||
1205 | */ | ||
1206 | if (!bp->b_iodone && !XFS_BUF_ISREAD(bp)) | ||
1207 | return xfs_bioerror_relse(bp); | ||
1208 | else | ||
1209 | return xfs_bioerror(bp); | ||
1210 | } | ||
1211 | |||
1212 | xfs_buf_iorequest(bp); | ||
1213 | return 0; | ||
1214 | } | ||
1215 | |||
1216 | /* | ||
1217 | * Wrapper around bdstrat so that we can stop data from going to disk in case | ||
1218 | * we are shutting down the filesystem. Typically user data goes thru this | ||
1219 | * path; one of the exceptions is the superblock. | ||
1220 | */ | ||
1221 | void | ||
1222 | xfsbdstrat( | ||
1223 | struct xfs_mount *mp, | ||
1224 | struct xfs_buf *bp) | ||
1225 | { | ||
1226 | if (XFS_FORCED_SHUTDOWN(mp)) { | ||
1227 | trace_xfs_bdstrat_shut(bp, _RET_IP_); | ||
1228 | xfs_bioerror_relse(bp); | ||
1229 | return; | ||
1230 | } | ||
1231 | |||
1232 | xfs_buf_iorequest(bp); | ||
1233 | } | ||
1234 | |||
1115 | STATIC void | 1235 | STATIC void |
1116 | _xfs_buf_ioend( | 1236 | _xfs_buf_ioend( |
1117 | xfs_buf_t *bp, | 1237 | xfs_buf_t *bp, |