1022 mutex_enter(&zfsvfs->z_os->os_user_ptr_lock); |
1023 mutex_enter(&zfsvfs->z_os->os_user_ptr_lock); |
1023 dmu_objset_set_user(zfsvfs->z_os, zfsvfs); |
1024 dmu_objset_set_user(zfsvfs->z_os, zfsvfs); |
1024 mutex_exit(&zfsvfs->z_os->os_user_ptr_lock); |
1025 mutex_exit(&zfsvfs->z_os->os_user_ptr_lock); |
1025 |
1026 |
1026 zfsvfs->z_log = zil_open(zfsvfs->z_os, zfs_get_data); |
1027 zfsvfs->z_log = zil_open(zfsvfs->z_os, zfs_get_data); |
1027 if (zil_disable) { |
|
1028 zil_destroy(zfsvfs->z_log, B_FALSE); |
|
1029 zfsvfs->z_log = NULL; |
|
1030 } |
|
1031 |
1028 |
1032 /* |
1029 /* |
1033 * If we are not mounting (ie: online recv), then we don't |
1030 * If we are not mounting (ie: online recv), then we don't |
1034 * have to worry about replaying the log as we blocked all |
1031 * have to worry about replaying the log as we blocked all |
1035 * operations out since we closed the ZIL. |
1032 * operations out since we closed the ZIL. |
1045 if (readonly != 0) |
1042 if (readonly != 0) |
1046 zfsvfs->z_vfs->vfs_flag &= ~VFS_RDONLY; |
1043 zfsvfs->z_vfs->vfs_flag &= ~VFS_RDONLY; |
1047 else |
1044 else |
1048 zfs_unlinked_drain(zfsvfs); |
1045 zfs_unlinked_drain(zfsvfs); |
1049 |
1046 |
1050 if (zfsvfs->z_log) { |
1047 /* |
1051 /* |
1048 * Parse and replay the intent log. |
1052 * Parse and replay the intent log. |
1049 * |
1053 * |
1050 * Because of ziltest, this must be done after |
1054 * Because of ziltest, this must be done after |
1051 * zfs_unlinked_drain(). (Further note: ziltest |
1055 * zfs_unlinked_drain(). (Further note: ziltest |
1052 * doesn't use readonly mounts, where |
1056 * doesn't use readonly mounts, where |
1053 * zfs_unlinked_drain() isn't called.) This is because |
1057 * zfs_unlinked_drain() isn't called.) This is because |
1054 * ziltest causes spa_sync() to think it's committed, |
1058 * ziltest causes spa_sync() to think it's committed, |
1055 * but actually it is not, so the intent log contains |
1059 * but actually it is not, so the intent log contains |
1056 * many txg's worth of changes. |
1060 * many txg's worth of changes. |
1057 * |
1061 * |
1058 * In particular, if object N is in the unlinked set in |
1062 * In particular, if object N is in the unlinked set in |
1059 * the last txg to actually sync, then it could be |
1063 * the last txg to actually sync, then it could be |
1060 * actually freed in a later txg and then reallocated |
1064 * actually freed in a later txg and then reallocated |
1061 * in a yet later txg. This would write a "create |
1065 * in a yet later txg. This would write a "create |
1062 * object N" record to the intent log. Normally, this |
1066 * object N" record to the intent log. Normally, this |
1063 * would be fine because the spa_sync() would have |
1067 * would be fine because the spa_sync() would have |
1064 * written out the fact that object N is free, before |
1068 * written out the fact that object N is free, before |
1065 * we could write the "create object N" intent log |
1069 * we could write the "create object N" intent log |
1066 * record. |
1070 * record. |
1067 * |
1071 * |
1068 * But when we are in ziltest mode, we advance the "open |
1072 * But when we are in ziltest mode, we advance the "open |
1069 * txg" without actually spa_sync()-ing the changes to |
1073 * txg" without actually spa_sync()-ing the changes to |
1070 * disk. So we would see that object N is still |
1074 * disk. So we would see that object N is still |
1071 * allocated and in the unlinked set, and there is an |
1075 * allocated and in the unlinked set, and there is an |
1072 * intent log record saying to allocate it. |
1076 * intent log record saying to allocate it. |
1073 */ |
1077 */ |
1074 if (zil_replay_disable) { |
|
1075 zil_destroy(zfsvfs->z_log, B_FALSE); |
|
1076 } else { |
1078 zfsvfs->z_replay = B_TRUE; |
1077 zfsvfs->z_replay = B_TRUE; |
1079 zil_replay(zfsvfs->z_os, zfsvfs, zfs_replay_vector); |
1078 zil_replay(zfsvfs->z_os, zfsvfs, zfs_replay_vector); |
1080 zfsvfs->z_replay = B_FALSE; |
1079 zfsvfs->z_replay = B_FALSE; |
1081 } |
1080 } |
1082 zfsvfs->z_vfs->vfs_flag |= readonly; /* restore readonly bit */ |
1081 zfsvfs->z_vfs->vfs_flag |= readonly; /* restore readonly bit */ |