~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2010-11-08 17:40:41 UTC
  • mto: (1921.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 1916.
  • Revision ID: brian@tangent.org-20101108174041-owap774v8l5vvnl4
Push some functions behind classes.

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.
 
3
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
4
4
 
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
38
38
#include "mtr0mtr.h"
39
39
#include "mtr0log.h"
40
40
#include "dict0dict.h"
41
 
#include "page0page.h"
42
41
#include "page0zip.h"
43
42
#ifndef UNIV_HOTBACKUP
44
43
# include "buf0lru.h"
121
120
/** The null file address */
122
121
UNIV_INTERN fil_addr_t  fil_addr_null = {FIL_NULL, 0};
123
122
 
124
 
#ifdef UNIV_PFS_MUTEX
125
 
/* Key to register fil_system_mutex with performance schema */
126
 
UNIV_INTERN mysql_pfs_key_t     fil_system_mutex_key;
127
 
#endif /* UNIV_PFS_MUTEX */
128
 
 
129
 
#ifdef UNIV_PFS_RWLOCK
130
 
/* Key to register file space latch with performance schema */
131
 
UNIV_INTERN mysql_pfs_key_t     fil_space_latch_key;
132
 
#endif /* UNIV_PFS_RWLOCK */
133
 
 
134
123
/** File node of a tablespace or the log data space */
135
124
struct fil_node_struct {
136
125
        fil_space_t*    space;  /*!< backpointer to the space where this node
289
278
                                        request */
290
279
        UT_LIST_BASE_NODE_T(fil_space_t) space_list;
291
280
                                        /*!< list of all file spaces */
292
 
        ibool           space_id_reuse_warned;
293
 
                                        /* !< TRUE if fil_space_create()
294
 
                                        has issued a warning about
295
 
                                        potential space_id reuse */
296
281
};
297
282
 
298
283
/** The tablespace memory cache. This variable is NULL before the module is
339
324
/*******************************************************************//**
340
325
Frees a space object from the tablespace memory cache. Closes the files in
341
326
the chain but does not delete them. There must not be any pending i/o's or
342
 
flushes on the files.
343
 
@return TRUE on success */
 
327
flushes on the files. */
344
328
static
345
329
ibool
346
330
fil_space_free(
347
331
/*===========*/
348
 
        ulint           id,             /* in: space id */
349
 
        ibool           x_latched);     /* in: TRUE if caller has space->latch
350
 
                                        in X mode */
 
332
                                /* out: TRUE if success */
 
333
        ulint           id,     /* in: space id */
 
334
        ibool           own_mutex);/* in: TRUE if own system->mutex */
351
335
/********************************************************************//**
352
336
Reads data from a space to a buffer. Remember that the possible incomplete
353
337
blocks at the end of file are ignored: they are not taken into account when
581
565
 
582
566
        mutex_enter(&fil_system->mutex);
583
567
 
584
 
        node = static_cast<fil_node_t *>(mem_alloc(sizeof(fil_node_t)));
 
568
        node = mem_alloc(sizeof(fil_node_t));
585
569
 
586
570
        node->name = mem_strdup(name);
587
571
        node->open = FALSE;
664
648
                async I/O! */
665
649
 
666
650
                node->handle = os_file_create_simple_no_error_handling(
667
 
                        innodb_file_data_key, node->name, OS_FILE_OPEN,
668
 
                        OS_FILE_READ_ONLY, &success);
 
651
                        node->name, OS_FILE_OPEN, OS_FILE_READ_ONLY, &success);
669
652
                if (!success) {
670
653
                        /* The following call prints an error message */
671
654
                        os_file_get_last_error(TRUE);
711
694
 
712
695
                /* Read the first page of the tablespace */
713
696
 
714
 
                buf2 = static_cast<unsigned char *>(ut_malloc(2 * UNIV_PAGE_SIZE));
 
697
                buf2 = ut_malloc(2 * UNIV_PAGE_SIZE);
715
698
                /* Align the memory for file i/o if we might have O_DIRECT
716
699
                set */
717
 
                page = static_cast<unsigned char *>(ut_align(buf2, UNIV_PAGE_SIZE));
 
700
                page = ut_align(buf2, UNIV_PAGE_SIZE);
718
701
 
719
702
                success = os_file_read(node->handle, page, 0, 0,
720
703
                                       UNIV_PAGE_SIZE);
783
766
        os_file_create() to fall back to the normal file I/O mode. */
784
767
 
785
768
        if (space->purpose == FIL_LOG) {
786
 
                node->handle = os_file_create(innodb_file_log_key,
787
 
                                              node->name, OS_FILE_OPEN,
788
 
                                              OS_FILE_AIO, OS_LOG_FILE,
789
 
                                              &ret);
 
769
                node->handle = os_file_create(node->name, OS_FILE_OPEN,
 
770
                                              OS_FILE_AIO, OS_LOG_FILE, &ret);
790
771
        } else if (node->is_raw_disk) {
791
 
                node->handle = os_file_create(innodb_file_data_key,
792
 
                                              node->name,
 
772
                node->handle = os_file_create(node->name,
793
773
                                              OS_FILE_OPEN_RAW,
794
 
                                              OS_FILE_AIO, OS_DATA_FILE,
795
 
                                                     &ret);
 
774
                                              OS_FILE_AIO, OS_DATA_FILE, &ret);
796
775
        } else {
797
 
                node->handle = os_file_create(innodb_file_data_key,
798
 
                                              node->name, OS_FILE_OPEN,
799
 
                                              OS_FILE_AIO, OS_DATA_FILE,
800
 
                                              &ret);
 
776
                node->handle = os_file_create(node->name, OS_FILE_OPEN,
 
777
                                              OS_FILE_AIO, OS_DATA_FILE, &ret);
801
778
        }
802
779
 
803
780
        ut_a(ret);
1120
1097
        fil_space_t*    space;
1121
1098
 
1122
1099
        /* The tablespace flags (FSP_SPACE_FLAGS) should be 0 for
1123
 
        ROW_FORMAT=COMPACT
1124
 
        ((table->flags & ~(~0 << DICT_TF_BITS)) == DICT_TF_COMPACT) and
 
1100
        ROW_FORMAT=COMPACT (table->flags == DICT_TF_COMPACT) and
1125
1101
        ROW_FORMAT=REDUNDANT (table->flags == 0).  For any other
1126
 
        format, the tablespace flags should equal
1127
 
        (table->flags & ~(~0 << DICT_TF_BITS)). */
 
1102
        format, the tablespace flags should equal table->flags. */
1128
1103
        ut_a(flags != DICT_TF_COMPACT);
1129
1104
        ut_a(!(flags & (~0UL << DICT_TF_BITS)));
1130
1105
 
1141
1116
        space = fil_space_get_by_name(name);
1142
1117
 
1143
1118
        if (UNIV_LIKELY_NULL(space)) {
1144
 
                ibool   success;
1145
1119
                ulint   namesake_id;
1146
1120
 
1147
1121
                ut_print_timestamp(stderr);
1180
1154
 
1181
1155
                namesake_id = space->id;
1182
1156
 
1183
 
                success = fil_space_free(namesake_id, FALSE);
1184
 
                ut_a(success);
1185
 
 
1186
1157
                mutex_exit(&fil_system->mutex);
1187
1158
 
 
1159
                fil_space_free(namesake_id, FALSE);
 
1160
 
1188
1161
                goto try_again;
1189
1162
        }
1190
1163
 
1208
1181
                return(FALSE);
1209
1182
        }
