From owner-svn-src-stable-11@freebsd.org Mon Aug 29 05:59:13 2016 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 48260B774CB; Mon, 29 Aug 2016 05:59:13 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1F33F303; Mon, 29 Aug 2016 05:59:13 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u7T5xCYB062032; Mon, 29 Aug 2016 05:59:12 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u7T5xCkb062030; Mon, 29 Aug 2016 05:59:12 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201608290559.u7T5xCkb062030@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 29 Aug 2016 05:59:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r304985 - stable/11/lib/libc/sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Aug 2016 05:59:13 -0000 Author: kib Date: Mon Aug 29 05:59:12 2016 New Revision: 304985 URL: https://svnweb.freebsd.org/changeset/base/304985 Log: MFC r304287: Add fdatasync(2) man page, combined with fsync(2). Modified: stable/11/lib/libc/sys/Makefile.inc stable/11/lib/libc/sys/fsync.2 Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/sys/Makefile.inc ============================================================================== --- stable/11/lib/libc/sys/Makefile.inc Mon Aug 29 05:53:59 2016 (r304984) +++ stable/11/lib/libc/sys/Makefile.inc Mon Aug 29 05:59:12 2016 (r304985) @@ -366,6 +366,7 @@ MLINKS+=ffclock.2 ffclock_getcounter.2 \ ffclock.2 ffclock_getestimate.2 \ ffclock.2 ffclock_setestimate.2 MLINKS+=fhopen.2 fhstat.2 fhopen.2 fhstatfs.2 +MLINKS+=fsync.2 fdatasync.2 MLINKS+=getdirentries.2 getdents.2 MLINKS+=getfh.2 lgetfh.2 MLINKS+=getgid.2 getegid.2 Modified: stable/11/lib/libc/sys/fsync.2 ============================================================================== --- stable/11/lib/libc/sys/fsync.2 Mon Aug 29 05:53:59 2016 (r304984) +++ stable/11/lib/libc/sys/fsync.2 Mon Aug 29 05:59:12 2016 (r304985) @@ -1,5 +1,11 @@ .\" Copyright (c) 1983, 1993 .\" The Regents of the University of California. All rights reserved. +.\" Copyright (c) 2016 The FreeBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" Parts of this documentation were written by +.\" Konstantin Belousov under sponsorship +.\" from the FreeBSD Foundation. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -28,40 +34,65 @@ .\" @(#)fsync.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 4, 1993 +.Dd August 17, 2016 .Dt FSYNC 2 .Os .Sh NAME -.Nm fsync +.Nm fdatasync, fsync .Nd "synchronise changes to a file" .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In unistd.h .Ft int +.Fn fdatasync "int fd" +.Ft int .Fn fsync "int fd" .Sh DESCRIPTION The .Fn fsync system call -causes all modified data and attributes of +causes all modified data and attributes of the file referenced by +the file descriptor .Fa fd to be moved to a permanent storage device. This normally results in all in-core modified copies of buffers for the associated file to be written to a disk. .Pp The +.Fn fdatasync +system call causes all modified data of +.Fa fd +to be moved to a permanent storage device. +Unlike +.Fn fsync , +the system call does not guarantee that file attributes or +metadata necessary to access the file are committed to the permanent storage. +.Pp +The .Fn fsync system call should be used by programs that require a file to be in a known state, for example, in building a simple transaction facility. +If the file metadata has already been committed, using +.Fn fdatasync +can be more efficient than +.Fn fsync . +.Pp +Both +.Fn fdatasync +and +.Fn fsync +calls are cancellation points. .Sh RETURN VALUES .Rv -std fsync .Sh ERRORS The .Fn fsync -fails if: +and +.Fn fdatasync +calls fail if: .Bl -tag -width Er .It Bq Er EBADF The @@ -85,3 +116,15 @@ The .Fn fsync system call appeared in .Bx 4.2 . +The +.Fn fdatasync +system call appeared in +.Fx 12.0 +.Sh BUGS +The +.Fn fdatasync +system call currently does not guarantee that enqueued +.Xr aio 4 +requests for the file referenced by +.Fa fd +are completed before the syscall returns.