[OpenAFS-devel] Re: Some doubts with Kernel Module data structures

Sanket Agarwal sanket@sanketagarwal.com
Mon, 24 May 2010 15:53:03 +0200


--00c09f88d1641852c80487575c93
Content-Type: text/plain; charset=ISO-8859-1

Okay, thanks for that help! It made reading the code easier.
But I continue with my doubts:

In lines in file src/afs/VNOPS/afs_vnop_read.c or
src/afs/VNOPS/afs_vnop_write.c I am unable to track the macros for VNOP_READ
and VNOP_WRITE. I do find some traces in IRIX/osi_vfs.h but that does not
really helps.

----------------------------------
#ifdef AFS_SUN510_ENV
    {
        caller_context_t ct;

        VOP_RWLOCK(tfile->vnode, 1, &ct);
        code = VOP_WRITE(tfile->vnode, &tuio, 0, afs_osi_credp, &ct);
        VOP_RWUNLOCK(tfile->vnode, 1, &ct);
    }
-----------------------------------

>From what I undestand this part does the OS dependent read from cache to
memory and write to cache from memory.

Cheers
Sanket


On Sat, May 22, 2010 at 9:27 PM, Andrew Deason <adeason@sinenomine.net>wrote:

> On Sat, 22 May 2010 12:34:06 -0400 (EDT)
> "Matt W. Benjamin" <matt@linuxbox.com> wrote:
>
> > ----- "Sanket Agarwal" <sanket@sanketagarwal.com> wrote:
> >
> > > I am looking into the core data structures of OpenAFS kernel module
> > > for clients, of which I find that struct dcache and struct fcache
> > > will be most important. I wish to ask you a few questions here:
> >
> > struct vcache
>
> I found this a bit confusing when I first looked at it, so a little more
> info... a vnode is the OS' filesystem-agnostic in-memory representation
> of a file. A vcache is the OpenAFS module's in-memory representation of
> a file. You can get a vnode from a vcache and a vcache from an AFS vnode
> a couple of different ways, depending on what the client OS is. That's
> what AFSTOV and VTOAFS are for.
>
> > > and is this chunk size same as that of Page size of pages in the
> > > memory(which the kernel will ultimately load as pages in the
> > > memory).
> >
> > no, typically a chunk is 64k, but you can set an alternate chunk size
> > when the cm is started, see AFSD(8)
>
> Default chunk sizes for a disk cache ranges from 256K to 1M, depending
> on the size of the cache. For caches smaller than around 500M, the
> chunksize is 256K; smaller than 1G and it's 512K. Larger and it's 1M.
>
> For memcache the default is 8k.
>
> > > 3. What is the role played by the structure struct fcache, what does
> > > it point to ?
> >
> > I'm not a dcache expert, but cribbing from the code, it looks as if
> > an fcache is involved with representing chunks in the cm's persistent
> > file cache
> >
> > > 4. I see that dcache is stored in the memory but fcache is disk
> > > saved on disk( where , along with the afs cache ?) And why such a
> > > decision.
>
> The CacheItems file is made up of a bunch of 'struct fcache's (each one
> representing a chunk, as Matt says). We need to save some information
> about each chunk to disk, so we can find them again. So when a client
> restarts and asks for file X chunk Y, we can find where that chunk is in
> the cache.
>
> --
> Andrew Deason
> adeason@sinenomine.net
>
> _______________________________________________
> OpenAFS-devel mailing list
> OpenAFS-devel@openafs.org
> https://lists.openafs.org/mailman/listinfo/openafs-devel
>

--00c09f88d1641852c80487575c93
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Okay, thanks for that help! It made reading the code easier.<br>But I conti=
nue with my doubts:<br><br>In lines in file src/afs/VNOPS/afs_vnop_read.c o=
r src/afs/VNOPS/afs_vnop_write.c I am unable to track the macros for VNOP_R=
EAD and VNOP_WRITE. I do find some traces in IRIX/osi_vfs.h but that does n=
ot really helps.<br>
<br>----------------------------------<br>#ifdef AFS_SUN510_ENV<br>=A0=A0=
=A0 {<br>=A0=A0=A0 =A0=A0=A0 caller_context_t ct;<br><br>=A0=A0=A0 =A0=A0=
=A0 VOP_RWLOCK(tfile-&gt;vnode, 1, &amp;ct);<br>=A0=A0=A0 =A0=A0=A0 code =
=3D VOP_WRITE(tfile-&gt;vnode, &amp;tuio, 0, afs_osi_credp, &amp;ct);<br>
=A0=A0=A0 =A0=A0=A0 VOP_RWUNLOCK(tfile-&gt;vnode, 1, &amp;ct);<br>=A0=A0=A0=
 }<br>-----------------------------------<br><br>From what I undestand this=
 part does the OS dependent read from cache to memory and write to cache fr=
