diff options
-rw-r--r-- | fs/xfs/xfs_buf.c | 18 | ||||
-rw-r--r-- | fs/xfs/xfs_buf.h | 6 | ||||
-rw-r--r-- | fs/xfs/xfs_fsops.c | 11 | ||||
-rw-r--r-- | fs/xfs/xfs_mount.c | 55 | ||||
-rw-r--r-- | fs/xfs/xfs_rtalloc.c | 30 |
5 files changed, 58 insertions, 62 deletions
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index d99ec8335750..6fbcbbfb4d1a 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c | |||
@@ -688,29 +688,39 @@ xfs_buf_readahead_map( | |||
688 | * Read an uncached buffer from disk. Allocates and returns a locked | 688 | * Read an uncached buffer from disk. Allocates and returns a locked |
689 | * buffer containing the disk contents or nothing. | 689 | * buffer containing the disk contents or nothing. |
690 | */ | 690 | */ |
691 | struct xfs_buf * | 691 | int |
692 | xfs_buf_read_uncached( | 692 | xfs_buf_read_uncached( |
693 | struct xfs_buftarg *target, | 693 | struct xfs_buftarg *target, |
694 | xfs_daddr_t daddr, | 694 | xfs_daddr_t daddr, |
695 | size_t numblks, | 695 | size_t numblks, |
696 | int flags, | 696 | int flags, |
697 | struct xfs_buf **bpp, | ||
697 | const struct xfs_buf_ops *ops) | 698 | const struct xfs_buf_ops *ops) |
698 | { | 699 | { |
699 | struct xfs_buf *bp; | 700 | struct xfs_buf *bp; |
700 | 701 | ||
702 | *bpp = NULL; | ||
703 | |||
701 | bp = xfs_buf_get_uncached(target, numblks, flags); | 704 | bp = xfs_buf_get_uncached(target, numblks, flags); |
702 | if (!bp) | 705 | if (!bp) |
703 | return NULL; | 706 | return -ENOMEM; |
704 | 707 | ||
705 | /* set up the buffer for a read IO */ | 708 | /* set up the buffer for a read IO */ |
706 | ASSERT(bp->b_map_count == 1); | 709 | ASSERT(bp->b_map_count == 1); |
707 | bp->b_bn = daddr; | 710 | bp->b_bn = XFS_BUF_DADDR_NULL; /* always null for uncached buffers */ |
708 | bp->b_maps[0].bm_bn = daddr; | 711 | bp->b_maps[0].bm_bn = daddr; |
709 | bp->b_flags |= XBF_READ; | 712 | bp->b_flags |= XBF_READ; |
710 | bp->b_ops = ops; | 713 | bp->b_ops = ops; |
711 | 714 | ||
712 | xfs_buf_submit_wait(bp); | 715 | xfs_buf_submit_wait(bp); |
713 | return bp; | 716 | if (bp->b_error) { |
717 | int error = bp->b_error; | ||
718 | xfs_buf_relse(bp); | ||
719 | return error; | ||
720 | } | ||
721 | |||
722 | *bpp = bp; | ||
723 | return 0; | ||
714 | } | 724 | } |
715 | 725 | ||
716 | /* | 726 | /* |
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h index 0acfc30ec0fd..82002c00af90 100644 --- a/fs/xfs/xfs_buf.h +++ b/fs/xfs/xfs_buf.h | |||
@@ -269,9 +269,9 @@ int xfs_buf_associate_memory(struct xfs_buf *bp, void *mem, size_t length); | |||
269 | 269 | ||
270 | struct xfs_buf *xfs_buf_get_uncached(struct xfs_buftarg *target, size_t numblks, | 270 | struct xfs_buf *xfs_buf_get_uncached(struct xfs_buftarg *target, size_t numblks, |
271 | int flags); | 271 | int flags); |
272 | struct xfs_buf *xfs_buf_read_uncached(struct xfs_buftarg *target, | 272 | int xfs_buf_read_uncached(struct xfs_buftarg *target, xfs_daddr_t daddr, |
273 | xfs_daddr_t daddr, size_t numblks, int flags, | 273 | size_t numblks, int flags, struct xfs_buf **bpp, |
274 | const struct xfs_buf_ops *ops); | 274 | const struct xfs_buf_ops *ops); |
275 | void xfs_buf_hold(struct xfs_buf *bp); | 275 | void xfs_buf_hold(struct xfs_buf *bp); |
276 | 276 | ||
277 | /* Releasing Buffers */ | 277 | /* Releasing Buffers */ |
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index f91de1ef05e1..c05ac8b70fa9 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c | |||
@@ -172,16 +172,11 @@ xfs_growfs_data_private( | |||
172 | if ((error = xfs_sb_validate_fsb_count(&mp->m_sb, nb))) | 172 | if ((error = xfs_sb_validate_fsb_count(&mp->m_sb, nb))) |
173 | return error; | 173 | return error; |
174 | dpct = pct - mp->m_sb.sb_imax_pct; | 174 | dpct = pct - mp->m_sb.sb_imax_pct; |
175 | bp = xfs_buf_read_uncached(mp->m_ddev_targp, | 175 | error = xfs_buf_read_uncached(mp->m_ddev_targp, |
176 | XFS_FSB_TO_BB(mp, nb) - XFS_FSS_TO_BB(mp, 1), | 176 | XFS_FSB_TO_BB(mp, nb) - XFS_FSS_TO_BB(mp, 1), |
177 | XFS_FSS_TO_BB(mp, 1), 0, NULL); | 177 | XFS_FSS_TO_BB(mp, 1), 0, &bp, NULL); |
178 | if (!bp) | 178 | if (error) |
179 | return -EIO; | ||
180 | if (bp->b_error) { | ||
181 | error = bp->b_error; | ||
182 | xfs_buf_relse(bp); | ||
183 | return error; | 179 | return error; |
184 | } | ||
185 | xfs_buf_relse(bp); | 180 | xfs_buf_relse(bp); |
186 | 181 | ||
187 | new = nb; /* use new as a temporary here */ | 182 | new = nb; /* use new as a temporary here */ |
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index fbf0384a466f..142c460fc64e 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c | |||
@@ -302,21 +302,15 @@ xfs_readsb( | |||
302 | * access to the superblock. | 302 | * access to the superblock. |
303 | */ | 303 | */ |
304 | reread: | 304 | reread: |
305 | bp = xfs_buf_read_uncached(mp->m_ddev_targp, XFS_SB_DADDR, | 305 | error = xfs_buf_read_uncached(mp->m_ddev_targp, XFS_SB_DADDR, |
306 | BTOBB(sector_size), 0, buf_ops); | 306 | BTOBB(sector_size), 0, &bp, buf_ops); |
307 | if (!bp) { | 307 | if (error) { |
308 | if (loud) | ||
309 | xfs_warn(mp, "SB buffer read failed"); | ||
310 | return -EIO; | ||
311 | } | ||
312 | if (bp->b_error) { | ||
313 | error = bp->b_error; | ||
314 | if (loud) | 308 | if (loud) |
315 | xfs_warn(mp, "SB validate failed with error %d.", error); | 309 | xfs_warn(mp, "SB validate failed with error %d.", error); |
316 | /* bad CRC means corrupted metadata */ | 310 | /* bad CRC means corrupted metadata */ |
317 | if (error == -EFSBADCRC) | 311 | if (error == -EFSBADCRC) |
318 | error = -EFSCORRUPTED; | 312 | error = -EFSCORRUPTED; |
319 | goto release_buf; | 313 | return error; |
320 | } | 314 | } |
321 | 315 | ||
322 | /* | 316 | /* |
@@ -546,40 +540,43 @@ xfs_set_inoalignment(xfs_mount_t *mp) | |||
546 | * Check that the data (and log if separate) is an ok size. | 540 | * Check that the data (and log if separate) is an ok size. |
547 | */ | 541 | */ |
548 | STATIC int | 542 | STATIC int |
549 | xfs_check_sizes(xfs_mount_t *mp) | 543 | xfs_check_sizes( |
544 | struct xfs_mount *mp) | ||
550 | { | 545 | { |
551 | xfs_buf_t *bp; | 546 | struct xfs_buf *bp; |
552 | xfs_daddr_t d; | 547 | xfs_daddr_t d; |
548 | int error; | ||
553 | 549 | ||
554 | d = (xfs_daddr_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks); | 550 | d = (xfs_daddr_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks); |
555 | if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_dblocks) { | 551 | if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_dblocks) { |
556 | xfs_warn(mp, "filesystem size mismatch detected"); | 552 | xfs_warn(mp, "filesystem size mismatch detected"); |
557 | return -EFBIG; | 553 | return -EFBIG; |
558 | } | 554 | } |
559 | bp = xfs_buf_read_uncached(mp->m_ddev_targp, | 555 | error = xfs_buf_read_uncached(mp->m_ddev_targp, |
560 | d - XFS_FSS_TO_BB(mp, 1), | 556 | d - XFS_FSS_TO_BB(mp, 1), |
561 | XFS_FSS_TO_BB(mp, 1), 0, NULL); | 557 | XFS_FSS_TO_BB(mp, 1), 0, &bp, NULL); |
562 | if (!bp) { | 558 | if (error) { |
563 | xfs_warn(mp, "last sector read failed"); | 559 | xfs_warn(mp, "last sector read failed"); |
564 | return -EIO; | 560 | return error; |
565 | } | 561 | } |
566 | xfs_buf_relse(bp); | 562 | xfs_buf_relse(bp); |
567 | 563 | ||
568 | if (mp->m_logdev_targp != mp->m_ddev_targp) { | 564 | if (mp->m_logdev_targp == mp->m_ddev_targp) |
569 | d = (xfs_daddr_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks); | 565 | return 0; |
570 | if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_logblocks) { | 566 | |
571 | xfs_warn(mp, "log size mismatch detected"); | 567 | d = (xfs_daddr_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks); |
572 | return -EFBIG; | 568 | if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_logblocks) { |
573 | } | 569 | xfs_warn(mp, "log size mismatch detected"); |
574 | bp = xfs_buf_read_uncached(mp->m_logdev_targp, | 570 | return -EFBIG; |
571 | } | ||
572 | error = xfs_buf_read_uncached(mp->m_logdev_targp, | ||
575 | d - XFS_FSB_TO_BB(mp, 1), | 573 | d - XFS_FSB_TO_BB(mp, 1), |
576 | XFS_FSB_TO_BB(mp, 1), 0, NULL); | 574 | XFS_FSB_TO_BB(mp, 1), 0, &bp, NULL); |
577 | if (!bp) { | 575 | if (error) { |
578 | xfs_warn(mp, "log device read failed"); | 576 | xfs_warn(mp, "log device read failed"); |
579 | return -EIO; | 577 | return error; |
580 | } | ||
581 | xfs_buf_relse(bp); | ||
582 | } | 578 | } |
579 | xfs_buf_relse(bp); | ||
583 | return 0; | 580 | return 0; |
584 | } | 581 | } |
585 | 582 | ||
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 909e143b87ae..1ad00937b485 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c | |||
@@ -972,16 +972,11 @@ xfs_growfs_rt( | |||
972 | /* | 972 | /* |
973 | * Read in the last block of the device, make sure it exists. | 973 | * Read in the last block of the device, make sure it exists. |
974 | */ | 974 | */ |
975 | bp = xfs_buf_read_uncached(mp->m_rtdev_targp, | 975 | error = xfs_buf_read_uncached(mp->m_rtdev_targp, |
976 | XFS_FSB_TO_BB(mp, nrblocks - 1), | 976 | XFS_FSB_TO_BB(mp, nrblocks - 1), |
977 | XFS_FSB_TO_BB(mp, 1), 0, NULL); | 977 | XFS_FSB_TO_BB(mp, 1), 0, &bp, NULL); |
978 | if (!bp) | 978 | if (error) |
979 | return -EIO; | ||
980 | if (bp->b_error) { | ||
981 | error = bp->b_error; | ||
982 | xfs_buf_relse(bp); | ||
983 | return error; | 979 | return error; |
984 | } | ||
985 | xfs_buf_relse(bp); | 980 | xfs_buf_relse(bp); |
986 | 981 | ||
987 | /* | 982 | /* |
@@ -1235,11 +1230,12 @@ xfs_rtallocate_extent( | |||
1235 | */ | 1230 | */ |
1236 | int /* error */ | 1231 | int /* error */ |
1237 | xfs_rtmount_init( | 1232 | xfs_rtmount_init( |
1238 | xfs_mount_t *mp) /* file system mount structure */ | 1233 | struct xfs_mount *mp) /* file system mount structure */ |
1239 | { | 1234 | { |
1240 | xfs_buf_t *bp; /* buffer for last block of subvolume */ | 1235 | struct xfs_buf *bp; /* buffer for last block of subvolume */ |
1241 | xfs_daddr_t d; /* address of last block of subvolume */ | 1236 | struct xfs_sb *sbp; /* filesystem superblock copy in mount */ |
1242 | xfs_sb_t *sbp; /* filesystem superblock copy in mount */ | 1237 | xfs_daddr_t d; /* address of last block of subvolume */ |
1238 | int error; | ||
1243 | 1239 | ||
1244 | sbp = &mp->m_sb; | 1240 | sbp = &mp->m_sb; |
1245 | if (sbp->sb_rblocks == 0) | 1241 | if (sbp->sb_rblocks == 0) |
@@ -1265,14 +1261,12 @@ xfs_rtmount_init( | |||
1265 | (unsigned long long) mp->m_sb.sb_rblocks); | 1261 | (unsigned long long) mp->m_sb.sb_rblocks); |
1266 | return -EFBIG; | 1262 | return -EFBIG; |
1267 | } | 1263 | } |
1268 | bp = xfs_buf_read_uncached(mp->m_rtdev_targp, | 1264 | error = xfs_buf_read_uncached(mp->m_rtdev_targp, |
1269 | d - XFS_FSB_TO_BB(mp, 1), | 1265 | d - XFS_FSB_TO_BB(mp, 1), |
1270 | XFS_FSB_TO_BB(mp, 1), 0, NULL); | 1266 | XFS_FSB_TO_BB(mp, 1), 0, &bp, NULL); |
1271 | if (!bp || bp->b_error) { | 1267 | if (error) { |
1272 | xfs_warn(mp, "realtime device size check failed"); | 1268 | xfs_warn(mp, "realtime device size check failed"); |
1273 | if (bp) | 1269 | return error; |
1274 | xfs_buf_relse(bp); | ||
1275 | return -EIO; | ||
1276 | } | 1270 | } |
1277 | xfs_buf_relse(bp); | 1271 | xfs_buf_relse(bp); |
1278 | return 0; | 1272 | return 0; |