~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Padraig O'Sullivan
  • Date: 2009-09-13 00:53:34 UTC
  • mto: (1126.9.2 captain-20090915-01)
  • mto: This revision was merged to the branch mainline in revision 1133.
  • Revision ID: osullivan.padraig@gmail.com-20090913005334-6wio2sbjugskfbm3
Added calls to the connection start/end dtrace probes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
Place, Suite 330, Boston, MA 02111-1307 USA
16
16
 
17
17
*****************************************************************************/
18
 
/***********************************************************************
19
 
 
20
 
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
21
 
Copyright (c) 2009, Percona Inc.
22
 
 
23
 
Portions of this file contain modifications contributed and copyrighted
24
 
by Percona Inc.. Those modifications are
25
 
gratefully acknowledged and are described briefly in the InnoDB
26
 
documentation. The contributions by Percona Inc. are incorporated with
27
 
their permission, and subject to the conditions contained in the file
28
 
COPYING.Percona.
29
 
 
30
 
This program is free software; you can redistribute it and/or modify it
31
 
under the terms of the GNU General Public License as published by the
32
 
Free Software Foundation; version 2 of the License.
33
 
 
34
 
This program is distributed in the hope that it will be useful, but
35
 
WITHOUT ANY WARRANTY; without even the implied warranty of
36
 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
37
 
Public License for more details.
38
 
 
39
 
You should have received a copy of the GNU General Public License along
40
 
with this program; if not, write to the Free Software Foundation, Inc.,
41
 
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
42
 
 
43
 
***********************************************************************/
44
 
 
45
 
/**************************************************//**
46
 
@file os/os0file.c
 
18
 
 
19
/******************************************************
47
20
The interface to the operating system file i/o primitives
48
21
 
49
22
Created 10/21/1995 Heikki Tuuri
50
23
*******************************************************/
51
24
 
52
25
#include "os0file.h"
 
26
#include "os0sync.h"
 
27
#include "os0thread.h"
53
28
#include "ut0mem.h"
54
29
#include "srv0srv.h"
55
30
#include "srv0start.h"
56
31
#include "fil0fil.h"
57
32
#include "buf0buf.h"
 
33
 
 
34
#if defined(UNIV_HOTBACKUP) && defined(__WIN__)
 
35
/* Add includes for the _stat() call to compile on Windows */
 
36
#include <sys/types.h>
 
37
#include <sys/stat.h>
58
38
#include <errno.h>
59
 
#include <fcntl.h>
60
 
#include <limits.h>
61
 
#include <unistd.h>
62
 
#ifndef UNIV_HOTBACKUP
63
 
# include "os0sync.h"
64
 
# include "os0thread.h"
65
 
#else /* !UNIV_HOTBACKUP */
66
 
# ifdef __WIN__
67
 
/* Add includes for the _stat() call to compile on Windows */
68
 
#  include <sys/types.h>
69
 
#  include <sys/stat.h>
70
 
# endif /* __WIN__ */
71
 
#endif /* !UNIV_HOTBACKUP */
 
39
#endif /* UNIV_HOTBACKUP */
72
40
 
73
41
/* This specifies the file permissions InnoDB uses when it creates files in
74
42
Unix; the value of os_innodb_umask is initialized in ha_innodb.cc to
75
43
my_umask */
76
44
 
77
45
#ifndef __WIN__
78
 
/** Umask for creating files */
79
46
UNIV_INTERN ulint       os_innodb_umask
80
47
                        = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
81
48
#else
82
 
/** Umask for creating files */
83
49
UNIV_INTERN ulint       os_innodb_umask         = 0;
84
50
#endif
85
51
 
91
57
/* We do not call os_file_flush in every os_file_write. */
92
58
#endif /* UNIV_DO_FLUSH */
93
59
 
94
 
#ifndef UNIV_HOTBACKUP
95
60
/* We use these mutexes to protect lseek + file i/o operation, if the
96
61
OS does not provide an atomic pread or pwrite, or similar */
97
62
#define OS_FILE_N_SEEK_MUTEXES  16
100
65
/* In simulated aio, merge at most this many consecutive i/os */
101
66
#define OS_AIO_MERGE_N_CONSECUTIVE      64
102
67
 
103
 
/** If this flag is TRUE, then we will use the native aio of the
 
68
/* If this flag is TRUE, then we will use the native aio of the
104
69
OS (provided we compiled Innobase with it in), otherwise we will
105
70
use simulated aio we build below with threads */
106
71
 
107
72
UNIV_INTERN ibool       os_aio_use_native_aio   = FALSE;
108
73
 
109
 
/** Flag: enable debug printout for asynchronous i/o */
110
74
UNIV_INTERN ibool       os_aio_print_debug      = FALSE;
111
75
 
112
 
/** The asynchronous i/o array slot structure */
 
76
/* The aio array slot structure */
113
77
typedef struct os_aio_slot_struct       os_aio_slot_t;
114
78
 
115
 
/** The asynchronous i/o array slot structure */
116
79
struct os_aio_slot_struct{
117
 
        ibool           is_read;        /*!< TRUE if a read operation */
118
 
        ulint           pos;            /*!< index of the slot in the aio
 
80
        ibool           is_read;        /* TRUE if a read operation */
 
81
        ulint           pos;            /* index of the slot in the aio
119
82
                                        array */
120
 
        ibool           reserved;       /*!< TRUE if this slot is reserved */
121
 
        time_t          reservation_time;/*!< time when reserved */
122
 
        ulint           len;            /*!< length of the block to read or
 
83
        ibool           reserved;       /* TRUE if this slot is reserved */
 
84
        time_t          reservation_time;/* time when reserved */
 
85
        ulint           len;            /* length of the block to read or
123
86
                                        write */
124
 
        byte*           buf;            /*!< buffer used in i/o */
125
 
        ulint           type;           /*!< OS_FILE_READ or OS_FILE_WRITE */
126
 
        ulint           offset;         /*!< 32 low bits of file offset in
 
87
        byte*           buf;            /* buffer used in i/o */
 
88
        ulint           type;           /* OS_FILE_READ or OS_FILE_WRITE */
 
89
        ulint           offset;         /* 32 low bits of file offset in
127
90
                                        bytes */
128
 
        ulint           offset_high;    /*!< 32 high bits of file offset */
129
 
        os_file_t       file;           /*!< file where to read or write */
130
 
        const char*     name;           /*!< file name or path */
131
 
        ibool           io_already_done;/*!< used only in simulated aio:
 
91
        ulint           offset_high;    /* 32 high bits of file offset */
 
92
        os_file_t       file;           /* file where to read or write */
 
93
        const char*     name;           /* file name or path */
 
94
        ibool           io_already_done;/* used only in simulated aio:
132
95
                                        TRUE if the physical i/o already
133
96
                                        made and only the slot message
134
97
                                        needs to be passed to the caller
135
98
                                        of os_aio_simulated_handle */
136
 
        fil_node_t*     message1;       /*!< message which is given by the */
137
 
        void*           message2;       /*!< the requester of an aio operation
 
99
        fil_node_t*     message1;       /* message which is given by the */
 
100
        void*           message2;       /* the requester of an aio operation
138
101
                                        and which can be used to identify
139
102
                                        which pending aio operation was
140
103
                                        completed */
141
104
#ifdef WIN_ASYNC_IO
142
 
        os_event_t      event;          /*!< event object we need in the
 
105
        os_event_t      event;          /* event object we need in the
143
106
                                        OVERLAPPED struct */
144
 
        OVERLAPPED      control;        /*!< Windows control block for the
 
107
        OVERLAPPED      control;        /* Windows control block for the
145
108
                                        aio request */
146
109
#endif
147
110
};
148
111
 
149
 
/** The asynchronous i/o array structure */
 
112
/* The aio array structure */
150
113
typedef struct os_aio_array_struct      os_aio_array_t;
151
114
 
152
 
/** The asynchronous i/o array structure */
153
115
struct os_aio_array_struct{
154
 
        os_mutex_t      mutex;  /*!< the mutex protecting the aio array */
155
 
        os_event_t      not_full;
156
 
                                /*!< The event which is set to the
157
 
                                signaled state when there is space in
158
 
                                the aio outside the ibuf segment */
159
 
        os_event_t      is_empty;
160
 
                                /*!< The event which is set to the
161
 
                                signaled state when there are no
162
 
                                pending i/os in this array */
163
 
        ulint           n_slots;/*!< Total number of slots in the aio
164
 
                                array.  This must be divisible by
165
 
                                n_threads. */
166
 
        ulint           n_segments;
167
 
                                /*!< Number of segments in the aio
168
 
                                array of pending aio requests. A
169
 
                                thread can wait separately for any one
170
 
                                of the segments. */
171
 
        ulint           n_reserved;
172
 
                                /*!< Number of reserved slots in the
173
 
                                aio array outside the ibuf segment */
174
 
        os_aio_slot_t*  slots;  /*!< Pointer to the slots in the array */
 
116
        os_mutex_t      mutex;    /* the mutex protecting the aio array */
 
117
        os_event_t      not_full; /* The event which is set to the signaled
 
118
                                  state when there is space in the aio
 
119
                                  outside the ibuf segment */
 
120
        os_event_t      is_empty; /* The event which is set to the signaled
 
121
                                  state when there are no pending i/os
 
122
                                  in this array */
 
123
        ulint           n_slots;  /* Total number of slots in the aio array.
 
124
                                  This must be divisible by n_threads. */
 
125
        ulint           n_segments;/* Number of segments in the aio array of
 
126
                                  pending aio requests. A thread can wait
 
127
                                  separately for any one of the segments. */
 
128
        ulint           n_reserved;/* Number of reserved slots in the
 
129
                                  aio array outside the ibuf segment */
 
130
        os_aio_slot_t*  slots;    /* Pointer to the slots in the array */
175
131
#ifdef __WIN__
176
132
        os_native_event_t* native_events;
177
 
