allow directio on XFS
Igor Sysoev
13 years ago
11 | 11 | #if 0 |
12 | 12 | #define NGX_SENDFILE_LIMIT 4096 |
13 | 13 | #endif |
14 | ||
15 | /* | |
16 | * When DIRECTIO is enabled FreeBSD, Solaris, and MacOSX read directly | |
17 | * to an application memory from a device if parameters are aligned | |
18 | * to device sector boundary(512 bytes). They fallback to usual read | |
19 | * operation if the parameters are not aligned. | |
20 | * Linux allows DIRECTIO only if the parameters are aligned to a filesystem | |
21 | * sector boundary, otherwise it returns EINVAL. The sector size is | |
22 | * usually 512 bytes, however, on XFS it may be 4096 bytes. | |
23 | */ | |
24 | #define NGX_DIRECTIO_BLOCK 4096 | |
14 | 25 | |
15 | 26 | |
16 | 27 | #define NGX_NONE 1 |
326 | 337 | |
327 | 338 | ctx->directio = 1; |
328 | 339 | |
329 | size = (size_t) (in->file_pos - (in->file_pos & ~511)); | |
340 | size = (size_t) (in->file_pos - (in->file_pos & ~(NGX_DIRECTIO_BLOCK - 1))); | |
330 | 341 | |
331 | 342 | if (size == 0) { |
332 | 343 | |
337 | 348 | size = (size_t) bsize; |
338 | 349 | |
339 | 350 | } else { |
340 | size = 512 - size; | |
351 | size = NGX_DIRECTIO_BLOCK - size; | |
341 | 352 | |
342 | 353 | if ((off_t) size > bsize) { |
343 | 354 | size = (size_t) bsize; |
412 | 423 | * userland buffer direct usage conjunctly with directio |
413 | 424 | */ |
414 | 425 | |
415 | b->start = ngx_pmemalign(ctx->pool, size, 512); | |
426 | b->start = ngx_pmemalign(ctx->pool, size, NGX_DIRECTIO_BLOCK); | |
416 | 427 | if (b->start == NULL) { |
417 | 428 | return NGX_ERROR; |
418 | 429 | } |