23
23
#endif /* UNIV_HOTBACKUP */
26
/* We assume in this case that the OS has standard Posix aio (at least SunOS
27
2.6, HP-UX 11i and AIX 4.3 have) */
31
25
/* This specifies the file permissions InnoDB uses when it creates files in
32
26
Unix; the value of os_innodb_umask is initialized in ha_innodb.cc to
332
323
if (err == ENOSPC) {
333
324
return(OS_FILE_DISK_FULL);
334
#ifdef POSIX_ASYNC_IO
335
} else if (err == EAGAIN) {
336
return(OS_FILE_AIO_RESOURCES_RESERVED);
338
325
} else if (err == ENOENT) {
339
326
return(OS_FILE_NOT_FOUND);
340
327
} else if (err == EEXIST) {
1254
1241
if (file == INVALID_HANDLE_VALUE) {
1255
1242
*success = FALSE;
1257
retry = os_file_handle_error(name,
1258
create_mode == OS_FILE_CREATE ?
1244
/* When srv_file_per_table is on, file creation failure may not
1245
be critical to the whole instance. Do not crash the server in
1246
case of unknown errors. */
1247
if (srv_file_per_table) {
1248
retry = os_file_handle_error_no_exit(name,
1249
create_mode == OS_FILE_CREATE ?
1252
retry = os_file_handle_error(name,
1253
create_mode == OS_FILE_CREATE ?
1261
1258
goto try_again;
1331
1328
if (file == -1) {
1332
1329
*success = FALSE;
1334
retry = os_file_handle_error(name,
1335
create_mode == OS_FILE_CREATE ?
1331
/* When srv_file_per_table is on, file creation failure may not
1332
be critical to the whole instance. Do not crash the server in
1333
case of unknown errors. */
1334
if (srv_file_per_table) {
1335
retry = os_file_handle_error_no_exit(name,
1336
create_mode == OS_FILE_CREATE ?
1339
retry = os_file_handle_error(name,
1340
create_mode == OS_FILE_CREATE ?
1338
1345
goto try_again;
2976
2981
os_last_printout = time(NULL);
2978
#ifdef POSIX_ASYNC_IO
2979
/* Block aio signals from the current thread and its children:
2980
for this to work, the current thread must be the first created
2981
in the database, so that all its children will inherit its
2984
/* TODO: to work MySQL needs the SIGALARM signal; the following
2985
will not work yet! */
2986
sigemptyset(&sigset);
2987
sigaddset(&sigset, SIGRTMIN + 1 + 0);
2988
sigaddset(&sigset, SIGRTMIN + 1 + 1);
2989
sigaddset(&sigset, SIGRTMIN + 1 + 2);
2990
sigaddset(&sigset, SIGRTMIN + 1 + 3);
2992
pthread_sigmask(SIG_BLOCK, &sigset, NULL); */
2996
2985
#ifdef WIN_ASYNC_IO
2997
2986
/****************************************************************************
3124
3113
/***********************************************************************
3125
Gets an integer value designating a specified aio array. This is used
3126
to give numbers to signals in Posix aio. */
3128
#if !defined(WIN_ASYNC_IO) && defined(POSIX_ASYNC_IO)
3131
os_aio_get_array_no(
3132
/*================*/
3133
os_aio_array_t* array) /* in: aio array */
3135
if (array == os_aio_ibuf_array) {
3139
} else if (array == os_aio_log_array) {
3143
} else if (array == os_aio_read_array) {
3146
} else if (array == os_aio_write_array) {
3156
/***********************************************************************
3157
Gets the aio array for its number. */
3160
os_aio_get_array_from_no(
3161
/*=====================*/
3162
/* out: aio array */
3163
ulint n) /* in: array number */
3166
return(os_aio_ibuf_array);
3167
} else if (n == 1) {
3169
return(os_aio_log_array);
3170
} else if (n == 2) {
3172
return(os_aio_read_array);
3173
} else if (n == 3) {
3175
return(os_aio_write_array);
3182
#endif /* if !defined(WIN_ASYNC_IO) && defined(POSIX_ASYNC_IO) */
3184
/***********************************************************************
3185
3114
Requests for a slot in the aio array. If no slot is available, waits until
3186
3115
not_full-event becomes signaled. */
3269
3194
control->Offset = (DWORD)offset;
3270
3195
control->OffsetHigh = (DWORD)offset_high;
3271
3196
os_event_reset(slot->event);
3273
#elif defined(POSIX_ASYNC_IO)
3275
#if (UNIV_WORD_SIZE == 8)
3276
offset = offset + (offset_high << 32);
3278
ut_a(offset_high == 0);
3280
control = &(slot->control);
3281
control->aio_fildes = file;
3282
control->aio_buf = buf;
3283
control->aio_nbytes = len;
3284
control->aio_offset = offset;
3285
control->aio_reqprio = 0;
3286
control->aio_sigevent.sigev_notify = SIGEV_SIGNAL;
3287
control->aio_sigevent.sigev_signo
3288
= SIGRTMIN + 1 + os_aio_get_array_no(array);
3289
/* TODO: How to choose the signal numbers? */
3291
fprintf(stderr, "AIO signal number %lu\n",
3292
(ulint) control->aio_sigevent.sigev_signo);
3294
control->aio_sigevent.sigev_value.sival_ptr = slot;
3296
3199
os_mutex_exit(array->mutex);
3541
3444
ret = ReadFile(file, buf, (DWORD)n, &len,
3542
3445
&(slot->control));
3543
#elif defined(POSIX_ASYNC_IO)
3544
slot->control.aio_lio_opcode = LIO_READ;
3545
err = (ulint) aio_read(&(slot->control));
3546
fprintf(stderr, "Starting POSIX aio read %lu\n", err);
3549
3448
if (!wake_later) {
3558
3457
os_n_file_writes++;
3559
3458
ret = WriteFile(file, buf, (DWORD)n, &len,
3560
3459
&(slot->control));
3561
#elif defined(POSIX_ASYNC_IO)
3562
slot->control.aio_lio_opcode = LIO_WRITE;
3563
err = (ulint) aio_write(&(slot->control));
3564
fprintf(stderr, "Starting POSIX aio write %lu\n", err);
3567
3462
if (!wake_later) {
3706
3601
if (ret && len == slot->len) {
3707
3602
ret_val = TRUE;
3709
# ifdef UNIV_DO_FLUSH
3604
#ifdef UNIV_DO_FLUSH
3710
3605
if (slot->type == OS_FILE_WRITE
3711
3606
&& !os_do_not_call_flush_at_each_write) {
3712
3607
ut_a(TRUE == os_file_flush(slot->file));
3714
# endif /* UNIV_DO_FLUSH */
3609
#endif /* UNIV_DO_FLUSH */
3716
3611
os_file_handle_error(slot->name, "Windows aio");
3729
#ifdef POSIX_ASYNC_IO
3731
/**************************************************************************
3732
This function is only used in Posix asynchronous i/o. Waits for an aio
3733
operation to complete. */
3736
os_aio_posix_handle(
3737
/*================*/
3738
/* out: TRUE if the aio operation succeeded */
3739
ulint array_no, /* in: array number 0 - 3 */
3740
fil_node_t**message1, /* out: the messages passed with the aio
3741
request; note that also in the case where
3742
the aio operation failed, these output
3743
parameters are valid and can be used to
3744
restart the operation, for example */
3747
os_aio_array_t* array;
3748
os_aio_slot_t* slot;
3751
sigset_t proc_sigset;
3752
sigset_t thr_sigset;
3757
sigemptyset(&sigset);
3758
sigaddset(&sigset, SIGRTMIN + 1 + array_no);
3760
pthread_sigmask(SIG_UNBLOCK, &sigset, NULL);
3763
sigprocmask(0, NULL, &proc_sigset);
3764
pthread_sigmask(0, NULL, &thr_sigset);
3766
for (i = 32 ; i < 40; i++) {
3767
fprintf(stderr, "%lu : %lu %lu\n", (ulint)i,
3768
(ulint) sigismember(&proc_sigset, i),
3769
(ulint) sigismember(&thr_sigset, i));
3773
ret = sigwaitinfo(&sigset, &info);
3775
if (sig != SIGRTMIN + 1 + array_no) {
3782
fputs("Handling POSIX aio\n", stderr);
3784
array = os_aio_get_array_from_no(array_no);
3786
os_mutex_enter(array->mutex);
3788
slot = info.si_value.sival_ptr;
3790
ut_a(slot->reserved);
3792
*message1 = slot->message1;
3793
*message2 = slot->message2;
3795
# ifdef UNIV_DO_FLUSH
3796
if (slot->type == OS_FILE_WRITE
3797
&& !os_do_not_call_flush_at_each_write) {
3798
ut_a(TRUE == os_file_flush(slot->file));
3800
# endif /* UNIV_DO_FLUSH */
3802
os_mutex_exit(array->mutex);
3804
os_aio_array_free_slot(array, slot);
3810
3624
/**************************************************************************
3811
3625
Does simulated aio. This function should be called by an i/o-handler