                                /*!< Pointer to an array of OS native
178
 
                                event handles where we copied the
179
 
                                handles from slots, in the same
180
 
                                order. This can be used in
181
 
                                WaitForMultipleObjects; used only in
182
 
                                Windows */
 
133
                                  /* Pointer to an array of OS native event
 
134
                                  handles where we copied the handles from
 
135
                                  slots, in the same order. This can be used
 
136
                                  in WaitForMultipleObjects; used only in
 
137
                                  Windows */
183
138
#endif
184
139
};
185
140
 
186
 
/** Array of events used in simulated aio */
 
141
/* Array of events used in simulated aio */
187
142
static os_event_t*      os_aio_segment_wait_events      = NULL;
188
143
 
189
 
/** The aio arrays for non-ibuf i/o and ibuf i/o, as well as sync aio. These
190
 
are NULL when the module has not yet been initialized. @{ */
191
 
static os_aio_array_t*  os_aio_read_array       = NULL; /*!< Reads */
192
 
static os_aio_array_t*  os_aio_write_array      = NULL; /*!< Writes */
193
 
static os_aio_array_t*  os_aio_ibuf_array       = NULL; /*!< Insert buffer */
194
 
static os_aio_array_t*  os_aio_log_array        = NULL; /*!< Redo log */
195
 
static os_aio_array_t*  os_aio_sync_array       = NULL; /*!< Synchronous I/O */
196
 
/* @} */
 
144
/* The aio arrays for non-ibuf i/o and ibuf i/o, as well as sync aio. These
 
145
are NULL when the module has not yet been initialized. */
 
146
static os_aio_array_t*  os_aio_read_array       = NULL;
 
147
static os_aio_array_t*  os_aio_write_array      = NULL;
 
148
static os_aio_array_t*  os_aio_ibuf_array       = NULL;
 
149
static os_aio_array_t*  os_aio_log_array        = NULL;
 
150
static os_aio_array_t*  os_aio_sync_array       = NULL;
197
151
 
198
 
/** Number of asynchronous I/O segments.  Set by os_aio_init(). */
199
152
static ulint    os_aio_n_segments       = ULINT_UNDEFINED;
200
153
 
201
 
/** If the following is TRUE, read i/o handler threads try to
 
154
/* If the following is TRUE, read i/o handler threads try to
202
155
wait until a batch of new read requests have been posted */
203
156
static ibool    os_aio_recommend_sleep_for_read_threads = FALSE;
204
 
#endif /* !UNIV_HOTBACKUP */
205
157
 
206
158
UNIV_INTERN ulint       os_n_file_reads         = 0;
207
159
UNIV_INTERN ulint       os_bytes_read_since_printout = 0;
214
166
 
215
167
UNIV_INTERN ibool       os_has_said_disk_full   = FALSE;
216
168
 
217
 
#ifndef UNIV_HOTBACKUP
218
 
/** The mutex protecting the following counts of pending I/O operations */
 
169
/* The mutex protecting the following counts of pending I/O operations */
219
170
static os_mutex_t       os_file_count_mutex;
220
 
#endif /* !UNIV_HOTBACKUP */
221
 
/** Number of pending os_file_pread() operations */
222
171
UNIV_INTERN ulint       os_file_n_pending_preads  = 0;
223
 
/** Number of pending os_file_pwrite() operations */
224
172
UNIV_INTERN ulint       os_file_n_pending_pwrites = 0;
225
 
/** Number of pending write operations */
226
173
UNIV_INTERN ulint       os_n_pending_writes = 0;
227
 
/** Number of pending read operations */
228
174
UNIV_INTERN ulint       os_n_pending_reads = 0;
229
175
 
230
 
/***********************************************************************//**
231
 
Gets the operating system version. Currently works only on Windows.
232
 
@return OS_WIN95, OS_WIN31, OS_WINNT, OS_WIN2000 */
 
176
/***************************************************************************
 
177
Gets the operating system version. Currently works only on Windows. */
233
178
UNIV_INTERN
234
179
ulint
235
180
os_get_os_version(void)
236
181
/*===================*/
 
182
                  /* out: OS_WIN95, OS_WIN31, OS_WINNT, OS_WIN2000 */
237
183
{
238
184
#ifdef __WIN__
239
185
        OSVERSIONINFO     os_info;
263
209
#endif
264
210
}
265
211
 
266
 
/***********************************************************************//**
 
212
/***************************************************************************
267
213
Retrieves the last error number if an error occurs in a file io function.
268
214
The number should be retrieved before any other OS calls (because they may
269
215
overwrite the error number). If the number is not known to this program,
270
 
the OS error number + 100 is returned.
271
 
@return error number, or OS error number + 100 */
 
216
the OS error number + 100 is returned. */
272
217
UNIV_INTERN
273
218
ulint
274
219
os_file_get_last_error(
275
220
/*===================*/
276
 
        ibool   report_all_errors)      /*!< in: TRUE if we want an error message
 
221
                                        /* out: error number, or OS error
 
222
                                        number + 100 */
 
223
        ibool   report_all_errors)      /* in: TRUE if we want an error message
277
224
                                        printed of all errors */
278
225
{
279
226
        ulint   err;
323
270
                                "InnoDB: Some operating system error numbers"
324
271
                                " are described at\n"
325
272
                                "InnoDB: "
326
 
                                REFMAN
 
273
                                "http://dev.mysql.com/doc/refman/5.1/en/"
327
274
                                "operating-system-error-codes.html\n");
328
275
                }
329
276
        }
382
329
                                "InnoDB: Some operating system"
383
330
                                " error numbers are described at\n"
384
331
                                "InnoDB: "
385
 
                                REFMAN
 
332
                                "http://dev.mysql.com/doc/refman/5.1/en/"
386
333
                                "operating-system-error-codes.html\n");
387
334
                }
388
335
        }
403
350
#endif
404
351
}
405
352
 
406
 
/****************************************************************//**
 
353
/********************************************************************
407
354
Does error handling when a file operation fails.
408
355
Conditionally exits (calling exit(3)) based on should_exit value and the
409
 
error type
410
 
@return TRUE if we should retry the operation */
 
356
error type */
411
357
static
412
358
ibool
413
359
os_file_handle_error_cond_exit(
414
360
/*===========================*/
415
 
        const char*     name,           /*!< in: name of a file or NULL */
416
 
        const char*     operation,      /*!< in: operation */
417
 
        ibool           should_exit)    /*!< in: call exit(3) if unknown error
 
361
                                        /* out: TRUE if we should retry the
 
362
                                        operation */
 
363
        const char*     name,           /* in: name of a file or NULL */
 
364
        const char*     operation,      /* in: operation */
 
365
        ibool           should_exit)    /* in: call exit(3) if unknown error
418
366
                                        and this parameter is TRUE */
419
367
{
420
368
        ulint   err;
477
425
        return(FALSE);
478
426
}
479
427
 
480
 
/****************************************************************//**
481
 
Does error handling when a file operation fails.
482
 
@return TRUE if we should retry the operation */
 
428
/********************************************************************
 
429
Does error handling when a file operation fails. */
483
430
static
484
431
ibool
485
432
os_file_handle_error(
486
433
/*=================*/
487
 
        const char*     name,   /*!< in: name of a file or NULL */
488
 
        const char*     operation)/*!< in: operation */
 
434
                                /* out: TRUE if we should retry the
 
435
                                operation */
 
436
        const char*     name,   /* in: name of a file or NULL */
 
437
        const char*     operation)/* in: operation */
489
438
{
490
439
        /* exit in case of unknown error */
491
440
        return(os_file_handle_error_cond_exit(name, operation, TRUE));
492
441
}
493
442
 
494
 
/****************************************************************//**
495
 
Does error handling when a file operation fails.
496
 
@return TRUE if we should retry the operation */
 
443
/********************************************************************
 
444
Does error handling when a file operation fails. */
497
445
static
498
446
ibool
499
447
os_file_handle_error_no_exit(
500
448
/*=========================*/
501
 
        const char*     name,   /*!< in: name of a file or NULL */
502
 
        const char*     operation)/*!< in: operation */
 
449
                                /* out: TRUE if we should retry the
 
450
                                operation */
 
451
        const char*     name,   /* in: name of a file or NULL */
 
452
        const char*     operation)/* in: operation */
503
453
{
504
454
        /* don't exit in case of unknown error */
505
455
        return(os_file_handle_error_cond_exit(name, operation, FALSE));
514
464
# undef USE_FILE_LOCK
515
465
#endif
516
466
#ifdef USE_FILE_LOCK
517
 
/****************************************************************//**
518
 
Obtain an exclusive lock on a file.
519
 
@return 0 on success */
 
467
/********************************************************************
 
468
Obtain an exclusive lock on a file. */
520
469
static
521
470
int
522
471
os_file_lock(
523
472
/*=========*/
524
 
        int             fd,     /*!< in: file descriptor */
525
 
        const char*     name)   /*!< in: file name */
 
473
                                /* out: 0 on success */
 
474
        int             fd,     /* in: file descriptor */
 
475
        const char*     name)   /* in: file name */
526
476
{
527
477
        struct flock lk;
528
478
        lk.l_type = F_WRLCK;
547
497
}
548
498
#endif /* USE_FILE_LOCK */
549
499
 
550
 
#ifndef UNIV_HOTBACKUP
551
 
/****************************************************************//**
 
500
/********************************************************************
552
501
Creates the seek mutexes used in positioned reads and writes. */
553
502
UNIV_INTERN
554
503
void
564
513
        }
565
514
}
566
515
 
567
 
/***********************************************************************//**
 
516
/***************************************************************************
568
517
Creates a temporary file.  This function is like tmpfile(3), but
569
518
the temporary file is created in the MySQL temporary directory.
570
519
On Netware, this function is like tmpfile(3), because the C run-time
571
 
library of Netware does not expose the delete-on-close flag.
572
 
@return temporary file handle, or NULL on error */
 
520
library of Netware does not expose the delete-on-close flag. */
573
521
UNIV_INTERN
574
522
FILE*
575
523
os_file_create_tmpfile(void)
576
524
/*========================*/
 
525
                        /* out: temporary file handle, or NULL on error */
