~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/fil/fil0fil.c

  • Committer: Lee Bieber
  • Date: 2010-12-23 02:14:02 UTC
  • mfrom: (2021.1.2 build)
  • Revision ID: kalebral@gmail.com-20101223021402-o4zhdsv3x8s0q6pz
Merge Stewart - Update innobase plugin to be based on innodb 1.1.4 from MySQL 5.5.8 
Merge Marisa - fixed markup in 'administrative.rst', which was throwing an error in the build

Show diffs side-by-side

added added

removed removed

Lines of Context:
339
339
/*******************************************************************//**
340
340
Frees a space object from the tablespace memory cache. Closes the files in
341
341
the chain but does not delete them. There must not be any pending i/o's or
342
 
flushes on the files. */
 
342
flushes on the files.
 
343
@return TRUE on success */
343
344
static
344
345
ibool
345
346
fil_space_free(
346
347
/*===========*/
347
 
                                /* out: TRUE if success */
348
 
        ulint           id,     /* in: space id */
349
 
        ibool           own_mutex);/* in: TRUE if own system->mutex */
 
348
        ulint           id,             /* in: space id */
 
349
        ibool           x_latched);     /* in: TRUE if caller has space->latch
 
350
                                        in X mode */
350
351
/********************************************************************//**
351
352
Reads data from a space to a buffer. Remember that the possible incomplete
352
353
blocks at the end of file are ignored: they are not taken into account when
1140
1141
        space = fil_space_get_by_name(name);
1141
1142
 
1142
1143
        if (UNIV_LIKELY_NULL(space)) {
 
1144
                ibool   success;
1143
1145
                ulint   namesake_id;
1144
1146
 
1145
1147
                ut_print_timestamp(stderr);
1178
1180
 
1179
1181
                namesake_id = space->id;
1180
1182
 
 
1183
                success = fil_space_free(namesake_id, FALSE);
 
1184
                ut_a(success);
 
1185
 
1181
1186
                mutex_exit(&fil_system->mutex);
1182
1187
 
1183
 
                fil_space_free(namesake_id, FALSE);
1184
 
 
1185
1188
                goto try_again;
1186
1189
        }
1187
1190
 
1331
1334
/*===========*/
1332
1335
                                        /* out: TRUE if success */
1333
1336
        ulint           id,             /* in: space id */
1334
 
        ibool           own_mutex)      /* in: TRUE if own system->mutex */
 
1337
        ibool           x_latched)      /* in: TRUE if caller has space->latch
 
1338
                                        in X mode */
1335
1339
{
1336
1340
        fil_space_t*    space;
1337
1341
        fil_space_t*    namespace;
1338
1342
        fil_node_t*     fil_node;
1339
1343
 
1340
 
        if (!own_mutex) {
1341
 
                mutex_enter(&fil_system->mutex);
1342
 
        }
 
1344
        ut_ad(mutex_own(&fil_system->mutex));
1343
1345
 
1344
1346
        space = fil_space_get_by_id(id);
1345
1347
 
1350
1352
                        " from the cache but\n"
1351
1353
                        "InnoDB: it is not there.\n", (ulong) id);
1352
1354
 
1353
 
                mutex_exit(&fil_system->mutex);
1354
 
 
1355
1355
                return(FALSE);
1356
1356
        }
1357
1357
 
1386
1386
 
1387
1387
        ut_a(0 == UT_LIST_GET_LEN(space->chain));
1388
1388
 
