afs/fs/afs volume.h,1.3,1.4 volume.c,1.5,1.6 vnode.h,1.3,1.4
vnode.c,1.3,1.4 vlocation.c,1.6,1.7 vlclient.h,1.3,1.4
vlclient.c,1.5,1.6 types.h,1.4,1.5 main.c,1.10,1.11
internal.h,1.13,1.14 inode.c,1.8,1.9 file.c,1.4,1.5 cell.h,1.3,1.4
cell.c,1.6,1.7 cache.h,1.12,1.13
dwh at infradead.org
dwh at infradead.org
Fri Jun 6 10:33:40 BST 2003
Update of /home/cvs/afs/fs/afs
In directory phoenix.infradead.org:/tmp/cvs-serv16348/fs/afs
Modified Files:
volume.h volume.c vnode.h vnode.c vlocation.c vlclient.h
vlclient.c types.h main.c internal.h inode.c file.c cell.h
cell.c cache.h
Log Message:
kAFS now creates indexes and cache files through cachefs
Index: volume.h
===================================================================
RCS file: /home/cvs/afs/fs/afs/volume.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- volume.h 16 Oct 2002 09:59:50 -0000 1.3
+++ volume.h 6 Jun 2003 08:33:37 -0000 1.4
@@ -16,7 +16,6 @@
#include "fsclient.h"
#include "kafstimod.h"
#include "kafsasyncd.h"
-#include "cache-layout.h"
#define __packed __attribute__((packed))
@@ -28,6 +27,41 @@
} __attribute__((packed)) afs_vlocation_upd_t;
+typedef u_int8_t afs_cache_vtype_t;
+
+/*****************************************************************************/
+/*
+ * entry in the cached volume location catalogue
+ */
+struct afs_cache_vlocation
+{
+ u_int8_t name[64]; /* volume name (lowercase, padded with NULs) */
+ u_int8_t nservers; /* number of entries used in servers[] */
+ u_int8_t vidmask; /* voltype mask for vid[] */
+ u_int8_t srvtmask[8]; /* voltype masks for servers[] */
+#define AFS_VOL_VTM_RW 0x01 /* R/W version of the volume is available (on this server) */
+#define AFS_VOL_VTM_RO 0x02 /* R/O version of the volume is available (on this server) */
+#define AFS_VOL_VTM_BAK 0x04 /* backup version of the volume is available (on this server) */
+
+ afs_volid_t vid[3]; /* volume IDs for R/W, R/O and Bak volumes */
+ struct in_addr servers[8]; /* fileserver addresses */
+ time_t rtime; /* last retrieval time */
+};
+
+extern struct cachefs_index_def afs_vlocation_cache_index_def;
+
+/*****************************************************************************/
+/*
+ * volume -> vnode hash table entry
+ */
+struct afs_cache_vhash
+{
+ afs_voltype_t vtype; /* which volume variation */
+ u_int8_t hash_bucket; /* which hash bucket this represents */
+} __attribute__((packed));
+
+extern struct cachefs_index_def afs_volume_cache_index_def;
+
/*****************************************************************************/
/*
* AFS volume location record
@@ -36,15 +70,15 @@
{
atomic_t usage;
struct list_head link; /* link in cell volume location list */
- afs_timer_t timeout; /* decaching timer */
- afs_cell_t *cell; /* cell to which volume belongs */
- struct list_head caches; /* backing caches */
- afsc_vldb_record_t vldb; /* volume information DB record */
+ struct afs_timer timeout; /* decaching timer */
+ struct afs_cell *cell; /* cell to which volume belongs */
+ struct cachefs_cookie *cache; /* caching cookie */
+ struct afs_cache_vlocation vldb; /* volume information DB record */
struct afs_volume *vols[3]; /* volume access record pointer (index by type) */
rwlock_t lock; /* access lock */
unsigned long read_jif; /* time at which last read from vlserver */
- afs_timer_t upd_timer; /* update timer */
- afs_async_op_t upd_op; /* update operation */
+ struct afs_timer upd_timer; /* update timer */
+ struct afs_async_op upd_op; /* update operation */
afs_vlocation_upd_t upd_state; /* update state */
unsigned short upd_first_svix; /* first server index during update */
unsigned short upd_curr_svix; /* current server index during update */
@@ -68,14 +102,15 @@
struct afs_volume
{
atomic_t usage;
- afs_cell_t *cell; /* cell to which belongs (unrefd ptr) */
- afs_vlocation_t *vlocation; /* volume location */
+ struct afs_cell *cell; /* cell to which belongs (unrefd ptr) */
+ struct afs_vlocation *vlocation; /* volume location */
+ struct cachefs_cookie *cache; /* caching cookie */
afs_volid_t vid; /* volume ID */
afs_voltype_t __packed type; /* type of volume */
char type_force; /* force volume type (suppress R/O -> R/W) */
unsigned short nservers; /* number of server slots filled */
unsigned short rjservers; /* number of servers discarded due to -ENOMEDIUM */
- afs_server_t *servers[8]; /* servers on which volume resides (ordered) */
+ struct afs_server *servers[8]; /* servers on which volume resides (ordered) */
struct rw_semaphore server_sem; /* lock for accessing current server */
};
Index: volume.c
===================================================================
RCS file: /home/cvs/afs/fs/afs/volume.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- volume.c 16 Oct 2002 09:59:50 -0000 1.5
+++ volume.c 6 Jun 2003 08:33:37 -0000 1.6
@@ -16,6 +16,7 @@
#include <linux/fs.h>
#include <linux/pagemap.h>
#include "volume.h"
+#include "vnode.h"
#include "cell.h"
#include "cmservice.h"
#include "fsclient.h"
@@ -24,6 +25,18 @@
const char *afs_voltypes[] = { "R/W", "R/O", "BAK" };
+static cachefs_match_val_t afs_volume_cache_match(void *target, const void *entry);
+static void afs_volume_cache_update(void *source, void *entry);
+
+struct cachefs_index_def afs_volume_cache_index_def = {
+ .name = "volume",
+ .data_size = sizeof(struct afs_cache_vhash),
+ .keys[0] = { CACHEFS_INDEX_KEYS_BIN, 1 },
+ .keys[1] = { CACHEFS_INDEX_KEYS_BIN, 1 },
+ .match = afs_volume_cache_match,
+ .update = afs_volume_cache_update,
+};
+
/*****************************************************************************/
/*
* lookup a volume by name
@@ -132,10 +145,10 @@
if (!(srvtmask & (1 <<type)))
goto error;
}
- else if (srvtmask & AFSC_VOL_STM_RO) {
+ else if (srvtmask & AFS_VOL_VTM_RO) {
type = AFSVL_ROVOL;
}
- else if (srvtmask & AFSC_VOL_STM_RW) {
+ else if (srvtmask & AFS_VOL_VTM_RW) {
type = AFSVL_RWVOL;
}
else {
@@ -162,10 +175,10 @@
memset(volume,0,sizeof(afs_volume_t));
atomic_set(&volume->usage,1);
- volume->type = type;
- volume->type_force = force;
- volume->cell = cell;
- volume->vid = vlocation->vldb.vid[type];
+ volume->type = type;
+ volume->type_force = force;
+ volume->cell = cell;
+ volume->vid = vlocation->vldb.vid[type];
init_rwsem(&volume->server_sem);
@@ -183,10 +196,13 @@
}
/* attach the cache and volume location */
-#if 0
- afs_get_cache(cache); volume->cache = cache;
-#endif
- afs_get_vlocation(vlocation); volume->vlocation = vlocation;
+ cachefs_acquire_cookie(vlocation->cache,
+ &afs_vnode_cache_index_def,
+ volume,
+ &volume->cache);
+
+ afs_get_vlocation(vlocation);
+ volume->vlocation = vlocation;
vlocation->vols[type] = volume;
@@ -246,12 +262,9 @@
up_write(&vlocation->cell->vl_sem);
- afs_put_vlocation(vlocation);
-
/* finish cleaning up the volume */
-#if 0
- if (volume->cache) afs_put_cache(volume->cache);
-#endif
+ cachefs_relinquish_cookie(volume->cache,0);
+ afs_put_vlocation(vlocation);
for (loop=volume->nservers-1; loop>=0; loop--)
if (volume->servers[loop])
@@ -428,3 +441,35 @@
return 0;
} /* end afs_volume_release_fileserver() */
+
+/*****************************************************************************/
+/*
+ * match a volume hash record stored in the cache
+ */
+static cachefs_match_val_t afs_volume_cache_match(void *target, const void *entry)
+{
+ const struct afs_cache_vhash *vhash = entry;
+ struct afs_volume *volume = target;
+
+ kenter("");
+
+ if (volume->type == vhash->vtype)
+ return CACHEFS_MATCH_SUCCESS;
+
+ return CACHEFS_MATCH_FAILED;
+} /* end afs_volume_cache_match() */
+
+/*****************************************************************************/
+/*
+ * update a volume hash record stored in the cache
+ */
+static void afs_volume_cache_update(void *source, void *entry)
+{
+ struct afs_cache_vhash *vhash = entry;
+ struct afs_volume *volume = source;
+
+ kenter("");
+
+ vhash->vtype = volume->type;
+
+} /* end afs_volume_cache_update() */
Index: vnode.h
===================================================================
RCS file: /home/cvs/afs/fs/afs/vnode.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- vnode.h 16 Oct 2002 12:45:03 -0000 1.3
+++ vnode.h 6 Jun 2003 08:33:37 -0000 1.4
@@ -23,16 +23,27 @@
/*****************************************************************************/
/*
+ * vnode catalogue entry
+ */
+struct afs_cache_vnode
+{
+ afs_vnodeid_t vnode; /* vnode ID */
+};
+
+extern struct cachefs_index_def afs_vnode_cache_index_def;
+
+/*****************************************************************************/
+/*
* AFS inode private data
*/
struct afs_vnode
{
struct inode vfs_inode; /* the VFS's inode record */
- afs_volume_t *volume; /* volume on which vnode resides */
- afs_fid_t fid; /* the file identifier for this inode */
- afs_file_status_t status; /* AFS status info for this file */
- unsigned nix; /* vnode index in cache */
+ struct afs_volume *volume; /* volume on which vnode resides */
+ struct afs_fid fid; /* the file identifier for this inode */
+ struct afs_file_status status; /* AFS status info for this file */
+ struct cachefs_cookie *cache; /* caching cookie */
wait_queue_head_t update_waitq; /* status fetch waitqueue */
unsigned update_cnt; /* number of outstanding ops that will update the
@@ -44,10 +55,10 @@
#define AFS_VNODE_MOUNTPOINT 0x00000004 /* set if vnode is a mountpoint symlink */
/* outstanding callback notification on this file */
- afs_server_t *cb_server; /* server that made the current promise */
+ struct afs_server *cb_server; /* server that made the current promise */
struct list_head cb_link; /* link in server's promises list */
struct list_head cb_hash_link; /* link in master callback hash */
- afs_timer_t cb_timeout; /* timeout on promise */
+ struct afs_timer cb_timeout; /* timeout on promise */
unsigned cb_version; /* callback version */
unsigned cb_expiry; /* callback expiry time */
afs_callback_type_t cb_type; /* type of callback */
Index: vnode.c
===================================================================
RCS file: /home/cvs/afs/fs/afs/vnode.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- vnode.c 16 Oct 2002 09:59:50 -0000 1.3
+++ vnode.c 6 Jun 2003 08:33:37 -0000 1.4
@@ -29,6 +29,17 @@
.timed_out = afs_vnode_cb_timed_out,
};
+static cachefs_match_val_t afs_vnode_cache_match(void *target, const void *entry);
+static void afs_vnode_cache_update(void *source, void *entry);
+
+struct cachefs_index_def afs_vnode_cache_index_def = {
+ .name = "vnode",
+ .data_size = sizeof(struct afs_cache_vnode),
+ .keys[0] = { CACHEFS_INDEX_KEYS_BIN, 4 },
+ .match = afs_vnode_cache_match,
+ .update = afs_vnode_cache_update,
+};
+
/*****************************************************************************/
/*
* handle a callback timing out
@@ -314,3 +325,35 @@
_leave(" = %d",ret);
return ret;
} /* end afs_vnode_give_up_callback() */
+
+/*****************************************************************************/
+/*
+ * match a vnode record stored in the cache
+ */
+static cachefs_match_val_t afs_vnode_cache_match(void *target, const void *entry)
+{
+ const struct afs_cache_vnode *cvnode = entry;
+ struct afs_vnode *vnode = target;
+
+ kenter("");
+
+ if (vnode->fid.vnode == cvnode->vnode)
+ return CACHEFS_MATCH_SUCCESS;
+
+ return CACHEFS_MATCH_FAILED;
+} /* end afs_vnode_cache_match() */
+
+/*****************************************************************************/
+/*
+ * update a vnode record stored in the cache
+ */
+static void afs_vnode_cache_update(void *source, void *entry)
+{
+ struct afs_cache_vnode *cvnode = entry;
+ struct afs_vnode *vnode = source;
+
+ kenter("");
+
+ cvnode->vnode = vnode->fid.vnode;
+
+} /* end afs_vnode_cache_update() */
Index: vlocation.c
===================================================================
RCS file: /home/cvs/afs/fs/afs/vlocation.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- vlocation.c 16 Oct 2002 09:59:50 -0000 1.6
+++ vlocation.c 6 Jun 2003 08:33:37 -0000 1.7
@@ -56,6 +56,17 @@
static afs_vlocation_t *afs_vlocation_update; /* VL currently being updated */
static spinlock_t afs_vlocation_update_lock = SPIN_LOCK_UNLOCKED; /* lock guarding update queue */
+static cachefs_match_val_t afs_vlocation_cache_match(void *target, const void *entry);
+static void afs_vlocation_cache_update(void *source, void *entry);
+
+struct cachefs_index_def afs_vlocation_cache_index_def = {
+ .name = "vldb",
+ .data_size = sizeof(struct afs_cache_vlocation),
+ .keys[0] = { CACHEFS_INDEX_KEYS_ASCIIZ, 64 },
+ .match = afs_vlocation_cache_match,
+ .update = afs_vlocation_cache_update,
+};
+
/*****************************************************************************/
/*
* iterate through the VL servers in a cell until one of them admits knowing about the volume in
@@ -64,7 +75,7 @@
*/
static int afs_vlocation_access_vl_by_name(afs_vlocation_t *vlocation,
const char *name,
- afsc_vldb_record_t *vldb)
+ struct afs_cache_vlocation *vldb)
{
afs_server_t *server = NULL;
afs_cell_t *cell = vlocation->cell;
@@ -140,7 +151,7 @@
static int afs_vlocation_access_vl_by_id(afs_vlocation_t *vlocation,
afs_volid_t volid,
afs_voltype_t voltype,
- afsc_vldb_record_t *vldb)
+ struct afs_cache_vlocation *vldb)
{
afs_server_t *server = NULL;
afs_cell_t *cell = vlocation->cell;
@@ -218,7 +229,7 @@
*/
int afs_vlocation_lookup(afs_cell_t *cell, const char *name, afs_vlocation_t **_vlocation)
{
- afsc_vldb_record_t vldb;
+ struct afs_cache_vlocation vldb;
struct list_head *_p;
afs_vlocation_t *vlocation;
afs_voltype_t voltype;
@@ -263,22 +274,19 @@
afs_timer_init(&vlocation->upd_timer,&afs_vlocation_update_timer_ops);
afs_async_op_init(&vlocation->upd_op,&afs_vlocation_update_op_ops);
- INIT_LIST_HEAD(&vlocation->caches);
-
afs_get_cell(cell);
vlocation->cell = cell;
list_add_tail(&vlocation->link,&cell->vl_list);
-#if 0
- /* search local cache if wasn't in memory */
- ret = afsc_lookup_vlocation(vlocation);
- switch (ret) {
- default: goto error; /* disk error */
- case 0: goto found_in_cache; /* pulled from local cache into memory */
- case -ENOENT: break; /* not in local cache */
- }
-#endif
+ /* we want to store it in the cache, plus it might already be encached */
+ cachefs_acquire_cookie(cell->cache,
+ &afs_volume_cache_index_def,
+ vlocation,
+ &vlocation->cache);
+
+ if (vlocation->valid)
+ goto found_in_cache;
/* try to look up an unknown volume in the cell VL databases by name */
ret = afs_vlocation_access_vl_by_name(vlocation,name,&vldb);
@@ -308,7 +316,7 @@
active:
active = 1;
-/* found_in_cache: */
+ found_in_cache:
/* try to look up a cached volume in the cell VL databases by ID */
_debug("found in cache");
@@ -323,15 +331,15 @@
_debug("Vids: %08x %08x %08x",
vlocation->vldb.vid[0],vlocation->vldb.vid[1],vlocation->vldb.vid[2]);
- if (vlocation->vldb.vidmask & AFSC_VOL_STM_RW) {
+ if (vlocation->vldb.vidmask & AFS_VOL_VTM_RW) {
vid = vlocation->vldb.vid[0];
voltype = AFSVL_RWVOL;
}
- else if (vlocation->vldb.vidmask & AFSC_VOL_STM_RO) {
+ else if (vlocation->vldb.vidmask & AFS_VOL_VTM_RO) {
vid = vlocation->vldb.vid[1];
voltype = AFSVL_ROVOL;
}
- else if (vlocation->vldb.vidmask & AFSC_VOL_STM_BAK) {
+ else if (vlocation->vldb.vidmask & AFS_VOL_VTM_BAK) {
vid = vlocation->vldb.vid[2];
voltype = AFSVL_BACKVOL;
}
@@ -350,7 +358,7 @@
goto error;
/* pulled from local cache into memory */
- case 0:
+ case 0:
goto found_on_vlserver;
/* uh oh... looks like the volume got deleted */
@@ -397,10 +405,8 @@
}
else {
list_del(&vlocation->link);
+ cachefs_relinquish_cookie(vlocation->cache,0);
afs_put_cell(vlocation->cell);
-#if 0
- afs_put_cache(vlocation->cache);
-#endif
kfree(vlocation);
}
}
@@ -469,7 +475,7 @@
{
afs_cell_t *cell;
- _enter("%s",vlocation->vldb.name);
+ kenter("%s",vlocation->vldb.name);
cell = vlocation->cell;
@@ -484,19 +490,17 @@
spin_unlock(&cell->vl_gylock);
if (!vlocation) {
- _leave("");
+ kleave("");
return; /* resurrected */
}
/* we can now destroy it properly */
+ cachefs_relinquish_cookie(vlocation->cache,0);
afs_put_cell(cell);
-#if 0
- afs_put_cache(vlocation->cache);
-#endif
kfree(vlocation);
- _leave(" [destroyed]");
+ kleave(" [destroyed]");
} /* end afs_vlocation_do_timeout() */
/*****************************************************************************/
@@ -513,15 +517,15 @@
vlocation->vldb.name,vlocation->upd_first_svix,vlocation->upd_curr_svix);
/* try to look up a cached volume in the cell VL databases by ID */
- if (vlocation->vldb.vidmask & AFSC_VOL_STM_RW) {
+ if (vlocation->vldb.vidmask & AFS_VOL_VTM_RW) {
vid = vlocation->vldb.vid[0];
voltype = AFSVL_RWVOL;
}
- else if (vlocation->vldb.vidmask & AFSC_VOL_STM_RO) {
+ else if (vlocation->vldb.vidmask & AFS_VOL_VTM_RO) {
vid = vlocation->vldb.vid[1];
voltype = AFSVL_ROVOL;
}
- else if (vlocation->vldb.vidmask & AFSC_VOL_STM_BAK) {
+ else if (vlocation->vldb.vidmask & AFS_VOL_VTM_BAK) {
vid = vlocation->vldb.vid[2];
voltype = AFSVL_BACKVOL;
}
@@ -669,7 +673,7 @@
*/
static void afs_vlocation_update_attend(afs_async_op_t *op)
{
- afsc_vldb_record_t vldb;
+ struct afs_cache_vlocation vldb;
afs_vlocation_t *vlocation = list_entry(op,afs_vlocation_t,upd_op);
unsigned tmp;
int ret;
@@ -822,3 +826,42 @@
_leave("");
} /* end afs_vlocation_update_discard() */
+
+/*****************************************************************************/
+/*
+ * match a VLDB record stored in the cache
+ * - may also load target from entry
+ */
+static cachefs_match_val_t afs_vlocation_cache_match(void *target, const void *entry)
+{
+ const struct afs_cache_vlocation *vldb = entry;
+ struct afs_vlocation *vlocation = target;
+
+ kenter("");
+
+ if (strncmp(vlocation->vldb.name,vldb->name,sizeof(vldb->name))==0) {
+ if (!vlocation->valid || vlocation->vldb.rtime == vldb->rtime) {
+ struct_cpy(&vlocation->vldb,vldb);
+ vlocation->valid = 1;
+ }
+
+ return CACHEFS_MATCH_SUCCESS;
+ }
+
+ return CACHEFS_MATCH_FAILED;
+} /* end afs_vlocation_cache_match() */
+
+/*****************************************************************************/
+/*
+ * update a VLDB record stored in the cache
+ */
+static void afs_vlocation_cache_update(void *source, void *entry)
+{
+ struct afs_cache_vlocation *vldb = entry;
+ struct afs_vlocation *vlocation = source;
+
+ kenter("");
+
+ struct_cpy(vldb,&vlocation->vldb);
+
+} /* end afs_vlocation_cache_update() */
Index: vlclient.h
===================================================================
RCS file: /home/cvs/afs/fs/afs/vlclient.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- vlclient.h 16 Oct 2002 09:59:50 -0000 1.3
+++ vlclient.h 6 Jun 2003 08:33:37 -0000 1.4
@@ -46,7 +46,7 @@
};
/* maps to "struct vldbentry" in vvl-spec.pdf */
-struct afsvl_dbentry {
+struct afs_vldbentry {
char name[65]; /* name of volume (including NUL char) */
afs_voltype_t type; /* volume type */
unsigned num_servers; /* num servers that hold instances of this vol */
@@ -77,19 +77,19 @@
/* look up a volume location database entry by name */
extern int afs_rxvl_get_entry_by_name(afs_server_t *server,
const char *volname,
- afsc_vldb_record_t *entry);
+ struct afs_cache_vlocation *entry);
/* look up a volume location database entry by ID */
extern int afs_rxvl_get_entry_by_id(afs_server_t *server,
afs_volid_t volid,
afs_voltype_t voltype,
- afsc_vldb_record_t *entry);
+ struct afs_cache_vlocation *entry);
extern int afs_rxvl_get_entry_by_id_async(afs_async_op_t *op,
afs_volid_t volid,
afs_voltype_t voltype);
extern int afs_rxvl_get_entry_by_id_async2(afs_async_op_t *op,
- afsc_vldb_record_t *entry);
+ struct afs_cache_vlocation *entry);
#endif /* _LINUX_AFS_VLCLIENT_H */
Index: vlclient.c
===================================================================
RCS file: /home/cvs/afs/fs/afs/vlclient.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- vlclient.c 4 Feb 2003 16:12:05 -0000 1.5
+++ vlclient.c 6 Jun 2003 08:33:37 -0000 1.6
@@ -177,7 +177,7 @@
* look up a volume location database entry by name
*/
int afs_rxvl_get_entry_by_name(afs_server_t *server, const char *volname,
- afsc_vldb_record_t *entry)
+ struct afs_cache_vlocation *entry)
{
DECLARE_WAITQUEUE(myself,current);
@@ -255,9 +255,9 @@
for (loop=0; loop<8; loop++) {
tmp = ntohl(*bp++);
- if (tmp & AFS_VLSF_RWVOL ) entry->srvtmask[loop] |= AFSC_VOL_STM_RW;
- if (tmp & AFS_VLSF_ROVOL ) entry->srvtmask[loop] |= AFSC_VOL_STM_RO;
- if (tmp & AFS_VLSF_BACKVOL) entry->srvtmask[loop] |= AFSC_VOL_STM_BAK;
+ if (tmp & AFS_VLSF_RWVOL ) entry->srvtmask[loop] |= AFS_VOL_VTM_RW;
+ if (tmp & AFS_VLSF_ROVOL ) entry->srvtmask[loop] |= AFS_VOL_VTM_RO;
+ if (tmp & AFS_VLSF_BACKVOL) entry->srvtmask[loop] |= AFS_VOL_VTM_BAK;
}
entry->vid[0] = ntohl(*bp++);
@@ -267,16 +267,16 @@
bp++; /* clone ID */
tmp = ntohl(*bp++); /* flags */
- if (tmp & AFS_VLF_RWEXISTS ) entry->vidmask |= AFSC_VOL_STM_RW;
- if (tmp & AFS_VLF_ROEXISTS ) entry->vidmask |= AFSC_VOL_STM_RO;
- if (tmp & AFS_VLF_BACKEXISTS) entry->vidmask |= AFSC_VOL_STM_BAK;
+ if (tmp & AFS_VLF_RWEXISTS ) entry->vidmask |= AFS_VOL_VTM_RW;
+ if (tmp & AFS_VLF_ROEXISTS ) entry->vidmask |= AFS_VOL_VTM_RO;
+ if (tmp & AFS_VLF_BACKEXISTS) entry->vidmask |= AFS_VOL_VTM_BAK;
ret = -ENOMEDIUM;
if (!entry->vidmask)
goto abort;
/* success */
- entry->ctime = xtime.tv_sec;
+ entry->rtime = get_seconds();
ret = 0;
out_unwait:
@@ -303,7 +303,7 @@
int afs_rxvl_get_entry_by_id(afs_server_t *server,
afs_volid_t volid,
afs_voltype_t voltype,
- afsc_vldb_record_t *entry)
+ struct afs_cache_vlocation *entry)
{
DECLARE_WAITQUEUE(myself,current);
@@ -375,9 +375,9 @@
for (loop=0; loop<8; loop++) {
tmp = ntohl(*bp++);
- if (tmp & AFS_VLSF_RWVOL ) entry->srvtmask[loop] |= AFSC_VOL_STM_RW;
- if (tmp & AFS_VLSF_ROVOL ) entry->srvtmask[loop] |= AFSC_VOL_STM_RO;
- if (tmp & AFS_VLSF_BACKVOL) entry->srvtmask[loop] |= AFSC_VOL_STM_BAK;
+ if (tmp & AFS_VLSF_RWVOL ) entry->srvtmask[loop] |= AFS_VOL_VTM_RW;
+ if (tmp & AFS_VLSF_ROVOL ) entry->srvtmask[loop] |= AFS_VOL_VTM_RO;
+ if (tmp & AFS_VLSF_BACKVOL) entry->srvtmask[loop] |= AFS_VOL_VTM_BAK;
}
entry->vid[0] = ntohl(*bp++);
@@ -387,9 +387,9 @@
bp++; /* clone ID */
tmp = ntohl(*bp++); /* flags */
- if (tmp & AFS_VLF_RWEXISTS ) entry->vidmask |= AFSC_VOL_STM_RW;
- if (tmp & AFS_VLF_ROEXISTS ) entry->vidmask |= AFSC_VOL_STM_RO;
- if (tmp & AFS_VLF_BACKEXISTS) entry->vidmask |= AFSC_VOL_STM_BAK;
+ if (tmp & AFS_VLF_RWEXISTS ) entry->vidmask |= AFS_VOL_VTM_RW;
+ if (tmp & AFS_VLF_ROEXISTS ) entry->vidmask |= AFS_VOL_VTM_RO;
+ if (tmp & AFS_VLF_BACKEXISTS) entry->vidmask |= AFS_VOL_VTM_BAK;
ret = -ENOMEDIUM;
if (!entry->vidmask)
@@ -401,13 +401,13 @@
entry->servers[1].s_addr = htonl(0xac101243);
entry->servers[2].s_addr = htonl(0xac10125b /*0xac10125b*/);
- entry->srvtmask[0] = AFSC_VOL_STM_RO;
- entry->srvtmask[1] = AFSC_VOL_STM_RO;
- entry->srvtmask[2] = AFSC_VOL_STM_RO | AFSC_VOL_STM_RW;
+ entry->srvtmask[0] = AFS_VOL_VTM_RO;
+ entry->srvtmask[1] = AFS_VOL_VTM_RO;
+ entry->srvtmask[2] = AFS_VOL_VTM_RO | AFS_VOL_VTM_RW;
#endif
/* success */
- entry->ctime = xtime.tv_sec;
+ entry->rtime = get_seconds();
ret = 0;
out_unwait:
@@ -520,7 +520,7 @@
* attend to the asynchronous get VLDB entry by ID
*/
int afs_rxvl_get_entry_by_id_async2(afs_async_op_t *op,
- afsc_vldb_record_t *entry)
+ struct afs_cache_vlocation *entry)
{
unsigned *bp, tmp;
int loop, ret;
@@ -550,9 +550,9 @@
for (loop=0; loop<8; loop++) {
tmp = ntohl(*bp++);
- if (tmp & AFS_VLSF_RWVOL ) entry->srvtmask[loop] |= AFSC_VOL_STM_RW;
- if (tmp & AFS_VLSF_ROVOL ) entry->srvtmask[loop] |= AFSC_VOL_STM_RO;
- if (tmp & AFS_VLSF_BACKVOL) entry->srvtmask[loop] |= AFSC_VOL_STM_BAK;
+ if (tmp & AFS_VLSF_RWVOL ) entry->srvtmask[loop] |= AFS_VOL_VTM_RW;
+ if (tmp & AFS_VLSF_ROVOL ) entry->srvtmask[loop] |= AFS_VOL_VTM_RO;
+ if (tmp & AFS_VLSF_BACKVOL) entry->srvtmask[loop] |= AFS_VOL_VTM_BAK;
}
entry->vid[0] = ntohl(*bp++);
@@ -562,9 +562,9 @@
bp++; /* clone ID */
tmp = ntohl(*bp++); /* flags */
- if (tmp & AFS_VLF_RWEXISTS ) entry->vidmask |= AFSC_VOL_STM_RW;
- if (tmp & AFS_VLF_ROEXISTS ) entry->vidmask |= AFSC_VOL_STM_RO;
- if (tmp & AFS_VLF_BACKEXISTS) entry->vidmask |= AFSC_VOL_STM_BAK;
+ if (tmp & AFS_VLF_RWEXISTS ) entry->vidmask |= AFS_VOL_VTM_RW;
+ if (tmp & AFS_VLF_ROEXISTS ) entry->vidmask |= AFS_VOL_VTM_RO;
+ if (tmp & AFS_VLF_BACKEXISTS) entry->vidmask |= AFS_VOL_VTM_BAK;
ret = -ENOMEDIUM;
if (!entry->vidmask) {
@@ -578,13 +578,13 @@
entry->servers[1].s_addr = htonl(0xac101243);
entry->servers[2].s_addr = htonl(0xac10125b /*0xac10125b*/);
- entry->srvtmask[0] = AFSC_VOL_STM_RO;
- entry->srvtmask[1] = AFSC_VOL_STM_RO;
- entry->srvtmask[2] = AFSC_VOL_STM_RO | AFSC_VOL_STM_RW;
+ entry->srvtmask[0] = AFS_VOL_VTM_RO;
+ entry->srvtmask[1] = AFS_VOL_VTM_RO;
+ entry->srvtmask[2] = AFS_VOL_VTM_RO | AFS_VOL_VTM_RW;
#endif
/* success */
- entry->ctime = xtime.tv_sec;
+ entry->rtime = get_seconds();
ret = 0;
goto done;
}
Index: types.h
===================================================================
RCS file: /home/cvs/afs/fs/afs/types.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- types.h 13 Sep 2002 10:34:43 -0000 1.4
+++ types.h 6 Jun 2003 08:33:37 -0000 1.5
@@ -33,26 +33,13 @@
typedef struct afs_volume afs_volume_t;
typedef struct afs_volume_info afs_volume_info_t;
-typedef struct afsc_cache afsc_cache_t;
-typedef struct afsc_cache_cell afsc_cache_cell_t;
-typedef struct afsc_cache_vldb afsc_cache_vldb_t;
-typedef struct afsc_cell_record afsc_cell_record_t;
-typedef struct afsc_inode afsc_inode_t;
-typedef struct afsc_io afsc_io_t;
-typedef struct afsc_io_subop afsc_io_subop_t;
-typedef struct afsc_io_queue afsc_io_queue_t;
-typedef struct afsc_super_block afsc_super_block_t;
-typedef struct afsc_vldb_record afsc_vldb_record_t;
-typedef struct afsc_vnode_catalogue afsc_vnode_catalogue_t;
-typedef struct afsc_vnode_meta afsc_vnode_meta_t;
-
typedef struct afsvl_dbentry afsvl_dbentry_t;
typedef enum {
AFSVL_RWVOL, /* read/write volume */
AFSVL_ROVOL, /* read-only volume */
AFSVL_BACKVOL, /* backup volume */
-} afs_voltype_t;
+} __attribute__((packed)) afs_voltype_t;
extern const char *afs_voltypes[];
Index: main.c
===================================================================
RCS file: /home/cvs/afs/fs/afs/main.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- main.c 23 May 2003 12:57:25 -0000 1.10
+++ main.c 6 Jun 2003 08:33:37 -0000 1.11
@@ -17,6 +17,7 @@
#include <rxrpc/transport.h>
#include <rxrpc/call.h>
#include <rxrpc/peer.h>
+#include "cache.h"
#include "cell.h"
#include "server.h"
#include "fsclient.h"
@@ -47,6 +48,16 @@
struct list_head afs_cb_hash_tbl[AFS_CB_HASH_COUNT];
spinlock_t afs_cb_hash_lock = SPIN_LOCK_UNLOCKED;
+static struct cachefs_netfs_operations afs_cache_ops = {
+ .get_page_cookie = afs_cache_get_page_cookie,
+};
+
+struct cachefs_netfs afs_cache_netfs = {
+ .name = "afs",
+ .version = 0,
+ .ops = &afs_cache_ops,
+};
+
/*****************************************************************************/
/*
* initialise the AFS client FS module
@@ -67,10 +78,15 @@
if (ret<0)
return ret;
+ /* we want to be able to cache */
+ ret = cachefs_register_netfs(&afs_cache_netfs,&afs_cache_cell_index_def);
+ if (ret<0)
+ goto error;
+
/* initialise the cell DB */
ret = afs_cell_init();
if (ret<0)
- goto error;
+ goto error_cache;
/* start the timeout daemon */
ret = afs_kafstimod_start();
@@ -102,6 +118,8 @@
afs_kafsasyncd_stop();
error_kafstimod:
afs_kafstimod_stop();
+ error_cache:
+ cachefs_unregister_netfs(&afs_cache_netfs);
error:
afs_cell_purge();
afs_proc_cleanup();
@@ -122,6 +140,7 @@
afs_kafstimod_stop();
afs_kafsasyncd_stop();
afs_cell_purge();
+ cachefs_unregister_netfs(&afs_cache_netfs);
afs_proc_cleanup();
} /* end afs_exit() */
Index: internal.h
===================================================================
RCS file: /home/cvs/afs/fs/afs/internal.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- internal.h 2 Mar 2003 18:56:15 -0000 1.13
+++ internal.h 6 Jun 2003 08:33:37 -0000 1.14
@@ -17,6 +17,7 @@
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/pagemap.h>
+#include <linux/cachefs.h>
/*
* debug tracing
@@ -57,6 +58,7 @@
*/
extern struct rw_semaphore afs_proc_cells_sem;
extern struct list_head afs_proc_cells;
+extern struct cachefs_index_def afs_cache_cell_index_def;
/*
* dir.c
@@ -71,12 +73,19 @@
extern struct inode_operations afs_file_inode_operations;
extern struct file_operations afs_file_file_operations;
+extern int afs_cache_get_page_cookie(struct page *page, struct cachefs_page **_page_cookie);
+
/*
* inode.c
*/
extern int afs_iget(struct super_block *sb, afs_fid_t *fid, struct inode **_inode);
extern int afs_inode_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
extern void afs_clear_inode(struct inode *inode);
+
+/*
+ * main.c
+ */
+extern struct cachefs_netfs afs_cache_netfs;
/*
* mntpt.c
Index: inode.c
===================================================================
RCS file: /home/cvs/afs/fs/afs/inode.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- inode.c 4 Feb 2003 16:12:05 -0000 1.8
+++ inode.c 6 Jun 2003 08:33:37 -0000 1.9
@@ -149,8 +149,8 @@
{
struct afs_iget_data data = { fid: *fid };
struct afs_super_info *as;
+ struct afs_vnode *vnode;
struct inode *inode;
- afs_vnode_t *vnode;
int ret;
_enter(",{%u,%u,%u},,",fid->vid,fid->vnode,fid->unique);
@@ -183,6 +183,11 @@
if (ret<0)
goto bad_inode;
+ cachefs_acquire_cookie(vnode->volume->cache,
+ NULL,
+ vnode,
+ &vnode->cache);
+
/* success */
unlock_new_inode(inode);
@@ -264,6 +269,9 @@
if (inode->i_ino!=vnode->fid.vnode) BUG();
afs_vnode_give_up_callback(vnode);
+
+ cachefs_relinquish_cookie(vnode->cache,0);
+ vnode->cache = NULL;
_leave("");
} /* end afs_clear_inode() */
Index: file.c
===================================================================
RCS file: /home/cvs/afs/fs/afs/file.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- file.c 16 Oct 2002 12:45:03 -0000 1.4
+++ file.c 6 Jun 2003 08:33:37 -0000 1.5
@@ -122,3 +122,13 @@
return ret;
} /* end afs_file_readpage() */
+
+/*****************************************************************************/
+/*
+ * get a page cookie for the specified page
+ */
+int afs_cache_get_page_cookie(struct page *page, struct cachefs_page **_page_cookie)
+{
+ return cachefs_page_get_private(page,_page_cookie,GFP_NOIO);
+
+} /* end afs_cache_get_page_cookie() */
Index: cell.h
===================================================================
RCS file: /home/cvs/afs/fs/afs/cell.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- cell.h 16 Oct 2002 09:59:51 -0000 1.3
+++ cell.h 6 Jun 2003 08:33:37 -0000 1.4
@@ -14,10 +14,22 @@
#include "types.h"
+#define AFS_CELL_MAX_ADDRS 15
+
extern volatile int afs_cells_being_purged; /* T when cells are being purged by rmmod */
/*****************************************************************************/
/*
+ * entry in the cached cell catalogue
+ */
+struct afs_cache_cell
+{
+ char name[64]; /* cell name (padded with NULs) */
+ struct in_addr servers[15]; /* cached cell servers */
+};
+
+/*****************************************************************************/
+/*
* AFS cell record
*/
struct afs_cell
@@ -26,7 +38,7 @@
struct list_head link; /* main cell list link */
struct list_head proc_link; /* /proc cell list link */
struct proc_dir_entry *proc_dir; /* /proc dir for this cell */
- struct list_head caches; /* list of caches currently backing this cell */
+ struct cachefs_cookie *cache; /* caching cookie */
/* server record management */
rwlock_t sv_lock; /* active server list lock */
@@ -41,7 +53,7 @@
spinlock_t vl_gylock; /* graveyard lock */
unsigned short vl_naddrs; /* number of VL servers in addr list */
unsigned short vl_curr_svix; /* current server index */
- struct in_addr vl_addrs[16]; /* cell VL server addresses */
+ struct in_addr vl_addrs[AFS_CELL_MAX_ADDRS]; /* cell VL server addresses */
char name[0]; /* cell name - must go last */
};
Index: cell.c
===================================================================
RCS file: /home/cvs/afs/fs/afs/cell.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- cell.c 16 Oct 2002 09:59:51 -0000 1.6
+++ cell.c 6 Jun 2003 08:33:37 -0000 1.7
@@ -36,6 +36,17 @@
MODULE_PARM(rootcell,"s");
MODULE_PARM_DESC(rootcell,"root AFS cell name and VL server IP addr list");
+static cachefs_match_val_t afs_cell_cache_match(void *target, const void *entry);
+static void afs_cell_cache_update(void *source, void *entry);
+
+struct cachefs_index_def afs_cache_cell_index_def = {
+ .name = "cell_ix",
+ .data_size = sizeof(afs_cell_t),
+ .keys[0] = { CACHEFS_INDEX_KEYS_ASCIIZ, 64 },
+ .match = afs_cell_cache_match,
+ .update = afs_cell_cache_update,
+};
+
/*****************************************************************************/
/*
* create a cell record
@@ -65,7 +76,6 @@
atomic_set(&cell->usage,0);
INIT_LIST_HEAD(&cell->link);
- INIT_LIST_HEAD(&cell->caches);
rwlock_init(&cell->sv_lock);
INIT_LIST_HEAD(&cell->sv_list);
@@ -96,7 +106,7 @@
cell->vl_addrs[cell->vl_naddrs++].s_addr =
htonl((a<<24)|(b<<16)|(c<<8)|d);
- if (cell->vl_naddrs>=16)
+ if (cell->vl_naddrs >= AFS_CELL_MAX_ADDRS)
break;
} while(vllist=next, vllist);
@@ -106,6 +116,12 @@
if (ret<0)
goto error;
+ /* put it up for caching */
+ cachefs_acquire_cookie(afs_cache_netfs.primary_index,
+ &afs_vlocation_cache_index_def,
+ cell,
+ &cell->cache);
+
/* add to the cell lists */
write_lock(&afs_cells_lock);
list_add_tail(&cell->link,&afs_cells);
@@ -212,7 +228,7 @@
cell = *_cell;
if (cell && !list_empty(&cell->link))
atomic_inc(&cell->usage);
- else
+ else
cell = NULL;
write_unlock(&afs_cells_lock);
@@ -278,6 +294,8 @@
list_del_init(&cell->proc_link);
up_write(&afs_proc_cells_sem);
+ cachefs_relinquish_cookie(cell->cache,0);
+
up_write(&afs_cells_sem);
if (!list_empty(&cell->sv_list)) BUG();
@@ -450,3 +468,35 @@
_leave("");
} /* end afs_cell_purge() */
+
+/*****************************************************************************/
+/*
+ * match a cell record obtained from the cache
+ */
+static cachefs_match_val_t afs_cell_cache_match(void *target, const void *entry)
+{
+ const struct afs_cache_cell *ccell = entry;
+ struct afs_cell *cell = target;
+
+ kenter("");
+
+ if (strncmp(ccell->name,cell->name,sizeof(ccell->name))==0)
+ return CACHEFS_MATCH_SUCCESS;
+
+ return CACHEFS_MATCH_FAILED;
+} /* end afs_cell_cache_match() */
+
+/*****************************************************************************/
+/*
+ * update a cell record in the cache
+ */
+static void afs_cell_cache_update(void *source, void *entry)
+{
+ struct afs_cache_cell *ccell = entry;
+ struct afs_cell *cell = source;
+
+ kenter("%p,%p",source,entry);
+
+ strncpy(ccell->name,cell->name,sizeof(ccell->name));
+
+} /* end afs_cell_cache_update() */
Index: cache.h
===================================================================
RCS file: /home/cvs/afs/fs/afs/cache.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- cache.h 11 Oct 2002 18:37:25 -0000 1.12
+++ cache.h 6 Jun 2003 08:33:37 -0000 1.13
@@ -14,28 +14,10 @@
#include <linux/version.h>
#include <linux/mm.h>
+#include <linux/cachefs.h>
#include "types.h"
#ifdef __KERNEL__
-
-typedef struct afs_cached_file {
- afsc_cache_vldb_t *vldb; /* VLDB, cell and cache records */
- unsigned index; /* vnode catalogue index */
- unsigned meta_ix; /* meta data record index */
- struct page *meta_page; /* page holding meta data record */
-} afs_cached_file_t;
-
-extern int afs_cache_cell_update(afs_cell_t *vnode);
-extern int afs_cache_cell_delete(afs_cell_t *vnode);
-extern int afs_cache_vlocation_update(afs_vlocation_t *vnode);
-extern int afs_cache_vlocation_delete(afs_vlocation_t *vnode);
-
-extern int afs_cache_file_open(afs_cached_file_t *handle, afs_vnode_t *vnode);
-extern int afs_cache_file_update(afs_cached_file_t *handle, afs_vnode_t *vnode);
-extern int afs_cache_file_release(afs_cached_file_t *handle);
-
-extern int afs_cache_file_readpage(afs_cached_file_t *handle, struct page *page);
-extern int afs_cache_file_writepage(afs_cached_file_t *handle, struct page *page);
#endif /* __KERNEL__ */
More information about the linux-afs-cvs
mailing list