577
526
{
578
 
#ifdef __NETWARE__
 
527
#ifdef UNIV_HOTBACKUP
 
528
        ut_error;
 
529
 
 
530
        return(NULL);
 
531
#else
 
532
# ifdef __NETWARE__
579
533
        FILE*   file    = tmpfile();
580
 
#else /* __NETWARE__ */
 
534
# else /* __NETWARE__ */
581
535
        FILE*   file    = NULL;
582
536
        int     fd      = innobase_mysql_tmpfile();
583
537
 
584
538
        if (fd >= 0) {
585
539
                file = fdopen(fd, "w+b");
586
540
        }
587
 
#endif /* __NETWARE__ */
 
541
# endif /* __NETWARE__ */
588
542
 
589
543
        if (!file) {
590
544
                ut_print_timestamp(stderr);
591
545
                fprintf(stderr,
592
546
                        "  InnoDB: Error: unable to create temporary file;"
593
547
                        " errno: %d\n", errno);
594
 
#ifndef __NETWARE__
 
548
# ifndef __NETWARE__
595
549
                if (fd >= 0) {
596
550
                        close(fd);
597
551
                }
598
 
#endif /* !__NETWARE__ */
 
552
# endif /* !__NETWARE__ */
599
553
        }
600
554
 
601
555
        return(file);
 
556
#endif /* UNIV_HOTBACKUP */
602
557
}
603
 
#endif /* !UNIV_HOTBACKUP */
604
558
 
605
 
/***********************************************************************//**
 
559
/***************************************************************************
606
560
The os_file_opendir() function opens a directory stream corresponding to the
607
561
directory named by the dirname argument. The directory stream is positioned
608
562
at the first entry. In both Unix and Windows we automatically skip the '.'
609
 
and '..' items at the start of the directory listing.
610
 
@return directory stream, NULL if error */
 
563
and '..' items at the start of the directory listing. */
611
564
UNIV_INTERN
612
565
os_file_dir_t
613
566
os_file_opendir(
614
567
/*============*/
615
 
        const char*     dirname,        /*!< in: directory name; it must not
 
568
                                        /* out: directory stream, NULL if
 
569
                                        error */
 
570
        const char*     dirname,        /* in: directory name; it must not
616
571
                                        contain a trailing '\' or '/' */
617
 
        ibool           error_is_fatal) /*!< in: TRUE if we should treat an
 
572
        ibool           error_is_fatal) /* in: TRUE if we should treat an
618
573
                                        error as a fatal error; if we try to
619
574
                                        open symlinks then we do not wish a
620
575
                                        fatal error if it happens not to be
661
616
#endif
662
617
}
663
618
 
664
 
/***********************************************************************//**
665
 
Closes a directory stream.
666
 
@return 0 if success, -1 if failure */
 
619
/***************************************************************************
 
620
Closes a directory stream. */
667
621
UNIV_INTERN
668
622
int
669
623
os_file_closedir(
670
624
/*=============*/
671
 
        os_file_dir_t   dir)    /*!< in: directory stream */
 
625
                                /* out: 0 if success, -1 if failure */
 
626
        os_file_dir_t   dir)    /* in: directory stream */
672
627
{
673
628
#ifdef __WIN__
674
629
        BOOL            ret;
695
650
#endif
696
651
}
697
652
 
698
 
/***********************************************************************//**
 
653
/***************************************************************************
699
654
This function returns information of the next file in the directory. We jump
700
 
over the '.' and '..' entries in the directory.
701
 
@return 0 if ok, -1 if error, 1 if at the end of the directory */
 
655
over the '.' and '..' entries in the directory. */
702
656
UNIV_INTERN
703
657
int
704
658
os_file_readdir_next_file(
705
659
/*======================*/
706
 
        const char*     dirname,/*!< in: directory name or path */
707
 
        os_file_dir_t   dir,    /*!< in: directory stream */
708
 
        os_file_stat_t* info)   /*!< in/out: buffer where the info is returned */
 
660
                                /* out: 0 if ok, -1 if error, 1 if at the end
 
661
                                of the directory */
 
662
        const char*     dirname,/* in: directory name or path */
 
663
        os_file_dir_t   dir,    /* in: directory stream */
 
664
        os_file_stat_t* info)   /* in/out: buffer where the info is returned */
709
665
{
710
666
#ifdef __WIN__
711
667
        LPWIN32_FIND_DATA       lpFindFileData;
737
693
                        /* TODO: MySQL has apparently its own symlink
738
694
                        implementation in Windows, dbname.sym can
739
695
                        redirect a database directory:
740
 
                        REFMAN "windows-symbolic-links.html" */
 
696
                        http://dev.mysql.com/doc/refman/5.1/en/
 
697
                        windows-symbolic-links.html */
741
698
                        info->type = OS_FILE_TYPE_LINK;
742
699
                } else if (lpFindFileData->dwFileAttributes
743
700
                           & FILE_ATTRIBUTE_DIRECTORY) {
845
802
#endif
846
803
}
847
804
 
848
 
/*****************************************************************//**
 
805
/*********************************************************************
849
806
This function attempts to create a directory named pathname. The new directory
850
807
gets default permissions. On Unix the permissions are (0770 & ~umask). If the
851
808
directory exists already, nothing is done and the call succeeds, unless the
852
 
fail_if_exists arguments is true.
853
 
@return TRUE if call succeeds, FALSE on error */
 
809
fail_if_exists arguments is true. */
854
810
UNIV_INTERN
855
811
ibool
856
812
os_file_create_directory(
857
813
/*=====================*/
858
 
        const char*     pathname,       /*!< in: directory name as
 
814
                                        /* out: TRUE if call succeeds,
 
815
                                        FALSE on error */
 
816
        const char*     pathname,       /* in: directory name as
859
817
                                        null-terminated string */
860
 
        ibool           fail_if_exists) /*!< in: if TRUE, pre-existing directory
 
818
        ibool           fail_if_exists) /* in: if TRUE, pre-existing directory
861
819
                                        is treated as an error. */
862
820
{
863
821
#ifdef __WIN__
890
848
#endif
891
849
}
892
850
 
893
 
/****************************************************************//**
894
 
A simple function to open or create a file.
895
 
@return own: handle to the file, not defined if error, error number
896
 
can be retrieved with os_file_get_last_error */
 
851
/********************************************************************
 
852
A simple function to open or create a file. */
897
853
UNIV_INTERN
898
854
os_file_t
899
855
os_file_create_simple(
900
856
/*==================*/
901
 
        const char*     name,   /*!< in: name of the file or path as a
 
857
                                /* out, own: handle to the file, not defined
 
858
                                if error, error number can be retrieved with
 
859
                                os_file_get_last_error */
 
860
        const char*     name,   /* in: name of the file or path as a
902
861
                                null-terminated string */
903
 
        ulint           create_mode,/*!< in: OS_FILE_OPEN if an existing file is
 
862
        ulint           create_mode,/* in: OS_FILE_OPEN if an existing file is
904
863
                                opened (if does not exist, error), or
905
864
                                OS_FILE_CREATE if a new file is created
906
865
                                (if exists, error), or
907
866
                                OS_FILE_CREATE_PATH if new file
908
867
                                (if exists, error) and subdirectories along
909
868
                                its path are created (if needed)*/
910
 
        ulint           access_type,/*!< in: OS_FILE_READ_ONLY or
 
869
        ulint           access_type,/* in: OS_FILE_READ_ONLY or
911
870
                                OS_FILE_READ_WRITE */
912
 
        ibool*          success)/*!< out: TRUE if succeed, FALSE if error */
 
871
        ibool*          success)/* out: TRUE if succeed, FALSE if error */
913
872
{
914
873
#ifdef __WIN__
915
874
        os_file_t       file;
955
914
                          NULL, /* default security attributes */
956
915
                          create_flag,
957
916
                          attributes,
958
 
                          NULL);        /*!< no template file */
 
917
                          NULL);        /* no template file */
959
918
 
960
919
        if (file == INVALID_HANDLE_VALUE) {
961
920
                *success = FALSE;
1031
990
#endif /* __WIN__ */
1032
991
}
1033
992
 
1034
 
/****************************************************************//**
1035
 
A simple function to open or create a file.
1036
 
@return own: handle to the file, not defined if error, error number
1037
 
can be retrieved with os_file_get_last_error */
 
993
/********************************************************************
 
994
A simple function to open or create a file. */
1038
995
UNIV_INTERN
1039
996
os_file_t
1040
997
os_file_create_simple_no_error_handling(
1041
998
/*====================================*/
1042
 
        const char*     name,   /*!< in: name of the file or path as a
 
999
                                /* out, own: handle to the file, not defined
 
1000
                                if error, error number can be retrieved with
 
1001
                                os_file_get_last_error */
 
1002
        const char*     name,   /* in: name of the file or path as a
1043
1003
                                null-terminated string */
1044
 
        ulint           create_mode,/*!< in: OS_FILE_OPEN if an existing file
 
1004
        ulint           create_mode,/* in: OS_FILE_OPEN if an existing file
1045
1005
                                is opened (if does not exist, error), or
1046
1006
                                OS_FILE_CREATE if a new file is created
1047
1007
                                (if exists, error) */
1048
 
        ulint           access_type,/*!< in: OS_FILE_READ_ONLY,
 
1008
        ulint           access_type,/* in: OS_FILE_READ_ONLY,
1049
1009
                                OS_FILE_READ_WRITE, or
1050
1010
                                OS_FILE_READ_ALLOW_DELETE; the last option is
1051
1011
                                used by a backup program reading the file */
1052
 
        ibool*          success)/*!< out: TRUE if succeed, FALSE if error */
 
1012
        ibool*          success)/* out: TRUE if succeed, FALSE if error */
1053
1013
{
1054
1014
#ifdef __WIN__
1055
1015
        os_file_t       file;
1076
1036
        } else if (access_type == OS_FILE_READ_ALLOW_DELETE) {
1077
1037
                access = GENERIC_READ;
1078
1038
                share_mode = FILE_SHARE_DELETE | FILE_SHARE_READ
1079
 
                        | FILE_SHARE_WRITE;     /*!< A backup program has to give
 
1039
                        | FILE_SHARE_WRITE;     /* A backup program has to give
1080
1040
                                                mysqld the maximum freedom to
1081
1041
                                                do what it likes with the
1082
1042
                                                file */
1091
1051
                          NULL, /* default security attributes */
1092
1052
                          create_flag,
1093
1053
                          attributes,
1094
 
                          NULL);        /*!< no template file */
 
