From owner-freebsd-fs@FreeBSD.ORG Wed May 18 23:24:30 2011 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 93F00106566B for ; Wed, 18 May 2011 23:24:30 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id E5F228FC14 for ; Wed, 18 May 2011 23:24:29 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id p4INOQ19046011 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 19 May 2011 02:24:26 +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.4/8.14.4) with ESMTP id p4INOPhW004185; Thu, 19 May 2011 02:24:25 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id p4INOPUw004184; Thu, 19 May 2011 02:24:25 +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, 19 May 2011 02:24:25 +0300 From: Kostik Belousov To: Rick Macklem Message-ID: <20110518232425.GX48734@deviant.kiev.zoral.com.ua> References: <20110517092011.GK48734@deviant.kiev.zoral.com.ua> <5718691.545130.1305751059426.JavaMail.root@erie.cs.uoguelph.ca> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="P33LUqzLXAslwFyJ" Content-Disposition: inline In-Reply-To: <5718691.545130.1305751059426.JavaMail.root@erie.cs.uoguelph.ca> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: FreeBSD FS Subject: Re: RFC: adding a lock flags argument to VFS_FHTOVP() for FreeBSD9 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: Wed, 18 May 2011 23:24:30 -0000 --P33LUqzLXAslwFyJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, May 18, 2011 at 04:37:39PM -0400, Rick Macklem wrote: > > Yes, the flag to specify the locking mode does only specify the > > minimal > > locking requirements, and filesystem is allowed to upgrade it to the > > more strict lock type. E.g. UFS would only return shared lock if the > > vnode was found in hash, AFAIR. If not told otherwise, getnewvnode(9) > > forces lockmgr to convert all lock requests into exclusive. > >=20 > That's exactly what UFS does, but I did notice some inconsistencies > w.r.t. the various file systems. >=20 > For VFS_VGET(), ffs/cd9660/udf do basically the following: > 1 error =3D vfs_hash_get(mp, ino, flags, curthread, vpp, NULL, NULL); > ... > 2 if ((flags & LK_TYPE_MASK) =3D=3D LK_SHARED) { > flags &=3D ~LK_TYPE_MASK; > flags |=3D LK_EXCLUSIVE; > } > ... > 3 lockmgr(vp->v_vnlock, LK_EXCLUSIVE, NULL); > ... > 4 error =3D vfs_hash_insert(vp, ino, flags, curthread, vpp, NULL, NULL); >=20 > but hpfs/ext2fs do something similar to the above, except > they omit step #2. (ie. They would do #4 with LK_SHARED, if > that was what flags is passed in as.) >=20 > Looking at vfs_hash_insert(), the "flags" argument is just > used for vget(), so it isn't obvious to me if it needs to > be LK_EXCLUSIVE or not. I would say that what ext2fs and hpfs trying to do is legitimate, since the caller expects to get only the lock specified in the flags. But, in fact, all locks for ext2fs and hpfs are exclusive, since as I said in the previous message, getnewvnode() initializes vnode lock for automatic converstion shared->exclusive, and ext2fs/hpfs do not override this. >=20 > So, does anyone know if this depend on the file system or are hpfs/ext2fs > broken? >=20 > Thanks in advance for any help with this, rick > ps: Fortunately, for my patch, I can just ignore the "flags" > argument for VFS_FHTOVP() for the file systems I'm not > sure about, so they'll just return LK_EXCLUSIVE locked > vnodes. >=20 --P33LUqzLXAslwFyJ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk3UVSkACgkQC3+MBN1Mb4j9PgCgpdZeYsOjTmCr7j9Bj87nTtKl /aAAoOdggCkJAm/feMdoMhOwIfifOefi =yn0L -----END PGP SIGNATURE----- --P33LUqzLXAslwFyJ--