~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/sync/sync0sync.c

  • Committer: Lee Bieber
  • Date: 2010-11-14 23:15:42 UTC
  • mfrom: (1929.1.42 warning-stack-frame)
  • Revision ID: kalebral@gmail.com-20101114231542-fnnu6ydd2p17n582
Merge Monty - fix bug 672372: some functions use > 32k stack

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (C) 1995, 2010, Innobase Oy. All Rights Reserved.
4
 
Copyright (C) 2008, Google Inc.
 
3
Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
 
4
Copyright (c) 2008, Google Inc.
5
5
 
6
6
Portions of this file contain modifications contributed and copyrighted by
7
7
Google, Inc. Those modifications are gratefully acknowledged and are described
40
40
#include "srv0srv.h"
41
41
#include "buf0types.h"
42
42
#include "os0sync.h" /* for HAVE_ATOMIC_BUILTINS */
43
 
#ifdef UNIV_SYNC_DEBUG
44
 
# include "srv0start.h" /* srv_is_being_started */
45
 
#endif /* UNIV_SYNC_DEBUG */
46
43
 
47
44
/*
48
45
        REASONS FOR IMPLEMENTING THE SPIN LOCK MUTEX
201
198
 
202
199
/** Mutex protecting sync_thread_level_arrays */
203
200
UNIV_INTERN mutex_t             sync_thread_mutex;
204
 
 
205
 
# ifdef UNIV_PFS_MUTEX
206
 
UNIV_INTERN mysql_pfs_key_t     sync_thread_mutex_key;
207
 
# endif /* UNIV_PFS_MUTEX */
208
201
#endif /* UNIV_SYNC_DEBUG */
209
202
 
210
203
/** Global list of database mutexes (not OS mutexes) created. */
213
206
/** Mutex protecting the mutex_list variable */
214
207
UNIV_INTERN mutex_t mutex_list_mutex;
215
208
 
216
 
#ifdef UNIV_PFS_MUTEX
217
 
UNIV_INTERN mysql_pfs_key_t     mutex_list_mutex_key;
218
 
#endif /* UNIV_PFS_MUTEX */
219
 
 
220
209
#ifdef UNIV_SYNC_DEBUG
221
210
/** Latching order checks start when this is set TRUE */
222
211
UNIV_INTERN ibool       sync_order_checks_on    = FALSE;
313
302
}
314
303
 
315
304
/******************************************************************//**
316
 
NOTE! Use the corresponding macro mutex_free(), not directly this function!
317
305
Calling this function is obligatory only if the memory buffer containing
318
306
the mutex is freed. Removes a mutex object from the mutex list. The mutex
319
307
is checked to be in the reset state. */
320
308
UNIV_INTERN
321
309
void
322
 
