~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/log/log0log.c

  • Committer: Brian Aker
  • Date: 2010-11-17 21:25:31 UTC
  • mto: (1939.1.1 quick)
  • mto: This revision was merged to the branch mainline in revision 1940.
  • Revision ID: brian@tangent.org-20101117212531-va13j4xh43zuma68
First pass though barriers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
/* Global log system variable */
83
83
UNIV_INTERN log_t*      log_sys = NULL;
84
84
 
85
 
#ifdef UNIV_PFS_RWLOCK
86
 
UNIV_INTERN mysql_pfs_key_t     checkpoint_lock_key;
87
 
# ifdef UNIV_LOG_ARCHIVE
88
 
UNIV_INTERN mysql_pfs_key_t     archive_lock_key;
89
 
# endif
90
 
#endif /* UNIV_PFS_RWLOCK */
91
 
 
92
 
#ifdef UNIV_PFS_MUTEX
93
 
UNIV_INTERN mysql_pfs_key_t     log_sys_mutex_key;
94
 
UNIV_INTERN mysql_pfs_key_t     log_flush_order_mutex_key;
95
 
#endif /* UNIV_PFS_MUTEX */
96
 
 
97
85
#ifdef UNIV_DEBUG
98
86
UNIV_INTERN ibool       log_do_write = TRUE;
99
87
#endif /* UNIV_DEBUG */
768
756
{
769
757
        log_sys = mem_alloc(sizeof(log_t));
770
758
 
771
 
        mutex_create(log_sys_mutex_key, &log_sys->mutex, SYNC_LOG);
772
 
 
773
 
        mutex_create(log_flush_order_mutex_key,
774
 
                     &log_sys->log_flush_order_mutex,
775
 
                     SYNC_LOG_FLUSH_ORDER);
 
759
        mutex_create(&log_sys->mutex, SYNC_LOG);
776
760
 
777
761
        mutex_enter(&(log_sys->mutex));
778
762
 
828
812
        log_sys->last_checkpoint_lsn = log_sys->lsn;
829
813
        log_sys->n_pending_checkpoint_writes = 0;
830
814
 
831
 
        rw_lock_create(checkpoint_lock_key, &log_sys->checkpoint_lock,
832
 
                       SYNC_NO_ORDER_CHECK);
 
815
        rw_lock_create(&log_sys->checkpoint_lock, SYNC_NO_ORDER_CHECK);
833
816
 
834
817
        log_sys->checkpoint_buf_ptr = mem_alloc(2 * OS_FILE_LOG_BLOCK_SIZE);
835
818
        log_sys->checkpoint_buf = ut_align(log_sys->checkpoint_buf_ptr,
845
828
 
846
829
        log_sys->n_pending_archive_ios = 0;
847
830
 
848
 
        rw_lock_create(archive_lock_key, &log_sys->archive_lock,
849
 
                       SYNC_NO_ORDER_CHECK);
 
831
        rw_lock_create(&log_sys->archive_lock, SYNC_NO_ORDER_CHECK);
850
832
 
851
833
        log_sys->archive_buf = NULL;
852
834
 
1655
1637
                recv_apply_hashed_log_recs(TRUE);
1656
1638
        }
1657
1639
 
1658
 
        n_pages = buf_flush_list(ULINT_MAX, new_oldest);
 
1640
        n_pages = buf_flush_batch(BUF_FLUSH_LIST, ULINT_MAX, new_oldest);
1659
1641
 
1660
1642
        if (sync) {
1661
 
                buf_flush_wait_batch_end(NULL, BUF_FLUSH_LIST);
 
1643
                buf_flush_wait_batch_end(BUF_FLUSH_LIST);
1662
1644
        }
1663
1645
 
1664
1646
        if (n_pages == ULINT_UNDEFINED) {
2372
2354
                log_archived_file_name_gen(name, group->id,
2373
2355
                                           group->archived_file_no + n_files);
2374
2356
 
2375
 
                file_handle = os_file_create(innodb_file_log_key,
2376
 
                                             name, open_mode,
2377
 
                                             OS_FILE_AIO,
 
2357
                file_handle = os_file_create(name, open_mode, OS_FILE_AIO,
2378
2358
                                             OS_DATA_FILE, &ret);
2379
2359
 
2380
2360
                if (!ret && (open_mode == OS_FILE_CREATE)) {
2381
2361
                        file_handle = os_file_create(
2382
 
                                innodb_file_log_key, name, OS_FILE_OPEN,
2383
 
                                OS_FILE_AIO, OS_DATA_FILE, &ret);
 
2362
                                name, OS_FILE_OPEN, OS_FILE_AIO,
 
2363
                                OS_DATA_FILE, &ret);
2384
2364
                }
2385
2365
 
2386
2366
                if (!ret) {
3131
3111
                return; /* We SKIP ALL THE REST !! */
3132
3112
        }
3133
3113
 
 
3114
        /* Check that the master thread is suspended */
 
3115
 
 
3116
        if (srv_n_threads_active[SRV_MASTER] != 0) {
 
3117
 
 
3118
                mutex_exit(&kernel_mutex);
 
3119
 
 
3120
                goto loop;
 
3121
        }
 
3122
 
3134
3123
        mutex_exit(&kernel_mutex);
3135
3124
 
3136
 
        /* Check that the background threads are suspended */
3137
 
 
3138
 
        if (srv_is_any_background_thread_active()) {
3139
 
                goto loop;
3140
 
        }
3141
 
 
3142
3125
        mutex_enter(&(log_sys->mutex));
3143
3126
 
3144
3127
        if (log_sys->n_pending_checkpoint_writes
3196
3179
 
3197
3180
        mutex_exit(&(log_sys->mutex));
3198
3181
 
3199
 
        /* Check that the background threads stay suspended */
3200
 
        if (srv_is_any_background_thread_active()) {
 
3182
        mutex_enter(&kernel_mutex);
 
3183
        /* Check that the master thread has stayed suspended */
 
3184
        if (srv_n_threads_active[SRV_MASTER] != 0) {
3201
3185
                fprintf(stderr,
3202
 
                        "InnoDB: Warning: some background thread woke up"
 
3186
                        "InnoDB: Warning: the master thread woke up"
3203
3187
                        " during shutdown\n");
3204
3188
 
 
3189
                mutex_exit(&kernel_mutex);
 
3190
 
3205
3191
                goto loop;
3206
3192
        }
 
3193
        mutex_exit(&kernel_mutex);
3207
3194
 
3208
3195
        fil_flush_file_spaces(FIL_TABLESPACE);
3209
3196
        fil_flush_file_spaces(FIL_LOG);
3221
3208
        srv_shutdown_state = SRV_SHUTDOWN_LAST_PHASE;
3222
3209
 
3223
3210
        /* Make some checks that the server really is quiet */
3224
 
        ut_a(!srv_is_any_background_thread_active());
3225
 
 
 
3211
        ut_a(srv_n_threads_active[SRV_MASTER] == 0);
3226
3212
        ut_a(buf_all_freed());
3227
3213
        ut_a(lsn == log_sys->lsn);
3228
3214
 
3243
3229
        fil_close_all_files();
3244
3230
 
3245
3231
        /* Make some checks that the server really is quiet */
3246
 
        ut_a(!srv_is_any_background_thread_active());
3247
 
 
 
3232
        ut_a(srv_n_threads_active[SRV_MASTER] == 0);
3248
3233
        ut_a(buf_all_freed());
3249
3234
        ut_a(lsn == log_sys->lsn);
3250
3235
}
3285
3270
 
3286
3271
        ut_memcpy(scan_buf, start, end - start);
3287
3272
 
3288
 
        recv_scan_log_recs((buf_pool_get_n_pages()
3289
 
                           - (recv_n_pool_free_frames * srv_buf_pool_instances))
3290
 
                           * UNIV_PAGE_SIZE, FALSE, scan_buf, end - start,
 
3273
        recv_scan_log_recs((buf_pool->curr_size
 
3274
                            - recv_n_pool_free_frames) * UNIV_PAGE_SIZE,
 
3275
                           FALSE, scan_buf, end - start,
3291
3276
                           ut_uint64_align_down(buf_start_lsn,
3292
3277
                                                OS_FILE_LOG_BLOCK_SIZE),
3293
3278
                           &contiguous_lsn, &scanned_lsn);