Klaus Demo nginx / 7f3c048
allow directio on XFS Igor Sysoev 13 years ago
1 changed file(s) with 14 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
1111 #if 0
1212 #define NGX_SENDFILE_LIMIT 4096
1313 #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
1425
1526
1627 #define NGX_NONE 1
326337
327338 ctx->directio = 1;
328339
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)));
330341
331342 if (size == 0) {
332343
337348 size = (size_t) bsize;
338349
339350 } else {
340 size = 512 - size;
351 size = NGX_DIRECTIO_BLOCK - size;
341352
342353 if ((off_t) size > bsize) {
343354 size = (size_t) bsize;
412423 * userland buffer direct usage conjunctly with directio
413424 */
414425
415 b->start = ngx_pmemalign(ctx->pool, size, 512);
426 b->start = ngx_pmemalign(ctx->pool, size, NGX_DIRECTIO_BLOCK);
416427 if (b->start == NULL) {
417428 return NGX_ERROR;
418429 }