1210
1183
 
1211
 
        space = static_cast<fil_space_t *>(mem_alloc(sizeof(fil_space_t)));
 
1184
        space = mem_alloc(sizeof(fil_space_t));
1212
1185
 
1213
1186
        space->name = mem_strdup(name);
1214
1187
        space->id = id;
1217
1190
        space->tablespace_version = fil_system->tablespace_version;
1218
1191
        space->mark = FALSE;
1219
1192
 
1220
 
        if (UNIV_LIKELY(purpose == FIL_TABLESPACE && !recv_recovery_on)
1221
 
            && UNIV_UNLIKELY(id > fil_system->max_assigned_id)) {
1222
 
                if (!fil_system->space_id_reuse_warned) {
1223
 
                        fil_system->space_id_reuse_warned = TRUE;
1224
 
 
1225
 
                        ut_print_timestamp(stderr);
1226
 
                        fprintf(stderr,
1227
 
                                "  InnoDB: Warning: allocated tablespace %lu,"
1228
 
                                " old maximum was %lu\n",
1229
 
                                (ulong) id,
1230
 
                                (ulong) fil_system->max_assigned_id);
1231
 
                }
1232
 
 
 
1193
        if (purpose == FIL_TABLESPACE && id > fil_system->max_assigned_id) {
1233
1194
                fil_system->max_assigned_id = id;
1234
1195
        }
1235
1196
 
1248
1209
        UT_LIST_INIT(space->chain);
1249
1210
        space->magic_n = FIL_SPACE_MAGIC_N;
1250
1211
 
1251
 
        rw_lock_create(fil_space_latch_key, &space->latch, SYNC_FSP);
 
1212
        rw_lock_create(&space->latch, SYNC_FSP);
1252
1213
 
1253
1214
        HASH_INSERT(fil_space_t, hash, fil_system->spaces, id, space);
1254
1215
 
1267
1228
Assigns a new space id for a new single-table tablespace. This works simply by
1268
1229
incrementing the global counter. If 4 billion id's is not enough, we may need
1269
1230
to recycle id's.
1270
 
@return TRUE if assigned, FALSE if not */
1271
 
UNIV_INTERN
1272
 
ibool
1273
 
fil_assign_new_space_id(
1274
 
/*====================*/
1275
 
        ulint*  space_id)       /*!< in/out: space id */
 
1231
@return new tablespace id; ULINT_UNDEFINED if could not assign an id */
 
1232
static
 
1233
ulint
 
1234
fil_assign_new_space_id(void)
 
1235
/*=========================*/
1276
1236
{
1277
 
        ulint   id;
1278
 
        ibool   success;
 
1237
        ulint           id;
1279
1238
 
1280
1239
        mutex_enter(&fil_system->mutex);
1281
1240
 
1282
 
        id = *space_id;
1283
 
 
1284
 
        if (id < fil_system->max_assigned_id) {
1285
 
                id = fil_system->max_assigned_id;
1286
 
        }
1287
 
 
1288
 
        id++;
 
1241
        fil_system->max_assigned_id++;
 
1242
 
 
1243
        id = fil_system->max_assigned_id;
1289
1244
 
1290
1245
        if (id > (SRV_LOG_SPACE_FIRST_ID / 2) && (id % 1000000UL == 0)) {
1291
1246
                ut_print_timestamp(stderr);
1301
1256
                        (ulong) SRV_LOG_SPACE_FIRST_ID);
1302
1257
        }
1303
1258
 
1304
 
        success = (id < SRV_LOG_SPACE_FIRST_ID);
1305
 
 
1306
 
        if (success) {
1307
 
                *space_id = fil_system->max_assigned_id = id;
1308
 
        } else {
 
1259
        if (id >= SRV_LOG_SPACE_FIRST_ID) {
1309
1260
                ut_print_timestamp(stderr);
1310
1261
                fprintf(stderr,
1311
1262
                        "InnoDB: You have run out of single-table"
1315
1266
                        " have to dump all your tables and\n"
1316
1267
                        "InnoDB: recreate the whole InnoDB installation.\n",
1317
1268
                        (ulong) id);
1318
 
                *space_id = ULINT_UNDEFINED;
 
1269
                fil_system->max_assigned_id--;
 
1270
 
 
1271
                id = ULINT_UNDEFINED;
1319
1272
        }
1320
1273
 
1321
1274
        mutex_exit(&fil_system->mutex);
1322
1275
 
1323
 
        return(success);
 
1276
        return(id);
1324
1277
}
1325
1278
 
1326
1279
/*******************************************************************//**
1334
1287
/*===========*/
1335
1288
                                        /* out: TRUE if success */
1336
1289
        ulint           id,             /* in: space id */
1337
 
        ibool           x_latched)      /* in: TRUE if caller has space->latch
1338
 
                                        in X mode */
 
1290
        ibool           own_mutex)      /* in: TRUE if own system->mutex */
