From owner-freebsd-fs@FreeBSD.ORG Thu Jul 12 14:21:41 2007 Return-Path: X-Original-To: fs@freebsd.org Delivered-To: freebsd-fs@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D32AD16A400; Thu, 12 Jul 2007 14:21:41 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from relay02.kiev.sovam.com (relay02.kiev.sovam.com [62.64.120.197]) by mx1.freebsd.org (Postfix) with ESMTP id 213E913C457; Thu, 12 Jul 2007 14:21:41 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from [89.162.146.170] (helo=skuns.kiev.zoral.com.ua) by relay02.kiev.sovam.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.67) (envelope-from ) id 1I8zY2-000GLx-0K; Thu, 12 Jul 2007 17:21:39 +0300 Received: from deviant.kiev.zoral.com.ua (root@[10.1.1.148]) by skuns.kiev.zoral.com.ua (8.14.1/8.14.1) with ESMTP id l6CELSnv098428 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 12 Jul 2007 17:21:28 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.1/8.14.1) with ESMTP id l6CELSVh025819; Thu, 12 Jul 2007 17:21:28 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.1/8.14.1/Submit) id l6CELRK5025818; Thu, 12 Jul 2007 17:21:27 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 12 Jul 2007 17:21:27 +0300 From: Kostik Belousov To: Bruce Evans Message-ID: <20070712142127.GD2200@deviant.kiev.zoral.com.ua> References: <20070710233455.O2101@besplex.bde.org> <20070712084115.GA2200@deviant.kiev.zoral.com.ua> <20070712225324.F9515@besplex.bde.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="QQBmthHSezQuldOP" Content-Disposition: inline In-Reply-To: <20070712225324.F9515@besplex.bde.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: ClamAV version 0.90.3, clamav-milter version 0.90.3 on skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=0.6 required=5.0 tests=ALL_TRUSTED, DNS_FROM_AHBL_RHSBL autolearn=no version=3.2.1 X-Spam-Checker-Version: SpamAssassin 3.2.1 (2007-05-02) on skuns.kiev.zoral.com.ua X-Scanner-Signature: 3f6c5f504711b4b2e39067d20b60c9d6 X-DrWeb-checked: yes X-SpamTest-Envelope-From: kostikbel@gmail.com X-SpamTest-Group-ID: 00000000 X-SpamTest-Header: Not Detected X-SpamTest-Info: Profiles 1214 [July 12 2007] X-SpamTest-Info: helo_type=3 X-SpamTest-Method: none X-SpamTest-Rate: 0 X-SpamTest-Status: Not detected X-SpamTest-Status-Extended: not_detected X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0255], KAS30/Release Cc: bugs@freebsd.org, fs@freebsd.org Subject: Re: msdosfs not MPSAFE X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jul 2007 14:21:41 -0000 --QQBmthHSezQuldOP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 12, 2007 at 11:33:40PM +1000, Bruce Evans wrote: >=20 >=20 > On Thu, 12 Jul 2007, Kostik Belousov wrote: >=20 > >On Wed, Jul 11, 2007 at 12:08:19AM +1000, Bruce Evans wrote: > >>msdsofs has been broken since Giant locking for file systems (or syscal= ls) > >>was removed. It allows multiple threads to race accessing the shared > >>static buffer `nambuf' and related variables. This causes remarkably >=20 > >>[Add Giant locking] >=20 > >>Please fix this better. mbnambuf_init() could return a non-static buff= er > >>that doesn't require locking. Deallocation would be painful. Note that > >>even the details for Giant locking can't be hidden in msdosfs_conv.c li= ke > >>the current interfaces intend, since mbnambuf_init() is used a lot to > >>reinitialize an in-use buffer, and there is no interface to drop usage. >=20 > >It seems that msdosfs_lookup() can sleep, thus Giant protection would be > >lost. >=20 > It can certainly block in bread(). Besides bread(), there is a (re)locking for ".." case, and deget() call, that itself calls malloc(M_WAITOK), vfs_hash_get(), getnewvnode() and readep(). The latter itself calls bread(). This is from the brief look. >=20 > I now think this is not really an SMP bug. The nambuf* data structure > requires a long-term global lock, but it has never had one. The bug > seems to be relatively new. nambuf* is for multi-byte characters, not > for long names, and has only existed since 2003 (msdosfs_vnops.c 1.141, > etc.). I thought that long names were built up in nambuf, but they > are apparently built up in the directory entry. This should work for > multi-byte characters too -- don't translate anything until all the low- > level directory entries have been accumulated. >=20 > How does my adding Giant locking help? I checked that at least in > FreeBSD-~5.2-current, msdosfs_readdir() is already Giant-locked, so my > fix just increments the recursion count. What happens to recursively- > held Giant locks across sleeps? I think they should cause a KASSERT() > failure, but if they are handled by only dropping Giant once then my > fix might sort of work but sleeps would be broken generally. >=20 Look at the kern/kern_sync.c:_sleep(). It does DROP_GIANT(), that (from the sys/mutex.h) calls mtx_unlock() until Giant is owned. --QQBmthHSezQuldOP Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (FreeBSD) iD8DBQFGljjmC3+MBN1Mb4gRAkMNAJwKu64+eN4bOF0xcIFEF4UjNIenuQCfVAP7 CpnkfmWcpcpbNRPidZxWAtk= =WeyX -----END PGP SIGNATURE----- --QQBmthHSezQuldOP--