From owner-freebsd-fs Sun Oct 13 0:14:27 2002 Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2F0CE37B401 for ; Sun, 13 Oct 2002 00:14:26 -0700 (PDT) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0DBED43E7B for ; Sun, 13 Oct 2002 00:14:25 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id RAA18524; Sun, 13 Oct 2002 17:14:16 +1000 Date: Sun, 13 Oct 2002 17:24:35 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Peter Godman Cc: freebsd-fs@FreeBSD.ORG Subject: Re: ufs_update and waitfor flag In-Reply-To: Message-ID: <20021013163315.F21287-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-fs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On Sat, 12 Oct 2002, Peter Godman wrote: > An application running on my system is doing basically: > > fd = open(file) > read(fd, ...) > fsync(fd) > close(fd) > > My root filesystem is mounted sync,noatime, but this sequence of > operations still results in a bwrite during fsync in ufs_update. This > seems to be the result of the following code in ufs_update: > > int > ffs_update(vp, waitfor) > struct vnode *vp; > int waitfor; > { > struct fs *fs; > struct buf *bp; > struct inode *ip; > int error; > > ufs_itimes(vp); > ip = VTOI(vp); > /* vvvvvvvvvvvv ?? */ > if ((ip->i_flag & IN_MODIFIED) == 0 && waitfor == 0) > return (0); > ip->i_flag &= ~(IN_LAZYMOD | IN_MODIFIED); > > ... > > The relevant part here is the "waitfor == 0" in the bailout check. Though > the flags on the inode do not indicate that the inode is modified, the > fact that we wish to wait for the operation to complete results a write > happening here that otherwise wouldn't have. Do other people read this > code the same way? Is this desired or expected behaviour? What would > happen if I commented out the check for waitfor == 0 at this > point? Anyone know why this check is there? Most likely I will modify > the application in question, but would like to know whether this code > should change too. The waitfor test was added in th first round of soft updates changes for reasons that I never completely understood. I vaguely remember that it is to get the DOINGSOFTDEP() case a little later in ffs_update() reached. I never liked this. It certainly seems to be wrong for fsync(2). ffs_fsync() is caled with waitfor set in that case, and we eventually write the inode even when it was perfectly clean. I'm fairly sure that you can remove the waitfor test in the !DOINGSOFTDEP() case. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-fs" in the body of the message