~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

Viewing changes to storage/innodb_plugin/fil/fil0fil.c

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
329
329
/*******************************************************************//**
330
330
Frees a space object from the tablespace memory cache. Closes the files in
331
331
the chain but does not delete them. There must not be any pending i/o's or
332
 
flushes on the files. */
 
332
flushes on the files.
 
333
@return TRUE on success */
333
334
static
334
335
ibool
335
336
fil_space_free(
336
337
/*===========*/
337
 
                                /* out: TRUE if success */
338
 
        ulint           id,     /* in: space id */
339
 
        ibool           own_mutex);/* in: TRUE if own system->mutex */
 
338
        ulint           id,             /* in: space id */
 
339
        ibool           x_latched);     /* in: TRUE if caller has space->latch
 
340
                                        in X mode */
340
341
/********************************************************************//**
341
342
Reads data from a space to a buffer. Remember that the possible incomplete
342
343
blocks at the end of file are ignored: they are not taken into account when
1123
1124
        space = fil_space_get_by_name(name);
1124
1125
 
1125
1126
        if (UNIV_LIKELY_NULL(space)) {
 
1127
                ibool   success;
1126
1128
                ulint   namesake_id;
1127
1129
 
1128
1130
                ut_print_timestamp(stderr);
1161
1163
 
1162
1164
                namesake_id = space->id;
1163
1165
 
 
1166
                success = fil_space_free(namesake_id, FALSE);
 
1167
                ut_a(success);
 
1168
 
1164
1169
                mutex_exit(&fil_system->mutex);
1165
1170
 
1166
 
                fil_space_free(namesake_id, FALSE);
1167
 
 
1168
1171
                goto try_again;
1169
1172
        }
1170
1173
 
1314
1317
/*===========*/
1315
1318
                                        /* out: TRUE if success */
1316
1319
        ulint           id,             /* in: space id */
1317
 
        ibool           own_mutex)      /* in: TRUE if own system->mutex */
 
1320
        ibool           x_latched)      /* in: TRUE if caller has space->latch
 
1321
                                        in X mode */
1318
1322
{
1319
1323
        fil_space_t*    space;
1320
1324
        fil_space_t*    namespace;
1321
1325
        fil_node_t*     fil_node;
1322
1326
 
1323
 
        if (!own_mutex) {
1324
 
                mutex_enter(&fil_system->mutex);
1325
 
        }
 
1327
        ut_ad(mutex_own(&fil_system->mutex));
1326
1328
 
1327
1329
        space = fil_space_get_by_id(id);
1328
1330
 
1333
1335
                        " from the cache but\n"
1334
1336
                        "InnoDB: it is not there.\n", (ulong) id);
1335
1337
 
1336
 
                mutex_exit(&fil_system->mutex);
1337
 
 
1338
1338
                return(FALSE);
1339
1339
        }
1340
1340
 
1369
1369
 
1370
1370
        ut_a(0 == UT_LIST_GET_LEN(space->chain));
1371
1371
 
