~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/os0file.ic

  • Committer: Monty Taylor
  • Date: 2010-11-26 22:50:54 UTC
  • mfrom: (1953.1.6 build)
  • Revision ID: mordred@inaugust.com-20101126225054-sg90svw8579t5p3i
Stewart - InnoDB 1.1.1
Monty - Fixed some autoconf tests which were returning false positives.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
 
 
3
Copyright (c) 2010, Oracle and/or its affiliates. All Rights Reserved.
 
4
 
 
5
This program is free software; you can redistribute it and/or modify it under
 
6
the terms of the GNU General Public License as published by the Free Software
 
7
Foundation; version 2 of the License.
 
8
 
 
9
This program is distributed in the hope that it will be useful, but WITHOUT
 
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 
12
 
 
13
You should have received a copy of the GNU General Public License along with
 
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 
15
Place, Suite 330, Boston, MA 02111-1307 USA
 
16
 
 
17
*****************************************************************************/
 
18
 
 
19
/**************************************************//**
 
20
@file include/os0file.ic
 
21
The interface to the operating system file io
 
22
 
 
23
Created 2/20/2010 Jimmy Yang
 
24
*******************************************************/
 
25
 
 
26
#include "univ.i"
 
27
 
 
28
#ifdef UNIV_PFS_IO
 
29
/****************************************************************//**
 
30
NOTE! Please use the corresponding macro os_file_create_simple(),
 
31
not directly this function!
 
32
A performance schema instrumented wrapper function for
 
33
os_file_create_simple() which opens or creates a file.
 
34
@return own: handle to the file, not defined if error, error number
 
35
can be retrieved with os_file_get_last_error */
 
36
UNIV_INLINE
 
37
os_file_t
 
38
pfs_os_file_create_simple_func(
 
39
/*===========================*/
 
40
        mysql_pfs_key_t key,    /*!< in: Performance Schema Key */
 
41
        const char*     name,   /*!< in: name of the file or path as a
 
42
                                null-terminated string */
 
43
        ulint           create_mode,/*!< in: OS_FILE_OPEN if an existing file is
 
44
                                opened (if does not exist, error), or
 
45
                                OS_FILE_CREATE if a new file is created
 
46
                                (if exists, error), or
 
47
                                OS_FILE_CREATE_PATH if new file
 
48
                                (if exists, error) and subdirectories along
 
49
                                its path are created (if needed)*/
 
50
        ulint           access_type,/*!< in: OS_FILE_READ_ONLY or
 
51
                                OS_FILE_READ_WRITE */
 
52
        ibool*          success,/*!< out: TRUE if succeed, FALSE if error */
 
53
        const char*     src_file,/*!< in: file name where func invoked */
 
54
        ulint           src_line)/*!< in: line where the func invoked */
 
55
{
 
56
        os_file_t       file;
 
57
        struct PSI_file_locker* locker = NULL;
 
58
 
 
59
        /* register a file open or creation depending on "create_mode" */
 
60
        register_pfs_file_open_begin(locker, key,
 
61
                                     ((create_mode == OS_FILE_CREATE)
 
62
                                        ? PSI_FILE_CREATE
 
63
                                        : PSI_FILE_OPEN),
 
64
                                     name, src_file, src_line);
 
65
 
 
66
        file = os_file_create_simple_func(name, create_mode,
 
67
                                          access_type, success);
 
68
 
 
69
        /* Regsiter the returning "file" value with the system */
 
70
        register_pfs_file_open_end(locker, file);
 
71
 
 
72
        return(file);
 
73
}
 
74
 
 
75
/****************************************************************//**
 
76
NOTE! Please use the corresponding macro
 
77
os_file_create_simple_no_error_handling(), not directly this function!
 
78
A performance schema instrumented wrapper function for
 
79
os_file_create_simple_no_error_handling(). Add instrumentation to
 
80
monitor file creation/open.
 
81
@return own: handle to the file, not defined if error, error number
 
82
can be retrieved with os_file_get_last_error */
 
83
UNIV_INLINE
 
84
os_file_t
 
85
pfs_os_file_create_simple_no_error_handling_func(
 
86
/*=============================================*/
 
87
        mysql_pfs_key_t key,    /*!< in: Performance Schema Key */
 
88
        const char*     name,   /*!< in: name of the file or path as a
 
89
                                null-terminated string */
 
90
        ulint           create_mode,/*!< in: OS_FILE_OPEN if an existing file
 
91
                                is opened (if does not exist, error), or
 
92
                                OS_FILE_CREATE if a new file is created
 
93
                                (if exists, error) */
 
94
        ulint           access_type,/*!< in: OS_FILE_READ_ONLY,
 
95
                                OS_FILE_READ_WRITE, or
 
96
                                OS_FILE_READ_ALLOW_DELETE; the last option is
 
97
                                used by a backup program reading the file */
 
98
        ibool*          success,/*!< out: TRUE if succeed, FALSE if error */
 
99
        const char*     src_file,/*!< in: file name where func invoked */
 
100
        ulint           src_line)/*!< in: line where the func invoked */
 
