diff options
Diffstat (limited to 'fs/xfs/xfs_mount.c')
| -rw-r--r-- | fs/xfs/xfs_mount.c | 118 |
1 files changed, 38 insertions, 80 deletions
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index da3988453b71..6c5d1325e7f6 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c | |||
| @@ -47,12 +47,10 @@ | |||
| 47 | 47 | ||
| 48 | STATIC int xfs_mount_log_sb(xfs_mount_t *, __int64_t); | 48 | STATIC int xfs_mount_log_sb(xfs_mount_t *, __int64_t); |
| 49 | STATIC int xfs_uuid_mount(xfs_mount_t *); | 49 | STATIC int xfs_uuid_mount(xfs_mount_t *); |
| 50 | STATIC void xfs_uuid_unmount(xfs_mount_t *mp); | ||
| 51 | STATIC void xfs_unmountfs_wait(xfs_mount_t *); | 50 | STATIC void xfs_unmountfs_wait(xfs_mount_t *); |
| 52 | 51 | ||
| 53 | 52 | ||
| 54 | #ifdef HAVE_PERCPU_SB | 53 | #ifdef HAVE_PERCPU_SB |
| 55 | STATIC void xfs_icsb_destroy_counters(xfs_mount_t *); | ||
| 56 | STATIC void xfs_icsb_balance_counter(xfs_mount_t *, xfs_sb_field_t, | 54 | STATIC void xfs_icsb_balance_counter(xfs_mount_t *, xfs_sb_field_t, |
| 57 | int); | 55 | int); |
| 58 | STATIC void xfs_icsb_balance_counter_locked(xfs_mount_t *, xfs_sb_field_t, | 56 | STATIC void xfs_icsb_balance_counter_locked(xfs_mount_t *, xfs_sb_field_t, |
| @@ -63,7 +61,6 @@ STATIC void xfs_icsb_disable_counter(xfs_mount_t *, xfs_sb_field_t); | |||
| 63 | 61 | ||
| 64 | #else | 62 | #else |
| 65 | 63 | ||
| 66 | #define xfs_icsb_destroy_counters(mp) do { } while (0) | ||
| 67 | #define xfs_icsb_balance_counter(mp, a, b) do { } while (0) | 64 | #define xfs_icsb_balance_counter(mp, a, b) do { } while (0) |
| 68 | #define xfs_icsb_balance_counter_locked(mp, a, b) do { } while (0) | 65 | #define xfs_icsb_balance_counter_locked(mp, a, b) do { } while (0) |
| 69 | #define xfs_icsb_modify_counters(mp, a, b, c) do { } while (0) | 66 | #define xfs_icsb_modify_counters(mp, a, b, c) do { } while (0) |
| @@ -126,33 +123,11 @@ static const struct { | |||
| 126 | }; | 123 | }; |
| 127 | 124 | ||
| 128 | /* | 125 | /* |
| 129 | * Return a pointer to an initialized xfs_mount structure. | ||
| 130 | */ | ||
| 131 | xfs_mount_t * | ||
| 132 | xfs_mount_init(void) | ||
| 133 | { | ||
| 134 | xfs_mount_t *mp; | ||
| 135 | |||
| 136 | mp = kmem_zalloc(sizeof(xfs_mount_t), KM_SLEEP); | ||
| 137 | |||
| 138 | if (xfs_icsb_init_counters(mp)) { | ||
| 139 | mp->m_flags |= XFS_MOUNT_NO_PERCPU_SB; | ||
| 140 | } | ||
| 141 | |||
| 142 | spin_lock_init(&mp->m_sb_lock); | ||
| 143 | mutex_init(&mp->m_ilock); | ||
| 144 | mutex_init(&mp->m_growlock); | ||
| 145 | atomic_set(&mp->m_active_trans, 0); | ||
| 146 | |||
| 147 | return mp; | ||
| 148 | } | ||
| 149 | |||
| 150 | /* | ||
| 151 | * Free up the resources associated with a mount structure. Assume that | 126 | * Free up the resources associated with a mount structure. Assume that |
| 152 | * the structure was initially zeroed, so we can tell which fields got | 127 | * the structure was initially zeroed, so we can tell which fields got |
| 153 | * initialized. | 128 | * initialized. |
| 154 | */ | 129 | */ |
| 155 | void | 130 | STATIC void |
| 156 | xfs_mount_free( | 131 | xfs_mount_free( |
| 157 | xfs_mount_t *mp) | 132 | xfs_mount_t *mp) |
| 158 | { | 133 | { |
| @@ -161,11 +136,8 @@ xfs_mount_free( | |||
| 161 | 136 | ||
| 162 | for (agno = 0; agno < mp->m_maxagi; agno++) | 137 | for (agno = 0; agno < mp->m_maxagi; agno++) |
| 163 | if (mp->m_perag[agno].pagb_list) | 138 | if (mp->m_perag[agno].pagb_list) |
| 164 | kmem_free(mp->m_perag[agno].pagb_list, | 139 | kmem_free(mp->m_perag[agno].pagb_list); |
| 165 | sizeof(xfs_perag_busy_t) * | 140 | kmem_free(mp->m_perag); |
| 166 | XFS_PAGB_NUM_SLOTS); | ||
| 167 | kmem_free(mp->m_perag, | ||
| 168 | sizeof(xfs_perag_t) * mp->m_sb.sb_agcount); | ||
| 169 | } | 141 | } |
| 170 | 142 | ||
| 171 | spinlock_destroy(&mp->m_ail_lock); | 143 | spinlock_destroy(&mp->m_ail_lock); |
| @@ -176,13 +148,11 @@ xfs_mount_free( | |||
| 176 | XFS_QM_DONE(mp); | 148 | XFS_QM_DONE(mp); |
| 177 | 149 | ||
| 178 | if (mp->m_fsname != NULL) | 150 | if (mp->m_fsname != NULL) |
| 179 | kmem_free(mp->m_fsname, mp->m_fsname_len); | 151 | kmem_free(mp->m_fsname); |
| 180 | if (mp->m_rtname != NULL) | 152 | if (mp->m_rtname != NULL) |
| 181 | kmem_free(mp->m_rtname, strlen(mp->m_rtname) + 1); | 153 | kmem_free(mp->m_rtname); |
| 182 | if (mp->m_logname != NULL) | 154 | if (mp->m_logname != NULL) |
| 183 | kmem_free(mp->m_logname, strlen(mp->m_logname) + 1); | 155 | kmem_free(mp->m_logname); |
| 184 | |||
| 185 | xfs_icsb_destroy_counters(mp); | ||
| 186 | } | 156 | } |
| 187 | 157 | ||
| 188 | /* | 158 | /* |
| @@ -288,6 +258,19 @@ xfs_mount_validate_sb( | |||
| 288 | return XFS_ERROR(EFSCORRUPTED); | 258 | return XFS_ERROR(EFSCORRUPTED); |
| 289 | } | 259 | } |
| 290 | 260 | ||
| 261 | /* | ||
| 262 | * Until this is fixed only page-sized or smaller data blocks work. | ||
| 263 | */ | ||
| 264 | if (unlikely(sbp->sb_blocksize > PAGE_SIZE)) { | ||
| 265 | xfs_fs_mount_cmn_err(flags, | ||
| 266 | "file system with blocksize %d bytes", | ||
| 267 | sbp->sb_blocksize); | ||
| 268 | xfs_fs_mount_cmn_err(flags, | ||
| 269 | "only pagesize (%ld) or less will currently work.", | ||
| 270 | PAGE_SIZE); | ||
| 271 | return XFS_ERROR(ENOSYS); | ||
| 272 | } | ||
| 273 | |||
| 291 | if (xfs_sb_validate_fsb_count(sbp, sbp->sb_dblocks) || | 274 | if (xfs_sb_validate_fsb_count(sbp, sbp->sb_dblocks) || |
| 292 | xfs_sb_validate_fsb_count(sbp, sbp->sb_rblocks)) { | 275 | xfs_sb_validate_fsb_count(sbp, sbp->sb_rblocks)) { |
| 293 | xfs_fs_mount_cmn_err(flags, | 276 | xfs_fs_mount_cmn_err(flags, |
| @@ -309,19 +292,6 @@ xfs_mount_validate_sb( | |||
| 309 | return XFS_ERROR(ENOSYS); | 292 | return XFS_ERROR(ENOSYS); |
| 310 | } | 293 | } |
| 311 | 294 | ||
| 312 | /* | ||
| 313 | * Until this is fixed only page-sized or smaller data blocks work. | ||
| 314 | */ | ||
| 315 | if (unlikely(sbp->sb_blocksize > PAGE_SIZE)) { | ||
| 316 | xfs_fs_mount_cmn_err(flags, | ||
| 317 | "file system with blocksize %d bytes", | ||
| 318 | sbp->sb_blocksize); | ||
| 319 | xfs_fs_mount_cmn_err(flags, | ||
| 320 | "only pagesize (%ld) or less will currently work.", | ||
| 321 | PAGE_SIZE); | ||
| 322 | return XFS_ERROR(ENOSYS); | ||
| 323 | } | ||
| 324 | |||
| 325 | return 0; | 295 | return 0; |
| 326 | } | 296 | } |
| 327 | 297 | ||
| @@ -994,9 +964,19 @@ xfs_mountfs( | |||
| 994 | * Re-check for ATTR2 in case it was found in bad_features2 | 964 | * Re-check for ATTR2 in case it was found in bad_features2 |
| 995 | * slot. | 965 | * slot. |
| 996 | */ | 966 | */ |
| 997 | if (xfs_sb_version_hasattr2(&mp->m_sb)) | 967 | if (xfs_sb_version_hasattr2(&mp->m_sb) && |
| 968 | !(mp->m_flags & XFS_MOUNT_NOATTR2)) | ||
| 998 | mp->m_flags |= XFS_MOUNT_ATTR2; | 969 | mp->m_flags |= XFS_MOUNT_ATTR2; |
| 970 | } | ||
| 971 | |||
| 972 | if (xfs_sb_version_hasattr2(&mp->m_sb) && | ||
| 973 | (mp->m_flags & XFS_MOUNT_NOATTR2)) { | ||
| 974 | xfs_sb_version_removeattr2(&mp->m_sb); | ||
| 975 | update_flags |= XFS_SB_FEATURES2; | ||
| 999 | 976 | ||
| 977 | /* update sb_versionnum for the clearing of the morebits */ | ||
| 978 | if (!sbp->sb_features2) | ||
| 979 | update_flags |= XFS_SB_VERSIONNUM; | ||
| 1000 | } | 980 | } |
| 1001 | 981 | ||
| 1002 | /* | 982 | /* |
| @@ -1255,15 +1235,13 @@ xfs_mountfs( | |||
| 1255 | error2: | 1235 | error2: |
| 1256 | for (agno = 0; agno < sbp->sb_agcount; agno++) | 1236 | for (agno = 0; agno < sbp->sb_agcount; agno++) |
| 1257 | if (mp->m_perag[agno].pagb_list) | 1237 | if (mp->m_perag[agno].pagb_list) |
| 1258 | kmem_free(mp->m_perag[agno].pagb_list, | 1238 | kmem_free(mp->m_perag[agno].pagb_list); |
| 1259 | sizeof(xfs_perag_busy_t) * XFS_PAGB_NUM_SLOTS); | 1239 | kmem_free(mp->m_perag); |
| 1260 | kmem_free(mp->m_perag, sbp->sb_agcount * sizeof(xfs_perag_t)); | ||
| 1261 | mp->m_perag = NULL; | 1240 | mp->m_perag = NULL; |
| 1262 | /* FALLTHROUGH */ | 1241 | /* FALLTHROUGH */ |
| 1263 | error1: | 1242 | error1: |
| 1264 | if (uuid_mounted) | 1243 | if (uuid_mounted) |
| 1265 | xfs_uuid_unmount(mp); | 1244 | uuid_table_remove(&mp->m_sb.sb_uuid); |
| 1266 | xfs_freesb(mp); | ||
| 1267 | return error; | 1245 | return error; |
| 1268 | } | 1246 | } |
| 1269 | 1247 | ||
| @@ -1274,7 +1252,7 @@ xfs_mountfs( | |||
| 1274 | * log and makes sure that incore structures are freed. | 1252 | * log and makes sure that incore structures are freed. |
| 1275 | */ | 1253 | */ |
| 1276 | int | 1254 | int |
| 1277 | xfs_unmountfs(xfs_mount_t *mp, struct cred *cr) | 1255 | xfs_unmountfs(xfs_mount_t *mp) |
| 1278 | { | 1256 | { |
| 1279 | __uint64_t resblks; | 1257 | __uint64_t resblks; |
| 1280 | int error = 0; | 1258 | int error = 0; |
| @@ -1341,9 +1319,8 @@ xfs_unmountfs(xfs_mount_t *mp, struct cred *cr) | |||
| 1341 | */ | 1319 | */ |
| 1342 | ASSERT(mp->m_inodes == NULL); | 1320 | ASSERT(mp->m_inodes == NULL); |
| 1343 | 1321 | ||
| 1344 | xfs_unmountfs_close(mp, cr); | ||
| 1345 | if ((mp->m_flags & XFS_MOUNT_NOUUID) == 0) | 1322 | if ((mp->m_flags & XFS_MOUNT_NOUUID) == 0) |
| 1346 | xfs_uuid_unmount(mp); | 1323 | uuid_table_remove(&mp->m_sb.sb_uuid); |
| 1347 | 1324 | ||
| 1348 | #if defined(DEBUG) || defined(INDUCE_IO_ERROR) | 1325 | #if defined(DEBUG) || defined(INDUCE_IO_ERROR) |
| 1349 | xfs_errortag_clearall(mp, 0); | 1326 | xfs_errortag_clearall(mp, 0); |
| @@ -1352,16 +1329,6 @@ xfs_unmountfs(xfs_mount_t *mp, struct cred *cr) | |||
| 1352 | return 0; | 1329 | return 0; |
| 1353 | } | 1330 | } |
| 1354 | 1331 | ||
| 1355 | void | ||
| 1356 | xfs_unmountfs_close(xfs_mount_t *mp, struct cred *cr) | ||
| 1357 | { | ||
| 1358 | if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) | ||
| 1359 | xfs_free_buftarg(mp->m_logdev_targp, 1); | ||
| 1360 | if (mp->m_rtdev_targp) | ||
| 1361 | xfs_free_buftarg(mp->m_rtdev_targp, 1); | ||
| 1362 | xfs_free_buftarg(mp->m_ddev_targp, 0); | ||
| 1363 | } | ||
| 1364 | |||
| 1365 | STATIC void | 1332 | STATIC void |
| 1366 | xfs_unmountfs_wait(xfs_mount_t *mp) | 1333 | xfs_unmountfs_wait(xfs_mount_t *mp) |
| 1367 | { | 1334 | { |
| @@ -1905,16 +1872,6 @@ xfs_uuid_mount( | |||
| 1905 | } | 1872 | } |
| 1906 | 1873 | ||
| 1907 | /* | 1874 | /* |
| 1908 | * Remove filesystem from the UUID table. | ||
| 1909 | */ | ||
| 1910 | STATIC void | ||
| 1911 | xfs_uuid_unmount( | ||
| 1912 | xfs_mount_t *mp) | ||
| 1913 | { | ||
| 1914 | uuid_table_remove(&mp->m_sb.sb_uuid); | ||
| 1915 | } | ||
| 1916 | |||
| 1917 | /* | ||
| 1918 | * Used to log changes to the superblock unit and width fields which could | 1875 | * Used to log changes to the superblock unit and width fields which could |
| 1919 | * be altered by the mount options, as well as any potential sb_features2 | 1876 | * be altered by the mount options, as well as any potential sb_features2 |
| 1920 | * fixup. Only the first superblock is updated. | 1877 | * fixup. Only the first superblock is updated. |
| @@ -1928,7 +1885,8 @@ xfs_mount_log_sb( | |||
| 1928 | int error; | 1885 | int error; |
| 1929 | 1886 | ||
| 1930 | ASSERT(fields & (XFS_SB_UNIT | XFS_SB_WIDTH | XFS_SB_UUID | | 1887 | ASSERT(fields & (XFS_SB_UNIT | XFS_SB_WIDTH | XFS_SB_UUID | |
| 1931 | XFS_SB_FEATURES2 | XFS_SB_BAD_FEATURES2)); | 1888 | XFS_SB_FEATURES2 | XFS_SB_BAD_FEATURES2 | |
| 1889 | XFS_SB_VERSIONNUM)); | ||
| 1932 | 1890 | ||
| 1933 | tp = xfs_trans_alloc(mp, XFS_TRANS_SB_UNIT); | 1891 | tp = xfs_trans_alloc(mp, XFS_TRANS_SB_UNIT); |
| 1934 | error = xfs_trans_reserve(tp, 0, mp->m_sb.sb_sectsize + 128, 0, 0, | 1892 | error = xfs_trans_reserve(tp, 0, mp->m_sb.sb_sectsize + 128, 0, 0, |
| @@ -2109,7 +2067,7 @@ xfs_icsb_reinit_counters( | |||
| 2109 | xfs_icsb_unlock(mp); | 2067 | xfs_icsb_unlock(mp); |
| 2110 | } | 2068 | } |
| 2111 | 2069 | ||
| 2112 | STATIC void | 2070 | void |
| 2113 | xfs_icsb_destroy_counters( | 2071 | xfs_icsb_destroy_counters( |
| 2114 | xfs_mount_t *mp) | 2072 | xfs_mount_t *mp) |
| 2115 | { | 2073 | { |