1372
 
        if (!own_mutex) {
1373
 
                mutex_exit(&fil_system->mutex);
 
1372
        if (x_latched) {
 
1373
                rw_lock_x_unlock(&space->latch);
1374
1374
        }
1375
1375
 
1376
1376
        rw_lock_free(&(space->latch));
1615
1615
/*=====================*/
1616
1616
{
1617
1617
        fil_space_t*    space;
1618
 
        fil_node_t*     node;
1619
1618
 
1620
1619
        mutex_enter(&fil_system->mutex);
1621
1620
 
1622
1621
        space = UT_LIST_GET_FIRST(fil_system->space_list);
1623
1622
 
1624
1623
        while (space != NULL) {
 
1624
                fil_node_t*     node;
1625
1625
                fil_space_t*    prev_space = space;
1626
1626
 
1627
 
                node = UT_LIST_GET_FIRST(space->chain);
 
1627
                for (node = UT_LIST_GET_FIRST(space->chain);
 
1628
                     node != NULL;
 
1629
                     node = UT_LIST_GET_NEXT(chain, node)) {
1628
1630
 
1629
 
                while (node != NULL) {
1630
1631
                        if (node->open) {
1631
1632
                                fil_node_close_file(node, fil_system);
1632
1633
                        }
1633
 
                        node = UT_LIST_GET_NEXT(chain, node);
1634
1634
                }
 
1635
 
1635
1636
                space = UT_LIST_GET_NEXT(space_list, space);
1636
 
                fil_space_free(prev_space->id, TRUE);
 
1637
 
 
1638
                fil_space_free(prev_space->id, FALSE);
1637
1639
        }
1638
1640
 
1639
1641
        mutex_exit(&fil_system->mutex);
2253
2255
        path = mem_strdup(space->name);
2254
2256
 
2255
2257
        mutex_exit(&fil_system->mutex);
 
2258
 
 
2259
        /* Important: We rely on the data dictionary mutex to ensure
 
2260
        that a race is not possible here. It should serialize the tablespace
 
2261
        drop/free. We acquire an X latch only to avoid a race condition
 
2262
        when accessing the tablespace instance via:
 
2263
 
 
2264
          fsp_get_available_space_in_free_extents().
 
2265
 
 
2266
        There our main motivation is to reduce the contention on the
 
2267
        dictionary mutex. */
 
2268
 
 
2269
        rw_lock_x_lock(&space->latch);
 
2270
 
2256
2271
#ifndef UNIV_HOTBACKUP
2257
2272
        /* Invalidate in the buffer pool all pages belonging to the
2258
2273
        tablespace. Since we have set space->is_being_deleted = TRUE, readahead
2265
2280
#endif
2266
2281
        /* printf("Deleting tablespace %s id %lu\n", space->name, id); */
2267
2282
 
2268
 
        success = fil_space_free(id, FALSE);
 
2283
        mutex_enter(&fil_system->mutex);
 
2284
 
 
2285
        success = fil_space_free(id, TRUE);
 
2286
 
 
2287
        mutex_exit(&fil_system->mutex);
2269
2288
 
2270
2289
        if (success) {
2271
2290
                success = os_file_delete(path);
2273
2292
                if (!success) {
2274
2293
                        success = os_file_delete_if_exists(path);
2275
2294
                }
 
2295
        } else {
 
2296
                rw_lock_x_unlock(&space->latch);
2276
2297
        }
2277
2298
 
2278
2299
        if (success) {
2300
2321
        return(FALSE);
2301
2322
}
2302
2323
 
 
2324
/*******************************************************************//**
 
2325
Returns TRUE if a single-table tablespace is being deleted.
 
2326
@return TRUE if being deleted */
 
2327
UNIV_INTERN
 
2328
ibool
 
2329
fil_tablespace_is_being_deleted(
 
2330
/*============================*/
 
2331
        ulint           id)     /*!< in: space id */
 
2332
{
 
2333
        fil_space_t*    space;
 
2334
        ibool           is_being_deleted;
 
2335
 
 
2336
        mutex_enter(&fil_system->mutex);
 
2337
 
 
2338
        space = fil_space_get_by_id(id);
 
2339
 
 
2340
        ut_a(space != NULL);
 
2341
 
 
2342
        is_being_deleted = space->is_being_deleted;
 
2343
 
 
2344
        mutex_exit(&fil_system->mutex);
 
2345
 
 
2346
        return(is_being_deleted);
 
2347
}
 
2348
 
2303
2349
#ifndef UNIV_HOTBACKUP
2304
2350
/*******************************************************************//**
2305
2351
Discards a single-table tablespace. The tablespace must be cached in the
4763
4809
        return(mach_read_from_2(page + FIL_PAGE_TYPE));
4764
4810
}
4765
4811
 
4766
 
/********************************************************************
 
4812
/****************************************************************//**
4767
4813
Initializes the tablespace memory cache. */
4768
4814
UNIV_INTERN
4769
4815
void