1054
                          NULL);        /* no template file */
1095
1055
 
1096
1056
        if (file == INVALID_HANDLE_VALUE) {
1097
1057
                *success = FALSE;
1143
1103
#endif /* __WIN__ */
1144
1104
}
1145
1105
 
1146
 
/****************************************************************//**
 
1106
/********************************************************************
1147
1107
Tries to disable OS caching on an opened file descriptor. */
1148
1108
UNIV_INTERN
1149
1109
void
1150
1110
os_file_set_nocache(
1151
1111
/*================*/
1152
 
        int             fd,             /*!< in: file descriptor to alter */
1153
 
        const char*     file_name,      /*!< in: file name, used in the
 
1112
        int             fd,             /* in: file descriptor to alter */
 
1113
        const char*     file_name,      /* in: file name, used in the
1154
1114
                                        diagnostic message */
1155
 
        const char*     operation_name) /*!< in: "open" or "create"; used in the
 
1115
        const char*     operation_name) /* in: "open" or "create"; used in the
1156
1116
                                        diagnostic message */
1157
1117
{
1158
1118
        /* some versions of Solaris may not have DIRECTIO_ON */
1190
1150
#endif
1191
1151
}
1192
1152
 
1193
 
/****************************************************************//**
1194
 
Opens an existing file or creates a new.
1195
 
@return own: handle to the file, not defined if error, error number
1196
 
can be retrieved with os_file_get_last_error */
 
1153
/********************************************************************
 
1154
Opens an existing file or creates a new. */
1197
1155
UNIV_INTERN
1198
1156
os_file_t
1199
1157
os_file_create(
1200
1158
/*===========*/
1201
 
        const char*     name,   /*!< in: name of the file or path as a
 
1159
                                /* out, own: handle to the file, not defined
 
1160
                                if error, error number can be retrieved with
 
1161
                                os_file_get_last_error */
 
1162
        const char*     name,   /* in: name of the file or path as a
1202
1163
                                null-terminated string */
1203
 
        ulint           create_mode,/*!< in: OS_FILE_OPEN if an existing file
 
1164
        ulint           create_mode,/* in: OS_FILE_OPEN if an existing file
1204
1165
                                is opened (if does not exist, error), or
1205
1166
                                OS_FILE_CREATE if a new file is created
1206
1167
                                (if exists, error),
1208
1169
                                or an old overwritten;
1209
1170
                                OS_FILE_OPEN_RAW, if a raw device or disk
1210
1171
                                partition should be opened */
1211
 
        ulint           purpose,/*!< in: OS_FILE_AIO, if asynchronous,
 
1172
        ulint           purpose,/* in: OS_FILE_AIO, if asynchronous,
1212
1173
                                non-buffered i/o is desired,
1213
1174
                                OS_FILE_NORMAL, if any normal file;
1214
1175
                                NOTE that it also depends on type, os_aio_..
1215
1176
                                and srv_.. variables whether we really use
1216
1177
                                async i/o or unbuffered i/o: look in the
1217
1178
                                function source code for the exact rules */
1218
 
        ulint           type,   /*!< in: OS_DATA_FILE or OS_LOG_FILE */
1219
 
        ibool*          success)/*!< out: TRUE if succeed, FALSE if error */
 
1179
        ulint           type,   /* in: OS_DATA_FILE or OS_LOG_FILE */
 
1180
        ibool*          success)/* out: TRUE if succeed, FALSE if error */
1220
1181
{
1221
1182
#ifdef __WIN__
1222
1183
        os_file_t       file;
1295
1256
                          NULL, /* default security attributes */
1296
1257
                          create_flag,
1297
1258
                          attributes,
1298
 
                          NULL);        /*!< no template file */
 
1259
                          NULL);        /* no template file */
1299
1260
 
1300
1261
        if (file == INVALID_HANDLE_VALUE) {
1301
1262
                *success = FALSE;
1448
1409
#endif /* __WIN__ */
1449
1410
}
1450
1411
 
1451
 
/***********************************************************************//**
1452
 
Deletes a file if it exists. The file has to be closed before calling this.
1453
 
@return TRUE if success */
 
1412
/***************************************************************************
 
1413
Deletes a file if it exists. The file has to be closed before calling this. */
1454
1414
UNIV_INTERN
1455
1415
ibool
1456
1416
os_file_delete_if_exists(
1457
1417
/*=====================*/
1458
 
        const char*     name)   /*!< in: file path as a null-terminated string */
 
1418
                                /* out: TRUE if success */
 
1419
        const char*     name)   /* in: file path as a null-terminated string */
1459
1420
{
1460
1421
#ifdef __WIN__
1461
1422
        BOOL    ret;
1510
1471
#endif
1511
1472
}
1512
1473
 
1513
 
/***********************************************************************//**
1514
 
Deletes a file. The file has to be closed before calling this.
1515
 
@return TRUE if success */
 
1474
/***************************************************************************
 
1475
Deletes a file. The file has to be closed before calling this. */
1516
1476
UNIV_INTERN
1517
1477
ibool
1518
1478
os_file_delete(
1519
1479
/*===========*/
1520
 
        const char*     name)   /*!< in: file path as a null-terminated string */
 
1480
                                /* out: TRUE if success */
 
1481
        const char*     name)   /* in: file path as a null-terminated string */
1521
1482
{
1522
1483
#ifdef __WIN__
1523
1484
        BOOL    ret;
1573
1534
#endif
1574
1535
}
1575
1536
 
1576
 
/***********************************************************************//**
 
1537
/***************************************************************************
1577
1538
Renames a file (can also move it to another directory). It is safest that the
1578
 
file is closed before calling this function.
1579
 
@return TRUE if success */
 
1539
file is closed before calling this function. */
1580
1540
UNIV_INTERN
1581
1541
ibool
1582
1542
os_file_rename(
1583
1543
/*===========*/
1584
 
        const char*     oldpath,/*!< in: old file path as a null-terminated
 
1544
                                /* out: TRUE if success */
 
1545
        const char*     oldpath,/* in: old file path as a null-terminated
1585
1546
                                string */
1586
 
        const char*     newpath)/*!< in: new file path */
 
1547
        const char*     newpath)/* in: new file path */
1587
1548
{
1588
1549
#ifdef __WIN__
1589
1550
        BOOL    ret;
1612
1573
#endif
1613
1574
}
1614
1575
 
1615
 
/***********************************************************************//**
 
1576
/***************************************************************************
1616
1577
Closes a file handle. In case of error, error number can be retrieved with
1617
 
os_file_get_last_error.
1618
 
@return TRUE if success */
 
1578
os_file_get_last_error. */
1619
1579
UNIV_INTERN
1620
1580
ibool
1621
1581
os_file_close(
1622
1582
/*==========*/
1623
 
        os_file_t       file)   /*!< in, own: handle to a file */
 
1583
                                /* out: TRUE if success */
 
1584
        os_file_t       file)   /* in, own: handle to a file */
1624
1585
{
1625
1586
#ifdef __WIN__
1626
1587
        BOOL    ret;
1651
1612
#endif
1652
1613
}
1653
1614
 
1654
 
#ifdef UNIV_HOTBACKUP
1655
 
/***********************************************************************//**
1656
 
Closes a file handle.
1657
 
@return TRUE if success */
 
1615
/***************************************************************************
 
1616
Closes a file handle. */
1658
1617
UNIV_INTERN
1659
1618
ibool
1660
1619
os_file_close_no_error_handling(
1661
1620
/*============================*/
1662
 
        os_file_t       file)   /*!< in, own: handle to a file */
 
1621
                                /* out: TRUE if success */
 
1622
        os_file_t       file)   /* in, own: handle to a file */
1663
1623
{
1664
1624
#ifdef __WIN__
1665
1625
        BOOL    ret;
1686
1646
        return(TRUE);
1687
1647
#endif
1688
1648
}
1689
 
#endif /* UNIV_HOTBACKUP */
1690
1649
 
1691
 
/***********************************************************************//**
1692
 
Gets a file size.
1693
 
@return TRUE if success */
 
1650
/***************************************************************************
 
1651
Gets a file size. */
1694
1652
UNIV_INTERN
1695
1653
ibool
1696
1654
os_file_get_size(
1697
1655
/*=============*/
1698
 
        os_file_t       file,   /*!< in: handle to a file */
1699
 
        ulint*          size,   /*!< out: least significant 32 bits of file
 
1656
                                /* out: TRUE if success */
 
1657
        os_file_t       file,   /* in: handle to a file */
 
1658
        ulint*          size,   /* out: least significant 32 bits of file
1700
1659
                                size */
1701
 
        ulint*          size_high)/*!< out: most significant 32 bits of size */
 
1660
        ulint*          size_high)/* out: most significant 32 bits of size */
1702
1661
{
1703
1662
#ifdef __WIN__
1704
1663
        DWORD   high;
1736
1695
#endif
1737
1696
}
1738
1697
 
1739
 
/***********************************************************************//**
1740
 
Gets file size as a 64-bit integer ib_int64_t.
1741
 
@return size in bytes, -1 if error */
 
1698
/***************************************************************************
 
1699
Gets file size as a 64-bit integer ib_int64_t. */
1742
1700
UNIV_INTERN
1743
1701
ib_int64_t
1744
1702
os_file_get_size_as_iblonglong(
1745
1703
/*===========================*/
1746
 
        os_file_t       file)   /*!< in: handle to a file */
 
1704
                                /* out: size in bytes, -1 if error */
 
1705
        os_file_t       file)   /* in: handle to a file */
1747
1706
{
1748
1707
        ulint   size;
1749
1708
        ulint   size_high;
1759
1718
        return((((ib_int64_t)size_high) << 32) + (ib_int64_t)size);
1760
1719
}
1761
1720
 
1762
 
/***********************************************************************//**
1763
 
Write the specified number of zeros to a newly created file.
1764
 
@return TRUE if success */
 
