From owner-svn-src-all@FreeBSD.ORG Mon Jul 28 01:11:30 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 63FF76EB; Mon, 28 Jul 2014 01:11:30 +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 517022D5A; Mon, 28 Jul 2014 01:11:30 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s6S1BUT2014537; Mon, 28 Jul 2014 01:11:30 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s6S1BTg4014534; Mon, 28 Jul 2014 01:11:29 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201407280111.s6S1BTg4014534@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 28 Jul 2014 01:11:29 +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: r269171 - in stable/10/sys: kern sys ufs/ffs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jul 2014 01:11:30 -0000 Author: kib Date: Mon Jul 28 01:11:29 2014 New Revision: 269171 URL: http://svnweb.freebsd.org/changeset/base/269171 Log: MFC r268612: Add helper helper vfs_write_suspend_umnt(). Fix the bug in the FFS unmount, when suspension failed, the ufs extattrs were not reinitialized. Modified: stable/10/sys/kern/vfs_vnops.c stable/10/sys/sys/vnode.h stable/10/sys/ufs/ffs/ffs_vfsops.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/vfs_vnops.c ============================================================================== --- stable/10/sys/kern/vfs_vnops.c Mon Jul 28 01:08:43 2014 (r269170) +++ stable/10/sys/kern/vfs_vnops.c Mon Jul 28 01:11:29 2014 (r269171) @@ -1830,6 +1830,37 @@ vfs_write_resume(struct mount *mp, int f } /* + * Helper loop around vfs_write_suspend() for filesystem unmount VFS + * methods. + */ +int +vfs_write_suspend_umnt(struct mount *mp) +{ + int error; + + KASSERT((curthread->td_pflags & TDP_IGNSUSP) == 0, + ("vfs_write_suspend_umnt: recursed")); + + /* dounmount() already called vn_start_write(). */ + for (;;) { + vn_finished_write(mp); + error = vfs_write_suspend(mp, 0); + if (error != 0) + return (error); + MNT_ILOCK(mp); + if ((mp->mnt_kern_flag & MNTK_SUSPENDED) != 0) + break; + MNT_IUNLOCK(mp); + vn_start_write(NULL, &mp, V_WAIT); + } + mp->mnt_kern_flag &= ~(MNTK_SUSPENDED | MNTK_SUSPEND2); + wakeup(&mp->mnt_flag); + MNT_IUNLOCK(mp); + curthread->td_pflags |= TDP_IGNSUSP; + return (0); +} + +/* * Implement kqueues for files by translating it to vnode operation. */ static int Modified: stable/10/sys/sys/vnode.h ============================================================================== --- stable/10/sys/sys/vnode.h Mon Jul 28 01:08:43 2014 (r269170) +++ stable/10/sys/sys/vnode.h Mon Jul 28 01:11:29 2014 (r269171) @@ -721,6 +721,7 @@ int vfs_cache_lookup(struct vop_lookup_a void vfs_timestamp(struct timespec *); void vfs_write_resume(struct mount *mp, int flags); int vfs_write_suspend(struct mount *mp, int flags); +int vfs_write_suspend_umnt(struct mount *mp); int vop_stdbmap(struct vop_bmap_args *); int vop_stdfsync(struct vop_fsync_args *); int vop_stdgetwritemount(struct vop_getwritemount_args *); Modified: stable/10/sys/ufs/ffs/ffs_vfsops.c ============================================================================== --- stable/10/sys/ufs/ffs/ffs_vfsops.c Mon Jul 28 01:08:43 2014 (r269170) +++ stable/10/sys/ufs/ffs/ffs_vfsops.c Mon Jul 28 01:11:29 2014 (r269171) @@ -255,31 +255,9 @@ ffs_mount(struct mount *mp) */ if ((error = vn_start_write(NULL, &mp, V_WAIT)) != 0) return (error); - for (;;) { - vn_finished_write(mp); - if ((error = vfs_write_suspend(mp, 0)) != 0) - return (error); - MNT_ILOCK(mp); - if (mp->mnt_kern_flag & MNTK_SUSPENDED) { - /* - * Allow the secondary writes - * to proceed. - */ - mp->mnt_kern_flag &= ~(MNTK_SUSPENDED | - MNTK_SUSPEND2); - wakeup(&mp->mnt_flag); - MNT_IUNLOCK(mp); - /* - * Allow the curthread to - * ignore the suspension to - * synchronize on-disk state. - */ - td->td_pflags |= TDP_IGNSUSP; - break; - } - MNT_IUNLOCK(mp); - vn_start_write(NULL, &mp, V_WAIT); - } + error = vfs_write_suspend_umnt(mp); + if (error != 0) + return (error); /* * Check for and optionally get rid of files open * for writing. @@ -1250,25 +1228,9 @@ ffs_unmount(mp, mntflags) } #endif if (susp) { - /* - * dounmount already called vn_start_write(). - */ - for (;;) { - vn_finished_write(mp); - if ((error = vfs_write_suspend(mp, 0)) != 0) - return (error); - MNT_ILOCK(mp); - if (mp->mnt_kern_flag & MNTK_SUSPENDED) { - mp->mnt_kern_flag &= ~(MNTK_SUSPENDED | - MNTK_SUSPEND2); - wakeup(&mp->mnt_flag); - MNT_IUNLOCK(mp); - td->td_pflags |= TDP_IGNSUSP; - break; - } - MNT_IUNLOCK(mp); - vn_start_write(NULL, &mp, V_WAIT); - } + error = vfs_write_suspend_umnt(mp); + if (error != 0) + goto fail1; } if (MOUNTEDSOFTDEP(mp)) error = softdep_flushfiles(mp, flags, td); @@ -1331,6 +1293,7 @@ ffs_unmount(mp, mntflags) fail: if (susp) vfs_write_resume(mp, VR_START_WRITE); +fail1: #ifdef UFS_EXTATTR if (e_restart) { ufs_extattr_uepm_init(&ump->um_extattr);