mutex_free_func(
323
 
/*============*/
 
310
mutex_free(
 
311
/*=======*/
324
312
        mutex_t*        mutex)  /*!< in: mutex */
325
313
{
326
314
        ut_ad(mutex_validate(mutex));
381
369
mutex_enter_nowait_func(
382
370
/*====================*/
383
371
        mutex_t*        mutex,          /*!< in: pointer to mutex */
384
 
        const char*     /*file_name __attribute__((unused))*/,
 
372
        const char*     file_name __attribute__((unused)),
385
373
                                        /*!< in: file name where mutex
386
374
                                        requested */
387
 
        ulint           /*line __attribute__((unused))*/)
 
375
        ulint           line __attribute__((unused)))
388
376
                                        /*!< in: line where requested */
389
377
{
390
378
        ut_ad(mutex_validate(mutex));
1155
1143
        case SYNC_TREE_NODE_FROM_HASH:
1156
1144
                /* Do no order checking */
1157
1145
                break;
1158
 
        case SYNC_TRX_SYS_HEADER:
1159
 
                if (srv_is_being_started) {
1160
 
                        /* This is violated during trx_sys_create_rsegs()
1161
 
                        when creating additional rollback segments when
1162
 
                        upgrading in innobase_start_or_create_for_mysql(). */
1163
 
                        break;
1164
 
                }
1165
1146
        case SYNC_MEM_POOL:
1166
1147
        case SYNC_MEM_HASH:
1167
1148
        case SYNC_RECV:
1168
1149
        case SYNC_WORK_QUEUE:
1169
1150
        case SYNC_LOG:
1170
 
        case SYNC_LOG_FLUSH_ORDER:
1171
1151
        case SYNC_THR_LOCAL:
1172
1152
        case SYNC_ANY_LATCH:
 
1153
        case SYNC_TRX_SYS_HEADER:
1173
1154
        case SYNC_FILE_FORMAT_TAG:
1174
1155
        case SYNC_DOUBLEWRITE:
 
1156
        case SYNC_BUF_POOL:
1175
1157
        case SYNC_SEARCH_SYS:
1176
1158
        case SYNC_SEARCH_SYS_CONF:
1177
1159
        case SYNC_TRX_LOCK_HEAP:
1193
1175
                        ut_error;
1194
1176
                }
1195
1177
                break;
1196
 
        case SYNC_BUF_FLUSH_LIST:
1197
 
        case SYNC_BUF_POOL:
1198
 
                /* We can have multiple mutexes of this type therefore we
1199
 
                can only check whether the greater than condition holds. */
1200
 
                if (!sync_thread_levels_g(array, level-1, TRUE)) {
1201
 
                        fprintf(stderr,
1202
 
                                "InnoDB: sync_thread_levels_g(array, %lu)"
1203
 
                                " does not hold!\n", level-1);
1204
 
                        ut_error;
1205
 
                }
1206
 
                break;
1207
 
 
1208
1178
        case SYNC_BUF_BLOCK:
1209
1179
                /* Either the thread must own the buffer pool mutex
1210
 
                (buf_pool->mutex), or it is allowed to latch only ONE
1211
 
                buffer block (block->mutex or buf_pool->zip_mutex). */
 
1180
                (buf_pool_mutex), or it is allowed to latch only ONE
 
1181
                buffer block (block->mutex or buf_pool_zip_mutex). */
1212
1182
                if (!sync_thread_levels_g(array, level, FALSE)) {
1213
1183
                        ut_a(sync_thread_levels_g(array, level - 1, TRUE));
1214
1184
                        ut_a(sync_thread_levels_contain(array, SYNC_BUF_POOL));
1231
1201
                        ut_a(sync_thread_levels_g(array, SYNC_IBUF_BITMAP - 1,
1232
1202
                                                  TRUE));
1233
1203
                } else {
1234
 
                        /* This is violated during trx_sys_create_rsegs()
1235
 
                        when creating additional rollback segments when
1236
 
                        upgrading in innobase_start_or_create_for_mysql(). */
1237
 
                        ut_a(srv_is_being_started
1238
 
                             || sync_thread_levels_g(array, SYNC_IBUF_BITMAP,
1239
 
                                                     TRUE));
 
1204
                        ut_a(sync_thread_levels_g(array, SYNC_IBUF_BITMAP,
 
1205
                                                  TRUE));
1240
1206
                }
1241
1207
                break;
1242
1208
        case SYNC_FSP_PAGE:
1432
1398
        /* Init the mutex list and create the mutex to protect it. */
1433
1399
 
1434
1400
        UT_LIST_INIT(mutex_list);
1435
 
        mutex_create(mutex_list_mutex_key, &mutex_list_mutex,
1436
 
                     SYNC_NO_ORDER_CHECK);
 
1401
        mutex_create(&mutex_list_mutex, SYNC_NO_ORDER_CHECK);
1437
1402
#ifdef UNIV_SYNC_DEBUG
1438
 
        mutex_create(sync_thread_mutex_key, &sync_thread_mutex,
1439
 
                     SYNC_NO_ORDER_CHECK);
 
1403
        mutex_create(&sync_thread_mutex, SYNC_NO_ORDER_CHECK);
1440
1404
#endif /* UNIV_SYNC_DEBUG */
1441
1405
 
1442
1406
        /* Init the rw-lock list and create the mutex to protect it. */
1443
1407
 
1444
1408
        UT_LIST_INIT(rw_lock_list);
1445
 
        mutex_create(rw_lock_list_mutex_key, &rw_lock_list_mutex,
1446
 
                     SYNC_NO_ORDER_CHECK);
 
1409
        mutex_create(&rw_lock_list_mutex, SYNC_NO_ORDER_CHECK);
1447
1410
 
1448
1411
#ifdef UNIV_SYNC_DEBUG
1449
 
        mutex_create(rw_lock_debug_mutex_key, &rw_lock_debug_mutex,
1450
 
                     SYNC_NO_ORDER_CHECK);
 
1412
        mutex_create(&rw_lock_debug_mutex, SYNC_NO_ORDER_CHECK);
1451
1413
 
1452
1414
        rw_lock_debug_event = os_event_create(NULL);
1453
1415
        rw_lock_debug_waiters = FALSE;
1506
1468
        fprintf(file,
1507
1469
                "Mutex spin waits %"PRId64", rounds %"PRId64", "
1508
1470
                "OS waits %"PRId64"\n"
1509
 
                "RW-shared spins %"PRId64", rounds %"PRId64", OS waits %"PRId64";"
1510
 
                " RW-excl spins %"PRId64", rounds %"PRId64", OS waits %"PRId64"\n",
 
1471
                "RW-shared spins %"PRId64", OS waits %"PRId64";"
 
1472
                " RW-excl spins %"PRId64", OS waits %"PRId64"\n",
1511
1473
                mutex_spin_wait_count,
1512
1474
                mutex_spin_round_count,
1513
1475
                mutex_os_wait_count,
1514
1476
                rw_s_spin_wait_count,
1515
 
                rw_s_spin_round_count,
1516
1477
                rw_s_os_wait_count,
1517
1478
                rw_x_spin_wait_count,
1518
 
                rw_x_spin_round_count,
1519
1479
                rw_x_os_wait_count);
1520
1480
 
1521
1481
        fprintf(file,