1721
/***************************************************************************
 
1722
Write the specified number of zeros to a newly created file. */
1765
1723
UNIV_INTERN
1766
1724
ibool
1767
1725
os_file_set_size(
1768
1726
/*=============*/
1769
 
        const char*     name,   /*!< in: name of the file or path as a
 
1727
                                /* out: TRUE if success */
 
1728
        const char*     name,   /* in: name of the file or path as a
1770
1729
                                null-terminated string */
1771
 
        os_file_t       file,   /*!< in: handle to a file */
1772
 
        ulint           size,   /*!< in: least significant 32 bits of file
 
1730
        os_file_t       file,   /* in: handle to a file */
 
1731
        ulint           size,   /* in: least significant 32 bits of file
1773
1732
                                size */
1774
 
        ulint           size_high)/*!< in: most significant 32 bits of size */
 
1733
        ulint           size_high)/* in: most significant 32 bits of size */
1775
1734
{
1776
1735
        ib_int64_t      current_size;
1777
1736
        ib_int64_t      desired_size;
1848
1807
        return(FALSE);
1849
1808
}
1850
1809
 
1851
 
/***********************************************************************//**
1852
 
Truncates a file at its current position.
1853
 
@return TRUE if success */
 
1810
/***************************************************************************
 
1811
Truncates a file at its current position. */
1854
1812
UNIV_INTERN
1855
1813
ibool
1856
1814
os_file_set_eof(
1857
1815
/*============*/
1858
 
        FILE*           file)   /*!< in: file to be truncated */
 
1816
                                /* out: TRUE if success */
 
1817
        FILE*           file)   /* in: file to be truncated */
1859
1818
{
1860
1819
#ifdef __WIN__
1861
1820
        HANDLE h = (HANDLE) _get_osfhandle(fileno(file));
1866
1825
}
1867
1826
 
1868
1827
#ifndef __WIN__
1869
 
/***********************************************************************//**
 
1828
/***************************************************************************
1870
1829
Wrapper to fsync(2) that retries the call on some errors.
1871
1830
Returns the value 0 if successful; otherwise the value -1 is returned and
1872
 
the global variable errno is set to indicate the error.
1873
 
@return 0 if success, -1 otherwise */
 
1831
the global variable errno is set to indicate the error. */
1874
1832
 
1875
1833
static
1876
1834
int
1877
1835
os_file_fsync(
1878
1836
/*==========*/
1879
 
        os_file_t       file)   /*!< in: handle to a file */
 
1837
                                /* out: 0 if success, -1 otherwise */
 
1838
        os_file_t       file)   /* in: handle to a file */
1880
1839
{
1881
1840
        int     ret;
1882
1841
        int     failures;
1914
1873
}
1915
1874
#endif /* !__WIN__ */
1916
1875
 
1917
 
/***********************************************************************//**
1918
 
Flushes the write buffers of a given file to the disk.
1919
 
@return TRUE if success */
 
1876
/***************************************************************************
 
1877
Flushes the write buffers of a given file to the disk. */
1920
1878
UNIV_INTERN
1921
1879
ibool
1922
1880
os_file_flush(
1923
1881
/*==========*/
1924
 
        os_file_t       file)   /*!< in, own: handle to a file */
 
1882
                                /* out: TRUE if success */
 
1883
        os_file_t       file)   /* in, own: handle to a file */
1925
1884
{
1926
1885
#ifdef __WIN__
1927
1886
        BOOL    ret;
2013
1972
}
2014
1973
 
2015
1974
#ifndef __WIN__
2016
 
/*******************************************************************//**
2017
 
Does a synchronous read operation in Posix.
2018
 
@return number of bytes read, -1 if error */
 
1975
/***********************************************************************
 
1976
Does a synchronous read operation in Posix. */
2019
1977
static
2020
1978
ssize_t
2021
1979
os_file_pread(
2022
1980
/*==========*/
2023
 
        os_file_t       file,   /*!< in: handle to a file */
2024
 
        void*           buf,    /*!< in: buffer where to read */
2025
 
        ulint           n,      /*!< in: number of bytes to read */
2026
 
        ulint           offset, /*!< in: least significant 32 bits of file
 
1981
                                /* out: number of bytes read, -1 if error */
 
1982
        os_file_t       file,   /* in: handle to a file */
 
1983
        void*           buf,    /* in: buffer where to read */
 
1984
        ulint           n,      /* in: number of bytes to read */
 
1985
        ulint           offset, /* in: least significant 32 bits of file
2027
1986
                                offset from where to read */
2028
 
        ulint           offset_high) /*!< in: most significant 32 bits of
 
1987
        ulint           offset_high) /* in: most significant 32 bits of
2029
1988
                                offset */
2030
1989
{
2031
1990
        off_t   offs;
2098
2057
#endif
2099
2058
}
2100
2059
 
2101
 
/*******************************************************************//**
2102
 
Does a synchronous write operation in Posix.
2103
 
@return number of bytes written, -1 if error */
 
2060
/***********************************************************************
 
2061
Does a synchronous write operation in Posix. */
2104
2062
static
2105
2063
ssize_t
2106
2064
os_file_pwrite(
2107
2065
/*===========*/
2108
 
        os_file_t       file,   /*!< in: handle to a file */
2109
 
        const void*     buf,    /*!< in: buffer from where to write */
2110
 
        ulint           n,      /*!< in: number of bytes to write */
2111
 
        ulint           offset, /*!< in: least significant 32 bits of file
 
2066
                                /* out: number of bytes written, -1 if error */
 
2067
        os_file_t       file,   /* in: handle to a file */
 
2068
        const void*     buf,    /* in: buffer from where to write */
 
2069
        ulint           n,      /* in: number of bytes to write */
 
2070
        ulint           offset, /* in: least significant 32 bits of file
2112
2071
                                offset where to write */
2113
 
        ulint           offset_high) /*!< in: most significant 32 bits of
 
2072
        ulint           offset_high) /* in: most significant 32 bits of
2114
2073
                                offset */
2115
2074
{
2116
2075
        ssize_t ret;
2212
2171
}
2213
2172
#endif
2214
2173
 
2215
 
/*******************************************************************//**
2216
 
Requests a synchronous positioned read operation.
2217
 
@return TRUE if request was successful, FALSE if fail */
 
2174
/***********************************************************************
 
2175
Requests a synchronous positioned read operation. */
2218
2176
UNIV_INTERN
2219
2177
ibool
2220
2178
os_file_read(
2221
2179
/*=========*/
2222
 
        os_file_t       file,   /*!< in: handle to a file */
2223
 
        void*           buf,    /*!< in: buffer where to read */
2224
 
        ulint           offset, /*!< in: least significant 32 bits of file
 
2180
                                /* out: TRUE if request was
 
2181
                                successful, FALSE if fail */
 
2182
        os_file_t       file,   /* in: handle to a file */
 
2183
        void*           buf,    /* in: buffer where to read */
 
2184
        ulint           offset, /* in: least significant 32 bits of file
2225
2185
                                offset where to read */
2226
 
        ulint           offset_high, /*!< in: most significant 32 bits of
 
2186
        ulint           offset_high, /* in: most significant 32 bits of
2227
2187
                                offset */
2228
 
        ulint           n)      /*!< in: number of bytes to read */
 
2188
        ulint           n)      /* in: number of bytes to read */
2229
2189
{
2230
2190
#ifdef __WIN__
2231
2191
        BOOL            ret;
2327
2287
        return(FALSE);
2328
2288
}
2329
2289
 
2330
 
/*******************************************************************//**
 
2290
/***********************************************************************
2331
2291
Requests a synchronous positioned read operation. This function does not do
2332
 
any error handling. In case of error it returns FALSE.
2333
 
@return TRUE if request was successful, FALSE if fail */
 
2292
any error handling. In case of error it returns FALSE. */
2334
2293
UNIV_INTERN
2335
2294
ibool
2336
2295
os_file_read_no_error_handling(
2337
2296
/*===========================*/
2338
 
        os_file_t       file,   /*!< in: handle to a file */
2339
 
        void*           buf,    /*!< in: buffer where to read */
2340
 
        ulint           offset, /*!< in: least significant 32 bits of file
 
2297
                                /* out: TRUE if request was
 
2298
                                successful, FALSE if fail */
 
2299
        os_file_t       file,   /* in: handle to a file */
 
2300
        void*           buf,    /* in: buffer where to read */
 
2301
        ulint           offset, /* in: least significant 32 bits of file
2341
2302
                                offset where to read */
2342
 
        ulint           offset_high, /*!< in: most significant 32 bits of
 
2303
        ulint           offset_high, /* in: most significant 32 bits of
2343
2304
                                offset */
2344
 
        ulint           n)      /*!< in: number of bytes to read */
 
2305
        ulint           n)      /* in: number of bytes to read */
2345
2306
{
2346
2307
#ifdef __WIN__
2347
2308
        BOOL            ret;
2424
2385
        return(FALSE);
2425
2386
}
2426
2387
 
2427
 
/*******************************************************************//**
 
2388
/***********************************************************************
2428
2389
Rewind file to its start, read at most size - 1 bytes from it to str, and
2429
2390
NUL-terminate str. All errors are silently ignored. This function is
2430
2391
mostly meant to be used with temporary files. */
2432
2393
void
2433
2394
os_file_read_string(
2434
2395
/*================*/
2435
 
        FILE*   file,   /*!< in: file to read from */
2436
 
        char*   str,    /*!< in: buffer where to read */
2437
 
        ulint   size)   /*!< in: size of buffer */
 
2396
        FILE*   file,   /* in: file to read from */
 
2397
        char*   str,    /* in: buffer where to read */
 
2398
        ulint   size)   /* in: size of buffer */
2438
2399
{
2439
2400
        size_t  flen;
2440
2401
 
2447
2408
        str[flen] = '\0';
2448
2409
}
2449
2410
 
2450
 
/*******************************************************************//**
2451
 
Requests a synchronous write operation.
2452
 
@return TRUE if request was successful, FALSE if fail */
 