1389
 
        if (!own_mutex) {
1390
 
                mutex_exit(&fil_system->mutex);
 
1389
        if (x_latched) {
 
1390
                rw_lock_x_unlock(&space->latch);
1391
1391
        }
1392
1392
 
1393
1393
        rw_lock_free(&(space->latch));
1633
1633
/*=====================*/
1634
1634
{
1635
1635
        fil_space_t*    space;
1636
 
        fil_node_t*     node;
1637
1636
 
1638
1637
        mutex_enter(&fil_system->mutex);
1639
1638
 
1640
1639
        space = UT_LIST_GET_FIRST(fil_system->space_list);
1641
1640
 
1642
1641
        while (space != NULL) {
 
1642
                fil_node_t*     node;
1643
1643
                fil_space_t*    prev_space = space;
1644
1644
 
1645
 
                node = UT_LIST_GET_FIRST(space->chain);
 
1645
                for (node = UT_LIST_GET_FIRST(space->chain);
 
1646
                     node != NULL;
 
1647
                     node = UT_LIST_GET_NEXT(chain, node)) {
1646
1648
 
1647
 
                while (node != NULL) {
1648
1649
                        if (node->open) {
1649
1650
                                fil_node_close_file(node, fil_system);
1650
1651
                        }
1651
 
                        node = UT_LIST_GET_NEXT(chain, node);
1652
1652
                }
 
1653
 
1653
1654
                space = UT_LIST_GET_NEXT(space_list, space);
1654
 
                fil_space_free(prev_space->id, TRUE);
 
1655
 
 
1656
                fil_space_free(prev_space->id, FALSE);
1655
1657
        }
1656
1658
 
1657
1659
        mutex_exit(&fil_system->mutex);
2271
2273
        path = mem_strdup(space->name);
2272
2274
 
2273
2275
        mutex_exit(&fil_system->mutex);
 
2276
 
 
2277
        /* Important: We rely on the data dictionary mutex to ensure
 
2278
        that a race is not possible here. It should serialize the tablespace
 
2279
        drop/free. We acquire an X latch only to avoid a race condition
 
2280
        when accessing the tablespace instance via:
 
2281
 
 
2282
          fsp_get_available_space_in_free_extents().
 
2283
 
 
2284
        There our main motivation is to reduce the contention on the
 
2285
        dictionary mutex. */
 
2286
 
 
2287
        rw_lock_x_lock(&space->latch);
 
2288
 
2274
2289
#ifndef UNIV_HOTBACKUP
2275
2290
        /* Invalidate in the buffer pool all pages belonging to the
2276
2291
        tablespace. Since we have set space->is_being_deleted = TRUE, readahead
2283
2298
#endif
2284
2299
        /* printf("Deleting tablespace %s id %lu\n", space->name, id); */
2285
2300
 
2286
 
        success = fil_space_free(id, FALSE);
 
2301
        mutex_enter(&fil_system->mutex);
 
2302
 
 
2303
        success = fil_space_free(id, TRUE);
 
2304
 
 
2305
        mutex_exit(&fil_system->mutex);
2287
2306
 
2288
2307
        if (success) {
2289
2308
                success = os_file_delete(path);
2291
2310
                if (!success) {
2292
2311
                        success = os_file_delete_if_exists(path);
2293
2312
                }
 
2313
        } else {
 
2314
                rw_lock_x_unlock(&space->latch);
2294
2315
        }
2295
2316
 
2296
2317
        if (success) {
2318
2339
        return(FALSE);
2319
2340
}
2320
2341
 
 
2342
/*******************************************************************//**
 
2343
Returns TRUE if a single-table tablespace is being deleted.
 
2344
@return TRUE if being deleted */
 
2345
UNIV_INTERN
 
2346
ibool
 
2347
fil_tablespace_is_being_deleted(
 
2348
/*============================*/
 
2349
        ulint           id)     /*!< in: space id */
 
2350
{
 
2351
        fil_space_t*    space;
 
2352
        ibool           is_being_deleted;
 
2353
 
 
2354
        mutex_enter(&fil_system->mutex);
 
2355
 
 
2356
        space = fil_space_get_by_id(id);
 
2357
 
 
2358
        ut_a(space != NULL);
 
2359
 
 
2360
        is_being_deleted = space->is_being_deleted;
 
2361
 
 
2362
        mutex_exit(&fil_system->mutex);
 
2363
 
 
2364
        return(is_being_deleted);
 
2365
}
 
2366
 
2321
2367
#ifndef UNIV_HOTBACKUP
2322
2368
/*******************************************************************//**
2323
2369
Discards a single-table tablespace. The tablespace must be cached in the
4788
4834
        return(mach_read_from_2(page + FIL_PAGE_TYPE));
4789
4835
}
4790
4836
 
4791
 
/********************************************************************
 
4837
/****************************************************************//**
4792
4838
Initializes the tablespace memory cache. */
4793
4839
UNIV_INTERN
4794
4840
void