101
{
 
102
        os_file_t       file;
 
103
        struct PSI_file_locker* locker = NULL;
 
104
 
 
105
        /* register a file open or creation depending on "create_mode" */
 
106
        register_pfs_file_open_begin(locker, key,
 
107
                                     ((create_mode == OS_FILE_CREATE)
 
108
                                        ? PSI_FILE_CREATE
 
109
                                        : PSI_FILE_OPEN),
 
110
                                     name, src_file, src_line);
 
111
 
 
112
        file = os_file_create_simple_no_error_handling_func(
 
113
                name, create_mode, access_type, success);
 
114
 
 
115
        register_pfs_file_open_end(locker, file);
 
116
 
 
117
        return(file);
 
118
}
 
119
 
 
120
/****************************************************************//**
 
121
NOTE! Please use the corresponding macro os_file_create(), not directly
 
122
this function!
 
123
A performance schema wrapper function for os_file_create().
 
124
Add instrumentation to monitor file creation/open.
 
125
@return own: handle to the file, not defined if error, error number
 
126
can be retrieved with os_file_get_last_error */
 
127
UNIV_INLINE
 
128
os_file_t
 
129
pfs_os_file_create_func(
 
130
/*====================*/
 
131
        mysql_pfs_key_t key,    /*!< in: Performance Schema Key */
 
132
        const char*     name,   /*!< in: name of the file or path as a
 
133
                                null-terminated string */
 
134
        ulint           create_mode,/*!< in: OS_FILE_OPEN if an existing file
 
135
                                is opened (if does not exist, error), or
 
136
                                OS_FILE_CREATE if a new file is created
 
137
                                (if exists, error),
 
138
                                OS_FILE_OVERWRITE if a new file is created
 
139
                                or an old overwritten;
 
140
                                OS_FILE_OPEN_RAW, if a raw device or disk
 
141
                                partition should be opened */
 
142
        ulint           purpose,/*!< in: OS_FILE_AIO, if asynchronous,
 
143
                                non-buffered i/o is desired,
 
144
                                OS_FILE_NORMAL, if any normal file;
 
145
                                NOTE that it also depends on type, os_aio_..
 
146
                                and srv_.. variables whether we really use
 
147
                                async i/o or unbuffered i/o: look in the
 
148
                                function source code for the exact rules */
 
149
        ulint           type,   /*!< in: OS_DATA_FILE or OS_LOG_FILE */
 
150
        ibool*          success,/*!< out: TRUE if succeed, FALSE if error */
 
151
        const char*     src_file,/*!< in: file name where func invoked */
 
152
        ulint           src_line)/*!< in: line where the func invoked */
 
153
{
 
154
        os_file_t       file;
 
155
        struct PSI_file_locker* locker = NULL;
 
156
 
 
157
        /* register a file open or creation depending on "create_mode" */
 
158
        register_pfs_file_open_begin(locker, key,
 
159
                                     ((create_mode == OS_FILE_CREATE)
 
160
                                        ? PSI_FILE_CREATE
 
161
                                        : PSI_FILE_OPEN),
 
162
                                     name, src_file, src_line);
 
163
 
 
164
        file = os_file_create_func(name, create_mode, purpose, type, success);
 
165
 
 
166
        register_pfs_file_open_end(locker, file);
 
167
 
 
168
        return(file);
 
169
}
 
170
 
 
171
/***********************************************************************//**
 
172
NOTE! Please use the corresponding macro os_file_close(), not directly
 
173
this function!
 
174
A performance schema instrumented wrapper function for os_file_close().
 
175
@return TRUE if success */
 
176
UNIV_INLINE
 
177
ibool
 
178
pfs_os_file_close_func(
 
179
/*===================*/
 
180
        os_file_t       file,   /*!< in, own: handle to a file */
 
181
        const char*     src_file,/*!< in: file name where func invoked */
 
182
        ulint           src_line)/*!< in: line where the func invoked */
 
183
{
 
184
        ibool   result;
 
185
        struct PSI_file_locker* locker = NULL;
 
186
 
 
187
        /* register the file close */
 
188
        register_pfs_file_io_begin(locker, file, 0, PSI_FILE_CLOSE,
 
189
                                   src_file, src_line);
 
190
 
 
191
        result = os_file_close_func(file);
 
192
 
 
193
        register_pfs_file_io_end(locker, 0);
 
194
 
 
195
        return(result);
 
196
}
 