2411
/***********************************************************************
 
2412
Requests a synchronous write operation. */
2453
2413
UNIV_INTERN
2454
2414
ibool
2455
2415
os_file_write(
2456
2416
/*==========*/
2457
 
        const char*     name,   /*!< in: name of the file or path as a
 
2417
                                /* out: TRUE if request was
 
2418
                                successful, FALSE if fail */
 
2419
        const char*     name,   /* in: name of the file or path as a
2458
2420
                                null-terminated string */
2459
 
        os_file_t       file,   /*!< in: handle to a file */
2460
 
        const void*     buf,    /*!< in: buffer from which to write */
2461
 
        ulint           offset, /*!< in: least significant 32 bits of file
 
2421
        os_file_t       file,   /* in: handle to a file */
 
2422
        const void*     buf,    /* in: buffer from which to write */
 
2423
        ulint           offset, /* in: least significant 32 bits of file
2462
2424
                                offset where to write */
2463
 
        ulint           offset_high, /*!< in: most significant 32 bits of
 
2425
        ulint           offset_high, /* in: most significant 32 bits of
2464
2426
                                offset */
2465
 
        ulint           n)      /*!< in: number of bytes to write */
 
2427
        ulint           n)      /* in: number of bytes to write */
2466
2428
{
2467
2429
#ifdef __WIN__
2468
2430
        BOOL            ret;
2514
2476
                        "InnoDB: Some operating system error numbers"
2515
2477
                        " are described at\n"
2516
2478
                        "InnoDB: "
2517
 
                        REFMAN "operating-system-error-codes.html\n",
 
2479
                        "http://dev.mysql.com/doc/refman/5.1/en/"
 
2480
                        "operating-system-error-codes.html\n",
2518
2481
                        name, (ulong) offset_high, (ulong) offset,
2519
2482
                        (ulong) GetLastError());
2520
2483
 
2585
2548
                        "InnoDB: Some operating system error numbers"
2586
2549
                        " are described at\n"
2587
2550
                        "InnoDB: "
2588
 
                        REFMAN "operating-system-error-codes.html\n");
 
2551
                        "http://dev.mysql.com/doc/refman/5.1/en/"
 
2552
                        "operating-system-error-codes.html\n");
2589
2553
 
2590
2554
                os_has_said_disk_full = TRUE;
2591
2555
        }
2627
2591
                        "InnoDB: Some operating system error numbers"
2628
2592
                        " are described at\n"
2629
2593
                        "InnoDB: "
2630
 
                        REFMAN "operating-system-error-codes.html\n");
 
2594
                        "http://dev.mysql.com/doc/refman/5.1/en/"
 
2595
                        "operating-system-error-codes.html\n");
2631
2596
 
2632
2597
                os_has_said_disk_full = TRUE;
2633
2598
        }
2636
2601
#endif
2637
2602
}
2638
2603
 
2639
 
/*******************************************************************//**
2640
 
Check the existence and type of the given file.
2641
 
@return TRUE if call succeeded */
 
2604
/***********************************************************************
 
2605
Check the existence and type of the given file. */
2642
2606
UNIV_INTERN
2643
2607
ibool
2644
2608
os_file_status(
2645
2609
/*===========*/
2646
 
        const char*     path,   /*!< in:        pathname of the file */
2647
 
        ibool*          exists, /*!< out: TRUE if file exists */
2648
 
        os_file_type_t* type)   /*!< out: type of the file (if it exists) */
 
2610
                                /* out: TRUE if call succeeded */
 
2611
        const char*     path,   /* in:  pathname of the file */
 
2612
        ibool*          exists, /* out: TRUE if file exists */
 
2613
        os_file_type_t* type)   /* out: type of the file (if it exists) */
2649
2614
{
2650
2615
#ifdef __WIN__
2651
2616
        int             ret;
2708
2673
#endif
2709
2674
}
2710
2675
 
2711
 
/*******************************************************************//**
2712
 
This function returns information about the specified file
2713
 
@return TRUE if stat information found */
 
2676
/***********************************************************************
 
2677
This function returns information about the specified file */
2714
2678
UNIV_INTERN
2715
2679
ibool
2716
2680
os_file_get_status(
2717
2681
/*===============*/
2718
 
        const char*     path,           /*!< in:        pathname of the file */
2719
 
        os_file_stat_t* stat_info)      /*!< information of a file in a
 
2682
                                        /* out: TRUE if stat
 
2683
                                        information found */
 
2684
        const char*     path,           /* in:  pathname of the file */
 
2685
        os_file_stat_t* stat_info)      /* information of a file in a
2720
2686
                                        directory */
2721
2687
{
2722
2688
#ifdef __WIN__
2793
2759
#  define OS_FILE_PATH_SEPARATOR        '/'
2794
2760
#endif
2795
2761
 
2796
 
/****************************************************************//**
 
2762
/********************************************************************
2797
2763
The function os_file_dirname returns a directory component of a
2798
2764
null-terminated pathname string.  In the usual case, dirname returns
2799
2765
the string up to, but not including, the final '/', and basename
2819
2785
       "/"            "/"            "/"
2820
2786
       "."            "."            "."
2821
2787
       ".."           "."            ".."
2822
 
 
2823
 
@return own: directory component of the pathname */
 
2788
*/
2824
2789
UNIV_INTERN
2825
2790
char*
2826
2791
os_file_dirname(
2827
2792
/*============*/
2828
 
        const char*     path)   /*!< in: pathname */
 
2793
                                /* out, own: directory component of the
 
2794
                                pathname */
 
2795
        const char*     path)   /* in: pathname */
2829
2796
{
2830
2797
        /* Find the offset of the last slash */
2831
2798
        const char* last_slash = strrchr(path, OS_FILE_PATH_SEPARATOR);
2848
2815
        return(mem_strdupl(path, last_slash - path));
2849
2816
}
2850
2817
 
2851
 
/****************************************************************//**
2852
 
Creates all missing subdirectories along the given path.
2853
 
@return TRUE if call succeeded FALSE otherwise */
 
2818
/********************************************************************
 
2819
Creates all missing subdirectories along the given path. */
2854
2820
UNIV_INTERN
2855
2821
ibool
2856
2822
os_file_create_subdirs_if_needed(
2857
2823
/*=============================*/
2858
 
        const char*     path)   /*!< in: path name */
 
2824
                                /* out: TRUE if call succeeded
 
2825
                                   FALSE otherwise */
 
2826
        const char*     path)   /* in: path name */
2859
2827
{
2860
2828
        char*           subdir;
2861
2829
        ibool           success, subdir_exists;
2888
2856
        return(success);
2889
2857
}
2890
2858
 
2891
 
#ifndef UNIV_HOTBACKUP
2892
 
/****************************************************************//**
2893
 
Returns a pointer to the nth slot in the aio array.
2894
 
@return pointer to slot */
 
2859
/********************************************************************
 
2860
Returns a pointer to the nth slot in the aio array. */
2895
2861
static
2896
2862
os_aio_slot_t*
2897
2863
os_aio_array_get_nth_slot(
2898
2864
/*======================*/
2899
 
        os_aio_array_t*         array,  /*!< in: aio array */
2900
 
        ulint                   index)  /*!< in: index of the slot */
 
2865
                                        /* out: pointer to slot */
 
2866
        os_aio_array_t*         array,  /* in: aio array */
 
2867
        ulint                   index)  /* in: index of the slot */
2901
2868
{
2902
2869
        ut_a(index < array->n_slots);
2903
2870
 
2904
2871
        return((array->slots) + index);
2905
2872
}
2906
2873
 
2907
 
/************************************************************************//**
2908
 
Creates an aio wait array.
2909
 
@return own: aio array */
 
2874
/****************************************************************************
 
2875
Creates an aio wait array. */
2910
2876
static
2911
2877
os_aio_array_t*
2912
2878
os_aio_array_create(
2913
2879
/*================*/
2914
 
        ulint   n,              /*!< in: maximum number of pending aio operations
 
2880
                                /* out, own: aio array */
 
2881
        ulint   n,              /* in: maximum number of pending aio operations
2915
2882
                                allowed; n must be divisible by n_segments */
2916
 
        ulint   n_segments)     /*!< in: number of segments in the aio array */
 
2883
        ulint   n_segments)     /* in: number of segments in the aio array */
2917
2884
{
2918
2885
        os_aio_array_t* array;
2919
2886
        ulint           i;
2958
2925
        return(array);
2959
2926
}
2960
2927
 
2961
 
/***********************************************************************
2962
 
Initializes the asynchronous io system. Creates one array each for ibuf
2963
 
and log i/o. Also creates one array each for read and write where each
2964
 
array is divided logically into n_read_segs and n_write_segs
2965
 
respectively. The caller must create an i/o handler thread for each
2966
 
segment in these arrays. This function also creates the sync array.
2967
 
No i/o handler thread needs to be created for that */
 
2928
/****************************************************************************
 
2929
Initializes the asynchronous io system. Calls also os_io_init_simple.
 
2930
Creates a separate aio array for
 
2931
non-ibuf read and write, a third aio array for the ibuf i/o, with just one
 
2932
segment, two aio arrays for log reads and writes with one segment, and a
 
2933
synchronous aio array of the specified size. The combined number of segments
 
2934
in the three first aio arrays is the parameter n_segments given to the
 
2935
function. The caller must create an i/o handler thread for each segment in
 
2936
the four first arrays, but not for the sync aio array. */
2968
2937
UNIV_INTERN
2969
2938
void
2970
2939
os_aio_init(
2971
2940
/*========*/
2972
 
        ulint   n_per_seg,      /*<! in: maximum number of pending aio
2973
 
                                operations allowed per segment */
2974
 
        ulint   n_read_segs,    /*<! in: number of reader threads */
2975
 
        ulint   n_write_segs,   /*<! in: number of writer threads */
2976
 
        ulint   n_slots_sync)   /*<! in: number of slots in the sync aio
2977
 
                                array */
 
2941
        ulint   n,              /* in: maximum number of pending aio operations
 
2942
                                allowed; n must be divisible by n_segments */
 
2943
        ulint   n_segments,     /* in: combined number of segments in the four
 
2944
                                first aio arrays; must be >= 4 */
 
2945
        ulint   n_slots_sync)   /* in: number of slots in the sync aio array */