1339
1291
{
1340
1292
        fil_space_t*    space;
1341
 
        fil_space_t*    tablespace;
 
1293
        fil_space_t*    namespace;
1342
1294
        fil_node_t*     fil_node;
1343
1295
 
1344
 
        ut_ad(mutex_own(&fil_system->mutex));
 
1296
        if (!own_mutex) {
 
1297
                mutex_enter(&fil_system->mutex);
 
1298
        }
1345
1299
 
1346
1300
        space = fil_space_get_by_id(id);
1347
1301
 
1352
1306
                        " from the cache but\n"
1353
1307
                        "InnoDB: it is not there.\n", (ulong) id);
1354
1308
 
 
1309
                mutex_exit(&fil_system->mutex);
 
1310
 
1355
1311
                return(FALSE);
1356
1312
        }
1357
1313
 
1358
1314
        HASH_DELETE(fil_space_t, hash, fil_system->spaces, id, space);
1359
1315
 
1360
 
        tablespace = fil_space_get_by_name(space->name);
1361
 
        ut_a(tablespace);
1362
 
        ut_a(space == tablespace);
 
1316
        namespace = fil_space_get_by_name(space->name);
 
1317
        ut_a(namespace);
 
1318
        ut_a(space == namespace);
1363
1319
 
1364
1320
        HASH_DELETE(fil_space_t, name_hash, fil_system->name_hash,
1365
1321
                    ut_fold_string(space->name), space);
1386
1342
 
1387
1343
        ut_a(0 == UT_LIST_GET_LEN(space->chain));
1388
1344
 
1389
 
        if (x_latched) {
1390
 
                rw_lock_x_unlock(&space->latch);
 
1345
        if (!own_mutex) {
 
1346
                mutex_exit(&fil_system->mutex);
1391
1347
        }
1392
1348
 
1393
1349
        rw_lock_free(&(space->latch));
1553
1509
        ut_a(hash_size > 0);
1554
1510
        ut_a(max_n_open > 0);
1555
1511
 
1556
 
        void *fil_system_ptr= mem_zalloc(sizeof(fil_system_t));
1557
 
        fil_system = static_cast<fil_system_t *>(fil_system_ptr);
 
1512
        fil_system = mem_alloc(sizeof(fil_system_t));
1558
1513
 
1559
 
        mutex_create(fil_system_mutex_key,
1560
 
                     &fil_system->mutex, SYNC_ANY_LATCH);
 
1514
        mutex_create(&fil_system->mutex, SYNC_ANY_LATCH);
1561
1515
 
1562
1516
        fil_system->spaces = hash_create(hash_size);
1563
1517
        fil_system->name_hash = hash_create(hash_size);
1564
1518
 
1565
1519
        UT_LIST_INIT(fil_system->LRU);
1566
1520
 
 
1521
        fil_system->n_open = 0;
1567
1522
        fil_system->max_n_open = max_n_open;
 
1523
 
 
1524
        fil_system->modification_counter = 0;
 
1525
        fil_system->max_assigned_id = 0;
 
1526
 
 
1527
        fil_system->tablespace_version = 0;
 
1528
 
 
1529
        UT_LIST_INIT(fil_system->unflushed_spaces);
 
1530
        UT_LIST_INIT(fil_system->space_list);
1568
1531
}
1569
1532
 
1570
1533
/*******************************************************************//**
1634
1597
/*=====================*/
1635
1598
{
1636
1599
        fil_space_t*    space;
 
1600
        fil_node_t*     node;
1637
1601
 
1638
1602
        mutex_enter(&fil_system->mutex);
1639
1603
 
1640
1604
        space = UT_LIST_GET_FIRST(fil_system->space_list);
1641
1605
 
1642
1606
        while (space != NULL) {
1643
 
                fil_node_t*     node;
1644
1607
                fil_space_t*    prev_space = space;
1645
1608
 
1646
 
                for (node = UT_LIST_GET_FIRST(space->chain);
1647
 
                     node != NULL;
1648
 
                     node = UT_LIST_GET_NEXT(chain, node)) {
 
1609
                node = UT_LIST_GET_FIRST(space->chain);
1649
1610
 
 
1611
                while (node != NULL) {
1650
1612
                        if (node->open) {
1651
1613
                                fil_node_close_file(node, fil_system);
1652
1614
                        }
 
1615
                        node = UT_LIST_GET_NEXT(chain, node);
1653
1616
                }
1654
 
 
1655
1617
                space = UT_LIST_GET_NEXT(space_list, space);
1656
 
 
1657
 
                fil_space_free(prev_space->id, FALSE);
 
1618
                fil_space_free(prev_space->id, TRUE);
1658
1619
        }
1659
1620
 
1660
1621
        mutex_exit(&fil_system->mutex);
1697
1658
        ulint           sum_of_sizes,   /*!< in: combined size of previous files
1698
1659
                                        in space, in database pages */
1699
1660
        ib_uint64_t     lsn,            /*!< in: lsn to write */
1700
 
        ulint           /*arch_log_no __attribute__((unused))*/)
 
1661
        ulint           arch_log_no __attribute__((unused)))
1701
1662
                                        /*!< in: archived log number to write */
