From owner-svn-src-stable@freebsd.org Wed Jun 1 04:07:35 2016 Return-Path: Delivered-To: svn-src-stable@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 0E9A1B586A3; Wed, 1 Jun 2016 04:07:35 +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 AC1E21BCE; Wed, 1 Jun 2016 04:07:34 +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 u5147X4i052322; Wed, 1 Jun 2016 04:07:33 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5147XM3052319; Wed, 1 Jun 2016 04:07:33 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201606010407.u5147XM3052319@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 1 Jun 2016 04:07:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301100 - in stable/10/sys: kern sys ufs/ufs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Jun 2016 04:07:35 -0000 Author: kib Date: Wed Jun 1 04:07:33 2016 New Revision: 301100 URL: https://svnweb.freebsd.org/changeset/base/301100 Log: MFC r300142: Ensure that ftruncate(2) is performed synchronously when file is opened in O_SYNC mode, at least for UFS. Modified: stable/10/sys/kern/vfs_vnops.c stable/10/sys/sys/vnode.h stable/10/sys/ufs/ufs/ufs_vnops.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/vfs_vnops.c ============================================================================== --- stable/10/sys/kern/vfs_vnops.c Wed Jun 1 04:03:55 2016 (r301099) +++ stable/10/sys/kern/vfs_vnops.c Wed Jun 1 04:07:33 2016 (r301100) @@ -1372,6 +1372,8 @@ vn_truncate(struct file *fp, off_t lengt if (error == 0) { VATTR_NULL(&vattr); vattr.va_size = length; + if ((fp->f_flag & O_FSYNC) != 0) + vattr.va_vaflags |= VA_SYNC; error = VOP_SETATTR(vp, &vattr, fp->f_cred); } out: Modified: stable/10/sys/sys/vnode.h ============================================================================== --- stable/10/sys/sys/vnode.h Wed Jun 1 04:03:55 2016 (r301099) +++ stable/10/sys/sys/vnode.h Wed Jun 1 04:07:33 2016 (r301100) @@ -286,6 +286,7 @@ struct vattr { */ #define VA_UTIMES_NULL 0x01 /* utimes argument was NULL */ #define VA_EXCLUSIVE 0x02 /* exclusive create request */ +#define VA_SYNC 0x04 /* O_SYNC truncation */ /* * Flags for ioflag. (high 16 bits used to ask for read-ahead and Modified: stable/10/sys/ufs/ufs/ufs_vnops.c ============================================================================== --- stable/10/sys/ufs/ufs/ufs_vnops.c Wed Jun 1 04:03:55 2016 (r301099) +++ stable/10/sys/ufs/ufs/ufs_vnops.c Wed Jun 1 04:07:33 2016 (r301100) @@ -626,7 +626,8 @@ ufs_setattr(ap) */ return (0); } - if ((error = UFS_TRUNCATE(vp, vap->va_size, IO_NORMAL, + if ((error = UFS_TRUNCATE(vp, vap->va_size, IO_NORMAL | + ((vap->va_vaflags & VA_SYNC) != 0 ? IO_SYNC : 0), cred)) != 0) return (error); }