Welcome! Log In Create A New Profile

Advanced

Re: [PATCH 4 of 4] Support for sendfile(SF_NOCACHE)

Sergey Kandaurov
November 30, 2021 07:16AM
On Thu, Nov 11, 2021 at 07:21:12AM +0300, Maxim Dounin wrote:
> # HG changeset patch
> # User Maxim Dounin <mdounin@mdounin.ru>
> # Date 1636603897 -10800
> # Thu Nov 11 07:11:37 2021 +0300
> # Node ID 10f96e74ae73e1c53a3fd08e7e1c26754c8969ed
> # Parent 98d3beb63f32cbb68d1cdcec385614d32129cad0
> Support for sendfile(SF_NOCACHE).
>
> The SF_NOCACHE flag, introduced in FreeBSD 11 along with the new non-blocking
> sendfile() implementation by glebius@, makes it possible to use sendfile()
> along with the "directio" directive.
>
> diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c
> --- a/src/core/ngx_output_chain.c
> +++ b/src/core/ngx_output_chain.c
> @@ -256,9 +256,11 @@ ngx_output_chain_as_is(ngx_output_chain_
> }
> #endif
>
> +#if !(NGX_HAVE_SENDFILE_NODISKIO)
> if (buf->in_file && buf->file->directio) {
> return 0;
> }
> +#endif

This probably deserves a comment, why it depends on such a macro test.
Though, it should be pretty clear from the commit log.

>
> sendfile = ctx->sendfile;
>
> diff --git a/src/event/ngx_event_openssl.c b/src/event/ngx_event_openssl.c
> --- a/src/event/ngx_event_openssl.c
> +++ b/src/event/ngx_event_openssl.c
> @@ -2955,7 +2955,13 @@ ngx_ssl_sendfile(ngx_connection_t *c, ng
> ngx_set_errno(0);
>
> #if (NGX_HAVE_SENDFILE_NODISKIO)
> +
> flags = (c->busy_count <= 2) ? SF_NODISKIO : 0;
> +
> + if (file->file->directio) {
> + flags |= SF_NOCACHE;
> + }
> +
> #else
> flags = 0;
> #endif
> diff --git a/src/os/unix/ngx_freebsd_sendfile_chain.c b/src/os/unix/ngx_freebsd_sendfile_chain.c
> --- a/src/os/unix/ngx_freebsd_sendfile_chain.c
> +++ b/src/os/unix/ngx_freebsd_sendfile_chain.c
> @@ -174,7 +174,13 @@ ngx_freebsd_sendfile_chain(ngx_connectio
> sent = 0;
>
> #if (NGX_HAVE_SENDFILE_NODISKIO)
> +
> flags = (c->busy_count <= 2) ? SF_NODISKIO : 0;
> +
> + if (file->file->directio) {
> + flags |= SF_NOCACHE;
> + }
> +
> #endif
>
> rc = sendfile(file->file->fd, c->fd, file->file_pos,
>

Otherwise, looks good.
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH 0 of 4] sendfile(SF_NODISKIO) on FreeBSD

Maxim Dounin 491 November 10, 2021 11:26PM

[PATCH 4 of 4] Support for sendfile(SF_NOCACHE)

Maxim Dounin 191 November 10, 2021 11:26PM

Re: [PATCH 4 of 4] Support for sendfile(SF_NOCACHE)

Sergey Kandaurov 134 November 30, 2021 07:16AM

Re: [PATCH 4 of 4] Support for sendfile(SF_NOCACHE)

Maxim Dounin 154 December 14, 2021 09:18AM

Re: [PATCH 4 of 4] Support for sendfile(SF_NOCACHE)

Sergey Kandaurov 143 December 27, 2021 09:34AM

[PATCH 1 of 4] Removed "aio sendfile", deprecated since 1.7.11

Maxim Dounin 270 November 10, 2021 11:26PM

[PATCH 2 of 4] Simplified sendfile(SF_NODISKIO) usage

Maxim Dounin 157 November 10, 2021 11:26PM

Re: [PATCH 2 of 4] Simplified sendfile(SF_NODISKIO) usage

Sergey Kandaurov 135 November 30, 2021 07:06AM

Re: [PATCH 2 of 4] Simplified sendfile(SF_NODISKIO) usage

Maxim Dounin 134 December 14, 2021 09:16AM

Re: [PATCH 2 of 4] Simplified sendfile(SF_NODISKIO) usage

Maxim Dounin 137 December 14, 2021 10:30AM

Re: [PATCH 2 of 4] Simplified sendfile(SF_NODISKIO) usage

Sergey Kandaurov 97 December 27, 2021 09:14AM

Re: [PATCH 2 of 4] Simplified sendfile(SF_NODISKIO) usage

Maxim Dounin 141 December 27, 2021 01:50PM

Re: [PATCH 2 of 4] Simplified sendfile(SF_NODISKIO) usage

Sergey Kandaurov 110 November 30, 2021 07:10AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 263
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready