From owner-svn-src-head@freebsd.org Wed Aug 17 20:20:43 2016 Return-Path: Delivered-To: svn-src-head@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 E411ABBC96D; Wed, 17 Aug 2016 20:20:43 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client CN "mailhost.stack.nl", Issuer "CA Cert Signing Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 7E9C01E48; Wed, 17 Aug 2016 20:20:43 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 894443592E5; Wed, 17 Aug 2016 22:20:40 +0200 (CEST) Received: by snail.stack.nl (Postfix, from userid 1677) id 5D3A928494; Wed, 17 Aug 2016 22:20:40 +0200 (CEST) Date: Wed, 17 Aug 2016 22:20:40 +0200 From: Jilles Tjoelker To: Konstantin Belousov Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r304176 - in head: include lib/libc/sys sys/compat/freebsd32 sys/kern Message-ID: <20160817202040.GA21263@stack.nl> References: <201608151908.u7FJ8phh091939@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201608151908.u7FJ8phh091939@repo.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Aug 2016 20:20:44 -0000 On Mon, Aug 15, 2016 at 07:08:51PM +0000, Konstantin Belousov wrote: > Author: kib > Date: Mon Aug 15 19:08:51 2016 > New Revision: 304176 > URL: https://svnweb.freebsd.org/changeset/base/304176 > Log: > Add an implementation of fdatasync(2). > The syscall is a trivial wrapper around new VOP_FDATASYNC(), sharing > code with fsync(2). For all filesystems, this commit provides the > implementation which delegates the work of VOP_FDATASYNC() to > VOP_FSYNC(). This is functionally correct but not efficient. > This is not yet POSIX-compliant implementation, because it does not > ensure that queued AIO requests are completed before returning. > Reviewed by: mckusick > Discussed with: avg (ZFS), jhb (AIO part) > Tested by: pho > Sponsored by: The FreeBSD Foundation > MFC after: 2 weeks > Differential revision: https://reviews.freebsd.org/D7471 > Modified: > head/include/unistd.h > head/lib/libc/sys/Symbol.map > head/sys/compat/freebsd32/syscalls.master > head/sys/kern/syscalls.master > head/sys/kern/vfs_default.c > head/sys/kern/vfs_syscalls.c > head/sys/kern/vnode_if.src > Modified: head/include/unistd.h > ============================================================================== > --- head/include/unistd.h Mon Aug 15 19:05:41 2016 (r304175) > +++ head/include/unistd.h Mon Aug 15 19:08:51 2016 (r304176) > @@ -384,6 +384,7 @@ extern int optind, opterr, optopt; > /* ISO/IEC 9945-1: 1996 */ > #if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE > int fsync(int); > +int fdatasync(int); > > /* > * ftruncate() was in the POSIX Realtime Extension (it's used for shared Apparently these functions were added closely enough in time that they can stay together here :) > [snip] > Modified: head/sys/kern/vfs_syscalls.c > ============================================================================== > --- head/sys/kern/vfs_syscalls.c Mon Aug 15 19:05:41 2016 (r304175) > +++ head/sys/kern/vfs_syscalls.c Mon Aug 15 19:08:51 2016 (r304176) > @@ -3354,20 +3354,8 @@ freebsd6_ftruncate(struct thread *td, st > } > #endif > > -/* > - * Sync an open file. > - */ > -#ifndef _SYS_SYSPROTO_H_ > -struct fsync_args { > - int fd; > -}; > -#endif > -int > -sys_fsync(td, uap) > - struct thread *td; > - struct fsync_args /* { > - int fd; > - } */ *uap; > +static int > +kern_fsync(struct thread *td, int fd, bool fullsync) > { > struct vnode *vp; > struct mount *mp; > @@ -3375,11 +3363,15 @@ sys_fsync(td, uap) > cap_rights_t rights; > int error, lock_flags; > > - AUDIT_ARG_FD(uap->fd); > - error = getvnode(td, uap->fd, cap_rights_init(&rights, CAP_FSYNC), &fp); > + AUDIT_ARG_FD(fd); > + error = getvnode(td, fd, cap_rights_init(&rights, CAP_FSYNC), &fp); > if (error != 0) > return (error); > vp = fp->f_vnode; > +#if 0 > + if (!fullsync) > + /* XXXKIB: compete outstanding aio writes */; Under the _POSIX_SYNCHRONIZED_IO option, completing outstanding I/O requests is in fact required for fsync() as well. The fdatasync() function is completely under the _POSIX_SYNCHRONIZED_IO option. We do not implement this option, but keeping fdatasync()'s guarantees a subset of fsync()'s guarantees seems sensible. > +#endif > error = vn_start_write(vp, &mp, V_WAIT | PCATCH); > if (error != 0) > goto drop; > [snip] > Modified: head/sys/kern/vnode_if.src > ============================================================================== > --- head/sys/kern/vnode_if.src Mon Aug 15 19:05:41 2016 (r304175) > +++ head/sys/kern/vnode_if.src Mon Aug 15 19:08:51 2016 (r304176) > @@ -703,6 +703,14 @@ vop_add_writecount { > IN int inc; > }; > > +%% fdatasync vp L L L > + > +vop_fdatasync { > + IN struct vnode *vp; > + IN struct thread *td; > +}; > + > + > # The VOPs below are spares at the end of the table to allow new VOPs to be > # added in stable branches without breaking the KBI. New VOPs in HEAD should > # be added above these spares. When merging a new VOP to a stable branch, A waitfor parameter like in vop_fsync may be useful to implement aio_fsync(O_DSYNC) later on. -- Jilles Tjoelker