From owner-svn-src-stable-10@freebsd.org Sat Jan 9 17:54:39 2016 Return-Path: Delivered-To: svn-src-stable-10@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 66CFEA69361; Sat, 9 Jan 2016 17:54:39 +0000 (UTC) (envelope-from dchagin@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 291121BF1; Sat, 9 Jan 2016 17:54:39 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u09HscCh068320; Sat, 9 Jan 2016 17:54:38 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u09HsbEB068313; Sat, 9 Jan 2016 17:54:37 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201601091754.u09HsbEB068313@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sat, 9 Jan 2016 17:54:37 +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: r293592 - in stable/10/sys: amd64/linux amd64/linux32 compat/linux i386/linux 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-10@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jan 2016 17:54:39 -0000 Author: dchagin Date: Sat Jan 9 17:54:37 2016 New Revision: 293592 URL: https://svnweb.freebsd.org/changeset/base/293592 Log: MFC r283492: Implement Linux specific syncfs() system call. Modified: stable/10/sys/amd64/linux/linux_dummy.c stable/10/sys/amd64/linux/syscalls.master stable/10/sys/amd64/linux32/linux32_dummy.c stable/10/sys/amd64/linux32/syscalls.master stable/10/sys/compat/linux/linux_stats.c stable/10/sys/i386/linux/linux_dummy.c stable/10/sys/i386/linux/syscalls.master Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/amd64/linux/linux_dummy.c ============================================================================== --- stable/10/sys/amd64/linux/linux_dummy.c Sat Jan 9 17:53:32 2016 (r293591) +++ stable/10/sys/amd64/linux/linux_dummy.c Sat Jan 9 17:54:37 2016 (r293592) @@ -113,7 +113,6 @@ DUMMY(fanotify_mark); DUMMY(name_to_handle_at); DUMMY(open_by_handle_at); DUMMY(clock_adjtime); -DUMMY(syncfs); DUMMY(setns); DUMMY(process_vm_readv); DUMMY(process_vm_writev); Modified: stable/10/sys/amd64/linux/syscalls.master ============================================================================== --- stable/10/sys/amd64/linux/syscalls.master Sat Jan 9 17:53:32 2016 (r293591) +++ stable/10/sys/amd64/linux/syscalls.master Sat Jan 9 17:54:37 2016 (r293592) @@ -502,7 +502,7 @@ 303 AUE_NULL STD { int linux_name_to_handle_at(void); } 304 AUE_NULL STD { int linux_open_by_handle_at(void); } 305 AUE_NULL STD { int linux_clock_adjtime(void); } -306 AUE_NULL STD { int linux_syncfs(void); } +306 AUE_SYNC STD { int linux_syncfs(l_int fd); } 307 AUE_NULL STD { int linux_sendmmsg(l_int s, \ struct l_mmsghdr *msg, l_uint vlen, \ l_uint flags); } Modified: stable/10/sys/amd64/linux32/linux32_dummy.c ============================================================================== --- stable/10/sys/amd64/linux32/linux32_dummy.c Sat Jan 9 17:53:32 2016 (r293591) +++ stable/10/sys/amd64/linux32/linux32_dummy.c Sat Jan 9 17:54:37 2016 (r293592) @@ -125,7 +125,6 @@ DUMMY(fanotify_mark); DUMMY(name_to_handle_at); DUMMY(open_by_handle_at); DUMMY(clock_adjtime); -DUMMY(syncfs); DUMMY(setns); DUMMY(process_vm_readv); DUMMY(process_vm_writev); Modified: stable/10/sys/amd64/linux32/syscalls.master ============================================================================== --- stable/10/sys/amd64/linux32/syscalls.master Sat Jan 9 17:53:32 2016 (r293591) +++ stable/10/sys/amd64/linux32/syscalls.master Sat Jan 9 17:54:37 2016 (r293592) @@ -573,7 +573,7 @@ 341 AUE_NULL STD { int linux_name_to_handle_at(void); } 342 AUE_NULL STD { int linux_open_by_handle_at(void); } 343 AUE_NULL STD { int linux_clock_adjtime(void); } -344 AUE_NULL STD { int linux_syncfs(void); } +344 AUE_SYNC STD { int linux_syncfs(l_int fd); } 345 AUE_NULL STD { int linux_sendmmsg(l_int s, \ struct l_mmsghdr *msg, l_uint vlen, \ l_uint flags); } Modified: stable/10/sys/compat/linux/linux_stats.c ============================================================================== --- stable/10/sys/compat/linux/linux_stats.c Sat Jan 9 17:53:32 2016 (r293591) +++ stable/10/sys/compat/linux/linux_stats.c Sat Jan 9 17:54:37 2016 (r293592) @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include "opt_compat.h" #include +#include #include #include #include @@ -653,3 +654,43 @@ linux_newfstatat(struct thread *td, stru } #endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */ + +int +linux_syncfs(struct thread *td, struct linux_syncfs_args *args) +{ + cap_rights_t rights; + struct mount *mp; + struct vnode *vp; + int error, save; + + error = fgetvp(td, args->fd, cap_rights_init(&rights, CAP_FSYNC), &vp); + if (error != 0) + /* + * Linux syncfs() returns only EBADF, however fgetvp() + * can return EINVAL in case of file descriptor does + * not represent a vnode. XXX. + */ + return (error); + + mp = vp->v_mount; + mtx_lock(&mountlist_mtx); + error = vfs_busy(mp, MBF_MNTLSTLOCK); + if (error != 0) { + /* See comment above. */ + mtx_unlock(&mountlist_mtx); + goto out; + } + if ((mp->mnt_flag & MNT_RDONLY) == 0 && + vn_start_write(NULL, &mp, V_NOWAIT) == 0) { + save = curthread_pflags_set(TDP_SYNCIO); + vfs_msync(mp, MNT_NOWAIT); + VFS_SYNC(mp, MNT_NOWAIT); + curthread_pflags_restore(save); + vn_finished_write(mp); + } + vfs_unbusy(mp); + + out: + vrele(vp); + return (error); +} Modified: stable/10/sys/i386/linux/linux_dummy.c ============================================================================== --- stable/10/sys/i386/linux/linux_dummy.c Sat Jan 9 17:53:32 2016 (r293591) +++ stable/10/sys/i386/linux/linux_dummy.c Sat Jan 9 17:54:37 2016 (r293592) @@ -121,7 +121,6 @@ DUMMY(fanotify_mark); DUMMY(name_to_handle_at); DUMMY(open_by_handle_at); DUMMY(clock_adjtime); -DUMMY(syncfs); DUMMY(setns); DUMMY(process_vm_readv); DUMMY(process_vm_writev); Modified: stable/10/sys/i386/linux/syscalls.master ============================================================================== --- stable/10/sys/i386/linux/syscalls.master Sat Jan 9 17:53:32 2016 (r293591) +++ stable/10/sys/i386/linux/syscalls.master Sat Jan 9 17:54:37 2016 (r293592) @@ -581,7 +581,7 @@ 341 AUE_NULL STD { int linux_name_to_handle_at(void); } 342 AUE_NULL STD { int linux_open_by_handle_at(void); } 343 AUE_NULL STD { int linux_clock_adjtime(void); } -344 AUE_NULL STD { int linux_syncfs(void); } +344 AUE_SYNC STD { int linux_syncfs(l_int fd); } 345 AUE_NULL STD { int linux_sendmmsg(l_int s, \ struct l_mmsghdr *msg, l_uint vlen, \ l_uint flags); }