aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ufs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ufs/inode.c')
-rw-r--r--fs/ufs/inode.c119
1 files changed, 62 insertions, 57 deletions
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index f2dbdf5a8769..488b5ff48afb 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -98,7 +98,9 @@ static u64 ufs_frag_map(struct inode *inode, sector_t frag)
98 u64 temp = 0L; 98 u64 temp = 0L;
99 99
100 UFSD(": frag = %llu depth = %d\n", (unsigned long long)frag, depth); 100 UFSD(": frag = %llu depth = %d\n", (unsigned long long)frag, depth);
101 UFSD(": uspi->s_fpbshift = %d ,uspi->s_apbmask = %x, mask=%llx\n",uspi->s_fpbshift,uspi->s_apbmask,mask); 101 UFSD(": uspi->s_fpbshift = %d ,uspi->s_apbmask = %x, mask=%llx\n",
102 uspi->s_fpbshift, uspi->s_apbmask,
103 (unsigned long long)mask);
102 104
103 if (depth == 0) 105 if (depth == 0)
104 return 0; 106 return 0;
@@ -429,7 +431,7 @@ int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buffer_head
429 431
430 if (!create) { 432 if (!create) {
431 phys64 = ufs_frag_map(inode, fragment); 433 phys64 = ufs_frag_map(inode, fragment);
432 UFSD("phys64 = %llu \n",phys64); 434 UFSD("phys64 = %llu\n", (unsigned long long)phys64);
433 if (phys64) 435 if (phys64)
434 map_bh(bh_result, sb, phys64); 436 map_bh(bh_result, sb, phys64);
435 return 0; 437 return 0;
@@ -574,7 +576,7 @@ static sector_t ufs_bmap(struct address_space *mapping, sector_t block)
574{ 576{
575 return generic_block_bmap(mapping,block,ufs_getfrag_block); 577 return generic_block_bmap(mapping,block,ufs_getfrag_block);
576} 578}
577struct address_space_operations ufs_aops = { 579const struct address_space_operations ufs_aops = {
578 .readpage = ufs_readpage, 580 .readpage = ufs_readpage,
579 .writepage = ufs_writepage, 581 .writepage = ufs_writepage,
580 .sync_page = block_sync_page, 582 .sync_page = block_sync_page,
@@ -605,39 +607,12 @@ static void ufs_set_inode_ops(struct inode *inode)
605 ufs_get_inode_dev(inode->i_sb, UFS_I(inode))); 607 ufs_get_inode_dev(inode->i_sb, UFS_I(inode)));
606} 608}
607 609
608void ufs_read_inode (struct inode * inode) 610static void ufs1_read_inode(struct inode *inode, struct ufs_inode *ufs_inode)
609{ 611{
610 struct ufs_inode_info *ufsi = UFS_I(inode); 612 struct ufs_inode_info *ufsi = UFS_I(inode);
611 struct super_block * sb; 613 struct super_block *sb = inode->i_sb;
612 struct ufs_sb_private_info * uspi;
613 struct ufs_inode * ufs_inode;
614 struct ufs2_inode *ufs2_inode;
615 struct buffer_head * bh;
616 mode_t mode; 614 mode_t mode;
617 unsigned i; 615 unsigned i;
618 unsigned flags;
619
620 UFSD("ENTER, ino %lu\n", inode->i_ino);
621
622 sb = inode->i_sb;
623 uspi = UFS_SB(sb)->s_uspi;
624 flags = UFS_SB(sb)->s_flags;
625
626 if (inode->i_ino < UFS_ROOTINO ||
627 inode->i_ino > (uspi->s_ncg * uspi->s_ipg)) {
628 ufs_warning (sb, "ufs_read_inode", "bad inode number (%lu)\n", inode->i_ino);
629 goto bad_inode;
630 }
631
632 bh = sb_bread(sb, uspi->s_sbbase + ufs_inotofsba(inode->i_ino));
633 if (!bh) {
634 ufs_warning (sb, "ufs_read_inode", "unable to read inode %lu\n", inode->i_ino);
635 goto bad_inode;
636 }
637 if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2)
638 goto ufs2_inode;
639
640 ufs_inode = (struct ufs_inode *) (bh->b_data + sizeof(struct ufs_inode) * ufs_inotofsbo(inode->i_ino));
641 616
642 /* 617 /*
643 * Copy data to the in-core inode. 618 * Copy data to the in-core inode.
@@ -661,14 +636,11 @@ void ufs_read_inode (struct inode * inode)
661 inode->i_atime.tv_nsec = 0; 636 inode->i_atime.tv_nsec = 0;
662 inode->i_ctime.tv_nsec = 0; 637 inode->i_ctime.tv_nsec = 0;
663 inode->i_blocks = fs32_to_cpu(sb, ufs_inode->ui_blocks); 638 inode->i_blocks = fs32_to_cpu(sb, ufs_inode->ui_blocks);
664 inode->i_blksize = PAGE_SIZE; /* This is the optimal IO size (for stat) */
665 inode->i_version++;
666 ufsi->i_flags = fs32_to_cpu(sb, ufs_inode->ui_flags); 639 ufsi->i_flags = fs32_to_cpu(sb, ufs_inode->ui_flags);
667 ufsi->i_gen = fs32_to_cpu(sb, ufs_inode->ui_gen); 640 ufsi->i_gen = fs32_to_cpu(sb, ufs_inode->ui_gen);
668 ufsi->i_shadow = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_shadow); 641 ufsi->i_shadow = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_shadow);
669 ufsi->i_oeftflag = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_oeftflag); 642 ufsi->i_oeftflag = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_oeftflag);
670 ufsi->i_lastfrag = (inode->i_size + uspi->s_fsize - 1) >> uspi->s_fshift; 643
671 ufsi->i_dir_start_lookup = 0;
672 644
673 if (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) { 645 if (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) {
674 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR); i++) 646 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR); i++)
@@ -677,24 +649,16 @@ void ufs_read_inode (struct inode * inode)
677 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++) 649 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++)
678 ufsi->i_u1.i_symlink[i] = ufs_inode->ui_u2.ui_symlink[i]; 650 ufsi->i_u1.i_symlink[i] = ufs_inode->ui_u2.ui_symlink[i];
679 } 651 }
680 ufsi->i_osync = 0; 652}
681
682 ufs_set_inode_ops(inode);
683
684 brelse (bh);
685
686 UFSD("EXIT\n");
687 return;
688 653
689bad_inode: 654static void ufs2_read_inode(struct inode *inode, struct ufs2_inode *ufs2_inode)
690 make_bad_inode(inode); 655{
691 return; 656 struct ufs_inode_info *ufsi = UFS_I(inode);
657 struct super_block *sb = inode->i_sb;
658 mode_t mode;
659 unsigned i;
692 660
693ufs2_inode :
694 UFSD("Reading ufs2 inode, ino %lu\n", inode->i_ino); 661 UFSD("Reading ufs2 inode, ino %lu\n", inode->i_ino);
695
696 ufs2_inode = (struct ufs2_inode *)(bh->b_data + sizeof(struct ufs2_inode) * ufs_inotofsbo(inode->i_ino));
697
698 /* 662 /*
699 * Copy data to the in-core inode. 663 * Copy data to the in-core inode.
700 */ 664 */
@@ -717,26 +681,64 @@ ufs2_inode :
717 inode->i_atime.tv_nsec = 0; 681 inode->i_atime.tv_nsec = 0;
718 inode->i_ctime.tv_nsec = 0; 682 inode->i_ctime.tv_nsec = 0;
719 inode->i_blocks = fs64_to_cpu(sb, ufs2_inode->ui_blocks); 683 inode->i_blocks = fs64_to_cpu(sb, ufs2_inode->ui_blocks);
720 inode->i_blksize = PAGE_SIZE; /*This is the optimal IO size(for stat)*/
721
722 inode->i_version++;
723 ufsi->i_flags = fs32_to_cpu(sb, ufs2_inode->ui_flags); 684 ufsi->i_flags = fs32_to_cpu(sb, ufs2_inode->ui_flags);
724 ufsi->i_gen = fs32_to_cpu(sb, ufs2_inode->ui_gen); 685 ufsi->i_gen = fs32_to_cpu(sb, ufs2_inode->ui_gen);
725 /* 686 /*
726 ufsi->i_shadow = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_shadow); 687 ufsi->i_shadow = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_shadow);
727 ufsi->i_oeftflag = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_oeftflag); 688 ufsi->i_oeftflag = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_oeftflag);
728 */ 689 */
729 ufsi->i_lastfrag= (inode->i_size + uspi->s_fsize- 1) >> uspi->s_fshift;
730 690
731 if (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) { 691 if (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) {
732 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR); i++) 692 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR); i++)
733 ufsi->i_u1.u2_i_data[i] = 693 ufsi->i_u1.u2_i_data[i] =
734 ufs2_inode->ui_u2.ui_addr.ui_db[i]; 694 ufs2_inode->ui_u2.ui_addr.ui_db[i];
735 } 695 } else {
736 else {
737 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++) 696 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++)
738 ufsi->i_u1.i_symlink[i] = ufs2_inode->ui_u2.ui_symlink[i]; 697 ufsi->i_u1.i_symlink[i] = ufs2_inode->ui_u2.ui_symlink[i];
739 } 698 }
699}
700
701void ufs_read_inode(struct inode * inode)
702{
703 struct ufs_inode_info *ufsi = UFS_I(inode);
704 struct super_block * sb;
705 struct ufs_sb_private_info * uspi;
706 struct buffer_head * bh;
707
708 UFSD("ENTER, ino %lu\n", inode->i_ino);
709
710 sb = inode->i_sb;
711 uspi = UFS_SB(sb)->s_uspi;
712
713 if (inode->i_ino < UFS_ROOTINO ||
714 inode->i_ino > (uspi->s_ncg * uspi->s_ipg)) {
715 ufs_warning(sb, "ufs_read_inode", "bad inode number (%lu)\n",
716 inode->i_ino);
717 goto bad_inode;
718 }
719
720 bh = sb_bread(sb, uspi->s_sbbase + ufs_inotofsba(inode->i_ino));
721 if (!bh) {
722 ufs_warning(sb, "ufs_read_inode", "unable to read inode %lu\n",
723 inode->i_ino);
724 goto bad_inode;
725 }
726 if ((UFS_SB(sb)->s_flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) {
727 struct ufs2_inode *ufs2_inode = (struct ufs2_inode *)bh->b_data;
728
729 ufs2_read_inode(inode,
730 ufs2_inode + ufs_inotofsbo(inode->i_ino));
731 } else {
732 struct ufs_inode *ufs_inode = (struct ufs_inode *)bh->b_data;
733
734 ufs1_read_inode(inode, ufs_inode + ufs_inotofsbo(inode->i_ino));
735 }
736
737 inode->i_blksize = PAGE_SIZE;/*This is the optimal IO size (for stat)*/
738 inode->i_version++;
739 ufsi->i_lastfrag =
740 (inode->i_size + uspi->s_fsize - 1) >> uspi->s_fshift;
741 ufsi->i_dir_start_lookup = 0;
740 ufsi->i_osync = 0; 742 ufsi->i_osync = 0;
741 743
742 ufs_set_inode_ops(inode); 744 ufs_set_inode_ops(inode);
@@ -745,6 +747,9 @@ ufs2_inode :
745 747
746 UFSD("EXIT\n"); 748 UFSD("EXIT\n");
747 return; 749 return;
750
751bad_inode:
752 make_bad_inode(inode);
748} 753}
749 754
750static int ufs_update_inode(struct inode * inode, int do_sync) 755static int ufs_update_inode(struct inode * inode, int do_sync)