~fallenpegasus/drizzle/logcsv

« back to all changes in this revision

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

  • Committer: lbieber at stabletransit
  • Date: 2010-10-13 16:20:08 UTC
  • mfrom: (1843.1.3 build)
  • Revision ID: lbieber@drizzle-build-n02.wc1.dfw1.stabletransit.com-20101013162008-qi2e6k5yvfm16964
Merge Stewart - update innobase plugin to be based on innodb_plugin 1.0.6
Merge Monty - more valgrind cleanup
Merge Monty - Moved libdrizzle api listings from doxygen to sphinx

Show diffs side-by-side

added added

removed removed

Lines of Context:
321
321
/*=======================*/
322
322
        const char*     name);  /*!< in: table name in the standard
323
323
                                'databasename/tablename' format */
 
324
/*******************************************************************//**
 
325
Frees a space object from the tablespace memory cache. Closes the files in
 
326
the chain but does not delete them. There must not be any pending i/o's or
 
327
flushes on the files. */
 
328
static
 
329
ibool
 
330
fil_space_free(
 
331
/*===========*/
 
332
                                /* out: TRUE if success */
 
333
        ulint           id,     /* in: space id */
 
334
        ibool           own_mutex);/* in: TRUE if own system->mutex */
324
335
/********************************************************************//**
325
336
Reads data from a space to a buffer. Remember that the possible incomplete
326
337
blocks at the end of file are ignored: they are not taken into account when
594
605
 
595
606
        UT_LIST_ADD_LAST(chain, space->chain, node);
596
607
 
 
608
        if (id < SRV_LOG_SPACE_FIRST_ID && fil_system->max_assigned_id < id) {
 
609
 
 
610
                fil_system->max_assigned_id = id;
 
611
        }
 
612
 
597
613
        mutex_exit(&fil_system->mutex);
598
614
}
599
615
 
613
629
        ulint           size_high;
614
630
        ibool           ret;
615
631
        ibool           success;
616
 
#ifndef UNIV_HOTBACKUP
617
632
        byte*           buf2;
618
633
        byte*           page;
619
634
        ulint           space_id;
620
635
        ulint           flags;
621
 
#endif /* !UNIV_HOTBACKUP */
622
636
 
623
637
        ut_ad(mutex_own(&(system->mutex)));
624
638
        ut_a(node->n_pending == 0);
654
668
                size_bytes = (((ib_int64_t)size_high) << 32)
655
669
                        + (ib_int64_t)size_low;
656
670
#ifdef UNIV_HOTBACKUP
657
 
                node->size = (ulint) (size_bytes / UNIV_PAGE_SIZE);
658
 
                /* TODO: adjust to zip_size, like below? */
659
 
#else
 
671
                if (space->id == 0) {
 
672
                        node->size = (ulint) (size_bytes / UNIV_PAGE_SIZE);
 
673
                        os_file_close(node->handle);
 
674
                        goto add_size;
 
675
                }
 
676
#endif /* UNIV_HOTBACKUP */
660
677
                ut_a(space->purpose != FIL_LOG);
661
678
                ut_a(space->id != 0);
662
679
 
735
752
                                (size_bytes
736
753
                                 / dict_table_flags_to_zip_size(flags));
737
754
                }
738
 
#endif
 
755
 
 
756
#ifdef UNIV_HOTBACKUP
 
757
add_size:
 
758
#endif /* UNIV_HOTBACKUP */
739
759
                space->size += node->size;
740
760
        }
741
761
 
955
975
                        " while the maximum\n"
956
976
                        "InnoDB: allowed value would be %lu.\n"
957
977
                        "InnoDB: You may need to raise the value of"
958
 
                        " innodb_max_files_open in\n"
 
978
                        " innodb_open_files in\n"
959
979
                        "InnoDB: my.cnf.\n",
960
980
                        (ulong) fil_system->n_open,
961
981
                        (ulong) fil_system->max_n_open);
1081
1101
        ROW_FORMAT=REDUNDANT (table->flags == 0).  For any other
1082
1102
        format, the tablespace flags should equal table->flags. */
1083
1103
        ut_a(flags != DICT_TF_COMPACT);
 
