Merge lp:~sergei.glushchenko/percona-xtrabackup/2.2-xb-bug1375383 into lp:percona-xtrabackup/2.2
- 2.2-xb-bug1375383
- Merge into 2.2
Proposed by
Sergei Glushchenko
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Alexey Kopytov | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 5035 | ||||
Proposed branch: | lp:~sergei.glushchenko/percona-xtrabackup/2.2-xb-bug1375383 | ||||
Merge into: | lp:percona-xtrabackup/2.2 | ||||
Diff against target: |
429 lines (+166/-150) 1 file modified
storage/innobase/os/os0file.cc (+166/-150) |
||||
To merge this branch: | bzr merge lp:~sergei.glushchenko/percona-xtrabackup/2.2-xb-bug1375383 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alexey Kopytov (community) | Approve | ||
Review via email: mp+237383@code.launchpad.net |
Commit message
Description of the change
1. os_file_
2. Port fix for MySQL bug #54430 from 5.7 tree.
http://
To post a comment you must log in.
Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote : | # |
I updated related code parts to the latest available state.
http://
Revision history for this message
Alexey Kopytov (akopytov) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'storage/innobase/os/os0file.cc' | |||
2 | --- storage/innobase/os/os0file.cc 2014-09-15 08:52:36 +0000 | |||
3 | +++ storage/innobase/os/os0file.cc 2014-10-09 19:02:11 +0000 | |||
4 | @@ -66,6 +66,9 @@ | |||
5 | 66 | /** Log segment id */ | 66 | /** Log segment id */ |
6 | 67 | static const ulint IO_LOG_SEGMENT = 1; | 67 | static const ulint IO_LOG_SEGMENT = 1; |
7 | 68 | 68 | ||
8 | 69 | /** Number of retries for partial I/O's */ | ||
9 | 70 | static const ulint NUM_RETRIES_ON_PARTIAL_IO = 10; | ||
10 | 71 | |||
11 | 69 | /* This specifies the file permissions InnoDB uses when it creates files in | 72 | /* This specifies the file permissions InnoDB uses when it creates files in |
12 | 70 | Unix; the value of os_innodb_umask is initialized in ha_innodb.cc to | 73 | Unix; the value of os_innodb_umask is initialized in ha_innodb.cc to |
13 | 71 | my_umask */ | 74 | my_umask */ |
14 | @@ -652,7 +655,7 @@ | |||
15 | 652 | } | 655 | } |
16 | 653 | 656 | ||
17 | 654 | if (should_exit) { | 657 | if (should_exit) { |
19 | 655 | exit(1); | 658 | ut_error; |
20 | 656 | } | 659 | } |
21 | 657 | } | 660 | } |
22 | 658 | 661 | ||
23 | @@ -2336,11 +2339,75 @@ | |||
24 | 2336 | #endif | 2339 | #endif |
25 | 2337 | } | 2340 | } |
26 | 2338 | 2341 | ||
28 | 2339 | #ifndef __WIN__ | 2342 | #ifndef _WIN32 |
29 | 2343 | /*******************************************************************//** | ||
30 | 2344 | Does a syncronous read or write depending upon the type specified | ||
31 | 2345 | In case of partial reads/writes the function tries | ||
32 | 2346 | NUM_RETRIES_ON_PARTIAL_IO times to read/write the complete data. | ||
33 | 2347 | @return number of bytes read/written, -1 if error */ | ||
34 | 2348 | static __attribute__((warn_unused_result)) | ||
35 | 2349 | ssize_t | ||
36 | 2350 | os_file_io( | ||
37 | 2351 | /*==========*/ | ||
38 | 2352 | os_file_t file, /*!< in: handle to a file */ | ||
39 | 2353 | void* buf, /*!< in: buffer where to read/write */ | ||
40 | 2354 | ulint n, /*!< in: number of bytes to read/write */ | ||
41 | 2355 | off_t offset, /*!< in: file offset from where to read/write */ | ||
42 | 2356 | ulint type) /*!< in: type for read or write */ | ||
43 | 2357 | { | ||
44 | 2358 | ssize_t bytes_returned = 0; | ||
45 | 2359 | ssize_t n_bytes; | ||
46 | 2360 | |||
47 | 2361 | for (ulint i = 0; i < NUM_RETRIES_ON_PARTIAL_IO; ++i) { | ||
48 | 2362 | if (type == OS_FILE_READ ) { | ||
49 | 2363 | n_bytes = pread(file, buf, n, offset); | ||
50 | 2364 | } else { | ||
51 | 2365 | ut_ad(type == OS_FILE_WRITE); | ||
52 | 2366 | n_bytes = pwrite(file, buf, n, offset); | ||
53 | 2367 | } | ||
54 | 2368 | |||
55 | 2369 | if ((ulint) n_bytes == n) { | ||
56 | 2370 | bytes_returned += n_bytes; | ||
57 | 2371 | return(bytes_returned); | ||
58 | 2372 | } else if (n_bytes > 0 && (ulint) n_bytes < n) { | ||
59 | 2373 | /* For partial read/write scenario */ | ||
60 | 2374 | if (type == OS_FILE_READ) { | ||
61 | 2375 | ib_logf(IB_LOG_LEVEL_WARN, | ||
62 | 2376 | "%lu bytes should have" | ||
63 | 2377 | " been read. Only %lu bytes" | ||
64 | 2378 | " read. Retrying again to read" | ||
65 | 2379 | " the remaining bytes.", | ||
66 | 2380 | (ulong) n, (ulong) n_bytes); | ||
67 | 2381 | } else { | ||
68 | 2382 | ib_logf(IB_LOG_LEVEL_WARN, | ||
69 | 2383 | "%lu bytes should have" | ||
70 | 2384 | " been written. Only %lu bytes" | ||
71 | 2385 | " written. Retrying again to" | ||
72 | 2386 | " write the remaining bytes.", | ||
73 | 2387 | (ulong) n, (ulong) n_bytes); | ||
74 | 2388 | } | ||
75 | 2389 | |||
76 | 2390 | buf = (uchar*) buf + (ulint) n_bytes; | ||
77 | 2391 | n -= (ulint) n_bytes; | ||
78 | 2392 | offset += n_bytes; | ||
79 | 2393 | bytes_returned += (ulint) n_bytes; | ||
80 | 2394 | |||
81 | 2395 | } else { | ||
82 | 2396 | break; | ||
83 | 2397 | } | ||
84 | 2398 | } | ||
85 | 2399 | |||
86 | 2400 | ib_logf(IB_LOG_LEVEL_WARN, | ||
87 | 2401 | "Retry attempts for %s partial data failed.", | ||
88 | 2402 | type == OS_FILE_READ ? "reading" : "writing"); | ||
89 | 2403 | |||
90 | 2404 | return(bytes_returned); | ||
91 | 2405 | } | ||
92 | 2406 | |||
93 | 2340 | /*******************************************************************//** | 2407 | /*******************************************************************//** |
94 | 2341 | Does a synchronous read operation in Posix. | 2408 | Does a synchronous read operation in Posix. |
97 | 2342 | @return number of bytes read, -1 if error */ | 2409 | @return number of bytes read, -1 if error */ |
98 | 2343 | static __attribute__((nonnull, warn_unused_result)) | 2410 | static __attribute__((warn_unused_result)) |
99 | 2344 | ssize_t | 2411 | ssize_t |
100 | 2345 | os_file_pread( | 2412 | os_file_pread( |
101 | 2346 | /*==========*/ | 2413 | /*==========*/ |
102 | @@ -2349,10 +2416,8 @@ | |||
103 | 2349 | ulint n, /*!< in: number of bytes to read */ | 2416 | ulint n, /*!< in: number of bytes to read */ |
104 | 2350 | os_offset_t offset) /*!< in: file offset from where to read */ | 2417 | os_offset_t offset) /*!< in: file offset from where to read */ |
105 | 2351 | { | 2418 | { |
110 | 2352 | off_t offs; | 2419 | off_t offs; |
111 | 2353 | #if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD) | 2420 | ssize_t read_bytes; |
108 | 2354 | ssize_t n_bytes; | ||
109 | 2355 | #endif /* HAVE_PREAD && !HAVE_BROKEN_PREAD */ | ||
112 | 2356 | 2421 | ||
113 | 2357 | ut_ad(n); | 2422 | ut_ad(n); |
114 | 2358 | 2423 | ||
115 | @@ -2360,98 +2425,45 @@ | |||
116 | 2360 | 64-bit address */ | 2425 | 64-bit address */ |
117 | 2361 | offs = (off_t) offset; | 2426 | offs = (off_t) offset; |
118 | 2362 | 2427 | ||
124 | 2363 | if (sizeof(off_t) <= 4) { | 2428 | if (sizeof(off_t) <= 4 && offset != (os_offset_t) offs) { |
125 | 2364 | if (offset != (os_offset_t) offs) { | 2429 | ib_logf(IB_LOG_LEVEL_ERROR, "File read at offset > 4 GB"); |
121 | 2365 | ib_logf(IB_LOG_LEVEL_ERROR, | ||
122 | 2366 | "File read at offset > 4 GB"); | ||
123 | 2367 | } | ||
126 | 2368 | } | 2430 | } |
127 | 2369 | 2431 | ||
128 | 2370 | os_n_file_reads++; | 2432 | os_n_file_reads++; |
129 | 2371 | 2433 | ||
132 | 2372 | #if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD) | 2434 | # if defined(HAVE_ATOMIC_BUILTINS) |
131 | 2373 | #if defined(HAVE_ATOMIC_BUILTINS) && UNIV_WORD_SIZE == 8 | ||
133 | 2374 | (void) os_atomic_increment_ulint(&os_n_pending_reads, 1); | 2435 | (void) os_atomic_increment_ulint(&os_n_pending_reads, 1); |
134 | 2375 | (void) os_atomic_increment_ulint(&os_file_n_pending_preads, 1); | 2436 | (void) os_atomic_increment_ulint(&os_file_n_pending_preads, 1); |
135 | 2376 | MONITOR_ATOMIC_INC(MONITOR_OS_PENDING_READS); | 2437 | MONITOR_ATOMIC_INC(MONITOR_OS_PENDING_READS); |
138 | 2377 | #else | 2438 | # else |
139 | 2378 | os_mutex_enter(os_file_count_mutex); | 2439 | mutex_enter(&os_file_count_mutex); |
140 | 2379 | os_file_n_pending_preads++; | 2440 | os_file_n_pending_preads++; |
141 | 2380 | os_n_pending_reads++; | 2441 | os_n_pending_reads++; |
142 | 2381 | MONITOR_INC(MONITOR_OS_PENDING_READS); | 2442 | MONITOR_INC(MONITOR_OS_PENDING_READS); |
149 | 2382 | os_mutex_exit(os_file_count_mutex); | 2443 | mutex_exit(&os_file_count_mutex); |
150 | 2383 | #endif /* HAVE_ATOMIC_BUILTINS && UNIV_WORD == 8 */ | 2444 | # endif /* HAVE_ATOMIC_BUILTINS */ |
151 | 2384 | 2445 | ||
152 | 2385 | n_bytes = pread(file, buf, n, offs); | 2446 | read_bytes = os_file_io(file, buf, n, offs, OS_FILE_READ); |
153 | 2386 | 2447 | ||
154 | 2387 | #if defined(HAVE_ATOMIC_BUILTINS) && UNIV_WORD_SIZE == 8 | 2448 | # ifdef HAVE_ATOMIC_BUILTINS |
155 | 2388 | (void) os_atomic_decrement_ulint(&os_n_pending_reads, 1); | 2449 | (void) os_atomic_decrement_ulint(&os_n_pending_reads, 1); |
156 | 2389 | (void) os_atomic_decrement_ulint(&os_file_n_pending_preads, 1); | 2450 | (void) os_atomic_decrement_ulint(&os_file_n_pending_preads, 1); |
157 | 2390 | MONITOR_ATOMIC_DEC(MONITOR_OS_PENDING_READS); | 2451 | MONITOR_ATOMIC_DEC(MONITOR_OS_PENDING_READS); |
160 | 2391 | #else | 2452 | # else |
161 | 2392 | os_mutex_enter(os_file_count_mutex); | 2453 | mutex_enter(&os_file_count_mutex); |
162 | 2393 | os_file_n_pending_preads--; | 2454 | os_file_n_pending_preads--; |
163 | 2394 | os_n_pending_reads--; | 2455 | os_n_pending_reads--; |
164 | 2395 | MONITOR_DEC(MONITOR_OS_PENDING_READS); | 2456 | MONITOR_DEC(MONITOR_OS_PENDING_READS); |
218 | 2396 | os_mutex_exit(os_file_count_mutex); | 2457 | mutex_exit(&os_file_count_mutex); |
219 | 2397 | #endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD == 8 */ | 2458 | # endif /* HAVE_ATOMIC_BUILTINS */ |
220 | 2398 | 2459 | ||
221 | 2399 | return(n_bytes); | 2460 | return(read_bytes); |
169 | 2400 | #else | ||
170 | 2401 | { | ||
171 | 2402 | off_t ret_offset; | ||
172 | 2403 | ssize_t ret; | ||
173 | 2404 | #ifndef UNIV_HOTBACKUP | ||
174 | 2405 | ulint i; | ||
175 | 2406 | #endif /* !UNIV_HOTBACKUP */ | ||
176 | 2407 | |||
177 | 2408 | #if defined(HAVE_ATOMIC_BUILTINS) && UNIV_WORD_SIZE == 8 | ||
178 | 2409 | (void) os_atomic_increment_ulint(&os_n_pending_reads, 1); | ||
179 | 2410 | MONITOR_ATOMIC_INC(MONITOR_OS_PENDING_READS); | ||
180 | 2411 | #else | ||
181 | 2412 | os_mutex_enter(os_file_count_mutex); | ||
182 | 2413 | os_n_pending_reads++; | ||
183 | 2414 | MONITOR_INC(MONITOR_OS_PENDING_READS); | ||
184 | 2415 | os_mutex_exit(os_file_count_mutex); | ||
185 | 2416 | #endif /* HAVE_ATOMIC_BUILTINS && UNIV_WORD == 8 */ | ||
186 | 2417 | #ifndef UNIV_HOTBACKUP | ||
187 | 2418 | /* Protect the seek / read operation with a mutex */ | ||
188 | 2419 | i = ((ulint) file) % OS_FILE_N_SEEK_MUTEXES; | ||
189 | 2420 | |||
190 | 2421 | os_mutex_enter(os_file_seek_mutexes[i]); | ||
191 | 2422 | #endif /* !UNIV_HOTBACKUP */ | ||
192 | 2423 | |||
193 | 2424 | ret_offset = lseek(file, offs, SEEK_SET); | ||
194 | 2425 | |||
195 | 2426 | if (ret_offset < 0) { | ||
196 | 2427 | ret = -1; | ||
197 | 2428 | } else { | ||
198 | 2429 | ret = read(file, buf, (ssize_t) n); | ||
199 | 2430 | } | ||
200 | 2431 | |||
201 | 2432 | #ifndef UNIV_HOTBACKUP | ||
202 | 2433 | os_mutex_exit(os_file_seek_mutexes[i]); | ||
203 | 2434 | #endif /* !UNIV_HOTBACKUP */ | ||
204 | 2435 | |||
205 | 2436 | #if defined(HAVE_ATOMIC_BUILTINS) && UNIV_WORD_SIZE == 8 | ||
206 | 2437 | (void) os_atomic_decrement_ulint(&os_n_pending_reads, 1); | ||
207 | 2438 | MONITOR_ATOIC_DEC(MONITOR_OS_PENDING_READS); | ||
208 | 2439 | #else | ||
209 | 2440 | os_mutex_enter(os_file_count_mutex); | ||
210 | 2441 | os_n_pending_reads--; | ||
211 | 2442 | MONITOR_DEC(MONITOR_OS_PENDING_READS); | ||
212 | 2443 | os_mutex_exit(os_file_count_mutex); | ||
213 | 2444 | #endif /* HAVE_ATOMIC_BUILTINS && UNIV_WORD_SIZE == 8 */ | ||
214 | 2445 | |||
215 | 2446 | return(ret); | ||
216 | 2447 | } | ||
217 | 2448 | #endif | ||
222 | 2449 | } | 2461 | } |
223 | 2450 | 2462 | ||
224 | 2451 | /*******************************************************************//** | 2463 | /*******************************************************************//** |
225 | 2452 | Does a synchronous write operation in Posix. | 2464 | Does a synchronous write operation in Posix. |
228 | 2453 | @return number of bytes written, -1 if error */ | 2465 | @return number of bytes written, -1 if error */ |
229 | 2454 | static __attribute__((nonnull, warn_unused_result)) | 2466 | static __attribute__((warn_unused_result)) |
230 | 2455 | ssize_t | 2467 | ssize_t |
231 | 2456 | os_file_pwrite( | 2468 | os_file_pwrite( |
232 | 2457 | /*===========*/ | 2469 | /*===========*/ |
233 | @@ -2460,95 +2472,49 @@ | |||
234 | 2460 | ulint n, /*!< in: number of bytes to write */ | 2472 | ulint n, /*!< in: number of bytes to write */ |
235 | 2461 | os_offset_t offset) /*!< in: file offset where to write */ | 2473 | os_offset_t offset) /*!< in: file offset where to write */ |
236 | 2462 | { | 2474 | { |
239 | 2463 | ssize_t ret; | 2475 | off_t offs; |
240 | 2464 | off_t offs; | 2476 | ssize_t written_bytes; |
241 | 2465 | 2477 | ||
242 | 2466 | ut_ad(n); | 2478 | ut_ad(n); |
243 | 2467 | ut_ad(!srv_read_only_mode); | ||
244 | 2468 | 2479 | ||
245 | 2469 | /* If off_t is > 4 bytes in size, then we assume we can pass a | 2480 | /* If off_t is > 4 bytes in size, then we assume we can pass a |
246 | 2470 | 64-bit address */ | 2481 | 64-bit address */ |
247 | 2471 | offs = (off_t) offset; | 2482 | offs = (off_t) offset; |
248 | 2472 | 2483 | ||
254 | 2473 | if (sizeof(off_t) <= 4) { | 2484 | if (sizeof(off_t) <= 4 && offset != (os_offset_t) offs) { |
255 | 2474 | if (offset != (os_offset_t) offs) { | 2485 | ib_logf(IB_LOG_LEVEL_ERROR, "file write at offset > 4 GB."); |
251 | 2475 | ib_logf(IB_LOG_LEVEL_ERROR, | ||
252 | 2476 | "File write at offset > 4 GB."); | ||
253 | 2477 | } | ||
256 | 2478 | } | 2486 | } |
257 | 2479 | 2487 | ||
258 | 2480 | os_n_file_writes++; | 2488 | os_n_file_writes++; |
259 | 2481 | 2489 | ||
268 | 2482 | #if defined(HAVE_PWRITE) && !defined(HAVE_BROKEN_PREAD) | 2490 | #ifdef HAVE_ATOMIC_BUILTINS |
261 | 2483 | #if !defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8 | ||
262 | 2484 | os_mutex_enter(os_file_count_mutex); | ||
263 | 2485 | os_file_n_pending_pwrites++; | ||
264 | 2486 | os_n_pending_writes++; | ||
265 | 2487 | MONITOR_INC(MONITOR_OS_PENDING_WRITES); | ||
266 | 2488 | os_mutex_exit(os_file_count_mutex); | ||
267 | 2489 | #else | ||
269 | 2490 | (void) os_atomic_increment_ulint(&os_n_pending_writes, 1); | 2491 | (void) os_atomic_increment_ulint(&os_n_pending_writes, 1); |
270 | 2491 | (void) os_atomic_increment_ulint(&os_file_n_pending_pwrites, 1); | 2492 | (void) os_atomic_increment_ulint(&os_file_n_pending_pwrites, 1); |
271 | 2492 | MONITOR_ATOMIC_INC(MONITOR_OS_PENDING_WRITES); | 2493 | MONITOR_ATOMIC_INC(MONITOR_OS_PENDING_WRITES); |
272 | 2493 | #endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD < 8 */ | ||
273 | 2494 | |||
274 | 2495 | ret = pwrite(file, buf, (ssize_t) n, offs); | ||
275 | 2496 | |||
276 | 2497 | #if !defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8 | ||
277 | 2498 | os_mutex_enter(os_file_count_mutex); | ||
278 | 2499 | os_file_n_pending_pwrites--; | ||
279 | 2500 | os_n_pending_writes--; | ||
280 | 2501 | MONITOR_DEC(MONITOR_OS_PENDING_WRITES); | ||
281 | 2502 | os_mutex_exit(os_file_count_mutex); | ||
282 | 2503 | #else | 2494 | #else |
283 | 2495 | mutex_enter(&os_file_count_mutex); | ||
284 | 2496 | os_file_n_pending_pwrites++; | ||
285 | 2497 | os_n_pending_writes++; | ||
286 | 2498 | MONITOR_INC(MONITOR_OS_PENDING_WRITES); | ||
287 | 2499 | mutex_exit(&os_file_count_mutex); | ||
288 | 2500 | #endif /* HAVE_ATOMIC_BUILTINS */ | ||
289 | 2501 | |||
290 | 2502 | written_bytes = os_file_io( | ||
291 | 2503 | file, (void*) buf, n, offs, OS_FILE_WRITE); | ||
292 | 2504 | |||
293 | 2505 | #ifdef HAVE_ATOMIC_BUILTINS | ||
294 | 2504 | (void) os_atomic_decrement_ulint(&os_n_pending_writes, 1); | 2506 | (void) os_atomic_decrement_ulint(&os_n_pending_writes, 1); |
295 | 2505 | (void) os_atomic_decrement_ulint(&os_file_n_pending_pwrites, 1); | 2507 | (void) os_atomic_decrement_ulint(&os_file_n_pending_pwrites, 1); |
296 | 2506 | MONITOR_ATOMIC_DEC(MONITOR_OS_PENDING_WRITES); | 2508 | MONITOR_ATOMIC_DEC(MONITOR_OS_PENDING_WRITES); |
297 | 2507 | #endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD < 8 */ | ||
298 | 2508 | |||
299 | 2509 | return(ret); | ||
300 | 2510 | #else | 2509 | #else |
342 | 2511 | { | 2510 | mutex_enter(&os_file_count_mutex); |
343 | 2512 | off_t ret_offset; | 2511 | os_file_n_pending_pwrites--; |
344 | 2513 | # ifndef UNIV_HOTBACKUP | 2512 | os_n_pending_writes--; |
345 | 2514 | ulint i; | 2513 | MONITOR_DEC(MONITOR_OS_PENDING_WRITES); |
346 | 2515 | # endif /* !UNIV_HOTBACKUP */ | 2514 | mutex_exit(&os_file_count_mutex); |
347 | 2516 | 2515 | #endif /* HAVE_ATOMIC_BUILTINS */ | |
348 | 2517 | os_mutex_enter(os_file_count_mutex); | 2516 | |
349 | 2518 | os_n_pending_writes++; | 2517 | return(written_bytes); |
309 | 2519 | MONITOR_INC(MONITOR_OS_PENDING_WRITES); | ||
310 | 2520 | os_mutex_exit(os_file_count_mutex); | ||
311 | 2521 | |||
312 | 2522 | # ifndef UNIV_HOTBACKUP | ||
313 | 2523 | /* Protect the seek / write operation with a mutex */ | ||
314 | 2524 | i = ((ulint) file) % OS_FILE_N_SEEK_MUTEXES; | ||
315 | 2525 | |||
316 | 2526 | os_mutex_enter(os_file_seek_mutexes[i]); | ||
317 | 2527 | # endif /* UNIV_HOTBACKUP */ | ||
318 | 2528 | |||
319 | 2529 | ret_offset = lseek(file, offs, SEEK_SET); | ||
320 | 2530 | |||
321 | 2531 | if (ret_offset < 0) { | ||
322 | 2532 | ret = -1; | ||
323 | 2533 | |||
324 | 2534 | goto func_exit; | ||
325 | 2535 | } | ||
326 | 2536 | |||
327 | 2537 | ret = write(file, buf, (ssize_t) n); | ||
328 | 2538 | |||
329 | 2539 | func_exit: | ||
330 | 2540 | # ifndef UNIV_HOTBACKUP | ||
331 | 2541 | os_mutex_exit(os_file_seek_mutexes[i]); | ||
332 | 2542 | # endif /* !UNIV_HOTBACKUP */ | ||
333 | 2543 | |||
334 | 2544 | os_mutex_enter(os_file_count_mutex); | ||
335 | 2545 | os_n_pending_writes--; | ||
336 | 2546 | MONITOR_DEC(MONITOR_OS_PENDING_WRITES); | ||
337 | 2547 | os_mutex_exit(os_file_count_mutex); | ||
338 | 2548 | |||
339 | 2549 | return(ret); | ||
340 | 2550 | } | ||
341 | 2551 | #endif /* !UNIV_HOTBACKUP */ | ||
350 | 2552 | } | 2518 | } |
351 | 2553 | #endif | 2519 | #endif |
352 | 2554 | 2520 | ||
353 | @@ -2659,6 +2625,13 @@ | |||
354 | 2659 | retry = os_file_handle_error(NULL, "read"); | 2625 | retry = os_file_handle_error(NULL, "read"); |
355 | 2660 | 2626 | ||
356 | 2661 | if (retry) { | 2627 | if (retry) { |
357 | 2628 | #ifndef _WIN32 | ||
358 | 2629 | if (ret > 0 && (ulint) ret < n) { | ||
359 | 2630 | buf = (uchar*) buf + (ulint) ret; | ||
360 | 2631 | offset += (ulint) ret; | ||
361 | 2632 | n -= (ulint) ret; | ||
362 | 2633 | } | ||
363 | 2634 | #endif | ||
364 | 2662 | goto try_again; | 2635 | goto try_again; |
365 | 2663 | } | 2636 | } |
366 | 2664 | 2637 | ||
367 | @@ -2782,6 +2755,13 @@ | |||
368 | 2782 | retry = os_file_handle_error_no_exit(NULL, "read", FALSE); | 2755 | retry = os_file_handle_error_no_exit(NULL, "read", FALSE); |
369 | 2783 | 2756 | ||
370 | 2784 | if (retry) { | 2757 | if (retry) { |
371 | 2758 | #ifndef _WIN32 | ||
372 | 2759 | if (ret > 0 && (ulint) ret < n) { | ||
373 | 2760 | buf = (uchar*) buf + (ulint) ret; | ||
374 | 2761 | offset += ret; | ||
375 | 2762 | n -= (ulint) ret; | ||
376 | 2763 | } | ||
377 | 2764 | #endif /* _WIN32 */ | ||
378 | 2785 | goto try_again; | 2765 | goto try_again; |
379 | 2786 | } | 2766 | } |
380 | 2787 | 2767 | ||
381 | @@ -5047,6 +5027,7 @@ | |||
382 | 5047 | segment = os_aio_get_array_and_local_segment(&array, global_seg); | 5027 | segment = os_aio_get_array_and_local_segment(&array, global_seg); |
383 | 5048 | n = array->n_slots / array->n_segments; | 5028 | n = array->n_slots / array->n_segments; |
384 | 5049 | 5029 | ||
385 | 5030 | wait_for_event: | ||
386 | 5050 | /* Loop until we have found a completed request. */ | 5031 | /* Loop until we have found a completed request. */ |
387 | 5051 | for (;;) { | 5032 | for (;;) { |
388 | 5052 | ibool any_reserved = FALSE; | 5033 | ibool any_reserved = FALSE; |
389 | @@ -5108,6 +5089,41 @@ | |||
390 | 5108 | if (slot->ret == 0 && slot->n_bytes == (long) slot->len) { | 5089 | if (slot->ret == 0 && slot->n_bytes == (long) slot->len) { |
391 | 5109 | 5090 | ||
392 | 5110 | ret = TRUE; | 5091 | ret = TRUE; |
393 | 5092 | } else if ((slot->ret == 0) && (slot->n_bytes > 0) | ||
394 | 5093 | && (slot->n_bytes < (long) slot->len)) { | ||
395 | 5094 | /* Partial read or write scenario */ | ||
396 | 5095 | int submit_ret; | ||
397 | 5096 | struct iocb* iocb; | ||
398 | 5097 | slot->buf = (byte*)slot->buf + slot->n_bytes; | ||
399 | 5098 | slot->offset = slot->offset + slot->n_bytes; | ||
400 | 5099 | slot->len = slot->len - slot->n_bytes; | ||
401 | 5100 | /* Resetting the bytes read/written */ | ||
402 | 5101 | slot->n_bytes = 0; | ||
403 | 5102 | slot->io_already_done = false; | ||
404 | 5103 | iocb = &(slot->control); | ||
405 | 5104 | |||
406 | 5105 | if (slot->type == OS_FILE_READ) { | ||
407 | 5106 | io_prep_pread(&slot->control, slot->file, slot->buf, | ||
408 | 5107 | slot->len, (off_t) slot->offset); | ||
409 | 5108 | } else { | ||
410 | 5109 | ut_a(slot->type == OS_FILE_WRITE); | ||
411 | 5110 | io_prep_pwrite(&slot->control, slot->file, slot->buf, | ||
412 | 5111 | slot->len, (off_t) slot->offset); | ||
413 | 5112 | } | ||
414 | 5113 | /* Resubmit an I/O request */ | ||
415 | 5114 | submit_ret = io_submit(array->aio_ctx[segment], 1, &iocb); | ||
416 | 5115 | if (submit_ret < 0 ) { | ||
417 | 5116 | /* Aborting in case of submit failure */ | ||
418 | 5117 | ib_logf(IB_LOG_LEVEL_FATAL, | ||
419 | 5118 | "Native Linux AIO interface. io_submit()" | ||
420 | 5119 | " call failed when resubmitting a partial" | ||
421 | 5120 | " I/O request on the file %s.", | ||
422 | 5121 | slot->name); | ||
423 | 5122 | } else { | ||
424 | 5123 | ret = false; | ||
425 | 5124 | os_mutex_exit(array->mutex); | ||
426 | 5125 | goto wait_for_event; | ||
427 | 5126 | } | ||
428 | 5111 | } else { | 5127 | } else { |
429 | 5112 | errno = -slot->ret; | 5128 | errno = -slot->ret; |
430 | 5113 | 5129 |
Sergei,
Wouldn't it be better to port the _current_ version of the code, rather than the original revision. That is, no HAVE_BROKEN_PREAD (HP-UX specific) code paths, and no spurious whitespace changes like in lines 289-290. Those have been fixed in later revisions.