diff options
-rw-r--r-- | fs/xfs/xfs_inode.c | 131 | ||||
-rw-r--r-- | fs/xfs/xfs_inode.h | 6 | ||||
-rw-r--r-- | fs/xfs/xfs_itable.c | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_log_recover.c | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_sync.c | 4 |
5 files changed, 54 insertions, 91 deletions
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 257f3c463e0e..34c985de5fa0 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c | |||
@@ -132,23 +132,28 @@ xfs_inobp_check( | |||
132 | #endif | 132 | #endif |
133 | 133 | ||
134 | /* | 134 | /* |
135 | * Find the buffer associated with the given inode map | 135 | * This routine is called to map an inode to the buffer containing the on-disk |
136 | * We do basic validation checks on the buffer once it has been | 136 | * version of the inode. It returns a pointer to the buffer containing the |
137 | * retrieved from disk. | 137 | * on-disk inode in the bpp parameter, and in the dipp parameter it returns a |
138 | * pointer to the on-disk inode within that buffer. | ||
139 | * | ||
140 | * If a non-zero error is returned, then the contents of bpp and dipp are | ||
141 | * undefined. | ||
138 | */ | 142 | */ |
139 | STATIC int | 143 | int |
140 | xfs_imap_to_bp( | 144 | xfs_imap_to_bp( |
141 | xfs_mount_t *mp, | 145 | struct xfs_mount *mp, |
142 | xfs_trans_t *tp, | 146 | struct xfs_trans *tp, |
143 | struct xfs_imap *imap, | 147 | struct xfs_imap *imap, |
144 | xfs_buf_t **bpp, | 148 | struct xfs_dinode **dipp, |
145 | uint buf_flags, | 149 | struct xfs_buf **bpp, |
146 | uint iget_flags) | 150 | uint buf_flags, |
151 | uint iget_flags) | ||
147 | { | 152 | { |
148 | int error; | 153 | struct xfs_buf *bp; |
149 | int i; | 154 | int error; |
150 | int ni; | 155 | int i; |
151 | xfs_buf_t *bp; | 156 | int ni; |
152 | 157 | ||
153 | buf_flags |= XBF_UNMAPPED; | 158 | buf_flags |= XBF_UNMAPPED; |
154 | error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, imap->im_blkno, | 159 | error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, imap->im_blkno, |
@@ -189,8 +194,8 @@ xfs_imap_to_bp( | |||
189 | xfs_trans_brelse(tp, bp); | 194 | xfs_trans_brelse(tp, bp); |
190 | return XFS_ERROR(EINVAL); | 195 | return XFS_ERROR(EINVAL); |
191 | } | 196 | } |
192 | XFS_CORRUPTION_ERROR("xfs_imap_to_bp", | 197 | XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_HIGH, |
193 | XFS_ERRLEVEL_HIGH, mp, dip); | 198 | mp, dip); |
194 | #ifdef DEBUG | 199 | #ifdef DEBUG |
195 | xfs_emerg(mp, | 200 | xfs_emerg(mp, |
196 | "bad inode magic/vsn daddr %lld #%d (magic=%x)", | 201 | "bad inode magic/vsn daddr %lld #%d (magic=%x)", |
@@ -204,7 +209,9 @@ xfs_imap_to_bp( | |||
204 | } | 209 | } |
205 | 210 | ||
206 | xfs_inobp_check(mp, bp); | 211 | xfs_inobp_check(mp, bp); |
212 | |||
207 | *bpp = bp; | 213 | *bpp = bp; |
214 | *dipp = (struct xfs_dinode *)xfs_buf_offset(bp, imap->im_boffset); | ||
208 | return 0; | 215 | return 0; |
209 | } | 216 | } |
210 | 217 | ||
@@ -240,63 +247,15 @@ xfs_inotobp( | |||
240 | if (error) | 247 | if (error) |
241 | return error; | 248 | return error; |
242 | 249 | ||
243 | error = xfs_imap_to_bp(mp, tp, &imap, &bp, 0, imap_flags); | 250 | error = xfs_imap_to_bp(mp, tp, &imap, dipp, &bp, 0, imap_flags); |
244 | if (error) | 251 | if (error) |
245 | return error; | 252 | return error; |
246 | 253 | ||
247 | *dipp = (xfs_dinode_t *)xfs_buf_offset(bp, imap.im_boffset); | ||
248 | *bpp = bp; | 254 | *bpp = bp; |
249 | *offset = imap.im_boffset; | 255 | *offset = imap.im_boffset; |
250 | return 0; | 256 | return 0; |
251 | } | 257 | } |
252 | 258 | ||
253 | |||
254 | /* | ||
255 | * This routine is called to map an inode to the buffer containing | ||
256 | * the on-disk version of the inode. It returns a pointer to the | ||
257 | * buffer containing the on-disk inode in the bpp parameter, and in | ||
258 | * the dip parameter it returns a pointer to the on-disk inode within | ||
259 | * that buffer. | ||
260 | * | ||
261 | * If a non-zero error is returned, then the contents of bpp and | ||
262 | * dipp are undefined. | ||
263 | * | ||
264 | * The inode is expected to already been mapped to its buffer and read | ||
265 | * in once, thus we can use the mapping information stored in the inode | ||
266 | * rather than calling xfs_imap(). This allows us to avoid the overhead | ||
267 | * of looking at the inode btree for small block file systems | ||
268 | * (see xfs_imap()). | ||
269 | */ | ||
270 | int | ||
271 | xfs_itobp( | ||
272 | xfs_mount_t *mp, | ||
273 | xfs_trans_t *tp, | ||
274 | xfs_inode_t *ip, | ||
275 | xfs_dinode_t **dipp, | ||
276 | xfs_buf_t **bpp, | ||
277 | uint buf_flags) | ||
278 | { | ||
279 | xfs_buf_t *bp; | ||
280 | int error; | ||
281 | |||
282 | ASSERT(ip->i_imap.im_blkno != 0); | ||
283 | |||
284 | error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &bp, buf_flags, 0); | ||
285 | if (error) | ||
286 | return error; | ||
287 | |||
288 | if (!bp) { | ||
289 | ASSERT(buf_flags & XBF_TRYLOCK); | ||
290 | ASSERT(tp == NULL); | ||
291 | *bpp = NULL; | ||
292 | return EAGAIN; | ||
293 | } | ||
294 | |||
295 | *dipp = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset); | ||
296 | *bpp = bp; | ||
297 | return 0; | ||
298 | } | ||
299 | |||
300 | /* | 259 | /* |
301 | * Move inode type and inode format specific information from the | 260 | * Move inode type and inode format specific information from the |
302 | * on-disk inode to the in-core inode. For fifos, devs, and sockets | 261 | * on-disk inode to the in-core inode. For fifos, devs, and sockets |
@@ -796,10 +755,9 @@ xfs_iread( | |||
796 | /* | 755 | /* |
797 | * Get pointers to the on-disk inode and the buffer containing it. | 756 | * Get pointers to the on-disk inode and the buffer containing it. |
798 | */ | 757 | */ |
799 | error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &bp, 0, iget_flags); | 758 | error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &dip, &bp, 0, iget_flags); |
800 | if (error) | 759 | if (error) |
801 | return error; | 760 | return error; |
802 | dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset); | ||
803 | 761 | ||
804 | /* | 762 | /* |
805 | * If we got something that isn't an inode it means someone | 763 | * If we got something that isn't an inode it means someone |
@@ -876,7 +834,7 @@ xfs_iread( | |||
876 | /* | 834 | /* |
877 | * Use xfs_trans_brelse() to release the buffer containing the | 835 | * Use xfs_trans_brelse() to release the buffer containing the |
878 | * on-disk inode, because it was acquired with xfs_trans_read_buf() | 836 | * on-disk inode, because it was acquired with xfs_trans_read_buf() |
879 | * in xfs_itobp() above. If tp is NULL, this is just a normal | 837 | * in xfs_imap_to_bp() above. If tp is NULL, this is just a normal |
880 | * brelse(). If we're within a transaction, then xfs_trans_brelse() | 838 | * brelse(). If we're within a transaction, then xfs_trans_brelse() |
881 | * will only release the buffer if it is not dirty within the | 839 | * will only release the buffer if it is not dirty within the |
882 | * transaction. It will be OK to release the buffer in this case, | 840 | * transaction. It will be OK to release the buffer in this case, |
@@ -1355,7 +1313,8 @@ xfs_iunlink( | |||
1355 | * Here we put the head pointer into our next pointer, | 1313 | * Here we put the head pointer into our next pointer, |
1356 | * and then we fall through to point the head at us. | 1314 | * and then we fall through to point the head at us. |
1357 | */ | 1315 | */ |
1358 | error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0); | 1316 | error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &dip, &ibp, |
1317 | 0, 0); | ||
1359 | if (error) | 1318 | if (error) |
1360 | return error; | 1319 | return error; |
1361 | 1320 | ||
@@ -1429,16 +1388,16 @@ xfs_iunlink_remove( | |||
1429 | 1388 | ||
1430 | if (be32_to_cpu(agi->agi_unlinked[bucket_index]) == agino) { | 1389 | if (be32_to_cpu(agi->agi_unlinked[bucket_index]) == agino) { |
1431 | /* | 1390 | /* |
1432 | * We're at the head of the list. Get the inode's | 1391 | * We're at the head of the list. Get the inode's on-disk |
1433 | * on-disk buffer to see if there is anyone after us | 1392 | * buffer to see if there is anyone after us on the list. |
1434 | * on the list. Only modify our next pointer if it | 1393 | * Only modify our next pointer if it is not already NULLAGINO. |
1435 | * is not already NULLAGINO. This saves us the overhead | 1394 | * This saves us the overhead of dealing with the buffer when |
1436 | * of dealing with the buffer when there is no need to | 1395 | * there is no need to change it. |
1437 | * change it. | ||
1438 | */ | 1396 | */ |
1439 | error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0); | 1397 | error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &dip, &ibp, |
1398 | 0, 0); | ||
1440 | if (error) { | 1399 | if (error) { |
1441 | xfs_warn(mp, "%s: xfs_itobp() returned error %d.", | 1400 | xfs_warn(mp, "%s: xfs_imap_to_bp returned error %d.", |
1442 | __func__, error); | 1401 | __func__, error); |
1443 | return error; | 1402 | return error; |
1444 | } | 1403 | } |
@@ -1493,13 +1452,15 @@ xfs_iunlink_remove( | |||
1493 | ASSERT(next_agino != NULLAGINO); | 1452 | ASSERT(next_agino != NULLAGINO); |
1494 | ASSERT(next_agino != 0); | 1453 | ASSERT(next_agino != 0); |
1495 | } | 1454 | } |
1455 | |||
1496 | /* | 1456 | /* |
1497 | * Now last_ibp points to the buffer previous to us on | 1457 | * Now last_ibp points to the buffer previous to us on the |
1498 | * the unlinked list. Pull us from the list. | 1458 | * unlinked list. Pull us from the list. |
1499 | */ | 1459 | */ |
1500 | error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0); | 1460 | error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &dip, &ibp, |
1461 | 0, 0); | ||
1501 | if (error) { | 1462 | if (error) { |
1502 | xfs_warn(mp, "%s: xfs_itobp(2) returned error %d.", | 1463 | xfs_warn(mp, "%s: xfs_imap_to_bp(2) returned error %d.", |
1503 | __func__, error); | 1464 | __func__, error); |
1504 | return error; | 1465 | return error; |
1505 | } | 1466 | } |
@@ -1749,7 +1710,8 @@ xfs_ifree( | |||
1749 | 1710 | ||
1750 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | 1711 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); |
1751 | 1712 | ||
1752 | error = xfs_itobp(ip->i_mount, tp, ip, &dip, &ibp, 0); | 1713 | error = xfs_imap_to_bp(ip->i_mount, tp, &ip->i_imap, &dip, &ibp, |
1714 | 0, 0); | ||
1753 | if (error) | 1715 | if (error) |
1754 | return error; | 1716 | return error; |
1755 | 1717 | ||
@@ -2428,7 +2390,7 @@ xfs_iflush( | |||
2428 | /* | 2390 | /* |
2429 | * For stale inodes we cannot rely on the backing buffer remaining | 2391 | * For stale inodes we cannot rely on the backing buffer remaining |
2430 | * stale in cache for the remaining life of the stale inode and so | 2392 | * stale in cache for the remaining life of the stale inode and so |
2431 | * xfs_itobp() below may give us a buffer that no longer contains | 2393 | * xfs_imap_to_bp() below may give us a buffer that no longer contains |
2432 | * inodes below. We have to check this after ensuring the inode is | 2394 | * inodes below. We have to check this after ensuring the inode is |
2433 | * unpinned so that it is safe to reclaim the stale inode after the | 2395 | * unpinned so that it is safe to reclaim the stale inode after the |
2434 | * flush call. | 2396 | * flush call. |
@@ -2454,7 +2416,8 @@ xfs_iflush( | |||
2454 | /* | 2416 | /* |
2455 | * Get the buffer containing the on-disk inode. | 2417 | * Get the buffer containing the on-disk inode. |
2456 | */ | 2418 | */ |
2457 | error = xfs_itobp(mp, NULL, ip, &dip, &bp, XBF_TRYLOCK); | 2419 | error = xfs_imap_to_bp(mp, NULL, &ip->i_imap, &dip, &bp, XBF_TRYLOCK, |
2420 | 0); | ||
2458 | if (error || !bp) { | 2421 | if (error || !bp) { |
2459 | xfs_ifunlock(ip); | 2422 | xfs_ifunlock(ip); |
2460 | return error; | 2423 | return error; |
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 1efff36a75b6..942fd7f9110b 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h | |||
@@ -560,9 +560,9 @@ do { \ | |||
560 | int xfs_inotobp(struct xfs_mount *, struct xfs_trans *, | 560 | int xfs_inotobp(struct xfs_mount *, struct xfs_trans *, |
561 | xfs_ino_t, struct xfs_dinode **, | 561 | xfs_ino_t, struct xfs_dinode **, |
562 | struct xfs_buf **, int *, uint); | 562 | struct xfs_buf **, int *, uint); |
563 | int xfs_itobp(struct xfs_mount *, struct xfs_trans *, | 563 | int xfs_imap_to_bp(struct xfs_mount *, struct xfs_trans *, |
564 | struct xfs_inode *, struct xfs_dinode **, | 564 | struct xfs_imap *, struct xfs_dinode **, |
565 | struct xfs_buf **, uint); | 565 | struct xfs_buf **, uint, uint); |
566 | int xfs_iread(struct xfs_mount *, struct xfs_trans *, | 566 | int xfs_iread(struct xfs_mount *, struct xfs_trans *, |
567 | struct xfs_inode *, uint); | 567 | struct xfs_inode *, uint); |
568 | void xfs_dinode_to_disk(struct xfs_dinode *, | 568 | void xfs_dinode_to_disk(struct xfs_dinode *, |
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c index eff577a9b67f..01d10a66e302 100644 --- a/fs/xfs/xfs_itable.c +++ b/fs/xfs/xfs_itable.c | |||
@@ -555,7 +555,7 @@ xfs_bulkstat_single( | |||
555 | 555 | ||
556 | /* | 556 | /* |
557 | * note that requesting valid inode numbers which are not allocated | 557 | * note that requesting valid inode numbers which are not allocated |
558 | * to inodes will most likely cause xfs_itobp to generate warning | 558 | * to inodes will most likely cause xfs_imap_to_bp to generate warning |
559 | * messages about bad magic numbers. This is ok. The fact that | 559 | * messages about bad magic numbers. This is ok. The fact that |
560 | * the inode isn't actually an inode is handled by the | 560 | * the inode isn't actually an inode is handled by the |
561 | * error check below. Done this way to make the usual case faster | 561 | * error check below. Done this way to make the usual case faster |
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index a76ba886e738..5da3ace352bf 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c | |||
@@ -3106,7 +3106,7 @@ xlog_recover_process_one_iunlink( | |||
3106 | /* | 3106 | /* |
3107 | * Get the on disk inode to find the next inode in the bucket. | 3107 | * Get the on disk inode to find the next inode in the bucket. |
3108 | */ | 3108 | */ |
3109 | error = xfs_itobp(mp, NULL, ip, &dip, &ibp, 0); | 3109 | error = xfs_imap_to_bp(mp, NULL, &ip->i_imap, &dip, &ibp, 0, 0); |
3110 | if (error) | 3110 | if (error) |
3111 | goto fail_iput; | 3111 | goto fail_iput; |
3112 | 3112 | ||
diff --git a/fs/xfs/xfs_sync.c b/fs/xfs/xfs_sync.c index 1e9ee064dbb2..e61fc1519073 100644 --- a/fs/xfs/xfs_sync.c +++ b/fs/xfs/xfs_sync.c | |||
@@ -712,8 +712,8 @@ restart: | |||
712 | * Note that xfs_iflush will never block on the inode buffer lock, as | 712 | * Note that xfs_iflush will never block on the inode buffer lock, as |
713 | * xfs_ifree_cluster() can lock the inode buffer before it locks the | 713 | * xfs_ifree_cluster() can lock the inode buffer before it locks the |
714 | * ip->i_lock, and we are doing the exact opposite here. As a result, | 714 | * ip->i_lock, and we are doing the exact opposite here. As a result, |
715 | * doing a blocking xfs_itobp() to get the cluster buffer would result | 715 | * doing a blocking xfs_imap_to_bp() to get the cluster buffer would |
716 | * in an ABBA deadlock with xfs_ifree_cluster(). | 716 | * result in an ABBA deadlock with xfs_ifree_cluster(). |
717 | * | 717 | * |
718 | * As xfs_ifree_cluser() must gather all inodes that are active in the | 718 | * As xfs_ifree_cluser() must gather all inodes that are active in the |
719 | * cache to mark them stale, if we hit this case we don't actually want | 719 | * cache to mark them stale, if we hit this case we don't actually want |