1702
1663
{
1703
1664
        byte*   buf1;
1704
1665
        byte*   buf;
1705
1666
 
1706
 
        buf1 = static_cast<byte *>(mem_alloc(2 * UNIV_PAGE_SIZE));
1707
 
        buf = static_cast<byte *>(ut_align(buf1, UNIV_PAGE_SIZE));
 
1667
        buf1 = mem_alloc(2 * UNIV_PAGE_SIZE);
 
1668
        buf = ut_align(buf1, UNIV_PAGE_SIZE);
1708
1669
 
1709
1670
        fil_read(TRUE, 0, 0, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL);
1710
1671
 
1711
 
        mach_write_to_8(buf + FIL_PAGE_FILE_FLUSH_LSN, lsn);
 
1672
        mach_write_ull(buf + FIL_PAGE_FILE_FLUSH_LSN, lsn);
1712
1673
 
1713
1674
        fil_write(TRUE, 0, 0, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL);
1714
1675
 
1796
1757
        byte*           buf2;
1797
1758
        ib_uint64_t     flushed_lsn;
1798
1759
 
1799
 
        buf2 = static_cast<byte *>(ut_malloc(2 * UNIV_PAGE_SIZE));
 
1760
        buf2 = ut_malloc(2 * UNIV_PAGE_SIZE);
1800
1761
        /* Align the memory for a possible read from a raw device */
1801
 
        buf = static_cast<byte *>(ut_align(buf2, UNIV_PAGE_SIZE));
 
1762
        buf = ut_align(buf2, UNIV_PAGE_SIZE);
1802
1763
 
1803
1764
        os_file_read(data_file, buf, 0, 0, UNIV_PAGE_SIZE);
1804
1765
 
1805
 
        flushed_lsn = mach_read_from_8(buf + FIL_PAGE_FILE_FLUSH_LSN);
 
1766
        flushed_lsn = mach_read_ull(buf + FIL_PAGE_FILE_FLUSH_LSN);
1806
1767
 
1807
1768
        ut_free(buf2);
1808
1769
 
1916
1877
        len = strlen(fil_path_to_mysql_datadir);
1917
1878
        namend = strchr(name, '/');
1918
1879
        ut_a(namend);
1919
 
        path = static_cast<char *>(mem_alloc(len + (namend - name) + 2));
 
1880
        path = mem_alloc(len + (namend - name) + 2);
1920
1881
 
1921
1882
        memcpy(path, fil_path_to_mysql_datadir, len);
1922
1883
        path[len] = '/';
2151
2112
                        fil_create_directory_for_tablename(name);
2152
2113
 
2153
2114
                        if (fil_create_new_single_table_tablespace(
2154
 
                                    space_id, name, FALSE, flags,
 
2115
                                    &space_id, name, FALSE, flags,
2155
2116
                                    FIL_IBD_FILE_INITIAL_SIZE) != DB_SUCCESS) {
2156
2117
                                ut_error;
2157
2118
                        }
2274
2235
        path = mem_strdup(space->name);
2275
2236
 
2276
2237
        mutex_exit(&fil_system->mutex);
2277
 
 
2278
 
        /* Important: We rely on the data dictionary mutex to ensure
2279
 
        that a race is not possible here. It should serialize the tablespace
2280
 
        drop/free. We acquire an X latch only to avoid a race condition
2281
 
        when accessing the tablespace instance via:
2282
 
 
2283
 
          fsp_get_available_space_in_free_extents().
2284
 
 
2285
 
        There our main motivation is to reduce the contention on the
2286
 
        dictionary mutex. */
2287
 
 
2288
 
        rw_lock_x_lock(&space->latch);
2289
 
 
2290
2238
#ifndef UNIV_HOTBACKUP
2291
2239
        /* Invalidate in the buffer pool all pages belonging to the
2292
2240
        tablespace. Since we have set space->is_being_deleted = TRUE, readahead
2299
2247
#endif
2300
2248
        /* printf("Deleting tablespace %s id %lu\n", space->name, id); */
2301
2249
 
2302
 
        mutex_enter(&fil_system->mutex);
2303
 
 
2304
 
        success = fil_space_free(id, TRUE);
2305
 
 
2306
 
        mutex_exit(&fil_system->mutex);
 
2250
        success = fil_space_free(id, FALSE);
2307
2251
 
2308
2252
        if (success) {
2309
2253
                success = os_file_delete(path);
2311
2255
                if (!success) {
2312
2256
                        success = os_file_delete_if_exists(path);
2313
2257
                }
2314
 
        } else {
2315
 
                rw_lock_x_unlock(&space->latch);
2316
2258
        }
2317
2259
 
2318
2260
        if (success) {
2340
2282
        return(FALSE);
2341
2283
}
2342
2284
 
2343
 
/*******************************************************************//**
2344
 
Returns TRUE if a single-table tablespace is being deleted.
2345
 
@return TRUE if being deleted */
2346
 
UNIV_INTERN
2347
 
ibool
2348
 
fil_tablespace_is_being_deleted(
2349
 
/*============================*/
2350
 
        ulint           id)     /*!< in: space id */
2351
 
{
2352
 
        fil_space_t*    space;
2353
 
        ibool           is_being_deleted;
2354
 
 
2355
 
        mutex_enter(&fil_system->mutex);
2356
 
 
2357
 
        space = fil_space_get_by_id(id);
2358
 
 
2359
 
        ut_a(space != NULL);
2360
 
 
2361
 
        is_being_deleted = space->is_being_deleted;
2362
 
 
2363
 
        mutex_exit(&fil_system->mutex);
2364
 
 
2365
 
        return(is_being_deleted);
2366
 
}
2367
 
 
2368
2285
#ifndef UNIV_HOTBACKUP
2369
2286
/*******************************************************************//**
2370
2287
Discards a single-table tablespace. The tablespace must be cached in the
2463
2380
{
2464
2381
        ulint   namelen         = strlen(name);
2465
2382
        ulint   dirlen          = strlen(fil_path_to_mysql_datadir);
2466
 
        char*   filename        = static_cast<char *>(mem_alloc(namelen + dirlen + sizeof "/.ibd"));
 
2383
        char*   filename        = mem_alloc(namelen + dirlen + sizeof "/.ibd");
2467
2384
 
2468
2385
        if (is_temp) {
2469
2386
                memcpy(filename, name, namelen);
2599
2516
        success = fil_rename_tablespace_in_mem(space, node, path);
2600
2517
 
2601
2518
        if (success) {
2602
 
                success = os_file_rename(innodb_file_data_key, old_path, path);
 
2519
                success = os_file_rename(old_path, path);
2603
2520
 
2604
2521
                if (!success) {
2605
2522
                        /* We have to revert the changes we made
2642
2559
ulint
2643
2560
fil_create_new_single_table_tablespace(
2644
2561
/*===================================*/
2645
 
        ulint           space_id,       /*!< in: space id */
 
2562
        ulint*          space_id,       /*!< in/out: space id; if this is != 0,
 
2563
                                        then this is an input parameter,
 
2564
                                        otherwise output */
2646
2565
        const char*     tablename,      /*!< in: the table name in the usual
2647
2566
                                        databasename/tablename format
2648
2567
                                        of InnoDB, or a dir path to a temp
2662
2581
        ibool           success;
2663
2582
        char*           path;
2664
2583
 
2665
 
        ut_a(space_id > 0);
2666
 
        ut_a(space_id < SRV_LOG_SPACE_FIRST_ID);
2667
2584
        ut_a(size >= FIL_IBD_FILE_INITIAL_SIZE);
2668
2585
        /* The tablespace flags (FSP_SPACE_FLAGS) should be 0 for
2669
 
        ROW_FORMAT=COMPACT
2670
 
        ((table->flags & ~(~0 << DICT_TF_BITS)) == DICT_TF_COMPACT) and
 
2586
        ROW_FORMAT=COMPACT (table->flags == DICT_TF_COMPACT) and
2671
2587
        ROW_FORMAT=REDUNDANT (table->flags == 0).  For any other
2672
 
        format, the tablespace flags should equal
2673
 
        (table->flags & ~(~0 << DICT_TF_BITS)). */
 
2588
        format, the tablespace flags should equal table->flags. */
2674
2589
        ut_a(flags != DICT_TF_COMPACT);
2675
2590
        ut_a(!(flags & (~0UL << DICT_TF_BITS)));
2676
2591
 
2677
2592
        path = fil_make_ibd_name(tablename, is_temp);
2678
2593
 
2679
 
        file = os_file_create(innodb_file_data_key, path,
2680
 
                              OS_FILE_CREATE, OS_FILE_NORMAL,
 
2594
        file = os_file_create(path, OS_FILE_CREATE, OS_FILE_NORMAL,
2681
2595
                              OS_DATA_FILE, &ret);
2682
2596
        if (ret == FALSE) {
2683
2597
                ut_print_timestamp(stderr);
2721
2635
                return(DB_ERROR);
2722
2636
        }
2723
2637
 
 
2638
        buf2 = ut_malloc(3 * UNIV_PAGE_SIZE);
 
2639
        /* Align the memory for file i/o if we might have O_DIRECT set */
 
2640
        page = ut_align(buf2, UNIV_PAGE_SIZE);
 
2641
 
2724
2642
        ret = os_file_set_size(path, file, size * UNIV_PAGE_SIZE, 0);
2725
2643
 
2726
2644
        if (!ret) {
2727
 
                err = DB_OUT_OF_FILE_SPACE;
 
2645
                ut_free(buf2);
 
2646
                os_file_close(file);
 
2647
                os_file_delete(path);
 
2648
 
 
2649
                mem_free(path);
 
2650
                return(DB_OUT_OF_FILE_SPACE);
 
2651
        }
 
2652
 
 
2653
        if (*space_id == 0) {
 
2654
                *space_id = fil_assign_new_space_id();
 
2655
        }
 
2656
 
 
2657
        /* printf("Creating tablespace %s id %lu\n", path, *space_id); */
 
2658
 
 
2659
        if (*space_id == ULINT_UNDEFINED) {
 
2660
                ut_free(buf2);
2728
2661
error_exit:
2729
2662
                os_file_close(file);
2730
2663
error_exit2:
2731
2664
                os_file_delete(path);
2732
2665
 
2733
2666
                mem_free(path);
2734
 
                return(err);
 
2667
                return(DB_ERROR);
2735
2668
        }
2736
2669
 
2737
 
        /* printf("Creating tablespace %s id %lu\n", path, space_id); */
2738
 
 
2739
2670
        /* We have to write the space id to the file immediately and flush the
2740
2671
        file to disk. This is because in crash recovery we must be aware what
2741
2672
        tablespaces exist and what are their space id's, so that we can apply
2745
2676
        with zeros from the call of os_file_set_size(), until a buffer pool
2746
2677
        flush would write to it. */
2747
2678
 
2748
 
        buf2 = static_cast<byte *>(ut_malloc(3 * UNIV_PAGE_SIZE));
2749
 
        /* Align the memory for file i/o if we might have O_DIRECT set */
2750
 
        page = static_cast<byte *>(ut_align(buf2, UNIV_PAGE_SIZE));
2751
 
 
2752
2679
        memset(page, '\0', UNIV_PAGE_SIZE);
2753
2680
 
2754
 
        fsp_header_init_fields(page, space_id, flags);
2755
 
        mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, space_id);
 
2681
        fsp_header_init_fields(page, *space_id, flags);
 
2682
        mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, *space_id);