2978
2946
{
 
2947
        ulint   n_read_segs;
 
2948
        ulint   n_write_segs;
 
2949
        ulint   n_per_seg;
2979
2950
        ulint   i;
2980
 
        ulint   n_segments = 2 + n_read_segs + n_write_segs;
2981
2951
 
 
2952
        ut_ad(n % n_segments == 0);
2982
2953
        ut_ad(n_segments >= 4);
2983
2954
 
2984
2955
        os_io_init_simple();
2987
2958
                srv_set_io_thread_op_info(i, "not started yet");
2988
2959
        }
2989
2960
 
 
2961
        n_per_seg = n / n_segments;
 
2962
        n_write_segs = (n_segments - 2) / 2;
 
2963
        n_read_segs = n_segments - 2 - n_write_segs;
2990
2964
 
2991
2965
        /* fprintf(stderr, "Array n per seg %lu\n", n_per_seg); */
2992
2966
 
3029
3003
}
3030
3004
 
3031
3005
#ifdef WIN_ASYNC_IO
3032
 
/************************************************************************//**
 
3006
/****************************************************************************
3033
3007
Wakes up all async i/o threads in the array in Windows async i/o at
3034
3008
shutdown. */
3035
3009
static
3036
3010
void
3037
3011
os_aio_array_wake_win_aio_at_shutdown(
3038
3012
/*==================================*/
3039
 
        os_aio_array_t* array)  /*!< in: aio array */
 
3013
        os_aio_array_t* array)  /* in: aio array */
3040
3014
{
3041
3015
        ulint   i;
3042
3016
 
3047
3021
}
3048
3022
#endif
3049
3023
 
3050
 
/************************************************************************//**
 
3024
/****************************************************************************
3051
3025
Wakes up all async i/o threads so that they know to exit themselves in
3052
3026
shutdown. */
3053
3027
UNIV_INTERN
3072
3046
        }
3073
3047
}
3074
3048
 
3075
 
/************************************************************************//**
 
3049
/****************************************************************************
3076
3050
Waits until there are no pending writes in os_aio_write_array. There can
3077
3051
be other, synchronous, pending writes. */
3078
3052
UNIV_INTERN
3083
3057
        os_event_wait(os_aio_write_array->is_empty);
3084
3058
}
3085
3059
 
3086
 
/**********************************************************************//**
3087
 
Calculates segment number for a slot.
3088
 
@return segment number (which is the number used by, for example,
3089
 
i/o-handler threads) */
 
3060
/**************************************************************************
 
3061
Calculates segment number for a slot. */
3090
3062
static
3091
3063
ulint
3092
3064
os_aio_get_segment_no_from_slot(
3093
3065
/*============================*/
3094
 
        os_aio_array_t* array,  /*!< in: aio wait array */
3095
 
        os_aio_slot_t*  slot)   /*!< in: slot in this array */
 
3066
                                /* out: segment number (which is the number
 
3067
                                used by, for example, i/o-handler threads) */
 
3068
        os_aio_array_t* array,  /* in: aio wait array */
 
3069
        os_aio_slot_t*  slot)   /* in: slot in this array */
3096
3070
{
3097
3071
        ulint   segment;
3098
3072
        ulint   seg_len;
3120
3094
        return(segment);
3121
3095
}
3122
3096
 
3123
 
/**********************************************************************//**
3124
 
Calculates local segment number and aio array from global segment number.
3125
 
@return local segment number within the aio array */
 
3097
/**************************************************************************
 
3098
Calculates local segment number and aio array from global segment number. */
3126
3099
static
3127
3100
ulint
3128
3101
os_aio_get_array_and_local_segment(
3129
3102
/*===============================*/
3130
 
        os_aio_array_t** array,         /*!< out: aio wait array */
3131
 
        ulint            global_segment)/*!< in: global segment number */
 
3103
                                        /* out: local segment number within
 
3104
                                        the aio array */
 
3105
        os_aio_array_t** array,         /* out: aio wait array */
 
3106
        ulint            global_segment)/* in: global segment number */
3132
3107
{
3133
3108
        ulint   segment;
3134
3109
 
3155
3130
        return(segment);
3156
3131
}
3157
3132
 
3158
 
/*******************************************************************//**
 
3133
/***********************************************************************
3159
3134
Requests for a slot in the aio array. If no slot is available, waits until
3160
 
not_full-event becomes signaled.
3161
 
@return pointer to slot */
 
3135
not_full-event becomes signaled. */
3162
3136
static
3163
3137
os_aio_slot_t*
3164
3138
os_aio_array_reserve_slot(
3165
3139
/*======================*/
3166
 
        ulint           type,   /*!< in: OS_FILE_READ or OS_FILE_WRITE */
3167
 
        os_aio_array_t* array,  /*!< in: aio array */
3168
 
        fil_node_t*     message1,/*!< in: message to be passed along with
3169
 
                                the aio operation */
3170
 
        void*           message2,/*!< in: message to be passed along with
3171
 
                                the aio operation */
3172
 
        os_file_t       file,   /*!< in: file handle */
3173
 
        const char*     name,   /*!< in: name of the file or path as a
 
3140
                                /* out: pointer to slot */
 
3141
        ulint           type,   /* in: OS_FILE_READ or OS_FILE_WRITE */
 
3142
        os_aio_array_t* array,  /* in: aio array */
 
3143
        fil_node_t*     message1,/* in: message to be passed along with
 
3144
                                the aio operation */
 
3145
        void*           message2,/* in: message to be passed along with
 
3146
                                the aio operation */
 
3147
        os_file_t       file,   /* in: file handle */
 
3148
        const char*     name,   /* in: name of the file or path as a
3174
3149
                                null-terminated string */
3175
 
        void*           buf,    /*!< in: buffer where to read or from which
 
3150
        void*           buf,    /* in: buffer where to read or from which
3176
3151
                                to write */
3177
 
        ulint           offset, /*!< in: least significant 32 bits of file
3178
 
                                offset */
3179
 
        ulint           offset_high, /*!< in: most significant 32 bits of
3180
 
                                offset */
3181
 
        ulint           len)    /*!< in: length of the block to read or write */
 
3152
        ulint           offset, /* in: least significant 32 bits of file
 
3153
                                offset */
 
3154
        ulint           offset_high, /* in: most significant 32 bits of
 
3155
                                offset */
 
3156
        ulint           len)    /* in: length of the block to read or write */
3182
3157
{
3183
3158
        os_aio_slot_t*  slot;
3184
3159
#ifdef WIN_ASYNC_IO
3185
3160
        OVERLAPPED*     control;
3186
3161
#endif
3187
3162
        ulint           i;
3188
 
        ulint           slots_per_seg;
3189
 
        ulint           local_seg;
3190
 
 
3191
 
        /* No need of a mutex. Only reading constant fields */
3192
 
        slots_per_seg = array->n_slots / array->n_segments;
3193
 
 
3194
 
        /* We attempt to keep adjacent blocks in the same local
3195
 
        segment. This can help in merging IO requests when we are
3196
 
        doing simulated AIO */
3197
 
        local_seg = (offset >> (UNIV_PAGE_SIZE_SHIFT + 6))
3198
 
                    % array->n_segments;
3199
 
 
3200
3163
loop:
3201
3164
        os_mutex_enter(array->mutex);
3202
3165
 
3215
3178
                goto loop;
3216
3179
        }
3217
3180
 
3218
 
        /* First try to find a slot in the preferred local segment */
3219
 
        for (i = local_seg * slots_per_seg; i < array->n_slots; i++) {
3220
 
                slot = os_aio_array_get_nth_slot(array, i);
3221
 
 
3222
 
                if (slot->reserved == FALSE) {
3223
 
                        goto found;
3224
 
                }
3225
 
        }
3226
 
 
3227
 
        /* Fall back to a full scan. We are guaranteed to find a slot */
3228
3181
        for (i = 0;; i++) {
3229
3182
                slot = os_aio_array_get_nth_slot(array, i);
3230
3183
 
3231
3184
                if (slot->reserved == FALSE) {
3232
 
                        goto found;
 
3185
                        break;
3233
3186
                }
3234
3187
        }
3235
3188
 
3236
 
found:
3237
 
        ut_a(slot->reserved == FALSE);
3238
3189
        array->n_reserved++;
3239
3190
 
3240
3191
        if (array->n_reserved == 1) {
3270
3221
        return(slot);
3271
3222
}
3272
3223
 
3273
 
/*******************************************************************//**
 
3224
/***********************************************************************
3274
3225
Frees a slot in the aio array. */
3275
3226
static
3276
3227
void
3277
3228
os_aio_array_free_slot(
3278
3229
/*===================*/
3279
 
        os_aio_array_t* array,  /*!< in: aio array */
3280
 
        os_aio_slot_t*  slot)   /*!< in: pointer to slot */
 
3230
        os_aio_array_t* array,  /* in: aio array */
 
3231
        os_aio_slot_t*  slot)   /* in: pointer to slot */
3281
3232
{
3282
3233
        ut_ad(array);
3283
3234
        ut_ad(slot);
3304
3255
        os_mutex_exit(array->mutex);
3305
3256
}
3306
3257
 
3307
 
/**********************************************************************//**
 
3258
/**************************************************************************
3308
3259
Wakes up a simulated aio i/o-handler thread if it has something to do. */
3309
3260
static
3310
3261
void
3311
3262
os_aio_simulated_wake_handler_thread(
3312
3263
/*=================================*/
3313
 
        ulint   global_segment) /*!< in: the number of the segment in the aio
 
3264
        ulint   global_segment) /* in: the number of the segment in the aio
3314
3265
                                arrays */
3315
3266
{
3316
3267
        os_aio_array_t* array;
3346
3297
        }
3347
3298
}
3348
3299
 
3349
 
/**********************************************************************//**
 
3300
/**************************************************************************
3350
3301
Wakes up simulated aio i/o-handler threads if they have something to do. */
3351
3302
UNIV_INTERN
3352
3303
void
3368
3319
        }
3369
3320
}
3370
3321
 
3371
 
