[4166] in arla-drinkers
Re: Arla on FreeBSD
daemon@ATHENA.MIT.EDU (Kostik Belousov)
Thu Feb 15 05:46:10 2007
From arla-drinkers-bounces@stacken.kth.se Thu Feb 15 10:46:10 2007
Return-Path: <arla-drinkers-bounces@stacken.kth.se>
Delivered-To: arla-drinkers-mtg@bloom-picayune.mit.edu
Received: (qmail 23117 invoked from network); 15 Feb 2007 10:46:09 -0000
Received: from mx2.kth.se (130.237.48.98)
by charon.mit.edu with SMTP; 15 Feb 2007 10:46:09 -0000
Received: from localhost (localhost.localdomain [127.0.0.1])
by mx2.kth.se (Postfix) with ESMTP id 36D56140736;
Thu, 15 Feb 2007 11:46:09 +0100 (CET)
Received: from mx2.kth.se ([127.0.0.1])
by localhost (mx2.kth.se [127.0.0.1]) (amavisd-new, port 10024) with LMTP
id 18070-01-80; Thu, 15 Feb 2007 11:46:07 +0100 (CET)
Received: from tapas.stacken.kth.se (tapas.stacken.kth.se [130.237.234.140])
by mx2.kth.se (Postfix) with ESMTP id CC82C14075D;
Thu, 15 Feb 2007 11:46:05 +0100 (CET)
Received: from tapas.stacken.kth.se (localhost [127.0.0.1])
by tapas.stacken.kth.se (Postfix) with ESMTP id 3C0A85350F;
Thu, 15 Feb 2007 11:46:05 +0100 (CET)
X-Original-To: arla-drinkers@tapas.stacken.kth.se
Delivered-To: arla-drinkers@tapas.stacken.kth.se
Received: from brev.stacken.kth.se (brev.stacken.kth.se [130.237.234.84])
by tapas.stacken.kth.se (Postfix) with ESMTP id E4F455350F
for <arla-drinkers@tapas.stacken.kth.se>;
Thu, 15 Feb 2007 11:46:02 +0100 (CET)
Received: from mx1.kth.se (mx1.kth.se [130.237.32.140])
by brev.stacken.kth.se (8.12.10/8.12.10) with ESMTP id l1FAk2OA005131
for <arla-drinkers@stacken.kth.se>;
Thu, 15 Feb 2007 11:46:02 +0100 (MET)
Received: from localhost (localhost.localdomain [127.0.0.1])
by mx1.kth.se (Postfix) with ESMTP id 0C16214064D
for <arla-drinkers@stacken.kth.se>;
Thu, 15 Feb 2007 11:46:02 +0100 (CET)
Received: from mx1.kth.se ([127.0.0.1])
by localhost (mx1.kth.se [127.0.0.1]) (amavisd-new,
port 10024) with LMTP
id 10510-01-80 for <arla-drinkers@stacken.kth.se>;
Thu, 15 Feb 2007 11:45:59 +0100 (CET)
Received: from fw.zoral.com.ua (fw.zoral.com.ua [213.186.206.134])
by mx1.kth.se (Postfix) with ESMTP id 12383140531
for <arla-drinkers@stacken.kth.se>;
Thu, 15 Feb 2007 11:45:58 +0100 (CET)
Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua
[10.1.1.148])
by fw.zoral.com.ua (8.13.4/8.13.4) with ESMTP id l1FAjchC098938
(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
Thu, 15 Feb 2007 12:45:38 +0200 (EET)
(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.13.8/8.13.8) with ESMTP id
l1FAjcPK084447; Thu, 15 Feb 2007 12:45:38 +0200 (EET)
(envelope-from kostikbel@gmail.com)
Received: (from kostik@localhost)
by deviant.kiev.zoral.com.ua (8.13.8/8.13.8/Submit) id l1FAjbrR084446;
Thu, 15 Feb 2007 12:45:38 +0200 (EET)
(envelope-from kostikbel@gmail.com)
X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to
kostikbel@gmail.com using -f
Date: Thu, 15 Feb 2007 12:45:37 +0200
From: Kostik Belousov <kostikbel@gmail.com>
To: Tomas Olsson <tol@it.su.se>
Subject: Re: Arla on FreeBSD
Message-ID: <20070215104537.GC39168@deviant.kiev.zoral.com.ua>
References: <6FC9F9894A9F8C49A722CF9F2132FC2204C9DAB6@ms05.mailstreet2003.net>
<45D1F30A.6080403@freebsd.org> <eqsut3$6a3$1@sea.gmane.org>
<20070213192906.U726@chrishome.localnet>
<20070214162938.GA96725@keira.kiwi-computer.com>
<20070214173211.L1054@chrishome.localnet>
<20070214170808.GC96725@keira.kiwi-computer.com>
<lsrvei45pq1.fsf@kashyyyk.ite.kth.se>
<20070215044707.GA39168@deviant.kiev.zoral.com.ua>
<lsrmz3f680v.fsf_-_@kashyyyk.ite.kth.se>
Mime-Version: 1.0
In-Reply-To: <lsrmz3f680v.fsf_-_@kashyyyk.ite.kth.se>
User-Agent: Mutt/1.4.2.2i
X-Virus-Scanned: ClamAV version 0.88.7,
clamav-milter version 0.88.7 on fw.zoral.com.ua
X-Virus-Status: Clean
X-Spam-Status: No, score=-0.1 required=5.0 tests=ALL_TRUSTED,SPF_NEUTRAL
autolearn=failed version=3.1.7
X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on fw.zoral.com.ua
X-Virus-Scanned: by amavisd-new at kth.se
X-Spam-Status: No, hits=-4.9 tagged_above=-200.0 required=5.0 tests=BAYES_00
X-Spam-Level:
Cc: freebsd-fs@freebsd.org, arla-drinkers@stacken.kth.se
X-BeenThere: arla-drinkers@stacken.kth.se
X-Mailman-Version: 2.1.6
Precedence: list
List-Id: Arla discussions <arla-drinkers.stacken.kth.se>
List-Unsubscribe: <https://lists.stacken.kth.se/mailman/listinfo/arla-drinkers>,
<mailto:arla-drinkers-request@stacken.kth.se?subject=unsubscribe>
List-Archive: <http://lists.stacken.kth.se/pipermail/arla-drinkers>
List-Post: <mailto:arla-drinkers@stacken.kth.se>
List-Help: <mailto:arla-drinkers-request@stacken.kth.se?subject=help>
List-Subscribe: <https://lists.stacken.kth.se/mailman/listinfo/arla-drinkers>,
<mailto:arla-drinkers-request@stacken.kth.se?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============1175765769=="
Sender: arla-drinkers-bounces@stacken.kth.se
Errors-To: arla-drinkers-bounces@stacken.kth.se
X-Virus-Scanned: by amavisd-new at kth.se
--===============1175765769==
Content-Type: multipart/signed; micalg=pgp-sha1;
protocol="application/pgp-signature"; boundary="p2kqVDKq5asng8Dg"
Content-Disposition: inline
--p2kqVDKq5asng8Dg
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Thu, Feb 15, 2007 at 11:16:00AM +0100, Tomas Olsson wrote:
> Kostik Belousov <kostikbel@gmail.com> writes:
> > > I'm already funded and can work full time on this, but a FreeBSD hack=
er
> > > would help a lot. Any volunteers?
> >=20
> > Sorry for me pointing out obvious, why not continue to use fs@ as place
> > where to ask ?
> >
> You're very right, I'm just to shy to do it... Thanks.
>=20
> Anyway;
>=20
> Arla is built around a "small" caching fs driver (nnpfs) servicing user
> requests by asking the 'arlad' daemon for help or just operating on local
> files created/fetched by arlad. They communicate over a char device.
>=20
> A simple read would be handled as such:
> getnode/getdata rpc to arlad
> installnode/installdata + wakeup msgs from arlad
> VOP_READ() on newly fetched cache file
>=20
> Subsequent reads on the same data would skip the rpc part, unless arlad h=
as
> invalidated the node.
>=20
> Previously, there was a 1:1 mapping between nnpfs vnode and cache file. T=
he
> installdata message was then handled by fetching the cache file's vnode (=
in
> arlad's context), storing it in the nnpfs_node for future reference/acces=
s.
> Now we ended up with one cache file per "block" (large) of data, and
> decided that it would be better to open/access/close the cache "block" fi=
le
> on each access. The closest we could get to the olden ways was to open t=
he
> directory where a node's cache blocks reside, in arlad's context.
>=20
> The interesting part is how we open and access the cache files, and from
> what context. arlad is in chroot() to avoid recursive lookups across /, a=
nd
> it seems like a good idea to avoid such lookups now too.
>=20
> So the main question is how to properly do VOP_{LOOKUP,CREATE,WRITE} etc =
on
> cache files in this dual context world, without mixing identities in bad
> ways or confusing the OS too much.
>=20
> The currently messed up code lives in
> http://cvsweb.stacken.kth.se/cvsweb.cgi/arla/nnpfs/bsd/
>=20
> Most interesting is nnpfs_vnodeops-common.c (nnpfs_write_common()) and
> nnpfs_blocks.c (open_file())
I made really quick look at the places you mentioned. I have some
comment for open_file(). For FreeBSD >=3D 6.x, the right way to open vnode
from the kernel code is to use vn_open() (and then vn_close()) API.
Something along the lines (this is for already existing file):
td =3D curthread;
NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_USERSPACE, fname, td);
flags =3D FREAD | FWRITE;
error =3D vn_open(&nd, &flags, 0, -1);
if (error)
return (error);
vfslocked =3D NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
vp =3D nd.ni_vp;
vp is now locked, shall be unlocked by VOP_UNLOCK() before returning to
usermode. Giant is conditionally locked based on MP-safeness of the fs vp
belongs to. When Giant-protected region shall be leaved, use
VFS_UNLOCK_GIANT(vfslocked);
To close the vnode, use
vn_close(vp, FREAD|FWRITE, td->td_ucred, td);
See, for instance, kern/kern_ktrace.c, ufs/ufs/ufs_quota.c or
security/audit/audit_syscalls.c for real code that does this.
--p2kqVDKq5asng8Dg
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (FreeBSD)
iD8DBQFF1DnRC3+MBN1Mb4gRAiqAAKCSlzaxnV3rWWufc/oKuB54/U0/sgCg3gY0
jAtwlMRvtskEz0U0iWUVkuA=
=jnpE
-----END PGP SIGNATURE-----
--p2kqVDKq5asng8Dg--
--===============1175765769==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Arla-drinkers mailing list
Arla-drinkers@stacken.kth.se
https://lists.stacken.kth.se/mailman/listinfo/arla-drinkers
--===============1175765769==--