Date: Mon, 13 Jul 2020 02:55:32 +0700 From: Eugene Grosbein <eugen@grosbein.net> To: Konstantin Belousov <kostikbel@gmail.com> Cc: Freebsd hackers list <freebsd-hackers@freebsd.org> Subject: Re: fsync(2) Message-ID: <12fb648f-8c37-be9b-f18a-5dc2ec9a09c9@grosbein.net> In-Reply-To: <20200712190517.GA44314@kib.kiev.ua> References: <0cdc3315-0213-8522-c8d6-695c2ee02923@grosbein.net> <20200712190517.GA44314@kib.kiev.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
13.07.2020 2:05, Konstantin Belousov wrote: > On Mon, Jul 13, 2020 at 01:49:22AM +0700, Eugene Grosbein wrote: >> Hi! >> >> Assume we have parent process that created a file and keeps it open not writing anything there. >> The parent spawns a child passing file name and the child opens it, >> fills it with data and exits without fsync()'ing the file. >> >> In case of UFS there is upto 30 seconds time gap when file size is not updated, >> so if crash occurs, the file ends up empty. >> >> The question: will fsync() in parent work for such still open file descriptor? > > fsync() syncs the vnode, not the file or file descriptor. So fsync() on > any file descriptor referencing the same vnode, is enough to ensure that > the data is written to the underlying volume. Thanks! This seems to be undocumented. https://pubs.opengroup.org/onlinepubs/009695399/functions/fsync.html does not mention implementation details (and could not) but our manual page could be improved, could it?
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?12fb648f-8c37-be9b-f18a-5dc2ec9a09c9>