om memory.<br>
<br>Cheers<br>Sanket<br><br><br><div class=3D"gmail_quote">On Sat, May 22, =
2010 at 9:27 PM, Andrew Deason <span dir=3D"ltr">&lt;<a href=3D"mailto:adea=
son@sinenomine.net">adeason@sinenomine.net</a>&gt;</span> wrote:<br><blockq=
uote class=3D"gmail_quote" style=3D"margin: 0pt 0pt 0pt 0.8ex; border-left:=
 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class=3D"im">On Sat, 22 May 2010 12:34:06 -0400 (EDT)<br>
&quot;Matt W. Benjamin&quot; &lt;<a href=3D"mailto:matt@linuxbox.com">matt@=
linuxbox.com</a>&gt; wrote:<br>
<br>
&gt; ----- &quot;Sanket Agarwal&quot; &lt;<a href=3D"mailto:sanket@sanketag=
arwal.com">sanket@sanketagarwal.com</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt; I am looking into the core data structures of OpenAFS kernel modu=
le<br>
&gt; &gt; for clients, of which I find that struct dcache and struct fcache=
<br>
&gt; &gt; will be most important. I wish to ask you a few questions here:<b=
r>
&gt;<br>
&gt; struct vcache<br>
<br>
</div>I found this a bit confusing when I first looked at it, so a little m=
ore<br>
info... a vnode is the OS&#39; filesystem-agnostic in-memory representation=
<br>
of a file. A vcache is the OpenAFS module&#39;s in-memory representation of=
<br>
a file. You can get a vnode from a vcache and a vcache from an AFS vnode<br=
>
a couple of different ways, depending on what the client OS is. That&#39;s<=
br>
what AFSTOV and VTOAFS are for.<br>
<div class=3D"im"><br>
&gt; &gt; and is this chunk size same as that of Page size of pages in the<=
br>
&gt; &gt; memory(which the kernel will ultimately load as pages in the<br>
&gt; &gt; memory).<br>
&gt;<br>
&gt; no, typically a chunk is 64k, but you can set an alternate chunk size<=
br>
&gt; when the cm is started, see AFSD(8)<br>
<br>
</div>Default chunk sizes for a disk cache ranges from 256K to 1M, dependin=
g<br>
on the size of the cache. For caches smaller than around 500M, the<br>
chunksize is 256K; smaller than 1G and it&#39;s 512K. Larger and it&#39;s 1=
M.<br>
<br>
For memcache the default is 8k.<br>
<div class=3D"im"><br>
&gt; &gt; 3. What is the role played by the structure struct fcache, what d=
oes<br>
&gt; &gt; it point to ?<br>
&gt;<br>
&gt; I&#39;m not a dcache expert, but cribbing from the code, it looks as i=
f<br>
&gt; an fcache is involved with representing chunks in the cm&#39;s persist=
ent<br>
&gt; file cache<br>
&gt;<br>
&gt; &gt; 4. I see that dcache is stored in the memory but fcache is disk<b=
r>
&gt; &gt; saved on disk( where , along with the afs cache ?) And why such a=
<br>
&gt; &gt; decision.<br>
<br>
</div>The CacheItems file is made up of a bunch of &#39;struct fcache&#39;s=
 (each one<br>
representing a chunk, as Matt says). We need to save some information<br>
about each chunk to disk, so we can find them again. So when a client<br>
restarts and asks for file X chunk Y, we can find where that chunk is in<br=
>
the cache.<br>
<font color=3D"#888888"><br>
--<br>
Andrew Deason<br>
<a href=3D"mailto:adeason@sinenomine.net">adeason@sinenomine.net</a><br>
<br>
_______________________________________________<br>
OpenAFS-devel mailing list<br>
<a href=3D"mailto:OpenAFS-devel@openafs.org">OpenAFS-devel@openafs.org</a><=
br>
<a href=3D"https://lists.openafs.org/mailman/listinfo/openafs-devel" target=
=3D"_blank">https://lists.openafs.org/mailman/listinfo/openafs-devel</a><br=
>
</font></blockquote></div><br>

--00c09f88d1641852c80487575c93--