2756
2683
 
2757
2684
        if (!(flags & DICT_TF_ZSSIZE_MASK)) {
2758
2685
                buf_flush_init_for_writing(page, NULL, 0);
2783
2710
                      " to tablespace ", stderr);
2784
2711
                ut_print_filename(stderr, path);
2785
2712
                putc('\n', stderr);
2786
 
                err = DB_ERROR;
2787
2713
                goto error_exit;
2788
2714
        }
2789
2715
 
2793
2719
                fputs("InnoDB: Error: file flush of tablespace ", stderr);
2794
2720
                ut_print_filename(stderr, path);
2795
2721
                fputs(" failed\n", stderr);
2796
 
                err = DB_ERROR;
2797
2722
                goto error_exit;
2798
2723
        }
2799
2724
 
2800
2725
        os_file_close(file);
2801
2726
 
2802
 
        success = fil_space_create(path, space_id, flags, FIL_TABLESPACE);
 
2727
        if (*space_id == ULINT_UNDEFINED) {
 
2728
                goto error_exit2;
 
2729
        }
 
2730
 
 
2731
        success = fil_space_create(path, *space_id, flags, FIL_TABLESPACE);
2803
2732
 
2804
2733
        if (!success) {
2805
 
                err = DB_ERROR;
2806
2734
                goto error_exit2;
2807
2735
        }
2808
2736
 
2809
 
        fil_node_create(path, size, space_id, FALSE);
 
2737
        fil_node_create(path, size, *space_id, FALSE);
2810
2738
 
2811
2739
#ifndef UNIV_HOTBACKUP
2812
2740
        {
2817
2745
                fil_op_write_log(flags
2818
2746
                                 ? MLOG_FILE_CREATE2
2819
2747
                                 : MLOG_FILE_CREATE,
2820
 
                                 space_id,
 
2748
                                 *space_id,
2821
2749
                                 is_temp ? MLOG_FILE_FLAG_TEMP : 0,
2822
2750
                                 flags,
2823
2751
                                 tablename, NULL, &mtr);
2860
2788
        ib_int64_t      offset;
2861
2789
        ulint           zip_size;
2862
2790
        ibool           success;
2863
 
        page_zip_des_t  page_zip;
2864
2791
 
2865
2792
        filepath = fil_make_ibd_name(name, FALSE);
2866
2793
 
2867
2794
        file = os_file_create_simple_no_error_handling(
2868
 
                innodb_file_data_key, filepath, OS_FILE_OPEN,
2869
 
                OS_FILE_READ_WRITE, &success);
 
2795
                filepath, OS_FILE_OPEN, OS_FILE_READ_WRITE, &success);
2870
2796
        if (!success) {
2871
2797
                /* The following call prints an error message */
2872
2798
                os_file_get_last_error(TRUE);
2885
2811
 
2886
2812
        /* Read the first page of the tablespace */
2887
2813
 
2888
 
        buf2 = static_cast<byte *>(ut_malloc(3 * UNIV_PAGE_SIZE));
 
2814
        buf2 = ut_malloc(3 * UNIV_PAGE_SIZE);
2889
2815
        /* Align the memory for file i/o if we might have O_DIRECT set */
2890
 
        page = static_cast<byte *>(ut_align(buf2, UNIV_PAGE_SIZE));
 
2816
        page = ut_align(buf2, UNIV_PAGE_SIZE);
2891
2817
 
2892
2818
        success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE);
2893
2819
        if (!success) {
2897
2823
 
2898
2824
        /* We have to read the file flush lsn from the header of the file */
2899
2825
 
2900
 
        flush_lsn = mach_read_from_8(page + FIL_PAGE_FILE_FLUSH_LSN);
 
2826
        flush_lsn = mach_read_ull(page + FIL_PAGE_FILE_FLUSH_LSN);
2901
2827
 
2902
2828
        if (current_lsn >= flush_lsn) {
2903
2829
                /* Ok */
2909
2835
        space_id = fsp_header_get_space_id(page);
2910
2836
        zip_size = fsp_header_get_zip_size(page);
2911
2837
 
2912
 
        page_zip_des_init(&page_zip);
2913
 
        page_zip_set_size(&page_zip, zip_size);
2914
 
        if (zip_size) {
2915
 
                page_zip.data = page + UNIV_PAGE_SIZE;
2916
 
        }
2917
 
 
2918
2838
        ut_print_timestamp(stderr);
2919
2839
        fprintf(stderr,
2920
2840
                "  InnoDB: Flush lsn in the tablespace file %lu"
2945
2865
 
2946
2866
                        goto func_exit;
2947
2867
                }
2948
 
                if (mach_read_from_8(page + FIL_PAGE_LSN) > current_lsn) {
 
2868
                if (mach_read_ull(page + FIL_PAGE_LSN) > current_lsn) {
2949
2869
                        /* We have to reset the lsn */
2950
2870
 
2951
2871
                        if (zip_size) {
2952
 
                                memcpy(page_zip.data, page, zip_size);
 
2872
                                memcpy(page + UNIV_PAGE_SIZE, page, zip_size);
2953
2873
                                buf_flush_init_for_writing(
2954
 
                                        page, &page_zip, current_lsn);
2955
 
                                success = os_file_write(
2956
 
                                        filepath, file, page_zip.data,
2957
 
                                        (ulint) offset & 0xFFFFFFFFUL,
2958
 
                                        (ulint) (offset >> 32), zip_size);
 
2874
                                        page, page + UNIV_PAGE_SIZE,
 
2875
                                        current_lsn);
2959
2876
                        } else {
2960
2877
                                buf_flush_init_for_writing(
2961
2878
                                        page, NULL, current_lsn);
2962
 
                                success = os_file_write(
2963
 
                                        filepath, file, page,
2964
 
                                        (ulint)(offset & 0xFFFFFFFFUL),
2965
 
                                        (ulint)(offset >> 32),
2966
 
                                        UNIV_PAGE_SIZE);
2967
2879
                        }
2968
 
 
 
2880
                        success = os_file_write(filepath, file, page,
 
2881
                                                (ulint)(offset & 0xFFFFFFFFUL),
 
2882
                                                (ulint)(offset >> 32),
 
2883
                                                zip_size
 
2884
                                                ? zip_size
 
2885
                                                : UNIV_PAGE_SIZE);
2969
2886
                        if (!success) {
2970
2887
 
2971
2888
                                goto func_exit;
2987
2904
                goto func_exit;
2988
2905
        }
2989
2906
 
2990
 
        mach_write_to_8(page + FIL_PAGE_FILE_FLUSH_LSN, current_lsn);
 
2907
        mach_write_ull(page + FIL_PAGE_FILE_FLUSH_LSN, current_lsn);
2991
2908
 
2992
2909
        success = os_file_write(filepath, file, page, 0, 0,
2993
2910
                                zip_size ? zip_size : UNIV_PAGE_SIZE);
3041
2958
        filepath = fil_make_ibd_name(name, FALSE);
3042
2959
 
3043
2960
        /* The tablespace flags (FSP_SPACE_FLAGS) should be 0 for
3044
 
        ROW_FORMAT=COMPACT
3045
 
        ((table->flags & ~(~0 << DICT_TF_BITS)) == DICT_TF_COMPACT) and
 
2961
        ROW_FORMAT=COMPACT (table->flags == DICT_TF_COMPACT) and
3046
2962
        ROW_FORMAT=REDUNDANT (table->flags == 0).  For any other
3047
 
        format, the tablespace flags should equal
3048
 
        (table->flags & ~(~0 << DICT_TF_BITS)). */
 
2963
        format, the tablespace flags should be equal to
 
2964
        table->flags & ~(~0 << DICT_TF_BITS). */
3049
2965
        ut_a(flags != DICT_TF_COMPACT);
3050
2966
        ut_a(!(flags & (~0UL << DICT_TF_BITS)));
3051
2967
 
3052
2968
        file = os_file_create_simple_no_error_handling(
3053
 
                innodb_file_data_key, filepath, OS_FILE_OPEN,
3054
 
                OS_FILE_READ_ONLY, &success);
 
2969
                filepath, OS_FILE_OPEN, OS_FILE_READ_ONLY, &success);
3055
2970
        if (!success) {
3056
2971
                /* The following call prints an error message */
3057
2972
                os_file_get_last_error(TRUE);
3087
3002
 
3088
3003
        /* Read the first page of the tablespace */
3089
3004
 
3090
 
        buf2 = static_cast<byte *>(ut_malloc(2 * UNIV_PAGE_SIZE));
 
3005
        buf2 = ut_malloc(2 * UNIV_PAGE_SIZE);
3091
3006
        /* Align the memory for file i/o if we might have O_DIRECT set */
3092
 
        page = static_cast<byte *>(ut_align(buf2, UNIV_PAGE_SIZE));
 
3007
        page = ut_align(buf2, UNIV_PAGE_SIZE);
3093
3008
 
3094
3009
        success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE);
3095
3010
 
3189
3104
#ifdef UNIV_HOTBACKUP
3190
3105
        fil_space_t*    space;
3191
3106
#endif
3192
 
        filepath = static_cast<char *>(mem_alloc(strlen(dbname) + strlen(filename)
3193
 
                             + strlen(fil_path_to_mysql_datadir) + 3));
 
3107
        filepath = mem_alloc(strlen(dbname) + strlen(filename)
 
3108
                             + strlen(fil_path_to_mysql_datadir) + 3);
3194
3109
 
3195
3110
        sprintf(filepath, "%s/%s/%s", fil_path_to_mysql_datadir, dbname,
3196
3111
                filename);
3207
3122
# endif /* !UNIV_HOTBACKUP */
3208
3123
#endif
3209
3124
        file = os_file_create_simple_no_error_handling(
3210
 
                innodb_file_data_key, filepath, OS_FILE_OPEN,
3211
 
                OS_FILE_READ_ONLY, &success);
 
3125
                filepath, OS_FILE_OPEN, OS_FILE_READ_ONLY, &success);
3212
3126
        if (!success) {
3213
3127
                /* The following call prints an error message */
3214
3128
                os_file_get_last_error(TRUE);
3324
3238
#endif
3325
3239
        /* Read the first page of the tablespace if the size big enough */
3326
3240
 
3327
 
        buf2 = static_cast<byte *>(ut_malloc(2 * UNIV_PAGE_SIZE));
 
3241
        buf2 = ut_malloc(2 * UNIV_PAGE_SIZE);
3328
3242
        /* Align the memory for file i/o if we might have O_DIRECT set */
3329
 
        page = static_cast<byte *>(ut_align(buf2, UNIV_PAGE_SIZE));
 
3243
        page = ut_align(buf2, UNIV_PAGE_SIZE);
3330
3244
 
3331
3245
        if (size >= FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
3332
3246
                success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE);
3366
3280
                os_file_close(file);
3367
3281
 
3368
3282
                new_path = fil_make_ibbackup_old_name(filepath);
3369
 
                ut_a(os_file_rename(innodb_file_data_key, filepath, new_path));
 
3283
                ut_a(os_file_rename(filepath, new_path));
3370
3284
 
3371
3285
                ut_free(buf2);
3372
3286
                mem_free(filepath);
3404
3318
 
3405
3319
                mutex_exit(&fil_system->mutex);
3406
3320
 
3407
 
                ut_a(os_file_rename(innodb_file_data_key, filepath, new_path));
 
3321
                ut_a(os_file_rename(filepath, new_path));
3408
3322
 
3409
3323
                ut_free(buf2);
3410
3324
                mem_free(filepath);
3513
3427
                return(DB_ERROR);
3514
3428
        }
3515
3429
 
3516
 
        dbpath = static_cast<char *>(mem_alloc(dbpath_len));
 
3430
        dbpath = mem_alloc(dbpath_len);
3517
3431
 
3518
3432
        /* Scan all directories under the datadir. They are the database
3519
3433
        directories of MySQL. */
3542
3456
                                mem_free(dbpath);
3543
3457
                        }
