diff options
Diffstat (limited to 'fs/xfs/xfs_mount.c')
-rw-r--r-- | fs/xfs/xfs_mount.c | 344 |
1 files changed, 194 insertions, 150 deletions
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index ebdb76da527c..6409b3762995 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c | |||
@@ -136,15 +136,9 @@ xfs_mount_init(void) | |||
136 | mp->m_flags |= XFS_MOUNT_NO_PERCPU_SB; | 136 | mp->m_flags |= XFS_MOUNT_NO_PERCPU_SB; |
137 | } | 137 | } |
138 | 138 | ||
139 | AIL_LOCKINIT(&mp->m_ail_lock, "xfs_ail"); | 139 | spin_lock_init(&mp->m_sb_lock); |
140 | spinlock_init(&mp->m_sb_lock, "xfs_sb"); | ||
141 | mutex_init(&mp->m_ilock); | 140 | mutex_init(&mp->m_ilock); |
142 | mutex_init(&mp->m_growlock); | 141 | mutex_init(&mp->m_growlock); |
143 | /* | ||
144 | * Initialize the AIL. | ||
145 | */ | ||
146 | xfs_trans_ail_init(mp); | ||
147 | |||
148 | atomic_set(&mp->m_active_trans, 0); | 142 | atomic_set(&mp->m_active_trans, 0); |
149 | 143 | ||
150 | return mp; | 144 | return mp; |
@@ -171,7 +165,7 @@ xfs_mount_free( | |||
171 | sizeof(xfs_perag_t) * mp->m_sb.sb_agcount); | 165 | sizeof(xfs_perag_t) * mp->m_sb.sb_agcount); |
172 | } | 166 | } |
173 | 167 | ||
174 | AIL_LOCK_DESTROY(&mp->m_ail_lock); | 168 | spinlock_destroy(&mp->m_ail_lock); |
175 | spinlock_destroy(&mp->m_sb_lock); | 169 | spinlock_destroy(&mp->m_sb_lock); |
176 | mutex_destroy(&mp->m_ilock); | 170 | mutex_destroy(&mp->m_ilock); |
177 | mutex_destroy(&mp->m_growlock); | 171 | mutex_destroy(&mp->m_growlock); |
@@ -616,7 +610,7 @@ xfs_mount_common(xfs_mount_t *mp, xfs_sb_t *sbp) | |||
616 | int i; | 610 | int i; |
617 | 611 | ||
618 | mp->m_agfrotor = mp->m_agirotor = 0; | 612 | mp->m_agfrotor = mp->m_agirotor = 0; |
619 | spinlock_init(&mp->m_agirotor_lock, "m_agirotor_lock"); | 613 | spin_lock_init(&mp->m_agirotor_lock); |
620 | mp->m_maxagi = mp->m_sb.sb_agcount; | 614 | mp->m_maxagi = mp->m_sb.sb_agcount; |
621 | mp->m_blkbit_log = sbp->sb_blocklog + XFS_NBBYLOG; | 615 | mp->m_blkbit_log = sbp->sb_blocklog + XFS_NBBYLOG; |
622 | mp->m_blkbb_log = sbp->sb_blocklog - BBSHIFT; | 616 | mp->m_blkbb_log = sbp->sb_blocklog - BBSHIFT; |
@@ -696,7 +690,6 @@ xfs_initialize_perag_data(xfs_mount_t *mp, xfs_agnumber_t agcount) | |||
696 | uint64_t bfreelst = 0; | 690 | uint64_t bfreelst = 0; |
697 | uint64_t btree = 0; | 691 | uint64_t btree = 0; |
698 | int error; | 692 | int error; |
699 | int s; | ||
700 | 693 | ||
701 | for (index = 0; index < agcount; index++) { | 694 | for (index = 0; index < agcount; index++) { |
702 | /* | 695 | /* |
@@ -721,11 +714,11 @@ xfs_initialize_perag_data(xfs_mount_t *mp, xfs_agnumber_t agcount) | |||
721 | /* | 714 | /* |
722 | * Overwrite incore superblock counters with just-read data | 715 | * Overwrite incore superblock counters with just-read data |
723 | */ | 716 | */ |
724 | s = XFS_SB_LOCK(mp); | 717 | spin_lock(&mp->m_sb_lock); |
725 | sbp->sb_ifree = ifree; | 718 | sbp->sb_ifree = ifree; |
726 | sbp->sb_icount = ialloc; | 719 | sbp->sb_icount = ialloc; |
727 | sbp->sb_fdblocks = bfree + bfreelst + btree; | 720 | sbp->sb_fdblocks = bfree + bfreelst + btree; |
728 | XFS_SB_UNLOCK(mp, s); | 721 | spin_unlock(&mp->m_sb_lock); |
729 | 722 | ||
730 | /* Fixup the per-cpu counters as well. */ | 723 | /* Fixup the per-cpu counters as well. */ |
731 | xfs_icsb_reinit_counters(mp); | 724 | xfs_icsb_reinit_counters(mp); |
@@ -734,49 +727,13 @@ xfs_initialize_perag_data(xfs_mount_t *mp, xfs_agnumber_t agcount) | |||
734 | } | 727 | } |
735 | 728 | ||
736 | /* | 729 | /* |
737 | * xfs_mountfs | 730 | * Update alignment values based on mount options and sb values |
738 | * | ||
739 | * This function does the following on an initial mount of a file system: | ||
740 | * - reads the superblock from disk and init the mount struct | ||
741 | * - if we're a 32-bit kernel, do a size check on the superblock | ||
742 | * so we don't mount terabyte filesystems | ||
743 | * - init mount struct realtime fields | ||
744 | * - allocate inode hash table for fs | ||
745 | * - init directory manager | ||
746 | * - perform recovery and init the log manager | ||
747 | */ | 731 | */ |
748 | int | 732 | STATIC int |
749 | xfs_mountfs( | 733 | xfs_update_alignment(xfs_mount_t *mp, int mfsi_flags, __uint64_t *update_flags) |
750 | xfs_mount_t *mp, | ||
751 | int mfsi_flags) | ||
752 | { | 734 | { |
753 | xfs_buf_t *bp; | ||
754 | xfs_sb_t *sbp = &(mp->m_sb); | 735 | xfs_sb_t *sbp = &(mp->m_sb); |
755 | xfs_inode_t *rip; | ||
756 | bhv_vnode_t *rvp = NULL; | ||
757 | int readio_log, writeio_log; | ||
758 | xfs_daddr_t d; | ||
759 | __uint64_t resblks; | ||
760 | __int64_t update_flags; | ||
761 | uint quotamount, quotaflags; | ||
762 | int agno; | ||
763 | int uuid_mounted = 0; | ||
764 | int error = 0; | ||
765 | 736 | ||
766 | if (mp->m_sb_bp == NULL) { | ||
767 | if ((error = xfs_readsb(mp, mfsi_flags))) { | ||
768 | return error; | ||
769 | } | ||
770 | } | ||
771 | xfs_mount_common(mp, sbp); | ||
772 | |||
773 | /* | ||
774 | * Check if sb_agblocks is aligned at stripe boundary | ||
775 | * If sb_agblocks is NOT aligned turn off m_dalign since | ||
776 | * allocator alignment is within an ag, therefore ag has | ||
777 | * to be aligned at stripe boundary. | ||
778 | */ | ||
779 | update_flags = 0LL; | ||
780 | if (mp->m_dalign && !(mfsi_flags & XFS_MFSI_SECOND)) { | 737 | if (mp->m_dalign && !(mfsi_flags & XFS_MFSI_SECOND)) { |
781 | /* | 738 | /* |
782 | * If stripe unit and stripe width are not multiples | 739 | * If stripe unit and stripe width are not multiples |
@@ -787,8 +744,7 @@ xfs_mountfs( | |||
787 | if (mp->m_flags & XFS_MOUNT_RETERR) { | 744 | if (mp->m_flags & XFS_MOUNT_RETERR) { |
788 | cmn_err(CE_WARN, | 745 | cmn_err(CE_WARN, |
789 | "XFS: alignment check 1 failed"); | 746 | "XFS: alignment check 1 failed"); |
790 | error = XFS_ERROR(EINVAL); | 747 | return XFS_ERROR(EINVAL); |
791 | goto error1; | ||
792 | } | 748 | } |
793 | mp->m_dalign = mp->m_swidth = 0; | 749 | mp->m_dalign = mp->m_swidth = 0; |
794 | } else { | 750 | } else { |
@@ -798,8 +754,7 @@ xfs_mountfs( | |||
798 | mp->m_dalign = XFS_BB_TO_FSBT(mp, mp->m_dalign); | 754 | mp->m_dalign = XFS_BB_TO_FSBT(mp, mp->m_dalign); |
799 | if (mp->m_dalign && (sbp->sb_agblocks % mp->m_dalign)) { | 755 | if (mp->m_dalign && (sbp->sb_agblocks % mp->m_dalign)) { |
800 | if (mp->m_flags & XFS_MOUNT_RETERR) { | 756 | if (mp->m_flags & XFS_MOUNT_RETERR) { |
801 | error = XFS_ERROR(EINVAL); | 757 | return XFS_ERROR(EINVAL); |
802 | goto error1; | ||
803 | } | 758 | } |
804 | xfs_fs_cmn_err(CE_WARN, mp, | 759 | xfs_fs_cmn_err(CE_WARN, mp, |
805 | "stripe alignment turned off: sunit(%d)/swidth(%d) incompatible with agsize(%d)", | 760 | "stripe alignment turned off: sunit(%d)/swidth(%d) incompatible with agsize(%d)", |
@@ -816,8 +771,7 @@ xfs_mountfs( | |||
816 | "stripe alignment turned off: sunit(%d) less than bsize(%d)", | 771 | "stripe alignment turned off: sunit(%d) less than bsize(%d)", |
817 | mp->m_dalign, | 772 | mp->m_dalign, |
818 | mp->m_blockmask +1); | 773 | mp->m_blockmask +1); |
819 | error = XFS_ERROR(EINVAL); | 774 | return XFS_ERROR(EINVAL); |
820 | goto error1; | ||
821 | } | 775 | } |
822 | mp->m_swidth = 0; | 776 | mp->m_swidth = 0; |
823 | } | 777 | } |
@@ -830,11 +784,11 @@ xfs_mountfs( | |||
830 | if (XFS_SB_VERSION_HASDALIGN(sbp)) { | 784 | if (XFS_SB_VERSION_HASDALIGN(sbp)) { |
831 | if (sbp->sb_unit != mp->m_dalign) { | 785 | if (sbp->sb_unit != mp->m_dalign) { |
832 | sbp->sb_unit = mp->m_dalign; | 786 | sbp->sb_unit = mp->m_dalign; |
833 | update_flags |= XFS_SB_UNIT; | 787 | *update_flags |= XFS_SB_UNIT; |
834 | } | 788 | } |
835 | if (sbp->sb_width != mp->m_swidth) { | 789 | if (sbp->sb_width != mp->m_swidth) { |
836 | sbp->sb_width = mp->m_swidth; | 790 | sbp->sb_width = mp->m_swidth; |
837 | update_flags |= XFS_SB_WIDTH; | 791 | *update_flags |= XFS_SB_WIDTH; |
838 | } | 792 | } |
839 | } | 793 | } |
840 | } else if ((mp->m_flags & XFS_MOUNT_NOALIGN) != XFS_MOUNT_NOALIGN && | 794 | } else if ((mp->m_flags & XFS_MOUNT_NOALIGN) != XFS_MOUNT_NOALIGN && |
@@ -843,49 +797,45 @@ xfs_mountfs( | |||
843 | mp->m_swidth = sbp->sb_width; | 797 | mp->m_swidth = sbp->sb_width; |
844 | } | 798 | } |
845 | 799 | ||
846 | xfs_alloc_compute_maxlevels(mp); | 800 | return 0; |
847 | xfs_bmap_compute_maxlevels(mp, XFS_DATA_FORK); | 801 | } |
848 | xfs_bmap_compute_maxlevels(mp, XFS_ATTR_FORK); | ||
849 | xfs_ialloc_compute_maxlevels(mp); | ||
850 | 802 | ||
851 | if (sbp->sb_imax_pct) { | 803 | /* |
852 | __uint64_t icount; | 804 | * Set the maximum inode count for this filesystem |
805 | */ | ||
806 | STATIC void | ||
807 | xfs_set_maxicount(xfs_mount_t *mp) | ||
808 | { | ||
809 | xfs_sb_t *sbp = &(mp->m_sb); | ||
810 | __uint64_t icount; | ||
853 | 811 | ||
854 | /* Make sure the maximum inode count is a multiple of the | 812 | if (sbp->sb_imax_pct) { |
855 | * units we allocate inodes in. | 813 | /* |
814 | * Make sure the maximum inode count is a multiple | ||
815 | * of the units we allocate inodes in. | ||
856 | */ | 816 | */ |
857 | |||
858 | icount = sbp->sb_dblocks * sbp->sb_imax_pct; | 817 | icount = sbp->sb_dblocks * sbp->sb_imax_pct; |
859 | do_div(icount, 100); | 818 | do_div(icount, 100); |
860 | do_div(icount, mp->m_ialloc_blks); | 819 | do_div(icount, mp->m_ialloc_blks); |
861 | mp->m_maxicount = (icount * mp->m_ialloc_blks) << | 820 | mp->m_maxicount = (icount * mp->m_ialloc_blks) << |
862 | sbp->sb_inopblog; | 821 | sbp->sb_inopblog; |
863 | } else | 822 | } else { |
864 | mp->m_maxicount = 0; | 823 | mp->m_maxicount = 0; |
865 | |||
866 | mp->m_maxioffset = xfs_max_file_offset(sbp->sb_blocklog); | ||
867 | |||
868 | /* | ||
869 | * XFS uses the uuid from the superblock as the unique | ||
870 | * identifier for fsid. We can not use the uuid from the volume | ||
871 | * since a single partition filesystem is identical to a single | ||
872 | * partition volume/filesystem. | ||
873 | */ | ||
874 | if ((mfsi_flags & XFS_MFSI_SECOND) == 0 && | ||
875 | (mp->m_flags & XFS_MOUNT_NOUUID) == 0) { | ||
876 | if (xfs_uuid_mount(mp)) { | ||
877 | error = XFS_ERROR(EINVAL); | ||
878 | goto error1; | ||
879 | } | ||
880 | uuid_mounted=1; | ||
881 | } | 824 | } |
825 | } | ||
826 | |||
827 | /* | ||
828 | * Set the default minimum read and write sizes unless | ||
829 | * already specified in a mount option. | ||
830 | * We use smaller I/O sizes when the file system | ||
831 | * is being used for NFS service (wsync mount option). | ||
832 | */ | ||
833 | STATIC void | ||
834 | xfs_set_rw_sizes(xfs_mount_t *mp) | ||
835 | { | ||
836 | xfs_sb_t *sbp = &(mp->m_sb); | ||
837 | int readio_log, writeio_log; | ||
882 | 838 | ||
883 | /* | ||
884 | * Set the default minimum read and write sizes unless | ||
885 | * already specified in a mount option. | ||
886 | * We use smaller I/O sizes when the file system | ||
887 | * is being used for NFS service (wsync mount option). | ||
888 | */ | ||
889 | if (!(mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)) { | 839 | if (!(mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)) { |
890 | if (mp->m_flags & XFS_MOUNT_WSYNC) { | 840 | if (mp->m_flags & XFS_MOUNT_WSYNC) { |
891 | readio_log = XFS_WSYNC_READIO_LOG; | 841 | readio_log = XFS_WSYNC_READIO_LOG; |
@@ -911,17 +861,14 @@ xfs_mountfs( | |||
911 | mp->m_writeio_log = writeio_log; | 861 | mp->m_writeio_log = writeio_log; |
912 | } | 862 | } |
913 | mp->m_writeio_blocks = 1 << (mp->m_writeio_log - sbp->sb_blocklog); | 863 | mp->m_writeio_blocks = 1 << (mp->m_writeio_log - sbp->sb_blocklog); |
864 | } | ||
914 | 865 | ||
915 | /* | 866 | /* |
916 | * Set the inode cluster size. | 867 | * Set whether we're using inode alignment. |
917 | * This may still be overridden by the file system | 868 | */ |
918 | * block size if it is larger than the chosen cluster size. | 869 | STATIC void |
919 | */ | 870 | xfs_set_inoalignment(xfs_mount_t *mp) |
920 | mp->m_inode_cluster_size = XFS_INODE_BIG_CLUSTER_SIZE; | 871 | { |
921 | |||
922 | /* | ||
923 | * Set whether we're using inode alignment. | ||
924 | */ | ||
925 | if (XFS_SB_VERSION_HASALIGN(&mp->m_sb) && | 872 | if (XFS_SB_VERSION_HASALIGN(&mp->m_sb) && |
926 | mp->m_sb.sb_inoalignmt >= | 873 | mp->m_sb.sb_inoalignmt >= |
927 | XFS_B_TO_FSBT(mp, mp->m_inode_cluster_size)) | 874 | XFS_B_TO_FSBT(mp, mp->m_inode_cluster_size)) |
@@ -937,14 +884,22 @@ xfs_mountfs( | |||
937 | mp->m_sinoalign = mp->m_dalign; | 884 | mp->m_sinoalign = mp->m_dalign; |
938 | else | 885 | else |
939 | mp->m_sinoalign = 0; | 886 | mp->m_sinoalign = 0; |
940 | /* | 887 | } |
941 | * Check that the data (and log if separate) are an ok size. | 888 | |
942 | */ | 889 | /* |
890 | * Check that the data (and log if separate) are an ok size. | ||
891 | */ | ||
892 | STATIC int | ||
893 | xfs_check_sizes(xfs_mount_t *mp, int mfsi_flags) | ||
894 | { | ||
895 | xfs_buf_t *bp; | ||
896 | xfs_daddr_t d; | ||
897 | int error; | ||
898 | |||
943 | d = (xfs_daddr_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks); | 899 | d = (xfs_daddr_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks); |
944 | if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_dblocks) { | 900 | if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_dblocks) { |
945 | cmn_err(CE_WARN, "XFS: size check 1 failed"); | 901 | cmn_err(CE_WARN, "XFS: size check 1 failed"); |
946 | error = XFS_ERROR(E2BIG); | 902 | return XFS_ERROR(E2BIG); |
947 | goto error1; | ||
948 | } | 903 | } |
949 | error = xfs_read_buf(mp, mp->m_ddev_targp, | 904 | error = xfs_read_buf(mp, mp->m_ddev_targp, |
950 | d - XFS_FSS_TO_BB(mp, 1), | 905 | d - XFS_FSS_TO_BB(mp, 1), |
@@ -953,10 +908,9 @@ xfs_mountfs( | |||
953 | xfs_buf_relse(bp); | 908 | xfs_buf_relse(bp); |
954 | } else { | 909 | } else { |
955 | cmn_err(CE_WARN, "XFS: size check 2 failed"); | 910 | cmn_err(CE_WARN, "XFS: size check 2 failed"); |
956 | if (error == ENOSPC) { | 911 | if (error == ENOSPC) |
957 | error = XFS_ERROR(E2BIG); | 912 | error = XFS_ERROR(E2BIG); |
958 | } | 913 | return error; |
959 | goto error1; | ||
960 | } | 914 | } |
961 | 915 | ||
962 | if (((mfsi_flags & XFS_MFSI_CLIENT) == 0) && | 916 | if (((mfsi_flags & XFS_MFSI_CLIENT) == 0) && |
@@ -964,8 +918,7 @@ xfs_mountfs( | |||
964 | d = (xfs_daddr_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks); | 918 | d = (xfs_daddr_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks); |
965 | if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_logblocks) { | 919 | if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_logblocks) { |
966 | cmn_err(CE_WARN, "XFS: size check 3 failed"); | 920 | cmn_err(CE_WARN, "XFS: size check 3 failed"); |
967 | error = XFS_ERROR(E2BIG); | 921 | return XFS_ERROR(E2BIG); |
968 | goto error1; | ||
969 | } | 922 | } |
970 | error = xfs_read_buf(mp, mp->m_logdev_targp, | 923 | error = xfs_read_buf(mp, mp->m_logdev_targp, |
971 | d - XFS_FSB_TO_BB(mp, 1), | 924 | d - XFS_FSB_TO_BB(mp, 1), |
@@ -974,17 +927,111 @@ xfs_mountfs( | |||
974 | xfs_buf_relse(bp); | 927 | xfs_buf_relse(bp); |
975 | } else { | 928 | } else { |
976 | cmn_err(CE_WARN, "XFS: size check 3 failed"); | 929 | cmn_err(CE_WARN, "XFS: size check 3 failed"); |
977 | if (error == ENOSPC) { | 930 | if (error == ENOSPC) |
978 | error = XFS_ERROR(E2BIG); | 931 | error = XFS_ERROR(E2BIG); |
979 | } | 932 | return error; |
933 | } | ||
934 | } | ||
935 | return 0; | ||
936 | } | ||
937 | |||
938 | /* | ||
939 | * xfs_mountfs | ||
940 | * | ||
941 | * This function does the following on an initial mount of a file system: | ||
942 | * - reads the superblock from disk and init the mount struct | ||
943 | * - if we're a 32-bit kernel, do a size check on the superblock | ||
944 | * so we don't mount terabyte filesystems | ||
945 | * - init mount struct realtime fields | ||
946 | * - allocate inode hash table for fs | ||
947 | * - init directory manager | ||
948 | * - perform recovery and init the log manager | ||
949 | */ | ||
950 | int | ||
951 | xfs_mountfs( | ||
952 | xfs_mount_t *mp, | ||
953 | int mfsi_flags) | ||
954 | { | ||
955 | xfs_sb_t *sbp = &(mp->m_sb); | ||
956 | xfs_inode_t *rip; | ||
957 | bhv_vnode_t *rvp = NULL; | ||
958 | __uint64_t resblks; | ||
959 | __int64_t update_flags = 0LL; | ||
960 | uint quotamount, quotaflags; | ||
961 | int agno; | ||
962 | int uuid_mounted = 0; | ||
963 | int error = 0; | ||
964 | |||
965 | if (mp->m_sb_bp == NULL) { | ||
966 | error = xfs_readsb(mp, mfsi_flags); | ||
967 | if (error) | ||
968 | return error; | ||
969 | } | ||
970 | xfs_mount_common(mp, sbp); | ||
971 | |||
972 | /* | ||
973 | * Check if sb_agblocks is aligned at stripe boundary | ||
974 | * If sb_agblocks is NOT aligned turn off m_dalign since | ||
975 | * allocator alignment is within an ag, therefore ag has | ||
976 | * to be aligned at stripe boundary. | ||
977 | */ | ||
978 | error = xfs_update_alignment(mp, mfsi_flags, &update_flags); | ||
979 | if (error) | ||
980 | goto error1; | ||
981 | |||
982 | xfs_alloc_compute_maxlevels(mp); | ||
983 | xfs_bmap_compute_maxlevels(mp, XFS_DATA_FORK); | ||
984 | xfs_bmap_compute_maxlevels(mp, XFS_ATTR_FORK); | ||
985 | xfs_ialloc_compute_maxlevels(mp); | ||
986 | |||
987 | xfs_set_maxicount(mp); | ||
988 | |||
989 | mp->m_maxioffset = xfs_max_file_offset(sbp->sb_blocklog); | ||
990 | |||
991 | /* | ||
992 | * XFS uses the uuid from the superblock as the unique | ||
993 | * identifier for fsid. We can not use the uuid from the volume | ||
994 | * since a single partition filesystem is identical to a single | ||
995 | * partition volume/filesystem. | ||
996 | */ | ||
997 | if ((mfsi_flags & XFS_MFSI_SECOND) == 0 && | ||
998 | (mp->m_flags & XFS_MOUNT_NOUUID) == 0) { | ||
999 | if (xfs_uuid_mount(mp)) { | ||
1000 | error = XFS_ERROR(EINVAL); | ||
980 | goto error1; | 1001 | goto error1; |
981 | } | 1002 | } |
1003 | uuid_mounted=1; | ||
982 | } | 1004 | } |
983 | 1005 | ||
984 | /* | 1006 | /* |
1007 | * Set the minimum read and write sizes | ||
1008 | */ | ||
1009 | xfs_set_rw_sizes(mp); | ||
1010 | |||
1011 | /* | ||
1012 | * Set the inode cluster size. | ||
1013 | * This may still be overridden by the file system | ||
1014 | * block size if it is larger than the chosen cluster size. | ||
1015 | */ | ||
1016 | mp->m_inode_cluster_size = XFS_INODE_BIG_CLUSTER_SIZE; | ||
1017 | |||
1018 | /* | ||
1019 | * Set inode alignment fields | ||
1020 | */ | ||
1021 | xfs_set_inoalignment(mp); | ||
1022 | |||
1023 | /* | ||
1024 | * Check that the data (and log if separate) are an ok size. | ||
1025 | */ | ||
1026 | error = xfs_check_sizes(mp, mfsi_flags); | ||
1027 | if (error) | ||
1028 | goto error1; | ||
1029 | |||
1030 | /* | ||
985 | * Initialize realtime fields in the mount structure | 1031 | * Initialize realtime fields in the mount structure |
986 | */ | 1032 | */ |
987 | if ((error = xfs_rtmount_init(mp))) { | 1033 | error = xfs_rtmount_init(mp); |
1034 | if (error) { | ||
988 | cmn_err(CE_WARN, "XFS: RT mount failed"); | 1035 | cmn_err(CE_WARN, "XFS: RT mount failed"); |
989 | goto error1; | 1036 | goto error1; |
990 | } | 1037 | } |
@@ -1102,7 +1149,8 @@ xfs_mountfs( | |||
1102 | /* | 1149 | /* |
1103 | * Initialize realtime inode pointers in the mount structure | 1150 | * Initialize realtime inode pointers in the mount structure |
1104 | */ | 1151 | */ |
1105 | if ((error = xfs_rtmount_inodes(mp))) { | 1152 | error = xfs_rtmount_inodes(mp); |
1153 | if (error) { | ||
1106 | /* | 1154 | /* |
1107 | * Free up the root inode. | 1155 | * Free up the root inode. |
1108 | */ | 1156 | */ |
@@ -1120,7 +1168,8 @@ xfs_mountfs( | |||
1120 | /* | 1168 | /* |
1121 | * Initialise the XFS quota management subsystem for this mount | 1169 | * Initialise the XFS quota management subsystem for this mount |
1122 | */ | 1170 | */ |
1123 | if ((error = XFS_QM_INIT(mp, "amount, "aflags))) | 1171 | error = XFS_QM_INIT(mp, "amount, "aflags); |
1172 | if (error) | ||
1124 | goto error4; | 1173 | goto error4; |
1125 | 1174 | ||
1126 | /* | 1175 | /* |
@@ -1137,7 +1186,8 @@ xfs_mountfs( | |||
1137 | /* | 1186 | /* |
1138 | * Complete the quota initialisation, post-log-replay component. | 1187 | * Complete the quota initialisation, post-log-replay component. |
1139 | */ | 1188 | */ |
1140 | if ((error = XFS_QM_MOUNT(mp, quotamount, quotaflags, mfsi_flags))) | 1189 | error = XFS_QM_MOUNT(mp, quotamount, quotaflags, mfsi_flags); |
1190 | if (error) | ||
1141 | goto error4; | 1191 | goto error4; |
1142 | 1192 | ||
1143 | /* | 1193 | /* |
@@ -1255,7 +1305,6 @@ xfs_unmountfs(xfs_mount_t *mp, struct cred *cr) | |||
1255 | #if defined(DEBUG) || defined(INDUCE_IO_ERROR) | 1305 | #if defined(DEBUG) || defined(INDUCE_IO_ERROR) |
1256 | xfs_errortag_clearall(mp, 0); | 1306 | xfs_errortag_clearall(mp, 0); |
1257 | #endif | 1307 | #endif |
1258 | XFS_IODONE(mp); | ||
1259 | xfs_mount_free(mp); | 1308 | xfs_mount_free(mp); |
1260 | return 0; | 1309 | return 0; |
1261 | } | 1310 | } |
@@ -1441,7 +1490,7 @@ xfs_mod_sb(xfs_trans_t *tp, __int64_t fields) | |||
1441 | * Fields are not allowed to dip below zero, so if the delta would | 1490 | * Fields are not allowed to dip below zero, so if the delta would |
1442 | * do this do not apply it and return EINVAL. | 1491 | * do this do not apply it and return EINVAL. |
1443 | * | 1492 | * |
1444 | * The SB_LOCK must be held when this routine is called. | 1493 | * The m_sb_lock must be held when this routine is called. |
1445 | */ | 1494 | */ |
1446 | int | 1495 | int |
1447 | xfs_mod_incore_sb_unlocked( | 1496 | xfs_mod_incore_sb_unlocked( |
@@ -1606,7 +1655,7 @@ xfs_mod_incore_sb_unlocked( | |||
1606 | /* | 1655 | /* |
1607 | * xfs_mod_incore_sb() is used to change a field in the in-core | 1656 | * xfs_mod_incore_sb() is used to change a field in the in-core |
1608 | * superblock structure by the specified delta. This modification | 1657 | * superblock structure by the specified delta. This modification |
1609 | * is protected by the SB_LOCK. Just use the xfs_mod_incore_sb_unlocked() | 1658 | * is protected by the m_sb_lock. Just use the xfs_mod_incore_sb_unlocked() |
1610 | * routine to do the work. | 1659 | * routine to do the work. |
1611 | */ | 1660 | */ |
1612 | int | 1661 | int |
@@ -1616,7 +1665,6 @@ xfs_mod_incore_sb( | |||
1616 | int64_t delta, | 1665 | int64_t delta, |
1617 | int rsvd) | 1666 | int rsvd) |
1618 | { | 1667 | { |
1619 | unsigned long s; | ||
1620 | int status; | 1668 | int status; |
1621 | 1669 | ||
1622 | /* check for per-cpu counters */ | 1670 | /* check for per-cpu counters */ |
@@ -1633,9 +1681,9 @@ xfs_mod_incore_sb( | |||
1633 | /* FALLTHROUGH */ | 1681 | /* FALLTHROUGH */ |
1634 | #endif | 1682 | #endif |
1635 | default: | 1683 | default: |
1636 | s = XFS_SB_LOCK(mp); | 1684 | spin_lock(&mp->m_sb_lock); |
1637 | status = xfs_mod_incore_sb_unlocked(mp, field, delta, rsvd); | 1685 | status = xfs_mod_incore_sb_unlocked(mp, field, delta, rsvd); |
1638 | XFS_SB_UNLOCK(mp, s); | 1686 | spin_unlock(&mp->m_sb_lock); |
1639 | break; | 1687 | break; |
1640 | } | 1688 | } |
1641 | 1689 | ||
@@ -1656,7 +1704,6 @@ xfs_mod_incore_sb( | |||
1656 | int | 1704 | int |
1657 | xfs_mod_incore_sb_batch(xfs_mount_t *mp, xfs_mod_sb_t *msb, uint nmsb, int rsvd) | 1705 | xfs_mod_incore_sb_batch(xfs_mount_t *mp, xfs_mod_sb_t *msb, uint nmsb, int rsvd) |
1658 | { | 1706 | { |
1659 | unsigned long s; | ||
1660 | int status=0; | 1707 | int status=0; |
1661 | xfs_mod_sb_t *msbp; | 1708 | xfs_mod_sb_t *msbp; |
1662 | 1709 | ||
@@ -1664,10 +1711,10 @@ xfs_mod_incore_sb_batch(xfs_mount_t *mp, xfs_mod_sb_t *msb, uint nmsb, int rsvd) | |||
1664 | * Loop through the array of mod structures and apply each | 1711 | * Loop through the array of mod structures and apply each |
1665 | * individually. If any fail, then back out all those | 1712 | * individually. If any fail, then back out all those |
1666 | * which have already been applied. Do all of this within | 1713 | * which have already been applied. Do all of this within |
1667 | * the scope of the SB_LOCK so that all of the changes will | 1714 | * the scope of the m_sb_lock so that all of the changes will |
1668 | * be atomic. | 1715 | * be atomic. |
1669 | */ | 1716 | */ |
1670 | s = XFS_SB_LOCK(mp); | 1717 | spin_lock(&mp->m_sb_lock); |
1671 | msbp = &msb[0]; | 1718 | msbp = &msb[0]; |
1672 | for (msbp = &msbp[0]; msbp < (msb + nmsb); msbp++) { | 1719 | for (msbp = &msbp[0]; msbp < (msb + nmsb); msbp++) { |
1673 | /* | 1720 | /* |
@@ -1681,11 +1728,11 @@ xfs_mod_incore_sb_batch(xfs_mount_t *mp, xfs_mod_sb_t *msb, uint nmsb, int rsvd) | |||
1681 | case XFS_SBS_IFREE: | 1728 | case XFS_SBS_IFREE: |
1682 | case XFS_SBS_FDBLOCKS: | 1729 | case XFS_SBS_FDBLOCKS: |
1683 | if (!(mp->m_flags & XFS_MOUNT_NO_PERCPU_SB)) { | 1730 | if (!(mp->m_flags & XFS_MOUNT_NO_PERCPU_SB)) { |
1684 | XFS_SB_UNLOCK(mp, s); | 1731 | spin_unlock(&mp->m_sb_lock); |
1685 | status = xfs_icsb_modify_counters(mp, | 1732 | status = xfs_icsb_modify_counters(mp, |
1686 | msbp->msb_field, | 1733 | msbp->msb_field, |
1687 | msbp->msb_delta, rsvd); | 1734 | msbp->msb_delta, rsvd); |
1688 | s = XFS_SB_LOCK(mp); | 1735 | spin_lock(&mp->m_sb_lock); |
1689 | break; | 1736 | break; |
1690 | } | 1737 | } |
1691 | /* FALLTHROUGH */ | 1738 | /* FALLTHROUGH */ |
@@ -1719,12 +1766,12 @@ xfs_mod_incore_sb_batch(xfs_mount_t *mp, xfs_mod_sb_t *msb, uint nmsb, int rsvd) | |||
1719 | case XFS_SBS_IFREE: | 1766 | case XFS_SBS_IFREE: |
1720 | case XFS_SBS_FDBLOCKS: | 1767 | case XFS_SBS_FDBLOCKS: |
1721 | if (!(mp->m_flags & XFS_MOUNT_NO_PERCPU_SB)) { | 1768 | if (!(mp->m_flags & XFS_MOUNT_NO_PERCPU_SB)) { |
1722 | XFS_SB_UNLOCK(mp, s); | 1769 | spin_unlock(&mp->m_sb_lock); |
1723 | status = xfs_icsb_modify_counters(mp, | 1770 | status = xfs_icsb_modify_counters(mp, |
1724 | msbp->msb_field, | 1771 | msbp->msb_field, |
1725 | -(msbp->msb_delta), | 1772 | -(msbp->msb_delta), |
1726 | rsvd); | 1773 | rsvd); |
1727 | s = XFS_SB_LOCK(mp); | 1774 | spin_lock(&mp->m_sb_lock); |
1728 | break; | 1775 | break; |
1729 | } | 1776 | } |
1730 | /* FALLTHROUGH */ | 1777 | /* FALLTHROUGH */ |
@@ -1740,7 +1787,7 @@ xfs_mod_incore_sb_batch(xfs_mount_t *mp, xfs_mod_sb_t *msb, uint nmsb, int rsvd) | |||
1740 | msbp--; | 1787 | msbp--; |
1741 | } | 1788 | } |
1742 | } | 1789 | } |
1743 | XFS_SB_UNLOCK(mp, s); | 1790 | spin_unlock(&mp->m_sb_lock); |
1744 | return status; | 1791 | return status; |
1745 | } | 1792 | } |
1746 | 1793 | ||
@@ -1888,12 +1935,12 @@ xfs_mount_log_sbunit( | |||
1888 | * | 1935 | * |
1889 | * Locking rules: | 1936 | * Locking rules: |
1890 | * | 1937 | * |
1891 | * 1. XFS_SB_LOCK() before picking up per-cpu locks | 1938 | * 1. m_sb_lock before picking up per-cpu locks |
1892 | * 2. per-cpu locks always picked up via for_each_online_cpu() order | 1939 | * 2. per-cpu locks always picked up via for_each_online_cpu() order |
1893 | * 3. accurate counter sync requires XFS_SB_LOCK + per cpu locks | 1940 | * 3. accurate counter sync requires m_sb_lock + per cpu locks |
1894 | * 4. modifying per-cpu counters requires holding per-cpu lock | 1941 | * 4. modifying per-cpu counters requires holding per-cpu lock |
1895 | * 5. modifying global counters requires holding XFS_SB_LOCK | 1942 | * 5. modifying global counters requires holding m_sb_lock |
1896 | * 6. enabling or disabling a counter requires holding the XFS_SB_LOCK | 1943 | * 6. enabling or disabling a counter requires holding the m_sb_lock |
1897 | * and _none_ of the per-cpu locks. | 1944 | * and _none_ of the per-cpu locks. |
1898 | * | 1945 | * |
1899 | * Disabled counters are only ever re-enabled by a balance operation | 1946 | * Disabled counters are only ever re-enabled by a balance operation |
@@ -1920,7 +1967,6 @@ xfs_icsb_cpu_notify( | |||
1920 | { | 1967 | { |
1921 | xfs_icsb_cnts_t *cntp; | 1968 | xfs_icsb_cnts_t *cntp; |
1922 | xfs_mount_t *mp; | 1969 | xfs_mount_t *mp; |
1923 | int s; | ||
1924 | 1970 | ||
1925 | mp = (xfs_mount_t *)container_of(nfb, xfs_mount_t, m_icsb_notifier); | 1971 | mp = (xfs_mount_t *)container_of(nfb, xfs_mount_t, m_icsb_notifier); |
1926 | cntp = (xfs_icsb_cnts_t *) | 1972 | cntp = (xfs_icsb_cnts_t *) |
@@ -1946,7 +1992,7 @@ xfs_icsb_cpu_notify( | |||
1946 | * count into the total on the global superblock and | 1992 | * count into the total on the global superblock and |
1947 | * re-enable the counters. */ | 1993 | * re-enable the counters. */ |
1948 | xfs_icsb_lock(mp); | 1994 | xfs_icsb_lock(mp); |
1949 | s = XFS_SB_LOCK(mp); | 1995 | spin_lock(&mp->m_sb_lock); |
1950 | xfs_icsb_disable_counter(mp, XFS_SBS_ICOUNT); | 1996 | xfs_icsb_disable_counter(mp, XFS_SBS_ICOUNT); |
1951 | xfs_icsb_disable_counter(mp, XFS_SBS_IFREE); | 1997 | xfs_icsb_disable_counter(mp, XFS_SBS_IFREE); |
1952 | xfs_icsb_disable_counter(mp, XFS_SBS_FDBLOCKS); | 1998 | xfs_icsb_disable_counter(mp, XFS_SBS_FDBLOCKS); |
@@ -1963,7 +2009,7 @@ xfs_icsb_cpu_notify( | |||
1963 | XFS_ICSB_SB_LOCKED, 0); | 2009 | XFS_ICSB_SB_LOCKED, 0); |
1964 | xfs_icsb_balance_counter(mp, XFS_SBS_FDBLOCKS, | 2010 | xfs_icsb_balance_counter(mp, XFS_SBS_FDBLOCKS, |
1965 | XFS_ICSB_SB_LOCKED, 0); | 2011 | XFS_ICSB_SB_LOCKED, 0); |
1966 | XFS_SB_UNLOCK(mp, s); | 2012 | spin_unlock(&mp->m_sb_lock); |
1967 | xfs_icsb_unlock(mp); | 2013 | xfs_icsb_unlock(mp); |
1968 | break; | 2014 | break; |
1969 | } | 2015 | } |
@@ -2194,11 +2240,10 @@ xfs_icsb_sync_counters_flags( | |||
2194 | int flags) | 2240 | int flags) |
2195 | { | 2241 | { |
2196 | xfs_icsb_cnts_t cnt; | 2242 | xfs_icsb_cnts_t cnt; |
2197 | int s; | ||
2198 | 2243 | ||
2199 | /* Pass 1: lock all counters */ | 2244 | /* Pass 1: lock all counters */ |
2200 | if ((flags & XFS_ICSB_SB_LOCKED) == 0) | 2245 | if ((flags & XFS_ICSB_SB_LOCKED) == 0) |
2201 | s = XFS_SB_LOCK(mp); | 2246 | spin_lock(&mp->m_sb_lock); |
2202 | 2247 | ||
2203 | xfs_icsb_count(mp, &cnt, flags); | 2248 | xfs_icsb_count(mp, &cnt, flags); |
2204 | 2249 | ||
@@ -2211,7 +2256,7 @@ xfs_icsb_sync_counters_flags( | |||
2211 | mp->m_sb.sb_fdblocks = cnt.icsb_fdblocks; | 2256 | mp->m_sb.sb_fdblocks = cnt.icsb_fdblocks; |
2212 | 2257 | ||
2213 | if ((flags & XFS_ICSB_SB_LOCKED) == 0) | 2258 | if ((flags & XFS_ICSB_SB_LOCKED) == 0) |
2214 | XFS_SB_UNLOCK(mp, s); | 2259 | spin_unlock(&mp->m_sb_lock); |
2215 | } | 2260 | } |
2216 | 2261 | ||
2217 | /* | 2262 | /* |
@@ -2252,11 +2297,10 @@ xfs_icsb_balance_counter( | |||
2252 | { | 2297 | { |
2253 | uint64_t count, resid; | 2298 | uint64_t count, resid; |
2254 | int weight = num_online_cpus(); | 2299 | int weight = num_online_cpus(); |
2255 | int s; | ||
2256 | uint64_t min = (uint64_t)min_per_cpu; | 2300 | uint64_t min = (uint64_t)min_per_cpu; |
2257 | 2301 | ||
2258 | if (!(flags & XFS_ICSB_SB_LOCKED)) | 2302 | if (!(flags & XFS_ICSB_SB_LOCKED)) |
2259 | s = XFS_SB_LOCK(mp); | 2303 | spin_lock(&mp->m_sb_lock); |
2260 | 2304 | ||
2261 | /* disable counter and sync counter */ | 2305 | /* disable counter and sync counter */ |
2262 | xfs_icsb_disable_counter(mp, field); | 2306 | xfs_icsb_disable_counter(mp, field); |
@@ -2290,10 +2334,10 @@ xfs_icsb_balance_counter( | |||
2290 | xfs_icsb_enable_counter(mp, field, count, resid); | 2334 | xfs_icsb_enable_counter(mp, field, count, resid); |
2291 | out: | 2335 | out: |
2292 | if (!(flags & XFS_ICSB_SB_LOCKED)) | 2336 | if (!(flags & XFS_ICSB_SB_LOCKED)) |
2293 | XFS_SB_UNLOCK(mp, s); | 2337 | spin_unlock(&mp->m_sb_lock); |
2294 | } | 2338 | } |
2295 | 2339 | ||
2296 | int | 2340 | STATIC int |
2297 | xfs_icsb_modify_counters( | 2341 | xfs_icsb_modify_counters( |
2298 | xfs_mount_t *mp, | 2342 | xfs_mount_t *mp, |
2299 | xfs_sb_field_t field, | 2343 | xfs_sb_field_t field, |
@@ -2302,7 +2346,7 @@ xfs_icsb_modify_counters( | |||
2302 | { | 2346 | { |
2303 | xfs_icsb_cnts_t *icsbp; | 2347 | xfs_icsb_cnts_t *icsbp; |
2304 | long long lcounter; /* long counter for 64 bit fields */ | 2348 | long long lcounter; /* long counter for 64 bit fields */ |
2305 | int cpu, ret = 0, s; | 2349 | int cpu, ret = 0; |
2306 | 2350 | ||
2307 | might_sleep(); | 2351 | might_sleep(); |
2308 | again: | 2352 | again: |
@@ -2380,15 +2424,15 @@ slow_path: | |||
2380 | * running atomically here, we know a rebalance cannot | 2424 | * running atomically here, we know a rebalance cannot |
2381 | * be in progress. Hence we can go straight to operating | 2425 | * be in progress. Hence we can go straight to operating |
2382 | * on the global superblock. We do not call xfs_mod_incore_sb() | 2426 | * on the global superblock. We do not call xfs_mod_incore_sb() |
2383 | * here even though we need to get the SB_LOCK. Doing so | 2427 | * here even though we need to get the m_sb_lock. Doing so |
2384 | * will cause us to re-enter this function and deadlock. | 2428 | * will cause us to re-enter this function and deadlock. |
2385 | * Hence we get the SB_LOCK ourselves and then call | 2429 | * Hence we get the m_sb_lock ourselves and then call |
2386 | * xfs_mod_incore_sb_unlocked() as the unlocked path operates | 2430 | * xfs_mod_incore_sb_unlocked() as the unlocked path operates |
2387 | * directly on the global counters. | 2431 | * directly on the global counters. |
2388 | */ | 2432 | */ |
2389 | s = XFS_SB_LOCK(mp); | 2433 | spin_lock(&mp->m_sb_lock); |
2390 | ret = xfs_mod_incore_sb_unlocked(mp, field, delta, rsvd); | 2434 | ret = xfs_mod_incore_sb_unlocked(mp, field, delta, rsvd); |
2391 | XFS_SB_UNLOCK(mp, s); | 2435 | spin_unlock(&mp->m_sb_lock); |
2392 | 2436 | ||
2393 | /* | 2437 | /* |
2394 | * Now that we've modified the global superblock, we | 2438 | * Now that we've modified the global superblock, we |