197
 
 
198
/*******************************************************************//**
 
199
NOTE! Please use the corresponding macro os_aio(), not directly this
 
200
function!
 
201
Performance schema instrumented wrapper function of os_aio() which
 
202
requests an asynchronous i/o operation.
 
203
@return TRUE if request was queued successfully, FALSE if fail */
 
204
UNIV_INLINE
 
205
ibool
 
206
pfs_os_aio_func(
 
207
/*============*/
 
208
        ulint           type,   /*!< in: OS_FILE_READ or OS_FILE_WRITE */
 
209
        ulint           mode,   /*!< in: OS_AIO_NORMAL etc. I/O mode */
 
210
        const char*     name,   /*!< in: name of the file or path as a
 
211
                                null-terminated string */
 
212
        os_file_t       file,   /*!< in: handle to a file */
 
213
        void*           buf,    /*!< in: buffer where to read or from which
 
214
                                to write */
 
215
        ulint           offset, /*!< in: least significant 32 bits of file
 
216
                                offset where to read or write */
 
217
        ulint           offset_high,/*!< in: most significant 32 bits of
 
218
                                offset */
 
219
        ulint           n,      /*!< in: number of bytes to read or write */
 
220
        fil_node_t*     message1,/*!< in: message for the aio handler
 
221
                                (can be used to identify a completed
 
222
                                aio operation); ignored if mode is
 
223
                                OS_AIO_SYNC */
 
224
        void*           message2,/*!< in: message for the aio handler
 
225
                                (can be used to identify a completed
 
226
                                aio operation); ignored if mode is
 
227
                                OS_AIO_SYNC */
 
228
        const char*     src_file,/*!< in: file name where func invoked */
 
229
        ulint           src_line)/*!< in: line where the func invoked */
 
230
{
 
231
        ibool   result;
 
232
        struct PSI_file_locker* locker = NULL;
 
233
 
 
234
        /* Register the read or write I/O depending on "type" */
 
235
        register_pfs_file_io_begin(locker, file, n,
 
236
                                   (type == OS_FILE_WRITE)
 
237
                                        ? PSI_FILE_WRITE
 
238
                                        : PSI_FILE_READ,
 
239
                                   src_file, src_line);
 
240
 
 
241
        result = os_aio_func(type, mode, name, file, buf, offset, offset_high,
 
242
                             n, message1, message2);
 
243
 
 
244
        register_pfs_file_io_end(locker, n);
 
245
 
 
246
        return(result);
 
247
}
 
248
 
 
249
/*******************************************************************//**
 
250
NOTE! Please use the corresponding macro os_file_read(), not directly
 
251
this function!
 
252
This is the performance schema instrumented wrapper function for
 
253
os_file_read() which requests a synchronous read operation.
 
254
@return TRUE if request was successful, FALSE if fail */
 
255
UNIV_INLINE
 
256
ibool
 
257
pfs_os_file_read_func(
 
258
/*==================*/
 
259
        os_file_t       file,   /*!< in: handle to a file */
 
260
        void*           buf,    /*!< in: buffer where to read */
 
261
        ulint           offset, /*!< in: least significant 32 bits of file
 
262
                                offset where to read */
 
263
        ulint           offset_high,/*!< in: most significant 32 bits of
 
264
                                offset */
 
265
        ulint           n,      /*!< in: number of bytes to read */
 
266
        const char*     src_file,/*!< in: file name where func invoked */
 
267
        ulint           src_line)/*!< in: line where the func invoked */
 
268
{
 
269
        ibool   result;
 
270
        struct PSI_file_locker* locker = NULL;
 
271
 
 
272
        register_pfs_file_io_begin(locker, file, n, PSI_FILE_READ,
 
273
                                   src_file, src_line);
 
274
 
 
275
        result = os_file_read_func(file, buf, offset, offset_high, n);
 
276
 
 
277
        register_pfs_file_io_end(locker, n);
 
278
 
 
279
        return(result);
 
280
}
 
281
 
 
282
/*******************************************************************//**
 
283
NOTE! Please use the corresponding macro
 
284
os_file_read_no_error_handling(), not directly this function!
 
285
This is the performance schema instrumented wrapper function for
 
286
os_file_read_no_error_handling() which requests a synchronous
 
287
positioned read operation. This function does not do any error
 
288
handling. In case of error it returns FALSE.
 
289
@return TRUE if request was successful, FALSE if fail */
 
290
UNIV_INLINE
 
291
ibool
 
292
pfs_os_file_read_no_error_handling_func(
 
293
/*====================================*/
 
294
        os_file_t       file,   /*!< in: handle to a file */
 
295
        void*           buf,    /*!< in: buffer where to read */
 
296
        ulint           offset, /*!< in: least significant 32 bits of file
 
297
                                offset where to read */
 
298
        ulint           offset_high,/*!< in: most significant 32 bits of
 
299
                                offset */
 
300
        ulint           n,      /*!< in: number of bytes to read */
 
301
        const char*     src_file,/*!< in: file name where func invoked */
 
302
        ulint           src_line)/*!< in: line where the func invoked */
 
