From owner-freebsd-fs@FreeBSD.ORG Mon Nov 8 18:00:35 2010 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 144271065673; Mon, 8 Nov 2010 18:00:35 +0000 (UTC) (envelope-from gleb.kurtsou@gmail.com) Received: from mail-bw0-f54.google.com (mail-bw0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id 6797D8FC18; Mon, 8 Nov 2010 18:00:34 +0000 (UTC) Received: by bwz3 with SMTP id 3so5134163bwz.13 for ; Mon, 08 Nov 2010 10:00:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=umDWEwINQ2QVEKnfcknVxs77tOY/6h8O7vg+W2V2o+E=; b=wwcR35J9uSsP0o3UJhgBZRFKTLJepY8bKGhpZ9m9yyq5fbhMaT+t4KqbMaraDB0QS3 O8ek0BlF9OhEgzlEAi6vJySDAemQOJ+bsge0ThmW2WXVbaN84pO/q21SQpILLnAgw9pS xfOSFhz4limUZzrSK5YeuVpeOBHmLMT4fWoS8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=XTNB99wqrByXu2Kh8E98jTiKx2M5iMg5XCNLXL20UFG1WnFKJOimOO9QnB6Vd7ANVm wydXOJJYq0VfSrzFVfn1fwLevTolImus0p75wcFWtRguxYqPREtynFg/2I1qIPkJDng8 JEdt8A+GvpC+aqVuDpWZI6qiGytBn3ctOdios= Received: by 10.204.120.136 with SMTP id d8mr5093014bkr.152.1289239233254; Mon, 08 Nov 2010 10:00:33 -0800 (PST) Received: from localhost ([91.187.5.20]) by mx.google.com with ESMTPS id v25sm148936bkt.18.2010.11.08.10.00.31 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 08 Nov 2010 10:00:32 -0800 (PST) Date: Mon, 8 Nov 2010 20:00:28 +0200 From: Gleb Kurtsou To: Aditya Sarawgi Message-ID: <20101108180028.GA3964@tops> References: <20101108143130.GA2799@tops> <20101108172136.GA2066@earth> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20101108172136.GA2066@earth> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-fs@freebsd.org, Ivan Voras Subject: Re: The state of Giant lock in the file systems? 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: Mon, 08 Nov 2010 18:00:35 -0000 On (08/11/2010 22:51), Aditya Sarawgi wrote: > On Mon, Nov 08, 2010 at 04:31:30PM +0200, Gleb Kurtsou wrote: > > On (08/11/2010 13:28), Ivan Voras wrote: > > > I was looking at fusefs sources and there is a dance it does with the > > > Giant lock which looks fishy. > > It's intended to be fishy. No kernel level locks should be held before > > returning to userland, in other words on each syscall vnode is locked (+ > > Gaint lock for fs if needed), than it's unlocked by filesystem and > > relocked upon callback from userspace. puffs is MPSAFE if that could be > > of any help for you. > > > > > Grepping for "-ir giant" in /sys/fs on 8-stable shows only a handful of > > > mentionings, but if I understand it correctly only these "active" instances: > > > > > > 1) one set of mtx_assert() calls on it in pseudofs, which I can't figure > > > out what they're guarding > > > 2) some manual locking and unlocking in nfsclient which appears to only > > > guard printf() (???) > > Somewhat unrelated, but. Does NFS client unlock vnodes while > > sending/waiting for RCP reply? I thought it does, but I'm not sure. > > > > > 3) some more locking in nfsserver which apparently is only there to > > > guard the underlying local file system > > > 4) coda, which appears to be the only one marked with D_NEEDGIANT, but > > > doesn't do much of its own interfacing with it > > > > > > Except for these, is there any more magic that would need to be resolved > > > to excise Giant from VFS? > > Kostik was working on it. > > > > > Would it be correct to think that coda is the single biggest obstacle? > > Filesystem should be marked as MPSAFE, it's not D_NEEDGIANT flag but > > MNTK_MPSAFE. A lot of filesystems are still locked by Gaint, i.e ext2fs, > > smbfs, nwfs, ntfs, etc. > > > > ext2fs on 9-CURRENT is MPSAFE. Didn't check it for a while, sorry. But there's a deadlock in ext2_rename, it doesn't following vnode locking order (parent -> child) by doing vn_lock(fvp). The problem can't be fixed in a generic way at the moment, the best solution would probably be to follow UFS and unlock all vnodes, lock one-by-one and relookup. The same applies to tmpfs.