~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/os/os0file.c

few updates and modifications to admin commands

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.
4
 
Copyright (C) 2009, Percona Inc.
 
3
Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
 
4
Copyright (c) 2009, Percona Inc.
5
5
 
6
6
Portions of this file contain modifications contributed and copyrighted
7
7
by Percona Inc.. Those modifications are
662
662
                if (errno == EAGAIN || errno == EACCES) {
663
663
                        fprintf(stderr,
664
664
                                "InnoDB: Check that you do not already have"
665
 
                                " another drizzled process\n"
 
665
                                " another mysqld process\n"
666
666
                                "InnoDB: using the same InnoDB data"
667
667
                                " or log files.\n");
668
668
                }
940
940
 
941
941
        strcpy(info->name, ent->d_name);
942
942
 
943
 
        full_path = static_cast<char* >(ut_malloc(strlen(dirname) + strlen(ent->d_name) + 10));
 
943
        full_path = ut_malloc(strlen(dirname) + strlen(ent->d_name) + 10);
944
944
 
945
945
        sprintf(full_path, "%s/%s", dirname, ent->d_name);
946
946
 
1298
1298
os_file_set_nocache(
1299
1299
/*================*/
1300
1300
        int             fd,             /*!< in: file descriptor to alter */
1301
 
        const char*     file_name,      /*!< in: used in the diagnostic message */
1302
 
        const char*     operation_name)
1303
 
                                        /*!< in: "open" or "create"; used in the
 
1301
        const char*     file_name,      /*!< in: file name, used in the
 
1302
                                        diagnostic message */
 
1303
        const char*     operation_name) /*!< in: "open" or "create"; used in the
1304
1304
                                        diagnostic message */