1104
        ut_a(!(flags & (~0UL << DICT_TF_BITS)));
1084
1105
 
1085
1106
try_again:
1086
1107
        /*printf(
1135
1156
 
1136
1157
                mutex_exit(&fil_system->mutex);
1137
1158
 
1138
 
                fil_space_free(namesake_id);
 
1159
                fil_space_free(namesake_id, FALSE);
1139
1160
 
1140
1161
                goto try_again;
1141
1162
        }
1260
1281
the chain but does not delete them. There must not be any pending i/o's or
1261
1282
flushes on the files.
1262
1283
@return TRUE if success */
1263
 
UNIV_INTERN
 
1284
static
1264
1285
ibool
1265
1286
fil_space_free(
1266
1287
/*===========*/
1267
 
        ulint   id)     /*!< in: space id */
 
1288
                                        /* out: TRUE if success */
 
1289
        ulint           id,             /* in: space id */
 
1290
        ibool           own_mutex)      /* in: TRUE if own system->mutex */
1268
1291
{
1269
1292
        fil_space_t*    space;
1270
1293
        fil_space_t*    namespace;
1271
1294
        fil_node_t*     fil_node;
1272
1295
 
1273
 
        mutex_enter(&fil_system->mutex);
 
1296
        if (!own_mutex) {
 
1297
                mutex_enter(&fil_system->mutex);
 
1298
        }
1274
1299
 
1275
1300
        space = fil_space_get_by_id(id);
1276
1301
 
1317
1342
 
1318
1343
        ut_a(0 == UT_LIST_GET_LEN(space->chain));
1319
1344
 
1320
 
        mutex_exit(&fil_system->mutex);
 
1345
        if (!own_mutex) {
 
1346
                mutex_exit(&fil_system->mutex);
 
1347
        }
1321
1348
 
1322
1349
        rw_lock_free(&(space->latch));
1323
1350
 
1535
1562
                                        fprintf(stderr,
1536
1563
                                                "InnoDB: Warning: you must"
1537
1564
                                                " raise the value of"
1538
 
                                                " innodb_max_open_files in\n"
 
1565
                                                " innodb_open_files in\n"
1539
1566
                                                "InnoDB: my.cnf! Remember that"
1540
1567
                                                " InnoDB keeps all log files"
1541
1568
                                                " and all system\n"
1577
1604
        space = UT_LIST_GET_FIRST(fil_system->space_list);
1578
1605
 
1579
1606
        while (space != NULL) {
 
1607
                fil_space_t*    prev_space = space;
 
1608
 
1580
1609
                node = UT_LIST_GET_FIRST(space->chain);
1581
1610
 
1582
1611
                while (node != NULL) {
1586
1615
                        node = UT_LIST_GET_NEXT(chain, node);
1587
1616
                }
1588
1617
                space = UT_LIST_GET_NEXT(space_list, space);
 
1618
                fil_space_free(prev_space->id, TRUE);
1589
1619
        }
1590
1620
 
1591
1621
        mutex_exit(&fil_system->mutex);
2217
2247
#endif
2218
2248
        /* printf("Deleting tablespace %s id %lu\n", space->name, id); */
2219
2249
 
2220
 
        success = fil_space_free(id);
 
2250
        success = fil_space_free(id, FALSE);
2221
2251
 
2222
2252
        if (success) {
2223
2253
                success = os_file_delete(path);
2557
2587
        ROW_FORMAT=REDUNDANT (table->flags == 0).  For any other
2558
2588
        format, the tablespace flags should equal table->flags. */
2559
2589
        ut_a(flags != DICT_TF_COMPACT);
 
2590
        ut_a(!(flags & (~0UL << DICT_TF_BITS)));
2560
2591
 
2561
2592
        path = fil_make_ibd_name(tablename, is_temp);
2562
2593
 
2923
2954
        byte*           page;
2924
2955
        ulint           space_id;
2925
2956
        ulint           space_flags;
2926
 
        ibool           ret             = TRUE;
2927
2957
 
2928
2958
        filepath = fil_make_ibd_name(name, FALSE);
2929
2959
 
2930
2960
        /* The tablespace flags (FSP_SPACE_FLAGS) should be 0 for
2931
2961
        ROW_FORMAT=COMPACT (table->flags == DICT_TF_COMPACT) and
2932
2962
        ROW_FORMAT=REDUNDANT (table->flags == 0).  For any other
2933
 
        format, the tablespace flags should equal table->flags. */
 
2963
        format, the tablespace flags should be equal to
 
2964
        table->flags & ~(~0 << DICT_TF_BITS). */
2934
2965
        ut_a(flags != DICT_TF_COMPACT);
 
2966
        ut_a(!(flags & (~0UL << DICT_TF_BITS)));
2935
2967
 
2936
2968
        file = os_file_create_simple_no_error_handling(
2937
2969
                filepath, OS_FILE_OPEN, OS_FILE_READ_ONLY, &success);
2983
3015
 
2984
3016
        ut_free(buf2);
2985
3017
 
2986
 
        if (UNIV_UNLIKELY(space_id != id || space_flags != flags)) {
 
3018
        if (UNIV_UNLIKELY(space_id != id
 
3019
                          || space_flags != (flags & ~(~0 << DICT_TF_BITS)))) {
2987
3020
                ut_print_timestamp(stderr);
2988
3021
 
2989
3022
                fputs("  InnoDB: Error: tablespace id and flags in file ",
3001
3034
                        (ulong) space_id, (ulong) space_flags,
3002
3035
                        (ulong) id, (ulong) flags);
3003
3036
 
3004
 
                ret = FALSE;
 
3037
                success = FALSE;
3005
3038
 
3006
3039
                goto func_exit;
3007
3040
        }
3021
3054
        os_file_close(file);
3022
3055
        mem_free(filepath);
3023
3056
 
3024
 
        return(ret);
 
3057
        return(success);
3025
3058
}
3026
3059
#endif /* !UNIV_HOTBACKUP */
3027
3060
 
3237
3270
                fprintf(stderr,
3238
3271
                        "InnoDB: Renaming tablespace %s of id %lu,\n"
3239
3272
                        "InnoDB: to %s_ibbackup_old_vers_<timestamp>\n"
3240
 
                        "InnoDB: because its size %lld is too small"
 
3273
                        "InnoDB: because its size %" PRId64 " is too small"
3241
3274
                        " (< 4 pages 16 kB each),\n"
3242
3275
                        "InnoDB: or the space id in the file header"
3243
3276
                        " is not sensible.\n"
3299
3332
 
3300
3333
        if (!success) {
3301
3334
 
3302
 
                goto func_exit;
 
3335
                if (srv_force_recovery > 0) {
 
3336
                        fprintf(stderr,
 
3337
                                "InnoDB: innodb_force_recovery"
 
3338
                                " was set to %lu. Continuing crash recovery\n"
 
3339
                                "InnoDB: even though the tablespace creation"
 
3340
                                " of this table failed.\n",
 
3341
                                srv_force_recovery);
 
3342
                        goto func_exit;
 
3343
                }
 
3344
 
 
3345
                exit(1);
3303
3346
        }
3304
3347
 
3305
3348
        /* We do not use the size information we have about the file, because
4735
4778
 
4736
4779
        return(mach_read_from_2(page + FIL_PAGE_TYPE));
4737
4780
}
 
4781
 
 
4782
/********************************************************************
 
4783
Initializes the tablespace memory cache. */
 
4784
UNIV_INTERN
 
4785
void
 
4786
fil_close(void)
 
4787
/*===========*/
 
4788
{
 
4789
        /* The mutex should already have been freed. */
 
4790
        ut_ad(fil_system->mutex.magic_n == 0);
 
4791
 
 
4792
        hash_table_free(fil_system->spaces);
 
4793
 
 
4794
        hash_table_free(fil_system->name_hash);
 
4795
 
 
4796
        ut_a(UT_LIST_GET_LEN(fil_system->LRU) == 0);
 
4797
        ut_a(UT_LIST_GET_LEN(fil_system->unflushed_spaces) == 0);
 
4798
        ut_a(UT_LIST_GET_LEN(fil_system->space_list) == 0);
 
4799
 
 
4800
        mem_free(fil_system);
 
4801
 
 
4802
        fil_system = NULL;
 
4803
}