From owner-svn-src-stable-9@FreeBSD.ORG Wed Apr 11 04:57:12 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 255211065672; Wed, 11 Apr 2012 04:57:12 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0E4468FC12; Wed, 11 Apr 2012 04:57:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3B4vBsr055417; Wed, 11 Apr 2012 04:57:11 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3B4vB7D055415; Wed, 11 Apr 2012 04:57:11 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201204110457.q3B4vB7D055415@svn.freebsd.org> From: Konstantin Belousov Date: Wed, 11 Apr 2012 04:57:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234119 - stable/9/sys/ufs/ffs X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Apr 2012 04:57:12 -0000 Author: kib Date: Wed Apr 11 04:57:11 2012 New Revision: 234119 URL: http://svn.freebsd.org/changeset/base/234119 Log: MFC r233609, r233610: Restore the writes of atimes, quotas and superblock from syncer vnode. Modified: stable/9/sys/ufs/ffs/ffs_vfsops.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/ufs/ffs/ffs_vfsops.c ============================================================================== --- stable/9/sys/ufs/ffs/ffs_vfsops.c Wed Apr 11 02:42:01 2012 (r234118) +++ stable/9/sys/ufs/ffs/ffs_vfsops.c Wed Apr 11 04:57:11 2012 (r234119) @@ -80,6 +80,8 @@ static int ffs_mountfs(struct vnode *, s static void ffs_oldfscompat_read(struct fs *, struct ufsmount *, ufs2_daddr_t); static void ffs_ifree(struct ufsmount *ump, struct inode *ip); +static int ffs_sync_lazy(struct mount *mp); + static vfs_init_t ffs_init; static vfs_uninit_t ffs_uninit; static vfs_extattrctl_t ffs_extattrctl; @@ -1411,11 +1413,77 @@ ffs_statfs(mp, sbp) } /* + * For a lazy sync, we only care about access times, quotas and the + * superblock. Other filesystem changes are already converted to + * cylinder group blocks or inode blocks updates and are written to + * disk by syncer. + */ +static int +ffs_sync_lazy(mp) + struct mount *mp; +{ + struct vnode *mvp, *vp; + struct inode *ip; + struct thread *td; + int allerror, error; + + allerror = 0; + td = curthread; + if ((mp->mnt_flag & MNT_NOATIME) != 0) + goto qupdate; + MNT_ILOCK(mp); + MNT_VNODE_FOREACH(vp, mp, mvp) { + VI_LOCK(vp); + if (vp->v_iflag & VI_DOOMED || vp->v_type == VNON) { + VI_UNLOCK(vp); + continue; + } + ip = VTOI(vp); + + /* + * The IN_ACCESS flag is converted to IN_MODIFIED by + * ufs_close() and ufs_getattr() by the calls to + * ufs_itimes_locked(), without subsequent UFS_UPDATE(). + * Test also all the other timestamp flags too, to pick up + * any other cases that could be missed. + */ + if ((ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_MODIFIED | + IN_UPDATE)) == 0) { + VI_UNLOCK(vp); + continue; + } + MNT_IUNLOCK(mp); + if ((error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, + td)) != 0) { + MNT_ILOCK(mp); + continue; + } + error = ffs_update(vp, 0); + if (error != 0) + allerror = error; + vput(vp); + MNT_ILOCK(mp); + } + MNT_IUNLOCK(mp); + +qupdate: +#ifdef QUOTA + qsync(mp); +#endif + + if (VFSTOUFS(mp)->um_fs->fs_fmod != 0 && + (error = ffs_sbupdate(VFSTOUFS(mp), MNT_LAZY, 0)) != 0) + allerror = error; + return (allerror); +} + +/* * Go through the disk queues to initiate sandbagged IO; * go through the inodes to write those that have been modified; * initiate the writing of the super block if it has been modified. * - * Note: we are always called with the filesystem marked `MPBUSY'. + * Note: we are always called with the filesystem marked busy using + * vfs_busy(). */ static int ffs_sync(mp, waitfor) @@ -1444,15 +1512,9 @@ ffs_sync(mp, waitfor) if (fs->fs_fmod != 0 && fs->fs_ronly != 0 && ump->um_fsckpid == 0) panic("%s: ffs_sync: modification on read-only filesystem", fs->fs_fsmnt); - /* - * For a lazy sync, we just care about the filesystem metadata. - */ - if (waitfor == MNT_LAZY) { - secondary_accwrites = 0; - secondary_writes = 0; - lockreq = 0; - goto metasync; - } + if (waitfor == MNT_LAZY) + return (ffs_sync_lazy(mp)); + /* * Write back each (modified) inode. */ @@ -1527,7 +1589,6 @@ loop: qsync(mp); #endif -metasync: devvp = ump->um_devvp; bo = &devvp->v_bufobj; BO_LOCK(bo);