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

Sanket Agarwal sanket@sanketagarwal.com
Sat, 22 May 2010 16:29:52 +0200


--00163630f3eb155bf204872fa419
Content-Type: text/plain; charset=ISO-8859-1

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:

1. One thing that I am not able to understand on the afs caching part is
what exactly is afs cached if I have a miss. Is that we afs cache the whole
file from the Volume Server ? Well that seems very unreasonable because a
large file then can never be read! Okay assuming it is that we afs cache
chunks of some specified size.
2. What exactly does a struct dcache points to ? Is it a specific chunk 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). Or is it that
dcache points to a specific file and keeps track of all it's chunks ?
3. What is the role played by the structure struct fcache, what does it
point to ?
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.

Cheers
Sanket

------------------------------
------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------

/* kept in memory */
struct dcache {
    struct afs_q lruq;      /* Free queue for in-memory images */
    struct afs_q dirty;     /* Queue of dirty entries that need written */
    afs_rwlock_t lock;      /* Protects validPos, some f */
    afs_rwlock_t tlock;     /* Atomizes updates to refCount */
    afs_rwlock_t mflock;    /* Atomizes accesses/updates to mflags */
    afs_size_t validPos;    /* number of valid bytes during fetch */
    afs_int32 index;        /* The index in the CacheInfo file */
    short refCount;     /* Associated reference count. */
    char dflags;        /* Data flags */
    char mflags;        /* Meta flags */
    struct fcache f;        /* disk image */
    afs_int32 bucket;           /* which bucket these dcache entries are in
*/
 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/* kept on disk and in dcache entries */
struct fcache {
    struct VenusFid fid;    /* Fid for this file */
    afs_int32 modTime;      /* last time this entry was modified */
    afs_hyper_t versionNo;  /* Associated data version number */
    afs_int32 chunk;        /* Relative chunk number */
    afs_dcache_id_t inode;      /* Unix inode for this chunk */
    afs_int32 chunkBytes;   /* Num bytes in this chunk */
    char states;        /* Has this chunk been modified? */
};

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

I am looking into the core data structures of OpenAFS kernel module for cli=
ents, of which I
 find that struct dcache and struct fcache will be most important. I=20
wish to ask you a few questions here:<br>
<br>1. One thing that I am not able to understand on the afs caching=20
part is what exactly is afs cached if I have a miss. Is that we afs=20
cache the whole file from the Volume Server ? Well that seems very=20
unreasonable because a large file then can never be read! Okay assuming=20
it is that we afs cache chunks of some specified size.<br>
2. What exactly does a struct dcache points to ? Is it a specific chunk=20
and is this chunk size same as that of Page size of pages in the=20
memory(which the kernel will ultimately load as pages in the memory). Or
 is it that dcache points to a specific file and keeps track of all it&#39;=
s
 chunks ?<br>
3. What is the role played by the structure struct fcache, what does it=20
point to ?<br>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=20
decision.<br>
<br>Cheers<br>Sanket<br><br>------------------------------<div id=3D":182" =
class=3D"ii gt">-----------------------------------------------------------=
-------------------------<br>----------------------------------------------=
--------------------------------------------------------------------<br>

<br>/* kept in memory */<br>struct dcache {<br>=A0=A0=A0 struct afs_q=20
lruq;=A0=A0=A0=A0=A0 /* Free queue for in-memory images */<br>=A0=A0=A0 str=
uct afs_q=20
dirty;=A0=A0=A0=A0 /* Queue of dirty entries that need written */<br>=A0=A0=
=A0=20
afs_rwlock_t lock;=A0=A0=A0=A0=A0 /* Protects validPos, some f */<br>
=A0=A0=A0 afs_rwlock_t tlock;=A0=A0=A0=A0 /* Atomizes updates to refCount *=
/<br>=A0=A0=A0=20
afs_rwlock_t mflock;=A0=A0=A0 /* Atomizes accesses/updates to mflags */<br>=
=A0=A0=A0
 afs_size_t validPos;=A0=A0=A0 /* number of valid bytes during fetch */<br>=
=A0=A0=A0
 afs_int32 index;=A0=A0=A0=A0=A0=A0=A0 /* The index in the CacheInfo file *=
/ <br>
=A0=A0=A0 short refCount;=A0=A0=A0=A0 /* Associated reference count. */<br>=
=A0=A0=A0 char=20
dflags;=A0=A0=A0=A0=A0=A0=A0 /* Data flags */<br>=A0=A0=A0 char mflags;=A0=
=A0=A0=A0=A0=A0=A0 /* Meta flags
 */<br>=A0=A0=A0 struct fcache f;=A0=A0=A0=A0=A0=A0=A0 /* disk image */<br>=
=A0=A0=A0 afs_int32=20
bucket;=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 /* which bucket these dcache entries =
are in */<br>
=A0------------------------------------------------------------------------=
---------------------------------------------------------------------------=
----------------------------------<br>/*
 kept on disk and in dcache entries */<br>
struct fcache {<br>=A0=A0=A0 struct VenusFid fid;=A0=A0=A0 /* Fid for this =
file */<br>=A0=A0=A0
 afs_int32 modTime;=A0=A0=A0=A0=A0 /* last time this entry was modified */<=
br>=A0=A0=A0=20
afs_hyper_t versionNo;=A0 /* Associated data version number */<br>=A0=A0=A0=
=20
afs_int32 chunk;=A0=A0=A0=A0=A0=A0=A0 /* Relative chunk number */<br>
=A0=A0=A0 afs_dcache_id_t inode;=A0=A0=A0=A0=A0 /* Unix inode for this chun=
k */<br>=A0=A0=A0=20
afs_int32 chunkBytes;=A0=A0 /* Num bytes in this chunk */<br>=A0=A0=A0 char=
=20
states;=A0=A0=A0=A0=A0=A0=A0 /* Has this chunk been modified? */<br>};</div=
>

--00163630f3eb155bf204872fa419--