3544
3458
 
3545
 
                        dbpath = static_cast<char *>(mem_alloc(dbpath_len));
 
3459
                        dbpath = mem_alloc(dbpath_len);
3546
3460
                }
3547
3461
                sprintf(dbpath, "%s/%s", fil_path_to_mysql_datadir,
3548
3462
                        dbinfo.name);
3611
3525
        return(err);
3612
3526
}
3613
3527
 
 
3528
/********************************************************************//**
 
3529
If we need crash recovery, and we have called
 
3530
fil_load_single_table_tablespaces() and dict_load_single_table_tablespaces(),
 
3531
we can call this function to print an error message of orphaned .ibd files
 
3532
for which there is not a data dictionary entry with a matching table name
 
3533
and space id. */
 
3534
UNIV_INTERN
 
3535
void
 
3536
fil_print_orphaned_tablespaces(void)
 
3537
/*================================*/
 
3538
{
 
3539
        fil_space_t*    space;
 
3540
 
 
3541
        mutex_enter(&fil_system->mutex);
 
3542
 
 
3543
        space = UT_LIST_GET_FIRST(fil_system->space_list);
 
3544
 
 
3545
        while (space) {
 
3546
                if (space->purpose == FIL_TABLESPACE && space->id != 0
 
3547
                    && !space->mark) {
 
3548
                        fputs("InnoDB: Warning: tablespace ", stderr);
 
3549
                        ut_print_filename(stderr, space->name);
 
3550
                        fprintf(stderr, " of id %lu has no matching table in\n"
 
3551
                                "InnoDB: the InnoDB data dictionary.\n",
 
3552
                                (ulong) space->id);
 
3553
                }
 
3554
 
 
3555
                space = UT_LIST_GET_NEXT(space_list, space);
 
3556
        }
 
3557
 
 
3558
        mutex_exit(&fil_system->mutex);
 
3559
}
 
3560
 
3614
3561
/*******************************************************************//**
3615
3562
Returns TRUE if a single-table tablespace does not exist in the memory cache,
3616
3563
or is being deleted there.
3699
3646
                                        matching tablespace is not found from
3700
3647
                                        memory */
