~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2011-03-10 18:09:05 UTC
  • mfrom: (2225.2.2 refactor)
  • mto: This revision was merged to the branch mainline in revision 2228.
  • Revision ID: mordred@inaugust.com-20110310180905-ttx05t7q7ff6nl7c
Merge Olad: Refactoring

Show diffs side-by-side

added added

removed removed

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