From owner-svn-src-head@FreeBSD.ORG Wed Apr 15 20:16:36 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B5ED3542; Wed, 15 Apr 2015 20:16:36 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 A05AFD11; Wed, 15 Apr 2015 20:16:36 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3FKGaoX067285; Wed, 15 Apr 2015 20:16:36 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3FKGWVa067264; Wed, 15 Apr 2015 20:16:32 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201504152016.t3FKGWVa067264@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Wed, 15 Apr 2015 20:16:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r281562 - in head/sys: fs/ext2fs fs/fuse fs/msdosfs fs/nandfs fs/nfsclient fs/nfsserver fs/nullfs kern sys ufs/ffs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 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, 15 Apr 2015 20:16:36 -0000 Author: rmacklem Date: Wed Apr 15 20:16:31 2015 New Revision: 281562 URL: https://svnweb.freebsd.org/changeset/base/281562 Log: File systems that do not use the buffer cache (such as ZFS) must use VOP_FSYNC() to perform the NFS server's Commit operation. This patch adds a mnt_kern_flag called MNTK_USES_BCACHE which is set by file systems that use the buffer cache. If this flag is not set, the NFS server always does a VOP_FSYNC(). This should be ok for old file system modules that do not set MNTK_USES_BCACHE, since calling VOP_FSYNC() is correct, although it might not be optimal for file systems that use the buffer cache. Reviewed by: kib MFC after: 2 weeks Modified: head/sys/fs/ext2fs/ext2_vfsops.c head/sys/fs/fuse/fuse_vfsops.c head/sys/fs/msdosfs/msdosfs_vfsops.c head/sys/fs/nandfs/nandfs_vfsops.c head/sys/fs/nfsclient/nfs_clvfsops.c head/sys/fs/nfsserver/nfs_nfsdport.c head/sys/fs/nullfs/null_vfsops.c head/sys/kern/vfs_subr.c head/sys/sys/mount.h head/sys/ufs/ffs/ffs_vfsops.c Modified: head/sys/fs/ext2fs/ext2_vfsops.c ============================================================================== --- head/sys/fs/ext2fs/ext2_vfsops.c Wed Apr 15 18:49:03 2015 (r281561) +++ head/sys/fs/ext2fs/ext2_vfsops.c Wed Apr 15 20:16:31 2015 (r281562) @@ -675,7 +675,8 @@ ext2_mountfs(struct vnode *devvp, struct * Initialize filesystem stat information in mount struct. */ MNT_ILOCK(mp); - mp->mnt_kern_flag |= MNTK_LOOKUP_SHARED | MNTK_EXTENDED_SHARED; + mp->mnt_kern_flag |= MNTK_LOOKUP_SHARED | MNTK_EXTENDED_SHARED | + MNTK_USES_BCACHE; MNT_IUNLOCK(mp); return (0); out: Modified: head/sys/fs/fuse/fuse_vfsops.c ============================================================================== --- head/sys/fs/fuse/fuse_vfsops.c Wed Apr 15 18:49:03 2015 (r281561) +++ head/sys/fs/fuse/fuse_vfsops.c Wed Apr 15 20:16:31 2015 (r281562) @@ -337,6 +337,7 @@ fuse_vfsop_mount(struct mount *mp) MNT_ILOCK(mp); mp->mnt_data = data; mp->mnt_flag |= MNT_LOCAL; + mp->mnt_kern_flag |= MNTK_USES_BCACHE; MNT_IUNLOCK(mp); /* We need this here as this slot is used by getnewvnode() */ mp->mnt_stat.f_iosize = PAGE_SIZE; Modified: head/sys/fs/msdosfs/msdosfs_vfsops.c ============================================================================== --- head/sys/fs/msdosfs/msdosfs_vfsops.c Wed Apr 15 18:49:03 2015 (r281561) +++ head/sys/fs/msdosfs/msdosfs_vfsops.c Wed Apr 15 20:16:31 2015 (r281562) @@ -759,6 +759,7 @@ mountmsdosfs(struct vnode *devvp, struct mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum; MNT_ILOCK(mp); mp->mnt_flag |= MNT_LOCAL; + mp->mnt_kern_flag |= MNTK_USES_BCACHE; MNT_IUNLOCK(mp); if (pmp->pm_flags & MSDOSFS_LARGEFS) Modified: head/sys/fs/nandfs/nandfs_vfsops.c ============================================================================== --- head/sys/fs/nandfs/nandfs_vfsops.c Wed Apr 15 18:49:03 2015 (r281561) +++ head/sys/fs/nandfs/nandfs_vfsops.c Wed Apr 15 20:16:31 2015 (r281562) @@ -1391,6 +1391,7 @@ nandfs_mountfs(struct vnode *devvp, stru nmp->nm_ronly = ronly; MNT_ILOCK(mp); mp->mnt_flag |= MNT_LOCAL; + mp->mnt_kern_flag |= MNTK_USES_BCACHE; MNT_IUNLOCK(mp); nmp->nm_nandfsdev = nandfsdev; /* Add our mountpoint */ Modified: head/sys/fs/nfsclient/nfs_clvfsops.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clvfsops.c Wed Apr 15 18:49:03 2015 (r281561) +++ head/sys/fs/nfsclient/nfs_clvfsops.c Wed Apr 15 20:16:31 2015 (r281562) @@ -1198,7 +1198,8 @@ nfs_mount(struct mount *mp) out: if (!error) { MNT_ILOCK(mp); - mp->mnt_kern_flag |= MNTK_LOOKUP_SHARED | MNTK_NO_IOPF; + mp->mnt_kern_flag |= MNTK_LOOKUP_SHARED | MNTK_NO_IOPF | + MNTK_USES_BCACHE; MNT_IUNLOCK(mp); } return (error); Modified: head/sys/fs/nfsserver/nfs_nfsdport.c ============================================================================== --- head/sys/fs/nfsserver/nfs_nfsdport.c Wed Apr 15 18:49:03 2015 (r281561) +++ head/sys/fs/nfsserver/nfs_nfsdport.c Wed Apr 15 20:16:31 2015 (r281562) @@ -1270,8 +1270,11 @@ nfsvno_fsync(struct vnode *vp, u_int64_t * file is done. At this time VOP_FSYNC does not accept offset and * byte count parameters so call VOP_FSYNC the whole file for now. * The same is true for NFSv4: RFC 3530 Sec. 14.2.3. + * File systems that do not use the buffer cache (as indicated + * by MNTK_USES_BCACHE not being set) must use VOP_FSYNC(). */ - if (cnt == 0 || cnt > MAX_COMMIT_COUNT) { + if (cnt == 0 || cnt > MAX_COMMIT_COUNT || + (vp->v_mount->mnt_kern_flag & MNTK_USES_BCACHE) == 0) { /* * Give up and do the whole thing */ Modified: head/sys/fs/nullfs/null_vfsops.c ============================================================================== --- head/sys/fs/nullfs/null_vfsops.c Wed Apr 15 18:49:03 2015 (r281561) +++ head/sys/fs/nullfs/null_vfsops.c Wed Apr 15 20:16:31 2015 (r281562) @@ -199,7 +199,7 @@ nullfs_mount(struct mount *mp) } mp->mnt_kern_flag |= MNTK_LOOKUP_EXCL_DOTDOT; mp->mnt_kern_flag |= lowerrootvp->v_mount->mnt_kern_flag & - MNTK_SUSPENDABLE; + (MNTK_SUSPENDABLE | MNTK_USES_BCACHE); MNT_IUNLOCK(mp); mp->mnt_data = xmp; vfs_getnewfsid(mp); Modified: head/sys/kern/vfs_subr.c ============================================================================== --- head/sys/kern/vfs_subr.c Wed Apr 15 18:49:03 2015 (r281561) +++ head/sys/kern/vfs_subr.c Wed Apr 15 20:16:31 2015 (r281562) @@ -3147,6 +3147,7 @@ DB_SHOW_COMMAND(mount, db_show_mount) MNT_KERN_FLAG(MNTK_VGONE_WAITER); MNT_KERN_FLAG(MNTK_LOOKUP_EXCL_DOTDOT); MNT_KERN_FLAG(MNTK_MARKER); + MNT_KERN_FLAG(MNTK_USES_BCACHE); MNT_KERN_FLAG(MNTK_NOASYNC); MNT_KERN_FLAG(MNTK_UNMOUNT); MNT_KERN_FLAG(MNTK_MWAIT); Modified: head/sys/sys/mount.h ============================================================================== --- head/sys/sys/mount.h Wed Apr 15 18:49:03 2015 (r281561) +++ head/sys/sys/mount.h Wed Apr 15 20:16:31 2015 (r281562) @@ -355,6 +355,7 @@ void __mnt_vnode_markerfree_act #define MNTK_LOOKUP_EXCL_DOTDOT 0x00000800 #define MNTK_MARKER 0x00001000 #define MNTK_UNMAPPED_BUFS 0x00002000 +#define MNTK_USES_BCACHE 0x00004000 /* FS uses the buffer cache. */ #define MNTK_NOASYNC 0x00800000 /* disable async */ #define MNTK_UNMOUNT 0x01000000 /* unmount in progress */ #define MNTK_MWAIT 0x02000000 /* waiting for unmount to finish */ Modified: head/sys/ufs/ffs/ffs_vfsops.c ============================================================================== --- head/sys/ufs/ffs/ffs_vfsops.c Wed Apr 15 18:49:03 2015 (r281561) +++ head/sys/ufs/ffs/ffs_vfsops.c Wed Apr 15 20:16:31 2015 (r281562) @@ -1055,7 +1055,8 @@ ffs_mountfs(devvp, mp, td) */ MNT_ILOCK(mp); mp->mnt_kern_flag |= MNTK_LOOKUP_SHARED | MNTK_EXTENDED_SHARED | - MNTK_NO_IOPF | MNTK_UNMAPPED_BUFS | MNTK_SUSPENDABLE; + MNTK_NO_IOPF | MNTK_UNMAPPED_BUFS | MNTK_SUSPENDABLE | + MNTK_USES_BCACHE; MNT_IUNLOCK(mp); #ifdef UFS_EXTATTR #ifdef UFS_EXTATTR_AUTOSTART