aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_iomap.c
diff options
context:
space:
mode:
authorNathan Scott <nathans@sgi.com>2006-09-27 21:03:20 -0400
committerTim Shimmin <tes@sgi.com>2006-09-27 21:03:20 -0400
commit572d95f49f3652fffe8242c4498b85f4083e52ab (patch)
tree5c452a69a005a6a18dc80e4ab7090d6d8e230fc6 /fs/xfs/xfs_iomap.c
parent948ecdb4c118293d2f3e267eec642c30c5d3a056 (diff)
[XFS] Improve error handling for the zero-fsblock extent detection code.
SGI-PV: 955302 SGI-Modid: xfs-linux-melb:xfs-kern:26802a Signed-off-by: Nathan Scott <nathans@sgi.com> Signed-off-by: Tim Shimmin <tes@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_iomap.c')
-rw-r--r--fs/xfs/xfs_iomap.c89
1 files changed, 34 insertions, 55 deletions
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index f1949c16df1..19655124da7 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -398,6 +398,23 @@ xfs_flush_space(
398 return 1; 398 return 1;
399} 399}
400 400
401STATIC int
402xfs_cmn_err_fsblock_zero(
403 xfs_inode_t *ip,
404 xfs_bmbt_irec_t *imap)
405{
406 xfs_cmn_err(XFS_PTAG_FSBLOCK_ZERO, CE_ALERT, ip->i_mount,
407 "Access to block zero in inode %llu "
408 "start_block: %llx start_off: %llx "
409 "blkcnt: %llx extent-state: %x\n",
410 (unsigned long long)ip->i_ino,
411 (unsigned long long)imap->br_startblock,
412 (unsigned long long)imap->br_startoff,
413 (unsigned long long)imap->br_blockcount,
414 imap->br_state);
415 return EFSCORRUPTED;
416}
417
401int 418int
402xfs_iomap_write_direct( 419xfs_iomap_write_direct(
403 xfs_inode_t *ip, 420 xfs_inode_t *ip,
@@ -536,23 +553,17 @@ xfs_iomap_write_direct(
536 * Copy any maps to caller's array and return any error. 553 * Copy any maps to caller's array and return any error.
537 */ 554 */
538 if (nimaps == 0) { 555 if (nimaps == 0) {
539 error = (ENOSPC); 556 error = ENOSPC;
557 goto error_out;
558 }
559
560 if (unlikely(!imap.br_startblock && !(io->io_flags & XFS_IOCORE_RT))) {
561 error = xfs_cmn_err_fsblock_zero(ip, &imap);
540 goto error_out; 562 goto error_out;
541 } 563 }
542 564
543 *ret_imap = imap; 565 *ret_imap = imap;
544 *nmaps = 1; 566 *nmaps = 1;
545 if ( !(io->io_flags & XFS_IOCORE_RT) && !ret_imap->br_startblock) {
546 cmn_err(CE_PANIC,"Access to block zero: fs <%s> inode: %lld "
547 "start_block : %llx start_off : %llx blkcnt : %llx "
548 "extent-state : %x \n",
549 (ip->i_mount)->m_fsname,
550 (long long)ip->i_ino,
551 (unsigned long long)ret_imap->br_startblock,
552 (unsigned long long)ret_imap->br_startoff,
553 (unsigned long long)ret_imap->br_blockcount,
554 ret_imap->br_state);
555 }
556 return 0; 567 return 0;
557 568
558error0: /* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */ 569error0: /* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */
@@ -715,17 +726,8 @@ retry:
715 goto retry; 726 goto retry;
716 } 727 }
717 728
718 if (!(io->io_flags & XFS_IOCORE_RT) && !ret_imap->br_startblock) { 729 if (unlikely(!imap[0].br_startblock && !(io->io_flags & XFS_IOCORE_RT)))
719 cmn_err(CE_PANIC,"Access to block zero: fs <%s> inode: %lld " 730 return xfs_cmn_err_fsblock_zero(ip, &imap[0]);
720 "start_block : %llx start_off : %llx blkcnt : %llx "
721 "extent-state : %x \n",
722 (ip->i_mount)->m_fsname,
723 (long long)ip->i_ino,
724 (unsigned long long)ret_imap->br_startblock,
725 (unsigned long long)ret_imap->br_startoff,
726 (unsigned long long)ret_imap->br_blockcount,
727 ret_imap->br_state);
728 }
729 731
730 *ret_imap = imap[0]; 732 *ret_imap = imap[0];
731 *nmaps = 1; 733 *nmaps = 1;
@@ -853,24 +855,10 @@ xfs_iomap_write_allocate(
853 * See if we were able to allocate an extent that 855 * See if we were able to allocate an extent that
854 * covers at least part of the callers request 856 * covers at least part of the callers request
855 */ 857 */
856
857 for (i = 0; i < nimaps; i++) { 858 for (i = 0; i < nimaps; i++) {
858 if (!(io->io_flags & XFS_IOCORE_RT) && 859 if (unlikely(!imap[i].br_startblock &&
859 !imap[i].br_startblock) { 860 !(io->io_flags & XFS_IOCORE_RT)))
860 cmn_err(CE_PANIC,"Access to block zero: " 861 return xfs_cmn_err_fsblock_zero(ip, &imap[i]);
861 "fs <%s> inode: %lld "
862 "start_block : %llx start_off : %llx "
863 "blkcnt : %llx extent-state : %x \n",
864 (ip->i_mount)->m_fsname,
865 (long long)ip->i_ino,
866 (unsigned long long)
867 imap[i].br_startblock,
868 (unsigned long long)
869 imap[i].br_startoff,
870 (unsigned long long)
871 imap[i].br_blockcount,
872 imap[i].br_state);
873 }
874 if ((offset_fsb >= imap[i].br_startoff) && 862 if ((offset_fsb >= imap[i].br_startoff) &&
875 (offset_fsb < (imap[i].br_startoff + 863 (offset_fsb < (imap[i].br_startoff +
876 imap[i].br_blockcount))) { 864 imap[i].br_blockcount))) {
@@ -941,7 +929,7 @@ xfs_iomap_write_unwritten(
941 XFS_WRITE_LOG_COUNT); 929 XFS_WRITE_LOG_COUNT);
942 if (error) { 930 if (error) {
943 xfs_trans_cancel(tp, 0); 931 xfs_trans_cancel(tp, 0);
944 goto error0; 932 return XFS_ERROR(error);
945 } 933 }
946 934
947 xfs_ilock(ip, XFS_ILOCK_EXCL); 935 xfs_ilock(ip, XFS_ILOCK_EXCL);
@@ -967,19 +955,11 @@ xfs_iomap_write_unwritten(
967 error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES, NULL); 955 error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES, NULL);
968 xfs_iunlock(ip, XFS_ILOCK_EXCL); 956 xfs_iunlock(ip, XFS_ILOCK_EXCL);
969 if (error) 957 if (error)
970 goto error0; 958 return XFS_ERROR(error);
971 959
972 if ( !(io->io_flags & XFS_IOCORE_RT) && !imap.br_startblock) { 960 if (unlikely(!imap.br_startblock &&
973 cmn_err(CE_PANIC,"Access to block zero: fs <%s> " 961 !(io->io_flags & XFS_IOCORE_RT)))
974 "inode: %lld start_block : %llx start_off : " 962 return xfs_cmn_err_fsblock_zero(ip, &imap);
975 "%llx blkcnt : %llx extent-state : %x \n",
976 (ip->i_mount)->m_fsname,
977 (long long)ip->i_ino,
978 (unsigned long long)imap.br_startblock,
979 (unsigned long long)imap.br_startoff,
980 (unsigned long long)imap.br_blockcount,
981 imap.br_state);
982 }
983 963
984 if ((numblks_fsb = imap.br_blockcount) == 0) { 964 if ((numblks_fsb = imap.br_blockcount) == 0) {
985 /* 965 /*
@@ -999,6 +979,5 @@ error_on_bmapi_transaction:
999 xfs_bmap_cancel(&free_list); 979 xfs_bmap_cancel(&free_list);
1000 xfs_trans_cancel(tp, (XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT)); 980 xfs_trans_cancel(tp, (XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT));
1001 xfs_iunlock(ip, XFS_ILOCK_EXCL); 981 xfs_iunlock(ip, XFS_ILOCK_EXCL);
1002error0:
1003 return XFS_ERROR(error); 982 return XFS_ERROR(error);
1004} 983}