http_dav_module fsync

Nagy, Attila bra at fsn.hu
Wed Nov 25 10:21:35 UTC 2015


Hi,

I want to make sure that when nginx's DAV module responds with an OK for 
a PUT (or COPY) request, the file is committed on disk.

I see the following solutions:
1. set the filesystem to be sync (for example zfs sync=always)
2. LD_PRELOAD a lib to nginx, which does an fsync before the close() call
3. introduce a dav_fsync on option
4. add a query parameter (or a header), which can be used to signal that 
the client wants the file to be fsync()-ed

#1 is the worst performance wise, #2 is easy, but seems a little bit 
hackish.

A quick glance to the source code tells me that implementing #3 could be 
as easy to call an fsync() at the end of ngx_http_dav_put_handler(), 
like this:

     r->headers_out.status = status;
     r->header_only = 1;

     fsync(r->request_body->temp_file->file.fd);

     ngx_http_finalize_request(r, ngx_http_send_header(r));
     return;

Of course this blocks, which may badly hurt nginx performance.

What is your opinion on this? How this should be handled?



More information about the nginx mailing list