Date: Wed, 1 Jun 2016 04:07:33 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> 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 Message-ID: <201606010407.u5147XM3052319@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201606010407.u5147XM3052319>