From owner-freebsd-current Sat Jul 14 19:17:19 2001 Delivered-To: freebsd-current@freebsd.org Received: from sneakerz.org (sneakerz.org [216.33.66.254]) by hub.freebsd.org (Postfix) with ESMTP id 4AB0F37B401; Sat, 14 Jul 2001 19:17:16 -0700 (PDT) (envelope-from bright@sneakerz.org) Received: by sneakerz.org (Postfix, from userid 1092) id EA8DB5D010; Sat, 14 Jul 2001 21:17:15 -0500 (CDT) Date: Sat, 14 Jul 2001 21:17:15 -0500 From: Alfred Perlstein To: Seigo Tanimura Cc: jake@FreeBSD.org, jhb@FreeBSD.org, current@FreeBSD.org Subject: Re: Lock of struct filedesc, file, pgrp, session and sigio Message-ID: <20010714211715.E15299@sneakerz.org> References: <200107020812.f628CfK44241@rina.r.dl.itc.u-tokyo.ac.jp> <20010707164249.C88962@sneakerz.org> <20010709032044.B1894@sneakerz.org> <200107100845.f6A8jqt99404@rina.r.dl.itc.u-tokyo.ac.jp> <20010710035347.Q1894@sneakerz.org> <200107100903.f6A93et02367@rina.r.dl.itc.u-tokyo.ac.jp> <200107111137.f6BBbQt22812@rina.r.dl.itc.u-tokyo.ac.jp> <20010713042504.O6664@sneakerz.org> <200107131049.f6DAnPt95755@rina.r.dl.itc.u-tokyo.ac.jp> <200107131200.f6DC0Pt05497@rina.r.dl.itc.u-tokyo.ac.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: <200107131200.f6DC0Pt05497@rina.r.dl.itc.u-tokyo.ac.jp>; from tanimura@r.dl.itc.u-tokyo.ac.jp on Fri, Jul 13, 2001 at 09:00:25PM +0900 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG * Seigo Tanimura [010713 07:00] wrote: > On Fri, 13 Jul 2001 19:49:25 +0900, > Seigo Tanimura said: > > Alfred> Certain operations, such as: > Alfred> kq = (struct kqueue *)fp->f_data; > Alfred> should not really require that the file be locked, it's implicitly frozen > Alfred> at creation time (i think) > > Seigo> Yes. > > Only one exception beats off everything. union_dircheck() in > fs/unionfs/union_subr.c may replace f_data with a new vnode. That code really scared me, but on careful inspection, the f_data is actually protected by the vnode exclusive lock from concurrant getdirentries() calls. (getdirentries() calls union_dircheck()) The code is still troublesome for mixing read() and getdirentries() at the same time, but since union mounts are rare we should leave it along and possibly revisit this later. My opinion is that you never need a lock for an assignment, unless that assignment spans multiple dependant operations or is dependant on some pre-condition, cases: /* no lock */ foo->a = 5; /* needs lock */ if (foo->b) foo->a = 5; /* might need lock to protect agianst inconsistant view */ foo->a = 5; foo->b = c; -- -Alfred Perlstein [alfred@freebsd.org] Ok, who wrote this damn function called '??'? And why do my programs keep crashing in it? To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message