/**********************************************************************//**
 
3322
/**************************************************************************
3372
3323
This function can be called if one wants to post a batch of reads and
3373
3324
prefers an i/o-handler thread to handle them all at once later. You must
3374
3325
call os_aio_simulated_wake_handler_threads later to ensure the threads
3393
3344
        }
3394
3345
}
3395
3346
 
3396
 
/*******************************************************************//**
3397
 
Requests an asynchronous i/o operation.
3398
 
@return TRUE if request was queued successfully, FALSE if fail */
 
3347
/***********************************************************************
 
3348
Requests an asynchronous i/o operation. */
3399
3349
UNIV_INTERN
3400
3350
ibool
3401
3351
os_aio(
3402
3352
/*===*/
3403
 
        ulint           type,   /*!< in: OS_FILE_READ or OS_FILE_WRITE */
3404
 
        ulint           mode,   /*!< in: OS_AIO_NORMAL, ..., possibly ORed
 
3353
                                /* out: TRUE if request was queued
 
3354
                                successfully, FALSE if fail */
 
3355
        ulint           type,   /* in: OS_FILE_READ or OS_FILE_WRITE */
 
3356
        ulint           mode,   /* in: OS_AIO_NORMAL, ..., possibly ORed
3405
3357
                                to OS_AIO_SIMULATED_WAKE_LATER: the
3406
3358
                                last flag advises this function not to wake
3407
3359
                                i/o-handler threads, but the caller will
3414
3366
                                because i/os are not actually handled until
3415
3367
                                all have been posted: use with great
3416
3368
                                caution! */
3417
 
        const char*     name,   /*!< in: name of the file or path as a
 
3369
        const char*     name,   /* in: name of the file or path as a
3418
3370
                                null-terminated string */
3419
 
        os_file_t       file,   /*!< in: handle to a file */
3420
 
        void*           buf,    /*!< in: buffer where to read or from which
 
3371
        os_file_t       file,   /* in: handle to a file */
 
3372
        void*           buf,    /* in: buffer where to read or from which
3421
3373
                                to write */
3422
 
        ulint           offset, /*!< in: least significant 32 bits of file
 
3374
        ulint           offset, /* in: least significant 32 bits of file
3423
3375
                                offset where to read or write */
3424
 
        ulint           offset_high, /*!< in: most significant 32 bits of
 
3376
        ulint           offset_high, /* in: most significant 32 bits of
3425
3377
                                offset */
3426
 
        ulint           n,      /*!< in: number of bytes to read or write */
3427
 
        fil_node_t*     message1,/*!< in: message for the aio handler
3428
 
                                (can be used to identify a completed
3429
 
                                aio operation); ignored if mode is
3430
 
                                OS_AIO_SYNC */
3431
 
        void*           message2)/*!< in: message for the aio handler
3432
 
                                (can be used to identify a completed
3433
 
                                aio operation); ignored if mode is
3434
 
                                OS_AIO_SYNC */
 
3378
        ulint           n,      /* in: number of bytes to read or write */
 
3379
        fil_node_t*     message1,/* in: messages for the aio handler (these
 
3380
                                can be used to identify a completed aio
 
3381
                                operation); if mode is OS_AIO_SYNC, these
 
3382
                                are ignored */
 
3383
        void*           message2)
3435
3384
{
3436
3385
        os_aio_array_t* array;
3437
3386
        os_aio_slot_t*  slot;
3587
3536
}
3588
3537
 
3589
3538
#ifdef WIN_ASYNC_IO
3590
 
/**********************************************************************//**
 
3539
/**************************************************************************
3591
3540
This function is only used in Windows asynchronous i/o.
3592
3541
Waits for an aio operation to complete. This function is used to wait the
3593
3542
for completed requests. The aio array of pending requests is divided
3594
3543
into segments. The thread specifies which segment or slot it wants to wait
3595
3544
for. NOTE: this function will also take care of freeing the aio slot,
3596
 
therefore no other thread is allowed to do the freeing!
3597
 
@return TRUE if the aio operation succeeded */
 
3545
therefore no other thread is allowed to do the freeing! */
3598
3546
UNIV_INTERN
3599
3547
ibool
3600
3548
os_aio_windows_handle(
3601
3549
/*==================*/
3602
 
        ulint   segment,        /*!< in: the number of the segment in the aio
 
3550
                                /* out: TRUE if the aio operation succeeded */
 
3551
        ulint   segment,        /* in: the number of the segment in the aio
3603
3552
                                arrays to wait for; segment 0 is the ibuf
3604
3553
                                i/o thread, segment 1 the log i/o thread,
3605
3554
                                then follow the non-ibuf read threads, and as
3607
3556
                                this is ULINT_UNDEFINED, then it means that
3608
3557
                                sync aio is used, and this parameter is
3609
3558
                                ignored */
3610
 
        ulint   pos,            /*!< this parameter is used only in sync aio:
 
3559
        ulint   pos,            /* this parameter is used only in sync aio:
3611
3560
                                wait for the aio slot at this position */
3612
 
        fil_node_t**message1,   /*!< out: the messages passed with the aio
 
3561
        fil_node_t**message1,   /* out: the messages passed with the aio
3613
3562
                                request; note that also in the case where
3614
3563
                                the aio operation failed, these output
3615
3564
                                parameters are valid and can be used to
3616
3565
                                restart the operation, for example */
3617
3566
        void**  message2,
3618
 
        ulint*  type)           /*!< out: OS_FILE_WRITE or ..._READ */
 
3567
        ulint*  type)           /* out: OS_FILE_WRITE or ..._READ */
3619
3568
{
3620
3569
        ulint           orig_seg        = segment;
3621
3570
        os_aio_array_t* array;
3692
3641
}
3693
3642
#endif
3694
3643
 
3695
 
/**********************************************************************//**
 
3644
/**************************************************************************
3696
3645
Does simulated aio. This function should be called by an i/o-handler
3697
 
thread.
3698
 
@return TRUE if the aio operation succeeded */
 
3646
thread. */
3699
3647
UNIV_INTERN
3700
3648
ibool
3701
3649
os_aio_simulated_handle(
3702
3650
/*====================*/
3703
 
        ulint   global_segment, /*!< in: the number of the segment in the aio
 
3651
                                /* out: TRUE if the aio operation succeeded */
 
3652
        ulint   global_segment, /* in: the number of the segment in the aio
3704
3653
                                arrays to wait for; segment 0 is the ibuf
3705
3654
                                i/o thread, segment 1 the log i/o thread,
3706
3655
                                then follow the non-ibuf read threads, and as
3707
3656
                                the last are the non-ibuf write threads */
3708
 
        fil_node_t**message1,   /*!< out: the messages passed with the aio
 
3657
        fil_node_t**message1,   /* out: the messages passed with the aio
3709
3658
                                request; note that also in the case where
3710
3659
                                the aio operation failed, these output
3711
3660
                                parameters are valid and can be used to
3712
3661
                                restart the operation, for example */
3713
3662
        void**  message2,
3714
 
        ulint*  type)           /*!< out: OS_FILE_WRITE or ..._READ */
 
3663
        ulint*  type)           /* out: OS_FILE_WRITE or ..._READ */
3715
3664
{
3716
3665
        os_aio_array_t* array;
3717
3666
        ulint           segment;
4014
3963
        goto restart;
4015
3964
}
4016
3965
 
4017
 
/**********************************************************************//**
4018
 
Validates the consistency of an aio array.
4019
 
@return TRUE if ok */
 
3966
/**************************************************************************
 
3967
Validates the consistency of an aio array. */
4020
3968
static
4021
3969
ibool
4022
3970
os_aio_array_validate(
4023
3971
/*==================*/
4024
 
        os_aio_array_t* array)  /*!< in: aio wait array */
 
3972
                                /* out: TRUE if ok */
 
3973
        os_aio_array_t* array)  /* in: aio wait array */
4025
3974
{
4026
3975
        os_aio_slot_t*  slot;
4027
3976
        ulint           n_reserved      = 0;
4050
3999
        return(TRUE);
4051
4000
}
4052
4001
 
4053
 
/**********************************************************************//**
4054
 
Validates the consistency the aio system.
4055
 
@return TRUE if ok */
 
4002
/**************************************************************************
 
4003
Validates the consistency the aio system. */
4056
4004
UNIV_INTERN
4057
4005
ibool
4058
4006
os_aio_validate(void)
4059
4007
/*=================*/
 
4008
                                /* out: TRUE if ok */
4060
4009
{
4061
4010
        os_aio_array_validate(os_aio_read_array);
4062
4011
        os_aio_array_validate(os_aio_write_array);
4067
4016
        return(TRUE);
4068
4017
}
4069
4018
 
4070
 
/**********************************************************************//**
 
4019
/**************************************************************************
4071
4020
Prints info of the aio arrays. */
4072
4021
UNIV_INTERN
4073
4022
void
4074
4023
os_aio_print(
4075
4024
/*=========*/
4076
 
        FILE*   file)   /*!< in: file where to print */
 
4025
        FILE*   file)   /* in: file where to print */
4077
4026
{
4078
4027
        os_aio_array_t* array;
4079
4028
        os_aio_slot_t*  slot;
4204
4153
        os_last_printout = current_time;
4205
4154
}
4206
4155
 
4207
 
/**********************************************************************//**
 
4156
/**************************************************************************
4208
4157
Refreshes the statistics used to print per-second averages. */
4209
4158
UNIV_INTERN
4210
4159
void
4220
4169
}
4221
4170
 
4222
4171
#ifdef UNIV_DEBUG
4223
 
/**********************************************************************//**
 
4172
/**************************************************************************
4224
4173
Checks that all slots in the system have been freed, that is, there are
4225
 
no pending io operations.
4226
 
@return TRUE if all free */
 
4174
no pending io operations. */
4227
4175
UNIV_INTERN
4228
4176
ibool
4229
4177
os_aio_all_slots_free(void)
4230
4178
/*=======================*/
 
4179
                                /* out: TRUE if all free */
4231
4180
{
4232
4181
        os_aio_array_t* array;
4233
4182
        ulint           n_res   = 0;
4280
4229
        return(FALSE);
4281
4230
}
4282
4231
#endif /* UNIV_DEBUG */
4283
 
 
4284
 
#endif /* !UNIV_HOTBACKUP */