diff options
author | Igor Sysoev <igor@sysoev.ru> | 2008-09-12 17:50:12 +0400 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2008-09-12 17:50:12 +0400 |
commit | fae2c00d02d3631347a17deab2709968be1a05c7 (patch) | |
tree | a62d5986fc44f517e87de51567145b12bbaab078 /src/core | |
parent | 0f8ea4de461b5fc54b69e09364c94b066363c0c9 (diff) |
disable directio for unaligned reads in Linux
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/ngx_buf.h | 3 | ||||
-rw-r--r-- | src/core/ngx_output_chain.c | 37 |
2 files changed, 40 insertions, 0 deletions
diff --git a/src/core/ngx_buf.h b/src/core/ngx_buf.h index d16656d6b..ce26c630e 100644 --- a/src/core/ngx_buf.h +++ b/src/core/ngx_buf.h @@ -79,6 +79,9 @@ typedef struct { unsigned sendfile; unsigned directio; +#if (NGX_HAVE_ALIGNED_DIRECTIO) + unsigned unaligned; +#endif unsigned need_in_memory; unsigned need_in_temp; diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c index ecb0f31bf..391852ffe 100644 --- a/src/core/ngx_output_chain.c +++ b/src/core/ngx_output_chain.c @@ -355,6 +355,10 @@ ngx_output_chain_align_file_buf(ngx_output_chain_ctx_t *ctx, off_t bsize) * to reuse the buf via ctx->free list */ +#if (NGX_HAVE_ALIGNED_DIRECTIO) + ctx->unaligned = 1; +#endif + return NGX_OK; } @@ -491,8 +495,41 @@ ngx_output_chain_copy_buf(ngx_output_chain_ctx_t *ctx) } } else { + +#if (NGX_HAVE_ALIGNED_DIRECTIO) + + if (ctx->unaligned) { + if (ngx_directio_off(src->file->fd) == -1) { + ngx_log_error(NGX_LOG_ALERT, ctx->pool->log, ngx_errno, + ngx_directio_off_n " \"%s\" failed", + src->file->name.data); + } + } + +#endif + n = ngx_read_file(src->file, dst->pos, (size_t) size, src->file_pos); +#if (NGX_HAVE_ALIGNED_DIRECTIO) + + if (ctx->unaligned) { + ngx_err_t err; + + err = ngx_errno; + + if (ngx_directio_on(src->file->fd) == -1) { + ngx_log_error(NGX_LOG_ALERT, ctx->pool->log, ngx_errno, + ngx_directio_on_n " \"%s\" failed", + src->file->name.data); + } + + ngx_set_errno(err); + + ctx->unaligned = 0; + } + +#endif + if (n == NGX_ERROR) { return (ngx_int_t) n; } |