summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2008-11-20 16:21:39 +0000
committerIgor Sysoev <igor@sysoev.ru>2008-11-20 16:21:39 +0000
commit7f3c048e2105b835055baaa8c5d43e1a2f11b0d7 (patch)
tree3f682dd91ad416e50dd90c42680530e81c15d20d
parent1bf7dc18846113dd16be360777b2ad788a114ac7 (diff)
downloadnginx-7f3c048e2105b835055baaa8c5d43e1a2f11b0d7.tar.gz
allow directio on XFS
-rw-r--r--src/core/ngx_output_chain.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c
index 391852ffe..71016996d 100644
--- a/src/core/ngx_output_chain.c
+++ b/src/core/ngx_output_chain.c
@@ -13,6 +13,17 @@
#define NGX_SENDFILE_LIMIT 4096
#endif
+/*
+ * 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
+ * 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
@@ -327,7 +338,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 & ~511));
+ size = (size_t) (in->file_pos - (in->file_pos & ~(NGX_DIRECTIO_BLOCK - 1)));
if (size == 0) {
@@ -338,7 +349,7 @@ ngx_output_chain_align_file_buf(ngx_output_chain_ctx_t *ctx, off_t bsize)
size = (size_t) bsize;
} else {
- size = 512 - size;
+ size = NGX_DIRECTIO_BLOCK - size;
if ((off_t) size > bsize) {
size = (size_t) bsize;
@@ -413,7 +424,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, 512);
+ b->start = ngx_pmemalign(ctx->pool, size, NGX_DIRECTIO_BLOCK);
if (b->start == NULL) {
return NGX_ERROR;
}