303
{
 
304
        ibool   result;
 
305
        struct PSI_file_locker* locker = NULL;
 
306
 
 
307
        register_pfs_file_io_begin(locker, file, n, PSI_FILE_READ,
 
308
                                   src_file, src_line);
 
309
 
 
310
        result = os_file_read_no_error_handling_func(file, buf, offset,
 
311
                                                     offset_high, n);
 
312
 
 
313
        register_pfs_file_io_end(locker, n);
 
314
 
 
315
        return(result);
 
316
}
 
317
 
 
318
/*******************************************************************//**
 
319
NOTE! Please use the corresponding macro os_file_write(), not directly
 
320
this function!
 
321
This is the performance schema instrumented wrapper function for
 
322
os_file_write() which requests a synchronous write operation.
 
323
@return TRUE if request was successful, FALSE if fail */
 
324
UNIV_INLINE
 
325
ibool
 
326
pfs_os_file_write_func(
 
327
/*===================*/
 
328
        const char*     name,   /*!< in: name of the file or path as a
 
329
                                null-terminated string */
 
330
        os_file_t       file,   /*!< in: handle to a file */
 
331
        const void*     buf,    /*!< in: buffer from which to write */
 
332
        ulint           offset, /*!< in: least significant 32 bits of file
 
333
                                offset where to write */
 
334
        ulint           offset_high,/*!< in: most significant 32 bits of
 
335
                                offset */
 
336
        ulint           n,      /*!< in: number of bytes to write */
 
337
        const char*     src_file,/*!< in: file name where func invoked */
 
338
        ulint           src_line)/*!< in: line where the func invoked */
 
339
{
 
340
        ibool   result;
 
341
        struct PSI_file_locker* locker = NULL;
 
342
 
 
343
        register_pfs_file_io_begin(locker, file, n, PSI_FILE_WRITE,
 
344
                                   src_file, src_line);
 
345
 
 
346
        result = os_file_write_func(name, file, buf, offset, offset_high, n);
 
347
 
 
348
        register_pfs_file_io_end(locker, n);
 
349
 
 
350
        return(result);
 
351
}
 
352
 
 
353
/***********************************************************************//**
 
354
NOTE! Please use the corresponding macro os_file_flush(), not directly
 
355
this function!
 
356
This is the performance schema instrumented wrapper function for
 
357
os_file_flush() which flushes the write buffers of a given file to the disk.
 
358
@return TRUE if success */
 
359
UNIV_INLINE
 
360
ibool
 
361
pfs_os_file_flush_func(
 
362
/*===================*/
 
363
        os_file_t       file,   /*!< in, own: handle to a file */
 
364
        const char*     src_file,/*!< in: file name where func invoked */
 
365
        ulint           src_line)/*!< in: line where the func invoked */
 
366
{
 
367
        ibool   result;
 
368
        struct PSI_file_locker* locker = NULL;
 
369
 
 
370
        register_pfs_file_io_begin(locker, file, 0, PSI_FILE_SYNC,
 
371
                                   src_file, src_line);
 
372
        result = os_file_flush_func(file);
 
373
 
 
374
        register_pfs_file_io_end(locker, 0);
 
375
 
 
376
        return(result);
 
377
}
 
378
 
 
379
/***********************************************************************//**
 
380
NOTE! Please use the corresponding macro os_file_rename(), not directly
 
381
this function!
 
382
This is the performance schema instrumented wrapper function for
 
383
os_file_rename()
 
384
@return TRUE if success */
 
385
UNIV_INLINE
 
386
ibool
 
387
pfs_os_file_rename_func(
 
388
/*====================*/
 
389
        mysql_pfs_key_t key,    /*!< in: Performance Schema Key */
 
390
        const char*     oldpath,/*!< in: old file path as a null-terminated
 
391
                                string */
 
392
        const char*     newpath,/*!< in: new file path */
 
393
        const char*     src_file,/*!< in: file name where func invoked */
 
394
        ulint           src_line)/*!< in: line where the func invoked */
 
395
{
 
396
        ibool   result;
 
397
        struct PSI_file_locker* locker = NULL;
 
398
 
 
399
        register_pfs_file_open_begin(locker, key, PSI_FILE_RENAME, newpath,
 
400
                                     src_file, src_line);
 
401
 
 
402
        result = os_file_rename_func(oldpath, newpath);
 
403
 
 
404
        register_pfs_file_open_end(locker, 0);
 
405
 
 
406
        return(result);
 
407
}
 
408
#endif /* UNIV_PFS_IO */