comparison src/core/ngx_output_chain.c @ 2316:402797ed988a

allow directio on XFS
author Igor Sysoev <igor@sysoev.ru>
date Thu, 20 Nov 2008 16:21:39 +0000
parents 1adec90a0e46
children 61d5b945730a
comparison
equal deleted inserted replaced
2315:31fafd8e7436 2316:402797ed988a
10 10
11 11
12 #if 0 12 #if 0
13 #define NGX_SENDFILE_LIMIT 4096 13 #define NGX_SENDFILE_LIMIT 4096
14 #endif 14 #endif
15
16 /*
17 * When DIRECTIO is enabled FreeBSD, Solaris, and MacOSX read directly
18 * to an application memory from a device if parameters are aligned
19 * to device sector boundary(512 bytes). They fallback to usual read
20 * operation if the parameters are not aligned.
21 * Linux allows DIRECTIO only if the parameters are aligned to a filesystem
22 * sector boundary, otherwise it returns EINVAL. The sector size is
23 * usually 512 bytes, however, on XFS it may be 4096 bytes.
24 */
25 #define NGX_DIRECTIO_BLOCK 4096
15 26
16 27
17 #define NGX_NONE 1 28 #define NGX_NONE 1
18 29
19 30
325 return NGX_DECLINED; 336 return NGX_DECLINED;
326 } 337 }
327 338
328 ctx->directio = 1; 339 ctx->directio = 1;
329 340
330 size = (size_t) (in->file_pos - (in->file_pos & ~511)); 341 size = (size_t) (in->file_pos - (in->file_pos & ~(NGX_DIRECTIO_BLOCK - 1)));
331 342
332 if (size == 0) { 343 if (size == 0) {
333 344
334 if (bsize >= (off_t) ctx->bufs.size) { 345 if (bsize >= (off_t) ctx->bufs.size) {
335 return NGX_DECLINED; 346 return NGX_DECLINED;
336 } 347 }
337 348
338 size = (size_t) bsize; 349 size = (size_t) bsize;
339 350
340 } else { 351 } else {
341 size = 512 - size; 352 size = NGX_DIRECTIO_BLOCK - size;
342 353
343 if ((off_t) size > bsize) { 354 if ((off_t) size > bsize) {
344 size = (size_t) bsize; 355 size = (size_t) bsize;
345 } 356 }
346 } 357 }
411 /* 422 /*
412 * allocate block aligned to a disk sector size to enable 423 * allocate block aligned to a disk sector size to enable
413 * userland buffer direct usage conjunctly with directio 424 * userland buffer direct usage conjunctly with directio
414 */ 425 */
415 426
416 b->start = ngx_pmemalign(ctx->pool, size, 512); 427 b->start = ngx_pmemalign(ctx->pool, size, NGX_DIRECTIO_BLOCK);
417 if (b->start == NULL) { 428 if (b->start == NULL) {
418 return NGX_ERROR; 429 return NGX_ERROR;
419 } 430 }
420 431
421 } else { 432 } else {