diff options
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_super.c')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_super.c | 189 |
1 files changed, 50 insertions, 139 deletions
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c index 30ae96397e31..73c65f19e549 100644 --- a/fs/xfs/linux-2.6/xfs_super.c +++ b/fs/xfs/linux-2.6/xfs_super.c | |||
@@ -581,118 +581,6 @@ xfs_max_file_offset( | |||
581 | return (((__uint64_t)pagefactor) << bitshift) - 1; | 581 | return (((__uint64_t)pagefactor) << bitshift) - 1; |
582 | } | 582 | } |
583 | 583 | ||
584 | STATIC_INLINE void | ||
585 | xfs_set_inodeops( | ||
586 | struct inode *inode) | ||
587 | { | ||
588 | switch (inode->i_mode & S_IFMT) { | ||
589 | case S_IFREG: | ||
590 | inode->i_op = &xfs_inode_operations; | ||
591 | inode->i_fop = &xfs_file_operations; | ||
592 | inode->i_mapping->a_ops = &xfs_address_space_operations; | ||
593 | break; | ||
594 | case S_IFDIR: | ||
595 | if (xfs_sb_version_hasasciici(&XFS_M(inode->i_sb)->m_sb)) | ||
596 | inode->i_op = &xfs_dir_ci_inode_operations; | ||
597 | else | ||
598 | inode->i_op = &xfs_dir_inode_operations; | ||
599 | inode->i_fop = &xfs_dir_file_operations; | ||
600 | break; | ||
601 | case S_IFLNK: | ||
602 | inode->i_op = &xfs_symlink_inode_operations; | ||
603 | if (!(XFS_I(inode)->i_df.if_flags & XFS_IFINLINE)) | ||
604 | inode->i_mapping->a_ops = &xfs_address_space_operations; | ||
605 | break; | ||
606 | default: | ||
607 | inode->i_op = &xfs_inode_operations; | ||
608 | init_special_inode(inode, inode->i_mode, inode->i_rdev); | ||
609 | break; | ||
610 | } | ||
611 | } | ||
612 | |||
613 | STATIC_INLINE void | ||
614 | xfs_revalidate_inode( | ||
615 | xfs_mount_t *mp, | ||
616 | bhv_vnode_t *vp, | ||
617 | xfs_inode_t *ip) | ||
618 | { | ||
619 | struct inode *inode = vn_to_inode(vp); | ||
620 | |||
621 | inode->i_mode = ip->i_d.di_mode; | ||
622 | inode->i_nlink = ip->i_d.di_nlink; | ||
623 | inode->i_uid = ip->i_d.di_uid; | ||
624 | inode->i_gid = ip->i_d.di_gid; | ||
625 | |||
626 | switch (inode->i_mode & S_IFMT) { | ||
627 | case S_IFBLK: | ||
628 | case S_IFCHR: | ||
629 | inode->i_rdev = | ||
630 | MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff, | ||
631 | sysv_minor(ip->i_df.if_u2.if_rdev)); | ||
632 | break; | ||
633 | default: | ||
634 | inode->i_rdev = 0; | ||
635 | break; | ||
636 | } | ||
637 | |||
638 | inode->i_generation = ip->i_d.di_gen; | ||
639 | i_size_write(inode, ip->i_d.di_size); | ||
640 | inode->i_atime.tv_sec = ip->i_d.di_atime.t_sec; | ||
641 | inode->i_atime.tv_nsec = ip->i_d.di_atime.t_nsec; | ||
642 | inode->i_mtime.tv_sec = ip->i_d.di_mtime.t_sec; | ||
643 | inode->i_mtime.tv_nsec = ip->i_d.di_mtime.t_nsec; | ||
644 | inode->i_ctime.tv_sec = ip->i_d.di_ctime.t_sec; | ||
645 | inode->i_ctime.tv_nsec = ip->i_d.di_ctime.t_nsec; | ||
646 | if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE) | ||
647 | inode->i_flags |= S_IMMUTABLE; | ||
648 | else | ||
649 | inode->i_flags &= ~S_IMMUTABLE; | ||
650 | if (ip->i_d.di_flags & XFS_DIFLAG_APPEND) | ||
651 | inode->i_flags |= S_APPEND; | ||
652 | else | ||
653 | inode->i_flags &= ~S_APPEND; | ||
654 | if (ip->i_d.di_flags & XFS_DIFLAG_SYNC) | ||
655 | inode->i_flags |= S_SYNC; | ||
656 | else | ||
657 | inode->i_flags &= ~S_SYNC; | ||
658 | if (ip->i_d.di_flags & XFS_DIFLAG_NOATIME) | ||
659 | inode->i_flags |= S_NOATIME; | ||
660 | else | ||
661 | inode->i_flags &= ~S_NOATIME; | ||
662 | xfs_iflags_clear(ip, XFS_IMODIFIED); | ||
663 | } | ||
664 | |||
665 | void | ||
666 | xfs_initialize_vnode( | ||
667 | struct xfs_mount *mp, | ||
668 | bhv_vnode_t *vp, | ||
669 | struct xfs_inode *ip) | ||
670 | { | ||
671 | struct inode *inode = vn_to_inode(vp); | ||
672 | |||
673 | if (!ip->i_vnode) { | ||
674 | ip->i_vnode = vp; | ||
675 | inode->i_private = ip; | ||
676 | } | ||
677 | |||
678 | /* | ||
679 | * We need to set the ops vectors, and unlock the inode, but if | ||
680 | * we have been called during the new inode create process, it is | ||
681 | * too early to fill in the Linux inode. We will get called a | ||
682 | * second time once the inode is properly set up, and then we can | ||
683 | * finish our work. | ||
684 | */ | ||
685 | if (ip->i_d.di_mode != 0 && (inode->i_state & I_NEW)) { | ||
686 | xfs_revalidate_inode(mp, vp, ip); | ||
687 | xfs_set_inodeops(inode); | ||
688 | |||
689 | xfs_iflags_clear(ip, XFS_INEW); | ||
690 | barrier(); | ||
691 | |||
692 | unlock_new_inode(inode); | ||
693 | } | ||
694 | } | ||
695 | |||
696 | int | 584 | int |
697 | xfs_blkdev_get( | 585 | xfs_blkdev_get( |
698 | xfs_mount_t *mp, | 586 | xfs_mount_t *mp, |
@@ -982,26 +870,21 @@ STATIC struct inode * | |||
982 | xfs_fs_alloc_inode( | 870 | xfs_fs_alloc_inode( |
983 | struct super_block *sb) | 871 | struct super_block *sb) |
984 | { | 872 | { |
985 | bhv_vnode_t *vp; | 873 | return kmem_zone_alloc(xfs_vnode_zone, KM_SLEEP); |
986 | |||
987 | vp = kmem_zone_alloc(xfs_vnode_zone, KM_SLEEP); | ||
988 | if (unlikely(!vp)) | ||
989 | return NULL; | ||
990 | return vn_to_inode(vp); | ||
991 | } | 874 | } |
992 | 875 | ||
993 | STATIC void | 876 | STATIC void |
994 | xfs_fs_destroy_inode( | 877 | xfs_fs_destroy_inode( |
995 | struct inode *inode) | 878 | struct inode *inode) |
996 | { | 879 | { |
997 | kmem_zone_free(xfs_vnode_zone, vn_from_inode(inode)); | 880 | kmem_zone_free(xfs_vnode_zone, inode); |
998 | } | 881 | } |
999 | 882 | ||
1000 | STATIC void | 883 | STATIC void |
1001 | xfs_fs_inode_init_once( | 884 | xfs_fs_inode_init_once( |
1002 | void *vnode) | 885 | void *vnode) |
1003 | { | 886 | { |
1004 | inode_init_once(vn_to_inode((bhv_vnode_t *)vnode)); | 887 | inode_init_once((struct inode *)vnode); |
1005 | } | 888 | } |
1006 | 889 | ||
1007 | /* | 890 | /* |
@@ -1106,7 +989,7 @@ void | |||
1106 | xfs_flush_inode( | 989 | xfs_flush_inode( |
1107 | xfs_inode_t *ip) | 990 | xfs_inode_t *ip) |
1108 | { | 991 | { |
1109 | struct inode *inode = ip->i_vnode; | 992 | struct inode *inode = VFS_I(ip); |
1110 | 993 | ||
1111 | igrab(inode); | 994 | igrab(inode); |
1112 | xfs_syncd_queue_work(ip->i_mount, inode, xfs_flush_inode_work); | 995 | xfs_syncd_queue_work(ip->i_mount, inode, xfs_flush_inode_work); |
@@ -1131,7 +1014,7 @@ void | |||
1131 | xfs_flush_device( | 1014 | xfs_flush_device( |
1132 | xfs_inode_t *ip) | 1015 | xfs_inode_t *ip) |
1133 | { | 1016 | { |
1134 | struct inode *inode = vn_to_inode(XFS_ITOV(ip)); | 1017 | struct inode *inode = VFS_I(ip); |
1135 | 1018 | ||
1136 | igrab(inode); | 1019 | igrab(inode); |
1137 | xfs_syncd_queue_work(ip->i_mount, inode, xfs_flush_device_work); | 1020 | xfs_syncd_queue_work(ip->i_mount, inode, xfs_flush_device_work); |
@@ -1201,6 +1084,15 @@ xfssyncd( | |||
1201 | } | 1084 | } |
1202 | 1085 | ||
1203 | STATIC void | 1086 | STATIC void |
1087 | xfs_free_fsname( | ||
1088 | struct xfs_mount *mp) | ||
1089 | { | ||
1090 | kfree(mp->m_fsname); | ||
1091 | kfree(mp->m_rtname); | ||
1092 | kfree(mp->m_logname); | ||
1093 | } | ||
1094 | |||
1095 | STATIC void | ||
1204 | xfs_fs_put_super( | 1096 | xfs_fs_put_super( |
1205 | struct super_block *sb) | 1097 | struct super_block *sb) |
1206 | { | 1098 | { |
@@ -1239,8 +1131,6 @@ xfs_fs_put_super( | |||
1239 | error = xfs_unmount_flush(mp, 0); | 1131 | error = xfs_unmount_flush(mp, 0); |
1240 | WARN_ON(error); | 1132 | WARN_ON(error); |
1241 | 1133 | ||
1242 | IRELE(rip); | ||
1243 | |||
1244 | /* | 1134 | /* |
1245 | * If we're forcing a shutdown, typically because of a media error, | 1135 | * If we're forcing a shutdown, typically because of a media error, |
1246 | * we want to make sure we invalidate dirty pages that belong to | 1136 | * we want to make sure we invalidate dirty pages that belong to |
@@ -1257,10 +1147,12 @@ xfs_fs_put_super( | |||
1257 | } | 1147 | } |
1258 | 1148 | ||
1259 | xfs_unmountfs(mp); | 1149 | xfs_unmountfs(mp); |
1150 | xfs_freesb(mp); | ||
1260 | xfs_icsb_destroy_counters(mp); | 1151 | xfs_icsb_destroy_counters(mp); |
1261 | xfs_close_devices(mp); | 1152 | xfs_close_devices(mp); |
1262 | xfs_qmops_put(mp); | 1153 | xfs_qmops_put(mp); |
1263 | xfs_dmops_put(mp); | 1154 | xfs_dmops_put(mp); |
1155 | xfs_free_fsname(mp); | ||
1264 | kfree(mp); | 1156 | kfree(mp); |
1265 | } | 1157 | } |
1266 | 1158 | ||
@@ -1517,6 +1409,8 @@ xfs_start_flags( | |||
1517 | struct xfs_mount_args *ap, | 1409 | struct xfs_mount_args *ap, |
1518 | struct xfs_mount *mp) | 1410 | struct xfs_mount *mp) |
1519 | { | 1411 | { |
1412 | int error; | ||
1413 | |||
1520 | /* Values are in BBs */ | 1414 | /* Values are in BBs */ |
1521 | if ((ap->flags & XFSMNT_NOALIGN) != XFSMNT_NOALIGN) { | 1415 | if ((ap->flags & XFSMNT_NOALIGN) != XFSMNT_NOALIGN) { |
1522 | /* | 1416 | /* |
@@ -1549,17 +1443,27 @@ xfs_start_flags( | |||
1549 | ap->logbufsize); | 1443 | ap->logbufsize); |
1550 | return XFS_ERROR(EINVAL); | 1444 | return XFS_ERROR(EINVAL); |
1551 | } | 1445 | } |
1446 | |||
1447 | error = ENOMEM; | ||
1448 | |||
1552 | mp->m_logbsize = ap->logbufsize; | 1449 | mp->m_logbsize = ap->logbufsize; |
1553 | mp->m_fsname_len = strlen(ap->fsname) + 1; | 1450 | mp->m_fsname_len = strlen(ap->fsname) + 1; |
1554 | mp->m_fsname = kmem_alloc(mp->m_fsname_len, KM_SLEEP); | 1451 | |
1555 | strcpy(mp->m_fsname, ap->fsname); | 1452 | mp->m_fsname = kstrdup(ap->fsname, GFP_KERNEL); |
1453 | if (!mp->m_fsname) | ||
1454 | goto out; | ||
1455 | |||
1556 | if (ap->rtname[0]) { | 1456 | if (ap->rtname[0]) { |
1557 | mp->m_rtname = kmem_alloc(strlen(ap->rtname) + 1, KM_SLEEP); | 1457 | mp->m_rtname = kstrdup(ap->rtname, GFP_KERNEL); |
1558 | strcpy(mp->m_rtname, ap->rtname); | 1458 | if (!mp->m_rtname) |
1459 | goto out_free_fsname; | ||
1460 | |||
1559 | } | 1461 | } |
1462 | |||
1560 | if (ap->logname[0]) { | 1463 | if (ap->logname[0]) { |
1561 | mp->m_logname = kmem_alloc(strlen(ap->logname) + 1, KM_SLEEP); | 1464 | mp->m_logname = kstrdup(ap->logname, GFP_KERNEL); |
1562 | strcpy(mp->m_logname, ap->logname); | 1465 | if (!mp->m_logname) |
1466 | goto out_free_rtname; | ||
1563 | } | 1467 | } |
1564 | 1468 | ||
1565 | if (ap->flags & XFSMNT_WSYNC) | 1469 | if (ap->flags & XFSMNT_WSYNC) |
@@ -1632,6 +1536,14 @@ xfs_start_flags( | |||
1632 | if (ap->flags & XFSMNT_DMAPI) | 1536 | if (ap->flags & XFSMNT_DMAPI) |
1633 | mp->m_flags |= XFS_MOUNT_DMAPI; | 1537 | mp->m_flags |= XFS_MOUNT_DMAPI; |
1634 | return 0; | 1538 | return 0; |
1539 | |||
1540 | |||
1541 | out_free_rtname: | ||
1542 | kfree(mp->m_rtname); | ||
1543 | out_free_fsname: | ||
1544 | kfree(mp->m_fsname); | ||
1545 | out: | ||
1546 | return error; | ||
1635 | } | 1547 | } |
1636 | 1548 | ||
1637 | /* | 1549 | /* |
@@ -1792,10 +1704,10 @@ xfs_fs_fill_super( | |||
1792 | */ | 1704 | */ |
1793 | error = xfs_start_flags(args, mp); | 1705 | error = xfs_start_flags(args, mp); |
1794 | if (error) | 1706 | if (error) |
1795 | goto out_destroy_counters; | 1707 | goto out_free_fsname; |
1796 | error = xfs_readsb(mp, flags); | 1708 | error = xfs_readsb(mp, flags); |
1797 | if (error) | 1709 | if (error) |
1798 | goto out_destroy_counters; | 1710 | goto out_free_fsname; |
1799 | error = xfs_finish_flags(args, mp); | 1711 | error = xfs_finish_flags(args, mp); |
1800 | if (error) | 1712 | if (error) |
1801 | goto out_free_sb; | 1713 | goto out_free_sb; |
@@ -1811,7 +1723,7 @@ xfs_fs_fill_super( | |||
1811 | if (error) | 1723 | if (error) |
1812 | goto out_free_sb; | 1724 | goto out_free_sb; |
1813 | 1725 | ||
1814 | error = xfs_mountfs(mp, flags); | 1726 | error = xfs_mountfs(mp); |
1815 | if (error) | 1727 | if (error) |
1816 | goto out_filestream_unmount; | 1728 | goto out_filestream_unmount; |
1817 | 1729 | ||
@@ -1825,7 +1737,7 @@ xfs_fs_fill_super( | |||
1825 | sb->s_time_gran = 1; | 1737 | sb->s_time_gran = 1; |
1826 | set_posix_acl_flag(sb); | 1738 | set_posix_acl_flag(sb); |
1827 | 1739 | ||
1828 | root = igrab(mp->m_rootip->i_vnode); | 1740 | root = igrab(VFS_I(mp->m_rootip)); |
1829 | if (!root) { | 1741 | if (!root) { |
1830 | error = ENOENT; | 1742 | error = ENOENT; |
1831 | goto fail_unmount; | 1743 | goto fail_unmount; |
@@ -1857,7 +1769,8 @@ xfs_fs_fill_super( | |||
1857 | xfs_filestream_unmount(mp); | 1769 | xfs_filestream_unmount(mp); |
1858 | out_free_sb: | 1770 | out_free_sb: |
1859 | xfs_freesb(mp); | 1771 | xfs_freesb(mp); |
1860 | out_destroy_counters: | 1772 | out_free_fsname: |
1773 | xfs_free_fsname(mp); | ||
1861 | xfs_icsb_destroy_counters(mp); | 1774 | xfs_icsb_destroy_counters(mp); |
1862 | xfs_close_devices(mp); | 1775 | xfs_close_devices(mp); |
1863 | out_put_qmops: | 1776 | out_put_qmops: |
@@ -1890,10 +1803,8 @@ xfs_fs_fill_super( | |||
1890 | error = xfs_unmount_flush(mp, 0); | 1803 | error = xfs_unmount_flush(mp, 0); |
1891 | WARN_ON(error); | 1804 | WARN_ON(error); |
1892 | 1805 | ||
1893 | IRELE(mp->m_rootip); | ||
1894 | |||
1895 | xfs_unmountfs(mp); | 1806 | xfs_unmountfs(mp); |
1896 | goto out_destroy_counters; | 1807 | goto out_free_sb; |
1897 | } | 1808 | } |
1898 | 1809 | ||
1899 | STATIC int | 1810 | STATIC int |
@@ -2014,7 +1925,7 @@ xfs_free_trace_bufs(void) | |||
2014 | STATIC int __init | 1925 | STATIC int __init |
2015 | xfs_init_zones(void) | 1926 | xfs_init_zones(void) |
2016 | { | 1927 | { |
2017 | xfs_vnode_zone = kmem_zone_init_flags(sizeof(bhv_vnode_t), "xfs_vnode", | 1928 | xfs_vnode_zone = kmem_zone_init_flags(sizeof(struct inode), "xfs_vnode", |
2018 | KM_ZONE_HWALIGN | KM_ZONE_RECLAIM | | 1929 | KM_ZONE_HWALIGN | KM_ZONE_RECLAIM | |
2019 | KM_ZONE_SPREAD, | 1930 | KM_ZONE_SPREAD, |
2020 | xfs_fs_inode_init_once); | 1931 | xfs_fs_inode_init_once); |