diff options
Diffstat (limited to 'fs/xfs/xfs_inode.c')
-rw-r--r-- | fs/xfs/xfs_inode.c | 213 |
1 files changed, 107 insertions, 106 deletions
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index bc9e7c891809..41a0c73b601a 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c | |||
@@ -193,8 +193,8 @@ xfs_inotobp( | |||
193 | } | 193 | } |
194 | dip = (xfs_dinode_t *)xfs_buf_offset(bp, 0); | 194 | dip = (xfs_dinode_t *)xfs_buf_offset(bp, 0); |
195 | di_ok = | 195 | di_ok = |
196 | INT_GET(dip->di_core.di_magic, ARCH_CONVERT) == XFS_DINODE_MAGIC && | 196 | be16_to_cpu(dip->di_core.di_magic) == XFS_DINODE_MAGIC && |
197 | XFS_DINODE_GOOD_VERSION(INT_GET(dip->di_core.di_version, ARCH_CONVERT)); | 197 | XFS_DINODE_GOOD_VERSION(dip->di_core.di_version); |
198 | if (unlikely(XFS_TEST_ERROR(!di_ok, mp, XFS_ERRTAG_ITOBP_INOTOBP, | 198 | if (unlikely(XFS_TEST_ERROR(!di_ok, mp, XFS_ERRTAG_ITOBP_INOTOBP, |
199 | XFS_RANDOM_ITOBP_INOTOBP))) { | 199 | XFS_RANDOM_ITOBP_INOTOBP))) { |
200 | XFS_CORRUPTION_ERROR("xfs_inotobp", XFS_ERRLEVEL_LOW, mp, dip); | 200 | XFS_CORRUPTION_ERROR("xfs_inotobp", XFS_ERRLEVEL_LOW, mp, dip); |
@@ -338,8 +338,8 @@ xfs_itobp( | |||
338 | 338 | ||
339 | dip = (xfs_dinode_t *)xfs_buf_offset(bp, | 339 | dip = (xfs_dinode_t *)xfs_buf_offset(bp, |
340 | (i << mp->m_sb.sb_inodelog)); | 340 | (i << mp->m_sb.sb_inodelog)); |
341 | di_ok = INT_GET(dip->di_core.di_magic, ARCH_CONVERT) == XFS_DINODE_MAGIC && | 341 | di_ok = be16_to_cpu(dip->di_core.di_magic) == XFS_DINODE_MAGIC && |
342 | XFS_DINODE_GOOD_VERSION(INT_GET(dip->di_core.di_version, ARCH_CONVERT)); | 342 | XFS_DINODE_GOOD_VERSION(dip->di_core.di_version); |
343 | if (unlikely(XFS_TEST_ERROR(!di_ok, mp, | 343 | if (unlikely(XFS_TEST_ERROR(!di_ok, mp, |
344 | XFS_ERRTAG_ITOBP_INOTOBP, | 344 | XFS_ERRTAG_ITOBP_INOTOBP, |
345 | XFS_RANDOM_ITOBP_INOTOBP))) { | 345 | XFS_RANDOM_ITOBP_INOTOBP))) { |
@@ -353,7 +353,7 @@ xfs_itobp( | |||
353 | "daddr %lld #%d (magic=%x)", | 353 | "daddr %lld #%d (magic=%x)", |
354 | XFS_BUFTARG_NAME(mp->m_ddev_targp), | 354 | XFS_BUFTARG_NAME(mp->m_ddev_targp), |
355 | (unsigned long long)imap.im_blkno, i, | 355 | (unsigned long long)imap.im_blkno, i, |
356 | INT_GET(dip->di_core.di_magic, ARCH_CONVERT)); | 356 | be16_to_cpu(dip->di_core.di_magic)); |
357 | #endif | 357 | #endif |
358 | XFS_CORRUPTION_ERROR("xfs_itobp", XFS_ERRLEVEL_HIGH, | 358 | XFS_CORRUPTION_ERROR("xfs_itobp", XFS_ERRLEVEL_HIGH, |
359 | mp, dip); | 359 | mp, dip); |
@@ -399,27 +399,26 @@ xfs_iformat( | |||
399 | XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t); | 399 | XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t); |
400 | error = 0; | 400 | error = 0; |
401 | 401 | ||
402 | if (unlikely( | 402 | if (unlikely(be32_to_cpu(dip->di_core.di_nextents) + |
403 | INT_GET(dip->di_core.di_nextents, ARCH_CONVERT) + | 403 | be16_to_cpu(dip->di_core.di_anextents) > |
404 | INT_GET(dip->di_core.di_anextents, ARCH_CONVERT) > | 404 | be64_to_cpu(dip->di_core.di_nblocks))) { |
405 | INT_GET(dip->di_core.di_nblocks, ARCH_CONVERT))) { | ||
406 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, | 405 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, |
407 | "corrupt dinode %Lu, extent total = %d, nblocks = %Lu.", | 406 | "corrupt dinode %Lu, extent total = %d, nblocks = %Lu.", |
408 | (unsigned long long)ip->i_ino, | 407 | (unsigned long long)ip->i_ino, |
409 | (int)(INT_GET(dip->di_core.di_nextents, ARCH_CONVERT) | 408 | (int)(be32_to_cpu(dip->di_core.di_nextents) + |
410 | + INT_GET(dip->di_core.di_anextents, ARCH_CONVERT)), | 409 | be16_to_cpu(dip->di_core.di_anextents)), |
411 | (unsigned long long) | 410 | (unsigned long long) |
412 | INT_GET(dip->di_core.di_nblocks, ARCH_CONVERT)); | 411 | be64_to_cpu(dip->di_core.di_nblocks)); |
413 | XFS_CORRUPTION_ERROR("xfs_iformat(1)", XFS_ERRLEVEL_LOW, | 412 | XFS_CORRUPTION_ERROR("xfs_iformat(1)", XFS_ERRLEVEL_LOW, |
414 | ip->i_mount, dip); | 413 | ip->i_mount, dip); |
415 | return XFS_ERROR(EFSCORRUPTED); | 414 | return XFS_ERROR(EFSCORRUPTED); |
416 | } | 415 | } |
417 | 416 | ||
418 | if (unlikely(INT_GET(dip->di_core.di_forkoff, ARCH_CONVERT) > ip->i_mount->m_sb.sb_inodesize)) { | 417 | if (unlikely(dip->di_core.di_forkoff > ip->i_mount->m_sb.sb_inodesize)) { |
419 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, | 418 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, |
420 | "corrupt dinode %Lu, forkoff = 0x%x.", | 419 | "corrupt dinode %Lu, forkoff = 0x%x.", |
421 | (unsigned long long)ip->i_ino, | 420 | (unsigned long long)ip->i_ino, |
422 | (int)(INT_GET(dip->di_core.di_forkoff, ARCH_CONVERT))); | 421 | dip->di_core.di_forkoff); |
423 | XFS_CORRUPTION_ERROR("xfs_iformat(2)", XFS_ERRLEVEL_LOW, | 422 | XFS_CORRUPTION_ERROR("xfs_iformat(2)", XFS_ERRLEVEL_LOW, |
424 | ip->i_mount, dip); | 423 | ip->i_mount, dip); |
425 | return XFS_ERROR(EFSCORRUPTED); | 424 | return XFS_ERROR(EFSCORRUPTED); |
@@ -430,25 +429,25 @@ xfs_iformat( | |||
430 | case S_IFCHR: | 429 | case S_IFCHR: |
431 | case S_IFBLK: | 430 | case S_IFBLK: |
432 | case S_IFSOCK: | 431 | case S_IFSOCK: |
433 | if (unlikely(INT_GET(dip->di_core.di_format, ARCH_CONVERT) != XFS_DINODE_FMT_DEV)) { | 432 | if (unlikely(dip->di_core.di_format != XFS_DINODE_FMT_DEV)) { |
434 | XFS_CORRUPTION_ERROR("xfs_iformat(3)", XFS_ERRLEVEL_LOW, | 433 | XFS_CORRUPTION_ERROR("xfs_iformat(3)", XFS_ERRLEVEL_LOW, |
435 | ip->i_mount, dip); | 434 | ip->i_mount, dip); |
436 | return XFS_ERROR(EFSCORRUPTED); | 435 | return XFS_ERROR(EFSCORRUPTED); |
437 | } | 436 | } |
438 | ip->i_d.di_size = 0; | 437 | ip->i_d.di_size = 0; |
439 | ip->i_size = 0; | 438 | ip->i_size = 0; |
440 | ip->i_df.if_u2.if_rdev = INT_GET(dip->di_u.di_dev, ARCH_CONVERT); | 439 | ip->i_df.if_u2.if_rdev = be32_to_cpu(dip->di_u.di_dev); |
441 | break; | 440 | break; |
442 | 441 | ||
443 | case S_IFREG: | 442 | case S_IFREG: |
444 | case S_IFLNK: | 443 | case S_IFLNK: |
445 | case S_IFDIR: | 444 | case S_IFDIR: |
446 | switch (INT_GET(dip->di_core.di_format, ARCH_CONVERT)) { | 445 | switch (dip->di_core.di_format) { |
447 | case XFS_DINODE_FMT_LOCAL: | 446 | case XFS_DINODE_FMT_LOCAL: |
448 | /* | 447 | /* |
449 | * no local regular files yet | 448 | * no local regular files yet |
450 | */ | 449 | */ |
451 | if (unlikely((INT_GET(dip->di_core.di_mode, ARCH_CONVERT) & S_IFMT) == S_IFREG)) { | 450 | if (unlikely((be16_to_cpu(dip->di_core.di_mode) & S_IFMT) == S_IFREG)) { |
452 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, | 451 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, |
453 | "corrupt inode %Lu " | 452 | "corrupt inode %Lu " |
454 | "(local format for regular file).", | 453 | "(local format for regular file).", |
@@ -459,7 +458,7 @@ xfs_iformat( | |||
459 | return XFS_ERROR(EFSCORRUPTED); | 458 | return XFS_ERROR(EFSCORRUPTED); |
460 | } | 459 | } |
461 | 460 | ||
462 | di_size = INT_GET(dip->di_core.di_size, ARCH_CONVERT); | 461 | di_size = be64_to_cpu(dip->di_core.di_size); |
463 | if (unlikely(di_size > XFS_DFORK_DSIZE(dip, ip->i_mount))) { | 462 | if (unlikely(di_size > XFS_DFORK_DSIZE(dip, ip->i_mount))) { |
464 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, | 463 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, |
465 | "corrupt inode %Lu " | 464 | "corrupt inode %Lu " |
@@ -501,7 +500,7 @@ xfs_iformat( | |||
501 | ip->i_afp = kmem_zone_zalloc(xfs_ifork_zone, KM_SLEEP); | 500 | ip->i_afp = kmem_zone_zalloc(xfs_ifork_zone, KM_SLEEP); |
502 | ip->i_afp->if_ext_max = | 501 | ip->i_afp->if_ext_max = |
503 | XFS_IFORK_ASIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t); | 502 | XFS_IFORK_ASIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t); |
504 | switch (INT_GET(dip->di_core.di_aformat, ARCH_CONVERT)) { | 503 | switch (dip->di_core.di_aformat) { |
505 | case XFS_DINODE_FMT_LOCAL: | 504 | case XFS_DINODE_FMT_LOCAL: |
506 | atp = (xfs_attr_shortform_t *)XFS_DFORK_APTR(dip); | 505 | atp = (xfs_attr_shortform_t *)XFS_DFORK_APTR(dip); |
507 | size = be16_to_cpu(atp->hdr.totsize); | 506 | size = be16_to_cpu(atp->hdr.totsize); |
@@ -709,70 +708,74 @@ xfs_iformat_btree( | |||
709 | return 0; | 708 | return 0; |
710 | } | 709 | } |
711 | 710 | ||
712 | /* | ||
713 | * xfs_xlate_dinode_core - translate an xfs_inode_core_t between ondisk | ||
714 | * and native format | ||
715 | * | ||
716 | * buf = on-disk representation | ||
717 | * dip = native representation | ||
718 | * dir = direction - +ve -> disk to native | ||
719 | * -ve -> native to disk | ||
720 | */ | ||
721 | void | 711 | void |
722 | xfs_xlate_dinode_core( | 712 | xfs_dinode_from_disk( |
723 | xfs_caddr_t buf, | 713 | xfs_icdinode_t *to, |
724 | xfs_dinode_core_t *dip, | 714 | xfs_dinode_core_t *from) |
725 | int dir) | ||
726 | { | 715 | { |
727 | xfs_dinode_core_t *buf_core = (xfs_dinode_core_t *)buf; | 716 | to->di_magic = be16_to_cpu(from->di_magic); |
728 | xfs_dinode_core_t *mem_core = (xfs_dinode_core_t *)dip; | 717 | to->di_mode = be16_to_cpu(from->di_mode); |
729 | xfs_arch_t arch = ARCH_CONVERT; | 718 | to->di_version = from ->di_version; |
730 | 719 | to->di_format = from->di_format; | |
731 | ASSERT(dir); | 720 | to->di_onlink = be16_to_cpu(from->di_onlink); |
732 | 721 | to->di_uid = be32_to_cpu(from->di_uid); | |
733 | INT_XLATE(buf_core->di_magic, mem_core->di_magic, dir, arch); | 722 | to->di_gid = be32_to_cpu(from->di_gid); |
734 | INT_XLATE(buf_core->di_mode, mem_core->di_mode, dir, arch); | 723 | to->di_nlink = be32_to_cpu(from->di_nlink); |
735 | INT_XLATE(buf_core->di_version, mem_core->di_version, dir, arch); | 724 | to->di_projid = be16_to_cpu(from->di_projid); |
736 | INT_XLATE(buf_core->di_format, mem_core->di_format, dir, arch); | 725 | memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad)); |
737 | INT_XLATE(buf_core->di_onlink, mem_core->di_onlink, dir, arch); | 726 | to->di_flushiter = be16_to_cpu(from->di_flushiter); |
738 | INT_XLATE(buf_core->di_uid, mem_core->di_uid, dir, arch); | 727 | to->di_atime.t_sec = be32_to_cpu(from->di_atime.t_sec); |
739 | INT_XLATE(buf_core->di_gid, mem_core->di_gid, dir, arch); | 728 | to->di_atime.t_nsec = be32_to_cpu(from->di_atime.t_nsec); |
740 | INT_XLATE(buf_core->di_nlink, mem_core->di_nlink, dir, arch); | 729 | to->di_mtime.t_sec = be32_to_cpu(from->di_mtime.t_sec); |
741 | INT_XLATE(buf_core->di_projid, mem_core->di_projid, dir, arch); | 730 | to->di_mtime.t_nsec = be32_to_cpu(from->di_mtime.t_nsec); |
742 | 731 | to->di_ctime.t_sec = be32_to_cpu(from->di_ctime.t_sec); | |
743 | if (dir > 0) { | 732 | to->di_ctime.t_nsec = be32_to_cpu(from->di_ctime.t_nsec); |
744 | memcpy(mem_core->di_pad, buf_core->di_pad, | 733 | to->di_size = be64_to_cpu(from->di_size); |
745 | sizeof(buf_core->di_pad)); | 734 | to->di_nblocks = be64_to_cpu(from->di_nblocks); |
746 | } else { | 735 | to->di_extsize = be32_to_cpu(from->di_extsize); |
747 | memcpy(buf_core->di_pad, mem_core->di_pad, | 736 | to->di_nextents = be32_to_cpu(from->di_nextents); |
748 | sizeof(buf_core->di_pad)); | 737 | to->di_anextents = be16_to_cpu(from->di_anextents); |
749 | } | 738 | to->di_forkoff = from->di_forkoff; |
750 | 739 | to->di_aformat = from->di_aformat; | |
751 | INT_XLATE(buf_core->di_flushiter, mem_core->di_flushiter, dir, arch); | 740 | to->di_dmevmask = be32_to_cpu(from->di_dmevmask); |
752 | 741 | to->di_dmstate = be16_to_cpu(from->di_dmstate); | |
753 | INT_XLATE(buf_core->di_atime.t_sec, mem_core->di_atime.t_sec, | 742 | to->di_flags = be16_to_cpu(from->di_flags); |
754 | dir, arch); | 743 | to->di_gen = be32_to_cpu(from->di_gen); |
755 | INT_XLATE(buf_core->di_atime.t_nsec, mem_core->di_atime.t_nsec, | 744 | } |
756 | dir, arch); | 745 | |
757 | INT_XLATE(buf_core->di_mtime.t_sec, mem_core->di_mtime.t_sec, | 746 | void |
758 | dir, arch); | 747 | xfs_dinode_to_disk( |
759 | INT_XLATE(buf_core->di_mtime.t_nsec, mem_core->di_mtime.t_nsec, | 748 | xfs_dinode_core_t *to, |
760 | dir, arch); | 749 | xfs_icdinode_t *from) |
761 | INT_XLATE(buf_core->di_ctime.t_sec, mem_core->di_ctime.t_sec, | 750 | { |
762 | dir, arch); | 751 | to->di_magic = cpu_to_be16(from->di_magic); |
763 | INT_XLATE(buf_core->di_ctime.t_nsec, mem_core->di_ctime.t_nsec, | 752 | to->di_mode = cpu_to_be16(from->di_mode); |
764 | dir, arch); | 753 | to->di_version = from ->di_version; |
765 | INT_XLATE(buf_core->di_size, mem_core->di_size, dir, arch); | 754 | to->di_format = from->di_format; |
766 | INT_XLATE(buf_core->di_nblocks, mem_core->di_nblocks, dir, arch); | 755 | to->di_onlink = cpu_to_be16(from->di_onlink); |
767 | INT_XLATE(buf_core->di_extsize, mem_core->di_extsize, dir, arch); | 756 | to->di_uid = cpu_to_be32(from->di_uid); |
768 | INT_XLATE(buf_core->di_nextents, mem_core->di_nextents, dir, arch); | 757 | to->di_gid = cpu_to_be32(from->di_gid); |
769 | INT_XLATE(buf_core->di_anextents, mem_core->di_anextents, dir, arch); | 758 | to->di_nlink = cpu_to_be32(from->di_nlink); |
770 | INT_XLATE(buf_core->di_forkoff, mem_core->di_forkoff, dir, arch); | 759 | to->di_projid = cpu_to_be16(from->di_projid); |
771 | INT_XLATE(buf_core->di_aformat, mem_core->di_aformat, dir, arch); | 760 | memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad)); |
772 | INT_XLATE(buf_core->di_dmevmask, mem_core->di_dmevmask, dir, arch); | 761 | to->di_flushiter = cpu_to_be16(from->di_flushiter); |
773 | INT_XLATE(buf_core->di_dmstate, mem_core->di_dmstate, dir, arch); | 762 | to->di_atime.t_sec = cpu_to_be32(from->di_atime.t_sec); |
774 | INT_XLATE(buf_core->di_flags, mem_core->di_flags, dir, arch); | 763 | to->di_atime.t_nsec = cpu_to_be32(from->di_atime.t_nsec); |
775 | INT_XLATE(buf_core->di_gen, mem_core->di_gen, dir, arch); | 764 | to->di_mtime.t_sec = cpu_to_be32(from->di_mtime.t_sec); |
765 | to->di_mtime.t_nsec = cpu_to_be32(from->di_mtime.t_nsec); | ||
766 | to->di_ctime.t_sec = cpu_to_be32(from->di_ctime.t_sec); | ||
767 | to->di_ctime.t_nsec = cpu_to_be32(from->di_ctime.t_nsec); | ||
768 | to->di_size = cpu_to_be64(from->di_size); | ||
769 | to->di_nblocks = cpu_to_be64(from->di_nblocks); | ||
770 | to->di_extsize = cpu_to_be32(from->di_extsize); | ||
771 | to->di_nextents = cpu_to_be32(from->di_nextents); | ||
772 | to->di_anextents = cpu_to_be16(from->di_anextents); | ||
773 | to->di_forkoff = from->di_forkoff; | ||
774 | to->di_aformat = from->di_aformat; | ||
775 | to->di_dmevmask = cpu_to_be32(from->di_dmevmask); | ||
776 | to->di_dmstate = cpu_to_be16(from->di_dmstate); | ||
777 | to->di_flags = cpu_to_be16(from->di_flags); | ||
778 | to->di_gen = cpu_to_be32(from->di_gen); | ||
776 | } | 779 | } |
777 | 780 | ||
778 | STATIC uint | 781 | STATIC uint |
@@ -819,7 +822,7 @@ uint | |||
819 | xfs_ip2xflags( | 822 | xfs_ip2xflags( |
820 | xfs_inode_t *ip) | 823 | xfs_inode_t *ip) |
821 | { | 824 | { |
822 | xfs_dinode_core_t *dic = &ip->i_d; | 825 | xfs_icdinode_t *dic = &ip->i_d; |
823 | 826 | ||
824 | return _xfs_dic2xflags(dic->di_flags) | | 827 | return _xfs_dic2xflags(dic->di_flags) | |
825 | (XFS_CFORK_Q(dic) ? XFS_XFLAG_HASATTR : 0); | 828 | (XFS_CFORK_Q(dic) ? XFS_XFLAG_HASATTR : 0); |
@@ -829,7 +832,7 @@ uint | |||
829 | xfs_dic2xflags( | 832 | xfs_dic2xflags( |
830 | xfs_dinode_core_t *dic) | 833 | xfs_dinode_core_t *dic) |
831 | { | 834 | { |
832 | return _xfs_dic2xflags(INT_GET(dic->di_flags, ARCH_CONVERT)) | | 835 | return _xfs_dic2xflags(be16_to_cpu(dic->di_flags)) | |
833 | (XFS_CFORK_Q_DISK(dic) ? XFS_XFLAG_HASATTR : 0); | 836 | (XFS_CFORK_Q_DISK(dic) ? XFS_XFLAG_HASATTR : 0); |
834 | } | 837 | } |
835 | 838 | ||
@@ -899,14 +902,14 @@ xfs_iread( | |||
899 | * If we got something that isn't an inode it means someone | 902 | * If we got something that isn't an inode it means someone |
900 | * (nfs or dmi) has a stale handle. | 903 | * (nfs or dmi) has a stale handle. |
901 | */ | 904 | */ |
902 | if (INT_GET(dip->di_core.di_magic, ARCH_CONVERT) != XFS_DINODE_MAGIC) { | 905 | if (be16_to_cpu(dip->di_core.di_magic) != XFS_DINODE_MAGIC) { |
903 | kmem_zone_free(xfs_inode_zone, ip); | 906 | kmem_zone_free(xfs_inode_zone, ip); |
904 | xfs_trans_brelse(tp, bp); | 907 | xfs_trans_brelse(tp, bp); |
905 | #ifdef DEBUG | 908 | #ifdef DEBUG |
906 | xfs_fs_cmn_err(CE_ALERT, mp, "xfs_iread: " | 909 | xfs_fs_cmn_err(CE_ALERT, mp, "xfs_iread: " |
907 | "dip->di_core.di_magic (0x%x) != " | 910 | "dip->di_core.di_magic (0x%x) != " |
908 | "XFS_DINODE_MAGIC (0x%x)", | 911 | "XFS_DINODE_MAGIC (0x%x)", |
909 | INT_GET(dip->di_core.di_magic, ARCH_CONVERT), | 912 | be16_to_cpu(dip->di_core.di_magic), |
910 | XFS_DINODE_MAGIC); | 913 | XFS_DINODE_MAGIC); |
911 | #endif /* DEBUG */ | 914 | #endif /* DEBUG */ |
912 | return XFS_ERROR(EINVAL); | 915 | return XFS_ERROR(EINVAL); |
@@ -920,8 +923,7 @@ xfs_iread( | |||
920 | * Otherwise, just get the truly permanent information. | 923 | * Otherwise, just get the truly permanent information. |
921 | */ | 924 | */ |
922 | if (dip->di_core.di_mode) { | 925 | if (dip->di_core.di_mode) { |
923 | xfs_xlate_dinode_core((xfs_caddr_t)&dip->di_core, | 926 | xfs_dinode_from_disk(&ip->i_d, &dip->di_core); |
924 | &(ip->i_d), 1); | ||
925 | error = xfs_iformat(ip, dip); | 927 | error = xfs_iformat(ip, dip); |
926 | if (error) { | 928 | if (error) { |
927 | kmem_zone_free(xfs_inode_zone, ip); | 929 | kmem_zone_free(xfs_inode_zone, ip); |
@@ -934,10 +936,10 @@ xfs_iread( | |||
934 | return error; | 936 | return error; |
935 | } | 937 | } |
936 | } else { | 938 | } else { |
937 | ip->i_d.di_magic = INT_GET(dip->di_core.di_magic, ARCH_CONVERT); | 939 | ip->i_d.di_magic = be16_to_cpu(dip->di_core.di_magic); |
938 | ip->i_d.di_version = INT_GET(dip->di_core.di_version, ARCH_CONVERT); | 940 | ip->i_d.di_version = dip->di_core.di_version; |
939 | ip->i_d.di_gen = INT_GET(dip->di_core.di_gen, ARCH_CONVERT); | 941 | ip->i_d.di_gen = be32_to_cpu(dip->di_core.di_gen); |
940 | ip->i_d.di_flushiter = INT_GET(dip->di_core.di_flushiter, ARCH_CONVERT); | 942 | ip->i_d.di_flushiter = be16_to_cpu(dip->di_core.di_flushiter); |
941 | /* | 943 | /* |
942 | * Make sure to pull in the mode here as well in | 944 | * Make sure to pull in the mode here as well in |
943 | * case the inode is released without being used. | 945 | * case the inode is released without being used. |
@@ -1959,8 +1961,7 @@ xfs_iunlink( | |||
1959 | if (error) { | 1961 | if (error) { |
1960 | return error; | 1962 | return error; |
1961 | } | 1963 | } |
1962 | ASSERT(INT_GET(dip->di_next_unlinked, ARCH_CONVERT) == NULLAGINO); | 1964 | ASSERT(be32_to_cpu(dip->di_next_unlinked) == NULLAGINO); |
1963 | ASSERT(dip->di_next_unlinked); | ||
1964 | /* both on-disk, don't endian flip twice */ | 1965 | /* both on-disk, don't endian flip twice */ |
1965 | dip->di_next_unlinked = agi->agi_unlinked[bucket_index]; | 1966 | dip->di_next_unlinked = agi->agi_unlinked[bucket_index]; |
1966 | offset = ip->i_boffset + | 1967 | offset = ip->i_boffset + |
@@ -2071,10 +2072,10 @@ xfs_iunlink_remove( | |||
2071 | error, mp->m_fsname); | 2072 | error, mp->m_fsname); |
2072 | return error; | 2073 | return error; |
2073 | } | 2074 | } |
2074 | next_agino = INT_GET(dip->di_next_unlinked, ARCH_CONVERT); | 2075 | next_agino = be32_to_cpu(dip->di_next_unlinked); |
2075 | ASSERT(next_agino != 0); | 2076 | ASSERT(next_agino != 0); |
2076 | if (next_agino != NULLAGINO) { | 2077 | if (next_agino != NULLAGINO) { |
2077 | INT_SET(dip->di_next_unlinked, ARCH_CONVERT, NULLAGINO); | 2078 | dip->di_next_unlinked = cpu_to_be32(NULLAGINO); |
2078 | offset = ip->i_boffset + | 2079 | offset = ip->i_boffset + |
2079 | offsetof(xfs_dinode_t, di_next_unlinked); | 2080 | offsetof(xfs_dinode_t, di_next_unlinked); |
2080 | xfs_trans_inode_buf(tp, ibp); | 2081 | xfs_trans_inode_buf(tp, ibp); |
@@ -2118,7 +2119,7 @@ xfs_iunlink_remove( | |||
2118 | error, mp->m_fsname); | 2119 | error, mp->m_fsname); |
2119 | return error; | 2120 | return error; |
2120 | } | 2121 | } |
2121 | next_agino = INT_GET(last_dip->di_next_unlinked, ARCH_CONVERT); | 2122 | next_agino = be32_to_cpu(last_dip->di_next_unlinked); |
2122 | ASSERT(next_agino != NULLAGINO); | 2123 | ASSERT(next_agino != NULLAGINO); |
2123 | ASSERT(next_agino != 0); | 2124 | ASSERT(next_agino != 0); |
2124 | } | 2125 | } |
@@ -2133,11 +2134,11 @@ xfs_iunlink_remove( | |||
2133 | error, mp->m_fsname); | 2134 | error, mp->m_fsname); |
2134 | return error; | 2135 | return error; |
2135 | } | 2136 | } |
2136 | next_agino = INT_GET(dip->di_next_unlinked, ARCH_CONVERT); | 2137 | next_agino = be32_to_cpu(dip->di_next_unlinked); |
2137 | ASSERT(next_agino != 0); | 2138 | ASSERT(next_agino != 0); |
2138 | ASSERT(next_agino != agino); | 2139 | ASSERT(next_agino != agino); |
2139 | if (next_agino != NULLAGINO) { | 2140 | if (next_agino != NULLAGINO) { |
2140 | INT_SET(dip->di_next_unlinked, ARCH_CONVERT, NULLAGINO); | 2141 | dip->di_next_unlinked = cpu_to_be32(NULLAGINO); |
2141 | offset = ip->i_boffset + | 2142 | offset = ip->i_boffset + |
2142 | offsetof(xfs_dinode_t, di_next_unlinked); | 2143 | offsetof(xfs_dinode_t, di_next_unlinked); |
2143 | xfs_trans_inode_buf(tp, ibp); | 2144 | xfs_trans_inode_buf(tp, ibp); |
@@ -2150,7 +2151,7 @@ xfs_iunlink_remove( | |||
2150 | /* | 2151 | /* |
2151 | * Point the previous inode on the list to the next inode. | 2152 | * Point the previous inode on the list to the next inode. |
2152 | */ | 2153 | */ |
2153 | INT_SET(last_dip->di_next_unlinked, ARCH_CONVERT, next_agino); | 2154 | last_dip->di_next_unlinked = cpu_to_be32(next_agino); |
2154 | ASSERT(next_agino != 0); | 2155 | ASSERT(next_agino != 0); |
2155 | offset = last_offset + offsetof(xfs_dinode_t, di_next_unlinked); | 2156 | offset = last_offset + offsetof(xfs_dinode_t, di_next_unlinked); |
2156 | xfs_trans_inode_buf(tp, last_ibp); | 2157 | xfs_trans_inode_buf(tp, last_ibp); |
@@ -3009,7 +3010,7 @@ xfs_iflush_fork( | |||
3009 | case XFS_DINODE_FMT_DEV: | 3010 | case XFS_DINODE_FMT_DEV: |
3010 | if (iip->ili_format.ilf_fields & XFS_ILOG_DEV) { | 3011 | if (iip->ili_format.ilf_fields & XFS_ILOG_DEV) { |
3011 | ASSERT(whichfork == XFS_DATA_FORK); | 3012 | ASSERT(whichfork == XFS_DATA_FORK); |
3012 | INT_SET(dip->di_u.di_dev, ARCH_CONVERT, ip->i_df.if_u2.if_rdev); | 3013 | dip->di_u.di_dev = cpu_to_be32(ip->i_df.if_u2.if_rdev); |
3013 | } | 3014 | } |
3014 | break; | 3015 | break; |
3015 | 3016 | ||
@@ -3358,11 +3359,11 @@ xfs_iflush_int( | |||
3358 | */ | 3359 | */ |
3359 | xfs_synchronize_atime(ip); | 3360 | xfs_synchronize_atime(ip); |
3360 | 3361 | ||
3361 | if (XFS_TEST_ERROR(INT_GET(dip->di_core.di_magic,ARCH_CONVERT) != XFS_DINODE_MAGIC, | 3362 | if (XFS_TEST_ERROR(be16_to_cpu(dip->di_core.di_magic) != XFS_DINODE_MAGIC, |
3362 | mp, XFS_ERRTAG_IFLUSH_1, XFS_RANDOM_IFLUSH_1)) { | 3363 | mp, XFS_ERRTAG_IFLUSH_1, XFS_RANDOM_IFLUSH_1)) { |
3363 | xfs_cmn_err(XFS_PTAG_IFLUSH, CE_ALERT, mp, | 3364 | xfs_cmn_err(XFS_PTAG_IFLUSH, CE_ALERT, mp, |
3364 | "xfs_iflush: Bad inode %Lu magic number 0x%x, ptr 0x%p", | 3365 | "xfs_iflush: Bad inode %Lu magic number 0x%x, ptr 0x%p", |
3365 | ip->i_ino, (int) INT_GET(dip->di_core.di_magic, ARCH_CONVERT), dip); | 3366 | ip->i_ino, be16_to_cpu(dip->di_core.di_magic), dip); |
3366 | goto corrupt_out; | 3367 | goto corrupt_out; |
3367 | } | 3368 | } |
3368 | if (XFS_TEST_ERROR(ip->i_d.di_magic != XFS_DINODE_MAGIC, | 3369 | if (XFS_TEST_ERROR(ip->i_d.di_magic != XFS_DINODE_MAGIC, |
@@ -3425,7 +3426,7 @@ xfs_iflush_int( | |||
3425 | * because if the inode is dirty at all the core must | 3426 | * because if the inode is dirty at all the core must |
3426 | * be. | 3427 | * be. |
3427 | */ | 3428 | */ |
3428 | xfs_xlate_dinode_core((xfs_caddr_t)&(dip->di_core), &(ip->i_d), -1); | 3429 | xfs_dinode_to_disk(&dip->di_core, &ip->i_d); |
3429 | 3430 | ||
3430 | /* Wrap, we never let the log put out DI_MAX_FLUSH */ | 3431 | /* Wrap, we never let the log put out DI_MAX_FLUSH */ |
3431 | if (ip->i_d.di_flushiter == DI_MAX_FLUSH) | 3432 | if (ip->i_d.di_flushiter == DI_MAX_FLUSH) |
@@ -3445,7 +3446,7 @@ xfs_iflush_int( | |||
3445 | * Convert it back. | 3446 | * Convert it back. |
3446 | */ | 3447 | */ |
3447 | ASSERT(ip->i_d.di_nlink <= XFS_MAXLINK_1); | 3448 | ASSERT(ip->i_d.di_nlink <= XFS_MAXLINK_1); |
3448 | INT_SET(dip->di_core.di_onlink, ARCH_CONVERT, ip->i_d.di_nlink); | 3449 | dip->di_core.di_onlink = cpu_to_be16(ip->i_d.di_nlink); |
3449 | } else { | 3450 | } else { |
3450 | /* | 3451 | /* |
3451 | * The superblock version has already been bumped, | 3452 | * The superblock version has already been bumped, |
@@ -3453,7 +3454,7 @@ xfs_iflush_int( | |||
3453 | * format permanent. | 3454 | * format permanent. |
3454 | */ | 3455 | */ |
3455 | ip->i_d.di_version = XFS_DINODE_VERSION_2; | 3456 | ip->i_d.di_version = XFS_DINODE_VERSION_2; |
3456 | INT_SET(dip->di_core.di_version, ARCH_CONVERT, XFS_DINODE_VERSION_2); | 3457 | dip->di_core.di_version = XFS_DINODE_VERSION_2; |
3457 | ip->i_d.di_onlink = 0; | 3458 | ip->i_d.di_onlink = 0; |
3458 | dip->di_core.di_onlink = 0; | 3459 | dip->di_core.di_onlink = 0; |
3459 | memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad)); | 3460 | memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad)); |