3701
3648
{
3702
 
        fil_space_t*    tablespace;
 
3649
        fil_space_t*    namespace;
3703
3650
        fil_space_t*    space;
3704
3651
        char*           path;
3705
3652
 
3716
3663
        /* Look if there is a space with the same name; the name is the
3717
3664
        directory path from the datadir to the file */
3718
3665
 
3719
 
        tablespace = fil_space_get_by_name(path);
3720
 
        if (space && space == tablespace) {
 
3666
        namespace = fil_space_get_by_name(path);
 
3667
        if (space && space == namespace) {
3721
3668
                /* Found */
3722
3669
 
3723
3670
                if (mark_space) {
3739
3686
        }
3740
3687
 
3741
3688
        if (space == NULL) {
3742
 
                if (tablespace == NULL) {
 
3689
                if (namespace == NULL) {
3743
3690
                        ut_print_timestamp(stderr);
3744
3691
                        fputs("  InnoDB: Error: table ", stderr);
3745
3692
                        ut_print_filename(stderr, name);
3768
3715
                                "InnoDB: a tablespace of name %s and id %lu,"
3769
3716
                                " though. Have\n"
3770
3717
                                "InnoDB: you deleted or moved .ibd files?\n",
3771
 
                                (ulong) id, tablespace->name,
3772
 
                                (ulong) tablespace->id);
 
3718
                                (ulong) id, namespace->name,
 
3719
                                (ulong) namespace->id);
3773
3720
                }
3774
3721
error_exit:
3775
3722
                fputs("InnoDB: Please refer to\n"
3794
3741
                        "InnoDB: Have you deleted or moved .ibd files?\n",
3795
3742
                        (ulong) id, space->name);
3796
3743
 
3797
 
                if (tablespace != NULL) {
 
3744
                if (namespace != NULL) {
3798
3745
                        fputs("InnoDB: There is a tablespace"
3799
3746
                              " with the right name\n"
3800
3747
                              "InnoDB: ", stderr);
3801
 
                        ut_print_filename(stderr, tablespace->name);
 
3748
                        ut_print_filename(stderr, namespace->name);
3802
3749
                        fprintf(stderr, ", but its id is %lu.\n",
3803
 
                                (ulong) tablespace->id);
 
3750
                                (ulong) namespace->id);
3804
3751
                }
3805
3752
 
3806
3753
                goto error_exit;
3823
3770
        const char*     name)   /*!< in: table name in the standard
3824
3771
                                'databasename/tablename' format */
3825
3772
{
3826
 
        fil_space_t*    tablespace;
 
3773
        fil_space_t*    namespace;
3827
3774
        ulint           id              = ULINT_UNDEFINED;
3828
3775
        char*           path;
3829
3776
 
3836
3783
        /* Look if there is a space with the same name; the name is the
3837
3784
        directory path to the file */
3838
3785
 
3839
 
        tablespace = fil_space_get_by_name(path);
 
3786
        namespace = fil_space_get_by_name(path);
3840
3787
 
3841
 
        if (tablespace) {
3842
 
                id = tablespace->id;
 
3788
        if (namespace) {
 
3789
                id = namespace->id;
3843
3790
        }
3844
3791
 
3845
3792
        mem_free(path);
3907
3854
 
3908
3855
        /* Extend at most 64 pages at a time */
3909
3856
        buf_size = ut_min(64, size_after_extend - start_page_no) * page_size;
3910
 
        buf2 = static_cast<byte *>(mem_alloc(buf_size + page_size));
3911
 
        buf = static_cast<byte *>(ut_align(buf2, page_size));
 
3857
        buf2 = mem_alloc(buf_size + page_size);
 
3858
        buf = ut_align(buf2, page_size);
3912
3859
 
3913
3860
        memset(buf, 0, buf_size);
3914
3861
 
4493
4440
 
4494
4441
        ut_ad(fil_validate());
4495
4442
 
4496
 
        if (srv_use_native_aio) {
 
4443
        if (os_aio_use_native_aio) {
4497
4444
                srv_set_io_thread_op_info(segment, "native aio handle");
4498
4445
#ifdef WIN_ASYNC_IO
4499
4446
                ret = os_aio_windows_handle(segment, 0, &fil_node,
4500
4447
                                            &message, &type);
4501
 
#elif defined(LINUX_NATIVE_AIO)
4502
 
                ret = os_aio_linux_handle(segment, &fil_node,
4503
 
                                          &message, &type);
4504
4448
#else
4505
4449
                ret = 0; /* Eliminate compiler warning */
4506
4450
                ut_error;
4532
4476
 
4533
4477
        if (fil_node->space->purpose == FIL_TABLESPACE) {
4534
4478
                srv_set_io_thread_op_info(segment, "complete io for buf page");
4535
 
                buf_page_io_complete(static_cast<buf_page_t *>(message));
 
4479
                buf_page_io_complete(message);
4536
4480
        } else {
4537
4481
                srv_set_io_thread_op_info(segment, "complete io for log");
4538
 
                log_io_complete(static_cast<log_group_t *>(message));
 
4482
                log_io_complete(message);
4539
4483
        }
4540
4484
}
4541
4485
#endif /* UNIV_HOTBACKUP */
4682
4626
        traversed fil_system->unflushed_spaces and called UT_LIST_GET_NEXT()
4683
4627
        on a space that was just removed from the list by fil_flush().
4684
4628
        Thus, the space could be dropped and the memory overwritten. */
4685
 
        space_ids = static_cast<unsigned long *>(mem_alloc(n_space_ids * sizeof *space_ids));
 
4629
        space_ids = mem_alloc(n_space_ids * sizeof *space_ids);
4686
4630
 
4687
4631
        n_space_ids = 0;
4688
4632
 
4727
4671
 
4728
4672
        for (i = 0; i < hash_get_n_cells(fil_system->spaces); i++) {
4729
4673
 
4730
 
                space = static_cast<fil_space_t *>(HASH_GET_FIRST(fil_system->spaces, i));
 
4674
                space = HASH_GET_FIRST(fil_system->spaces, i);
4731
4675
 
4732
4676
                while (space != NULL) {
4733
4677
                        UT_LIST_VALIDATE(chain, fil_node_t, space->chain,
4746
4690
                                }
4747
4691
                                fil_node = UT_LIST_GET_NEXT(chain, fil_node);
4748
4692
                        }
4749
 
                        space = static_cast<fil_space_t *>(HASH_GET_NEXT(hash, space));
 
4693
                        space = HASH_GET_NEXT(hash, space);
4750
4694
                }
4751
4695
        }
4752
4696
 
4835
4779
        return(mach_read_from_2(page + FIL_PAGE_TYPE));
4836
4780
}
4837
4781
 
4838
 
/****************************************************************//**
 
4782
/********************************************************************
4839
4783
Initializes the tablespace memory cache. */
4840
4784
UNIV_INTERN
4841
4785
void
4842
4786
fil_close(void)
4843
4787
/*===========*/
4844
4788
{
4845
 
#ifndef UNIV_HOTBACKUP
4846
4789
        /* The mutex should already have been freed. */
4847
4790
        ut_ad(fil_system->mutex.magic_n == 0);
4848
 
#endif /* !UNIV_HOTBACKUP */
4849
4791
 
4850
4792
        hash_table_free(fil_system->spaces);
4851
4793