summaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2009-08-28 08:15:55 +0000
committerIgor Sysoev <igor@sysoev.ru>2009-08-28 08:15:55 +0000
commit6fb506a21500dcdf3878d1553c57bd49d0f844b2 (patch)
tree1005ae8c25fc8bc7b169e674f3a6e1aed3810d3d /src/core
parenta962506498d3930bea4e34bc21d261613065f98f (diff)
downloadnginx-6fb506a21500dcdf3878d1553c57bd49d0f844b2.tar.gz
nginx-6fb506a21500dcdf3878d1553c57bd49d0f844b2.tar.bz2
directio_alignment
Diffstat (limited to 'src/core')
-rw-r--r--src/core/ngx_buf.h2
-rw-r--r--src/core/ngx_output_chain.c10
2 files changed, 6 insertions, 6 deletions
diff --git a/src/core/ngx_buf.h b/src/core/ngx_buf.h
index b455270ad..ba4854489 100644
--- a/src/core/ngx_buf.h
+++ b/src/core/ngx_buf.h
@@ -90,6 +90,8 @@ struct ngx_output_chain_ctx_s {
unsigned need_in_memory:1;
unsigned need_in_temp:1;
+ off_t alignment;
+
ngx_pool_t *pool;
ngx_int_t allocated;
ngx_bufs_t bufs;
diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c
index 99e0a9434..592f14aaf 100644
--- a/src/core/ngx_output_chain.c
+++ b/src/core/ngx_output_chain.c
@@ -16,14 +16,12 @@
/*
* When DIRECTIO is enabled FreeBSD, Solaris, and MacOSX read directly
* to an application memory from a device if parameters are aligned
- * to device sector boundary(512 bytes). They fallback to usual read
+ * to device sector boundary (512 bytes). They fallback to usual read
* operation if the parameters are not aligned.
* Linux allows DIRECTIO only if the parameters are aligned to a filesystem
* sector boundary, otherwise it returns EINVAL. The sector size is
* usually 512 bytes, however, on XFS it may be 4096 bytes.
*/
-#define NGX_DIRECTIO_BLOCK 4096
-
#define NGX_NONE 1
@@ -337,7 +335,7 @@ ngx_output_chain_align_file_buf(ngx_output_chain_ctx_t *ctx, off_t bsize)
ctx->directio = 1;
- size = (size_t) (in->file_pos - (in->file_pos & ~(NGX_DIRECTIO_BLOCK - 1)));
+ size = (size_t) (in->file_pos - (in->file_pos & ~(ctx->alignment - 1)));
if (size == 0) {
@@ -348,7 +346,7 @@ ngx_output_chain_align_file_buf(ngx_output_chain_ctx_t *ctx, off_t bsize)
size = (size_t) bsize;
} else {
- size = NGX_DIRECTIO_BLOCK - size;
+ size = ctx->alignment - size;
if ((off_t) size > bsize) {
size = (size_t) bsize;
@@ -423,7 +421,7 @@ ngx_output_chain_get_buf(ngx_output_chain_ctx_t *ctx, off_t bsize)
* userland buffer direct usage conjunctly with directio
*/
- b->start = ngx_pmemalign(ctx->pool, size, NGX_DIRECTIO_BLOCK);
+ b->start = ngx_pmemalign(ctx->pool, size, ctx->alignment);
if (b->start == NULL) {
return NGX_ERROR;
}