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 | |
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>
-rw-r--r-- | fs/xfs/linux-2.6/xfs_buf.c | 120 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_buf.h | 4 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_lrw.c | 47 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_lrw.h | 3 | ||||
-rw-r--r-- | fs/xfs/xfs_rw.c | 82 | ||||
-rw-r--r-- | fs/xfs/xfs_rw.h | 2 |
6 files changed, 124 insertions, 134 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, |
diff --git a/fs/xfs/linux-2.6/xfs_buf.h b/fs/xfs/linux-2.6/xfs_buf.h index f69b8e714a11..9a29d18656ec 100644 --- a/fs/xfs/linux-2.6/xfs_buf.h +++ b/fs/xfs/linux-2.6/xfs_buf.h | |||
@@ -235,6 +235,10 @@ extern void xfs_buf_unlock(xfs_buf_t *); | |||
235 | extern int xfs_bwrite(struct xfs_mount *mp, struct xfs_buf *bp); | 235 | extern int xfs_bwrite(struct xfs_mount *mp, struct xfs_buf *bp); |
236 | extern int xfs_bawrite(void *mp, xfs_buf_t *bp); | 236 | extern int xfs_bawrite(void *mp, xfs_buf_t *bp); |
237 | extern void xfs_bdwrite(void *mp, xfs_buf_t *bp); | 237 | extern void xfs_bdwrite(void *mp, xfs_buf_t *bp); |
238 | |||
239 | extern void xfsbdstrat(struct xfs_mount *, struct xfs_buf *); | ||
240 | extern int xfs_bdstrat_cb(struct xfs_buf *); | ||
241 | |||
238 | extern void xfs_buf_ioend(xfs_buf_t *, int); | 242 | extern void xfs_buf_ioend(xfs_buf_t *, int); |
239 | extern void xfs_buf_ioerror(xfs_buf_t *, int); | 243 | extern void xfs_buf_ioerror(xfs_buf_t *, int); |
240 | extern int xfs_buf_iorequest(xfs_buf_t *); | 244 | extern int xfs_buf_iorequest(xfs_buf_t *); |
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c index 0d32457abef1..c80fa00d2ad7 100644 --- a/fs/xfs/linux-2.6/xfs_lrw.c +++ b/fs/xfs/linux-2.6/xfs_lrw.c | |||
@@ -784,53 +784,6 @@ write_retry: | |||
784 | } | 784 | } |
785 | 785 | ||
786 | /* | 786 | /* |
787 | * All xfs metadata buffers except log state machine buffers | ||
788 | * get this attached as their b_bdstrat callback function. | ||
789 | * This is so that we can catch a buffer | ||
790 | * after prematurely unpinning it to forcibly shutdown the filesystem. | ||
791 | */ | ||
792 | int | ||
793 | xfs_bdstrat_cb(struct xfs_buf *bp) | ||
794 | { | ||
795 | if (XFS_FORCED_SHUTDOWN(bp->b_mount)) { | ||
796 | trace_xfs_bdstrat_shut(bp, _RET_IP_); | ||
797 | /* | ||
798 | * Metadata write that didn't get logged but | ||
799 | * written delayed anyway. These aren't associated | ||
800 | * with a transaction, and can be ignored. | ||
801 | */ | ||
802 | if (XFS_BUF_IODONE_FUNC(bp) == NULL && | ||
803 | (XFS_BUF_ISREAD(bp)) == 0) | ||
804 | return (xfs_bioerror_relse(bp)); | ||
805 | else | ||
806 | return (xfs_bioerror(bp)); | ||
807 | } | ||
808 | |||
809 | xfs_buf_iorequest(bp); | ||
810 | return 0; | ||
811 | } | ||
812 | |||
813 | /* | ||
814 | * Wrapper around bdstrat so that we can stop data from going to disk in case | ||
815 | * we are shutting down the filesystem. Typically user data goes thru this | ||
816 | * path; one of the exceptions is the superblock. | ||
817 | */ | ||
818 | void | ||
819 | xfsbdstrat( | ||
820 | struct xfs_mount *mp, | ||
821 | struct xfs_buf *bp) | ||
822 | { | ||
823 | ASSERT(mp); | ||
824 | if (!XFS_FORCED_SHUTDOWN(mp)) { | ||
825 | xfs_buf_iorequest(bp); | ||
826 | return; | ||
827 | } | ||
828 | |||
829 | trace_xfs_bdstrat_shut(bp, _RET_IP_); | ||
830 | xfs_bioerror_relse(bp); | ||
831 | } | ||
832 | |||
833 | /* | ||
834 | * If the underlying (data/log/rt) device is readonly, there are some | 787 | * If the underlying (data/log/rt) device is readonly, there are some |
835 | * operations that cannot proceed. | 788 | * operations that cannot proceed. |
836 | */ | 789 | */ |
diff --git a/fs/xfs/linux-2.6/xfs_lrw.h b/fs/xfs/linux-2.6/xfs_lrw.h index d1f7789c7ffb..342ae8c0d011 100644 --- a/fs/xfs/linux-2.6/xfs_lrw.h +++ b/fs/xfs/linux-2.6/xfs_lrw.h | |||
@@ -22,9 +22,6 @@ struct xfs_mount; | |||
22 | struct xfs_inode; | 22 | struct xfs_inode; |
23 | struct xfs_buf; | 23 | struct xfs_buf; |
24 | 24 | ||
25 | /* errors from xfsbdstrat() must be extracted from the buffer */ | ||
26 | extern void xfsbdstrat(struct xfs_mount *, struct xfs_buf *); | ||
27 | extern int xfs_bdstrat_cb(struct xfs_buf *); | ||
28 | extern int xfs_dev_is_read_only(struct xfs_mount *, char *); | 25 | extern int xfs_dev_is_read_only(struct xfs_mount *, char *); |
29 | 26 | ||
30 | extern int xfs_zero_eof(struct xfs_inode *, xfs_off_t, xfs_fsize_t); | 27 | extern int xfs_zero_eof(struct xfs_inode *, xfs_off_t, xfs_fsize_t); |
diff --git a/fs/xfs/xfs_rw.c b/fs/xfs/xfs_rw.c index 9d933a10d6bb..abb2c458b148 100644 --- a/fs/xfs/xfs_rw.c +++ b/fs/xfs/xfs_rw.c | |||
@@ -153,88 +153,6 @@ xfs_do_force_shutdown( | |||
153 | } | 153 | } |
154 | } | 154 | } |
155 | 155 | ||
156 | |||
157 | /* | ||
158 | * Called when we want to stop a buffer from getting written or read. | ||
159 | * We attach the EIO error, muck with its flags, and call biodone | ||
160 | * so that the proper iodone callbacks get called. | ||
161 | */ | ||
162 | int | ||
163 | xfs_bioerror( | ||
164 | xfs_buf_t *bp) | ||
165 | { | ||
166 | |||
167 | #ifdef XFSERRORDEBUG | ||
168 | ASSERT(XFS_BUF_ISREAD(bp) || bp->b_iodone); | ||
169 | #endif | ||
170 | |||
171 | /* | ||
172 | * No need to wait until the buffer is unpinned. | ||
173 | * We aren't flushing it. | ||
174 | */ | ||
175 | XFS_BUF_ERROR(bp, EIO); | ||
176 | /* | ||
177 | * We're calling biodone, so delete B_DONE flag. Either way | ||
178 | * we have to call the iodone callback, and calling biodone | ||
179 | * probably is the best way since it takes care of | ||
180 | * GRIO as well. | ||
181 | */ | ||
182 | XFS_BUF_UNREAD(bp); | ||
183 | XFS_BUF_UNDELAYWRITE(bp); | ||
184 | XFS_BUF_UNDONE(bp); | ||
185 | XFS_BUF_STALE(bp); | ||
186 | |||
187 | XFS_BUF_CLR_BDSTRAT_FUNC(bp); | ||
188 | xfs_biodone(bp); | ||
189 | |||
190 | return (EIO); | ||
191 | } | ||
192 | |||
193 | /* | ||
194 | * Same as xfs_bioerror, except that we are releasing the buffer | ||
195 | * here ourselves, and avoiding the biodone call. | ||
196 | * This is meant for userdata errors; metadata bufs come with | ||
197 | * iodone functions attached, so that we can track down errors. | ||
198 | */ | ||
199 | int | ||
200 | xfs_bioerror_relse( | ||
201 | xfs_buf_t *bp) | ||
202 | { | ||
203 | int64_t fl; | ||
204 | |||
205 | ASSERT(XFS_BUF_IODONE_FUNC(bp) != xfs_buf_iodone_callbacks); | ||
206 | ASSERT(XFS_BUF_IODONE_FUNC(bp) != xlog_iodone); | ||
207 | |||
208 | fl = XFS_BUF_BFLAGS(bp); | ||
209 | /* | ||
210 | * No need to wait until the buffer is unpinned. | ||
211 | * We aren't flushing it. | ||
212 | * | ||
213 | * chunkhold expects B_DONE to be set, whether | ||
214 | * we actually finish the I/O or not. We don't want to | ||
215 | * change that interface. | ||
216 | */ | ||
217 | XFS_BUF_UNREAD(bp); | ||
218 | XFS_BUF_UNDELAYWRITE(bp); | ||
219 | XFS_BUF_DONE(bp); | ||
220 | XFS_BUF_STALE(bp); | ||
221 | XFS_BUF_CLR_IODONE_FUNC(bp); | ||
222 | XFS_BUF_CLR_BDSTRAT_FUNC(bp); | ||
223 | if (!(fl & XFS_B_ASYNC)) { | ||
224 | /* | ||
225 | * Mark b_error and B_ERROR _both_. | ||
226 | * Lot's of chunkcache code assumes that. | ||
227 | * There's no reason to mark error for | ||
228 | * ASYNC buffers. | ||
229 | */ | ||
230 | XFS_BUF_ERROR(bp, EIO); | ||
231 | XFS_BUF_FINISH_IOWAIT(bp); | ||
232 | } else { | ||
233 | xfs_buf_relse(bp); | ||
234 | } | ||
235 | return (EIO); | ||
236 | } | ||
237 | |||
238 | /* | 156 | /* |
239 | * Prints out an ALERT message about I/O error. | 157 | * Prints out an ALERT message about I/O error. |
240 | */ | 158 | */ |
diff --git a/fs/xfs/xfs_rw.h b/fs/xfs/xfs_rw.h index ff68eb5e738e..a54c3b7cd376 100644 --- a/fs/xfs/xfs_rw.h +++ b/fs/xfs/xfs_rw.h | |||
@@ -40,8 +40,6 @@ xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb) | |||
40 | * Prototypes for functions in xfs_rw.c. | 40 | * Prototypes for functions in xfs_rw.c. |
41 | */ | 41 | */ |
42 | extern int xfs_write_clear_setuid(struct xfs_inode *ip); | 42 | extern int xfs_write_clear_setuid(struct xfs_inode *ip); |
43 | extern int xfs_bioerror(struct xfs_buf *bp); | ||
44 | extern int xfs_bioerror_relse(struct xfs_buf *bp); | ||
45 | extern int xfs_read_buf(struct xfs_mount *mp, xfs_buftarg_t *btp, | 43 | extern int xfs_read_buf(struct xfs_mount *mp, xfs_buftarg_t *btp, |
46 | xfs_daddr_t blkno, int len, uint flags, | 44 | xfs_daddr_t blkno, int len, uint flags, |
47 | struct xfs_buf **bpp); | 45 | struct xfs_buf **bpp); |