1305
1305
{
1306
1306
        /* some versions of Solaris may not have DIRECTIO_ON */
1937
1937
        /* Write up to 1 megabyte at a time. */
1938
1938
        buf_size = ut_min(64, (ulint) (desired_size / UNIV_PAGE_SIZE))
1939
1939
                * UNIV_PAGE_SIZE;
1940
 
        buf2 = static_cast<unsigned char *>(ut_malloc(buf_size + UNIV_PAGE_SIZE));
 
1940
        buf2 = ut_malloc(buf_size + UNIV_PAGE_SIZE);
1941
1941
 
1942
1942
        /* Align the buffer for possible raw i/o */
1943
 
        buf = static_cast<unsigned char *>(ut_align(buf2, UNIV_PAGE_SIZE));
 
1943
        buf = ut_align(buf2, UNIV_PAGE_SIZE);
1944
1944
 
1945
1945
        /* Write buffer full of zeros */
1946
1946
        memset(buf, 0, buf_size);
2404
2404
        ulint           i;
2405
2405
#endif /* !UNIV_HOTBACKUP */
2406
2406
 
2407
 
        /* On 64-bit Windows, ulint is 64 bits. But offset and n should be
2408
 
        no more than 32 bits. */
2409
2407
        ut_a((offset & 0xFFFFFFFFUL) == offset);
2410
 
        ut_a((n & 0xFFFFFFFFUL) == n);
2411
2408
 
2412
2409
        os_n_file_reads++;
2413
2410
        os_bytes_read_since_printout += n;
2533
2530
        ulint           i;
2534
2531
#endif /* !UNIV_HOTBACKUP */
2535
2532
 
2536
 
        /* On 64-bit Windows, ulint is 64 bits. But offset and n should be
2537
 
        no more than 32 bits. */
2538
2533
        ut_a((offset & 0xFFFFFFFFUL) == offset);
2539
 
        ut_a((n & 0xFFFFFFFFUL) == n);
2540
2534
 
2541
2535
        os_n_file_reads++;
2542
2536
        os_bytes_read_since_printout += n;
2668
2662
        ulint           i;
2669
2663
#endif /* !UNIV_HOTBACKUP */
2670
2664
 
2671
 
        /* On 64-bit Windows, ulint is 64 bits. But offset and n should be
2672
 
        no more than 32 bits. */
2673
 
        ut_a((offset & 0xFFFFFFFFUL) == offset);
2674
 
        ut_a((n & 0xFFFFFFFFUL) == n);
 
2665
        ut_a((offset & 0xFFFFFFFF) == offset);
2675
2666
 
2676
2667
        os_n_file_writes++;
2677
2668
 
3215
3206
#ifdef WIN_ASYNC_IO
3216
3207
        OVERLAPPED*     over;
3217
3208
#elif defined(LINUX_NATIVE_AIO)
3218
 
        struct io_event*        aio_event = NULL;
 
3209
        struct io_event*        io_event = NULL;
3219
3210
#endif
3220
3211
        ut_a(n > 0);
3221
3212
        ut_a(n_segments > 0);
3222
3213
 
3223
 
        array = static_cast<os_aio_array_t *>(ut_malloc(sizeof(os_aio_array_t)));
 
3214
        array = ut_malloc(sizeof(os_aio_array_t));
3224
3215
 
3225
3216
        array->mutex            = os_mutex_create();
3226
3217
        array->not_full         = os_event_create(NULL);
3232
3223
        array->n_segments       = n_segments;
3233
3224
        array->n_reserved       = 0;
3234
3225
        array->cur_seg          = 0;
3235
 
        array->slots            = static_cast<os_aio_slot_t *>(ut_malloc(n * sizeof(os_aio_slot_t)));
 
3226
        array->slots            = ut_malloc(n * sizeof(os_aio_slot_t));
3236
3227
#ifdef __WIN__
3237
3228
        array->handles          = ut_malloc(n * sizeof(HANDLE));
3238
3229
#endif
3250
3241
        /* Initialize the io_context array. One io_context
3251
3242
        per segment in the array. */
3252
3243
 
3253
 
        array->aio_ctx = (io_context**) ut_malloc(n_segments *
 
3244
        array->aio_ctx = ut_malloc(n_segments *
3254
3245
                                   sizeof(*array->aio_ctx));
3255
3246
        for (i = 0; i < n_segments; ++i) {
3256
3247
                if (!os_aio_linux_create_io_ctx(n/n_segments,
3266
3257
        }
3267
3258
 
3268
3259
        /* Initialize the event array. One event per slot. */
3269
 
        aio_event = (io_event*) ut_malloc(n * sizeof(io_event));
3270
 
        memset(aio_event, 0x0, sizeof(io_event) * n);
3271
 
        array->aio_events = aio_event;
 
3260
        io_event = ut_malloc(n * sizeof(*io_event));
 
3261
        memset(io_event, 0x0, sizeof(*io_event) * n);
 
3262
        array->aio_events = io_event;
3272
3263
 
3273
3264
skip_native_aio:
3274
3265
#endif /* LINUX_NATIVE_AIO */
3410
3401
 
3411
3402
        os_aio_validate();
3412
3403
 
3413
 
        os_aio_segment_wait_events = static_cast<os_event_t *>(ut_malloc(n_segments * sizeof(void*)));
 
3404
        os_aio_segment_wait_events = ut_malloc(n_segments * sizeof(void*));
3414
3405
 
3415
3406
        for (i = 0; i < n_segments; i++) {
3416
3407
                os_aio_segment_wait_events[i] = os_event_create(NULL);
3634
3625
        ulint           slots_per_seg;
3635
3626
        ulint           local_seg;
3636
3627
 
3637
 
#ifdef WIN_ASYNC_IO
3638
 
        ut_a((len & 0xFFFFFFFFUL) == len);
3639
 
#endif
3640
 
 
3641
3628
        /* No need of a mutex. Only reading constant fields */
3642
3629
        slots_per_seg = array->n_slots / array->n_segments;
3643
3630
 
3702
3689
        slot->name     = name;
3703
3690
        slot->len      = len;
3704
3691
        slot->type     = type;
3705
 
        slot->buf      = static_cast<unsigned char *>(buf);
 
3692
        slot->buf      = buf;
3706
3693
        slot->offset   = offset;
3707
3694
        slot->offset_high = offset_high;
3708
3695
        slot->io_already_done = FALSE;
4015
4002
        ut_ad(n % OS_FILE_LOG_BLOCK_SIZE == 0);
4016
4003
        ut_ad(offset % OS_FILE_LOG_BLOCK_SIZE == 0);
4017
4004
        ut_ad(os_aio_validate());
4018
 
#ifdef WIN_ASYNC_IO
4019
 
        ut_ad((n & 0xFFFFFFFFUL) == n);
4020
 
#endif
4021
4005
 
4022
4006
        wake_later = mode & OS_AIO_SIMULATED_WAKE_LATER;
4023
4007
        mode = mode & (~OS_AIO_SIMULATED_WAKE_LATER);
4295
4279
                                            __FILE__, __LINE__);
4296
4280
#endif
4297
4281
 
4298
 
                ut_a((slot->len & 0xFFFFFFFFUL) == slot->len);
4299
 
 
4300
4282
                switch (slot->type) {
4301
4283
                case OS_FILE_WRITE:
4302
4284
                        ret = WriteFile(slot->file, slot->buf,
4303
 
                                        (DWORD) slot->len, &len,
 
4285
                                        slot->len, &len,
4304
4286
                                        &(slot->control));
4305
4287
 
4306
4288
                        break;
4307
4289
                case OS_FILE_READ:
4308
4290
                        ret = ReadFile(slot->file, slot->buf,
4309
 
                                       (DWORD) slot->len, &len,
 
4291
                                       slot->len, &len,
4310
4292
                                       &(slot->control));
4311
4293
 
4312
4294
                        break;
4797
4779
                combined_buf = slot->buf;
4798
4780
                combined_buf2 = NULL;
4799
4781
        } else {
4800
 
                combined_buf2 = static_cast<unsigned char *>(ut_malloc(total_len + UNIV_PAGE_SIZE));
 
4782
                combined_buf2 = ut_malloc(total_len + UNIV_PAGE_SIZE);
4801
4783
 
4802
4784
                ut_a(combined_buf2);
4803
4785
 
4804
 
                combined_buf = static_cast<unsigned char *>(ut_align(combined_buf2, UNIV_PAGE_SIZE));
 
4786
                combined_buf = ut_align(combined_buf2, UNIV_PAGE_SIZE);
4805
4787
        }
4806
4788
 
4807
4789
        /* We release the array mutex for the time of the i/o: NOTE that