From owner-freebsd-fs@freebsd.org Thu May 19 00:24:04 2016 Return-Path: Delivered-To: freebsd-fs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CE72AB4197B for ; Thu, 19 May 2016 00:24:04 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mailman.ysv.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id BAF191AD0 for ; Thu, 19 May 2016 00:24:04 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: by mailman.ysv.freebsd.org (Postfix) id B6508B41979; Thu, 19 May 2016 00:24:04 +0000 (UTC) Delivered-To: fs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B5FD1B41978 for ; Thu, 19 May 2016 00:24:04 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail104.syd.optusnet.com.au (mail104.syd.optusnet.com.au [211.29.132.246]) by mx1.freebsd.org (Postfix) with ESMTP id 55E6F1ACE for ; Thu, 19 May 2016 00:24:03 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from c122-106-149-109.carlnfd1.nsw.optusnet.com.au (c122-106-149-109.carlnfd1.nsw.optusnet.com.au [122.106.149.109]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id C8019425632; Thu, 19 May 2016 10:23:54 +1000 (AEST) Date: Thu, 19 May 2016 10:23:54 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Bruce Evans cc: Konstantin Belousov , fs@freebsd.org Subject: Re: fix for per-mount i/o counting in ffs In-Reply-To: <20160519065714.H1393@besplex.bde.org> Message-ID: <20160519094901.O1798@besplex.bde.org> References: <20160517072104.I2137@besplex.bde.org> <20160517084241.GY89104@kib.kiev.ua> <20160518061040.D5948@besplex.bde.org> <20160518070252.F6121@besplex.bde.org> <20160517220055.GF89104@kib.kiev.ua> <20160518084931.T6534@besplex.bde.org> <20160518110834.GJ89104@kib.kiev.ua> <20160519065714.H1393@besplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=TuMb/2jh c=1 sm=1 tr=0 a=R/f3m204ZbWUO/0rwPSMPw==:117 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=o_ISSmQlpySo1G4zfAAA:9 a=CjuIK1q_8ugA:10 X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 May 2016 00:24:04 -0000 On Thu, 19 May 2016, Bruce Evans wrote: > ... > I think the following works to prevent multiple mounts via all of the > known buggy paths: early in every fsmount(): > > dev = devvp->v_rdev; > if (dev->si_mountpt != NULL) { > cleanup(); > return (EBUSY); > } > dev->si_mountpt = mp; > > This also prevents other mounts racing with us before we complete. Too > bad if we fail but the other mount would have succeeded. In fsunmount(), > move clearing si_mountpt to near the end. I hope si_mountpt is locked > by the device reference and that this makes si_mountpt robust enough to > use as an exclusive access flag. Nah, the reference is not a lock. This needs dev_lock() or similar to be robust. struct cdef has no documented locking, bug dev_lock() should work and is probably needed for writes. It is never used for accesses to si_mountpt now. Reads are safe enough since the are of the form 'mp = dev->si_mountpt; if (mp == NULL) dont_use_mp();'. Bruce