~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

Tags: innodb-plugin-1.0.3
InnoDB Plugin 1.0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
 
 
3
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
 
4
 
 
5
This program is free software; you can redistribute it and/or modify it under
 
6
the terms of the GNU General Public License as published by the Free Software
 
7
Foundation; version 2 of the License.
 
8
 
 
9
This program is distributed in the hope that it will be useful, but WITHOUT
 
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 
12
 
 
13
You should have received a copy of the GNU General Public License along with
 
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 
15
Place, Suite 330, Boston, MA 02111-1307 USA
 
16
 
 
17
*****************************************************************************/
 
18
 
1
19
/******************************************************
2
20
The tablespace memory cache
3
21
 
4
 
(c) 1995 Innobase Oy
5
 
 
6
22
Created 10/25/1995 Heikki Tuuri
7
23
*******************************************************/
8
24
 
18
34
#include "buf0buf.h"
19
35
#include "buf0flu.h"
20
36
#include "buf0lru.h"
21
 
#include "log0log.h"
22
37
#include "log0recv.h"
23
38
#include "fsp0fsp.h"
24
39
#include "srv0srv.h"
191
206
                                currently in the list above */
192
207
        UT_LIST_NODE_T(fil_space_t) space_list;
193
208
                                /* list of all spaces */
194
 
        ibuf_data_t*    ibuf_data;
195
 
                                /* insert buffer data */
196
209
        ulint           magic_n;
197
210
};
198
211
 
365
378
        ut_ad(mutex_own(&fil_system->mutex));
366
379
 
367
380
        HASH_SEARCH(hash, fil_system->spaces, id,
368
 
                    fil_space_t*, space, space->id == id);
 
381
                    fil_space_t*, space,
 
382
                    ut_ad(space->magic_n == FIL_SPACE_MAGIC_N),
 
383
                    space->id == id);
369
384
 
370
385
        return(space);
371
386
}
386
401
        fold = ut_fold_string(name);
387
402
 
388
403
        HASH_SEARCH(name_hash, fil_system->name_hash, fold,
389
 
                    fil_space_t*, space, !strcmp(name, space->name));
 
404
                    fil_space_t*, space,
 
405
                    ut_ad(space->magic_n == FIL_SPACE_MAGIC_N),
 
406
                    !strcmp(name, space->name));
390
407
 
391
408
        return(space);
392
409
}
475
492
        return(space->purpose);
476
493
}
477
494
 
478
 
/***********************************************************************
479
 
Returns the ibuf data of a file space. */
480
 
UNIV_INTERN
481
 
ibuf_data_t*
482
 
fil_space_get_ibuf_data(
483
 
/*====================*/
484
 
                        /* out: ibuf data for this space */
485
 
        ulint   id)     /* in: space id */
486
 
{
487
 
        fil_system_t*   system          = fil_system;
488
 
        fil_space_t*    space;
489
 
 
490
 
        ut_ad(system);
491
 
 
492
 
        ut_a(id == 0);
493
 
 
494
 
        mutex_enter(&(system->mutex));
495
 
 
496
 
        space = fil_space_get_by_id(id);
497
 
 
498
 
        mutex_exit(&(system->mutex));
499
 
 
500
 
        ut_a(space);
501
 
 
502
 
        return(space->ibuf_data);
503
 
}
504
 
 
505
495
/**************************************************************************
506
496
Checks if all the file nodes in a space are flushed. The caller must hold
507
497
the fil_system mutex. */
1192
1182
        UT_LIST_INIT(space->chain);
1193
1183
        space->magic_n = FIL_SPACE_MAGIC_N;
1194
1184
 
1195
 
        space->ibuf_data = NULL;
1196
 
 
1197
1185
        rw_lock_create(&space->latch, SYNC_FSP);
1198
1186
 
1199
1187
        HASH_INSERT(fil_space_t, hash, system->spaces, id, space);
1681
1669
}
1682
1670
 
1683
1671
/********************************************************************
1684
 
Initializes the ibuf data structure for space 0 == the system tablespace.
1685
 
This can be called after the file space headers have been created and the
1686
 
dictionary system has been initialized. */
1687
 
UNIV_INTERN
1688
 
void
1689
 
fil_ibuf_init_at_db_start(void)
1690
 
/*===========================*/
1691
 
{
1692
 
        fil_space_t*    space;
1693
 
 
1694
 
        space = UT_LIST_GET_FIRST(fil_system->space_list);
1695
 
 
1696
 
        ut_a(space);
1697
 
        ut_a(space->purpose == FIL_TABLESPACE);
1698
 
 
1699
 
        space->ibuf_data = ibuf_data_init_for_space(space->id);
1700
 
}
1701
 
 
1702
 
/********************************************************************
1703
1672
Writes the flushed lsn and the latest archived log number to the page header
1704
1673
of the first page of a data file of the system tablespace (space 0),
1705
1674
which is uncompressed. */
1725
1694
 
1726
1695
        fil_write(TRUE, 0, 0, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL);
1727
1696
 
 
1697
        mem_free(buf1);
 
1698
 
1728
1699
        return(DB_SUCCESS);
1729
1700
}
1730
1701
 
4313
4284
              || !ibuf_bitmap_page(zip_size, block_offset)
4314
4285
              || sync || is_log);
4315
4286
        ut_ad(!ibuf_inside() || is_log || (type == OS_FILE_WRITE)
4316
 
              || ibuf_page(space_id, zip_size, block_offset));
 
4287
              || ibuf_page(space_id, zip_size, block_offset, NULL));
4317
4288
#endif
4318
4289
        if (sync) {
4319
4290
                mode = OS_AIO_SYNC;
4320
4291
        } else if (is_log) {
4321
4292
                mode = OS_AIO_LOG;
4322
4293
        } else if (type == OS_FILE_READ
4323
 
                   && ibuf_page(space_id, zip_size, block_offset)) {
 
4294
                   && !recv_no_ibuf_operations
 
4295
                   && ibuf_page(space_id, zip_size, block_offset, NULL)) {
4324
4296
                mode = OS_AIO_IBUF;
4325
4297
        } else {
4326
4298
                mode = OS_AIO_NORMAL;