Commit 2244b109 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] AFS upgrade

From: David Howells <dhowells@redhat.com>

Here's a patch to improve the AFS linux support. It:

 (1) Includes Pete's patch to skip the colon in the volume name, compile
     directly into the kernel, and not try to access non-existent caching
     routines.

 (2) Changes if (...) BUG() to BUG_ON()

 (3) Gets rid of typedefs.

 (4) Changes list_for_each() into list_for_each_entry().

 (5) Adds more whitespace and wraps lines to please the CodingStyle sticklers.
parent ae450eb1
...@@ -24,28 +24,28 @@ ...@@ -24,28 +24,28 @@
/* /*
* allow the fileserver to request callback state (re-)initialisation * allow the fileserver to request callback state (re-)initialisation
*/ */
int SRXAFSCM_InitCallBackState(afs_server_t *server) int SRXAFSCM_InitCallBackState(struct afs_server *server)
{ {
struct list_head callbacks; struct list_head callbacks;
_enter("%p",server); _enter("%p", server);
INIT_LIST_HEAD(&callbacks); INIT_LIST_HEAD(&callbacks);
/* transfer the callback list from the server to a temp holding area */ /* transfer the callback list from the server to a temp holding area */
spin_lock(&server->cb_lock); spin_lock(&server->cb_lock);
list_add(&callbacks,&server->cb_promises); list_add(&callbacks, &server->cb_promises);
list_del_init(&server->cb_promises); list_del_init(&server->cb_promises);
/* munch our way through the list, grabbing the inode, dropping all the locks and regetting /* munch our way through the list, grabbing the inode, dropping all the
* them in the right order * locks and regetting them in the right order
*/ */
while (!list_empty(&callbacks)) { while (!list_empty(&callbacks)) {
struct afs_vnode *vnode;
struct inode *inode; struct inode *inode;
afs_vnode_t *vnode;
vnode = list_entry(callbacks.next,afs_vnode_t,cb_link); vnode = list_entry(callbacks.next, struct afs_vnode, cb_link);
list_del_init(&vnode->cb_link); list_del_init(&vnode->cb_link);
/* try and grab the inode - may fail */ /* try and grab the inode - may fail */
...@@ -56,7 +56,7 @@ int SRXAFSCM_InitCallBackState(afs_server_t *server) ...@@ -56,7 +56,7 @@ int SRXAFSCM_InitCallBackState(afs_server_t *server)
spin_unlock(&server->cb_lock); spin_unlock(&server->cb_lock);
spin_lock(&vnode->lock); spin_lock(&vnode->lock);
if (vnode->cb_server==server) { if (vnode->cb_server == server) {
vnode->cb_server = NULL; vnode->cb_server = NULL;
afs_kafstimod_del_timer(&vnode->cb_timeout); afs_kafstimod_del_timer(&vnode->cb_timeout);
spin_lock(&afs_cb_hash_lock); spin_lock(&afs_cb_hash_lock);
...@@ -84,15 +84,14 @@ int SRXAFSCM_InitCallBackState(afs_server_t *server) ...@@ -84,15 +84,14 @@ int SRXAFSCM_InitCallBackState(afs_server_t *server)
/* /*
* allow the fileserver to break callback promises * allow the fileserver to break callback promises
*/ */
int SRXAFSCM_CallBack(afs_server_t *server, size_t count, afs_callback_t callbacks[]) int SRXAFSCM_CallBack(struct afs_server *server, size_t count,
struct afs_callback callbacks[])
{ {
struct list_head *_p; _enter("%p,%u,", server, count);
_enter("%p,%u,",server,count); for (; count > 0; callbacks++, count--) {
struct afs_vnode *vnode = NULL;
for (; count>0; callbacks++, count--) {
struct inode *inode = NULL; struct inode *inode = NULL;
afs_vnode_t *vnode = NULL;
int valid = 0; int valid = 0;
_debug("- Fid { vl=%08x n=%u u=%u } CB { v=%u x=%u t=%u }", _debug("- Fid { vl=%08x n=%u u=%u } CB { v=%u x=%u t=%u }",
...@@ -107,14 +106,15 @@ int SRXAFSCM_CallBack(afs_server_t *server, size_t count, afs_callback_t callbac ...@@ -107,14 +106,15 @@ int SRXAFSCM_CallBack(afs_server_t *server, size_t count, afs_callback_t callbac
/* find the inode for this fid */ /* find the inode for this fid */
spin_lock(&afs_cb_hash_lock); spin_lock(&afs_cb_hash_lock);
list_for_each(_p,&afs_cb_hash(server,&callbacks->fid)) { list_for_each_entry(vnode,
vnode = list_entry(_p,afs_vnode_t,cb_hash_link); &afs_cb_hash(server, &callbacks->fid),
cb_hash_link) {
if (memcmp(&vnode->fid,&callbacks->fid,sizeof(afs_fid_t))!=0) if (memcmp(&vnode->fid, &callbacks->fid,
sizeof(struct afs_fid)) != 0)
continue; continue;
/* right vnode, but is it same server? */ /* right vnode, but is it same server? */
if (vnode->cb_server!=server) if (vnode->cb_server != server)
break; /* no */ break; /* no */
/* try and nail the inode down */ /* try and nail the inode down */
...@@ -127,7 +127,7 @@ int SRXAFSCM_CallBack(afs_server_t *server, size_t count, afs_callback_t callbac ...@@ -127,7 +127,7 @@ int SRXAFSCM_CallBack(afs_server_t *server, size_t count, afs_callback_t callbac
if (inode) { if (inode) {
/* we've found the record for this vnode */ /* we've found the record for this vnode */
spin_lock(&vnode->lock); spin_lock(&vnode->lock);
if (vnode->cb_server==server) { if (vnode->cb_server == server) {
/* the callback _is_ on the calling server */ /* the callback _is_ on the calling server */
vnode->cb_server = NULL; vnode->cb_server = NULL;
valid = 1; valid = 1;
...@@ -161,8 +161,8 @@ int SRXAFSCM_CallBack(afs_server_t *server, size_t count, afs_callback_t callbac ...@@ -161,8 +161,8 @@ int SRXAFSCM_CallBack(afs_server_t *server, size_t count, afs_callback_t callbac
/* /*
* allow the fileserver to see if the cache manager is still alive * allow the fileserver to see if the cache manager is still alive
*/ */
int SRXAFSCM_Probe(afs_server_t *server) int SRXAFSCM_Probe(struct afs_server *server)
{ {
_debug("SRXAFSCM_Probe(%p)\n",server); _debug("SRXAFSCM_Probe(%p)\n", server);
return 0; return 0;
} /* end SRXAFSCM_Probe() */ } /* end SRXAFSCM_Probe() */
This diff is collapsed.
...@@ -61,7 +61,7 @@ struct afs_cell ...@@ -61,7 +61,7 @@ struct afs_cell
char name[0]; /* cell name - must go last */ char name[0]; /* cell name - must go last */
}; };
extern int afs_cell_init(void); extern int afs_cell_init(char *rootcell);
extern int afs_cell_create(const char *name, char *vllist, struct afs_cell **_cell); extern int afs_cell_create(const char *name, char *vllist, struct afs_cell **_cell);
......
This diff is collapsed.
...@@ -20,8 +20,10 @@ extern int afscm_start(void); ...@@ -20,8 +20,10 @@ extern int afscm_start(void);
extern void afscm_stop(void); extern void afscm_stop(void);
/* cache manager server functions */ /* cache manager server functions */
extern int SRXAFSCM_InitCallBackState(afs_server_t *server); extern int SRXAFSCM_InitCallBackState(struct afs_server *server);
extern int SRXAFSCM_CallBack(afs_server_t *server, size_t count, afs_callback_t callbacks[]); extern int SRXAFSCM_CallBack(struct afs_server *server,
extern int SRXAFSCM_Probe(afs_server_t *server); size_t count,
struct afs_callback callbacks[]);
extern int SRXAFSCM_Probe(struct afs_server *server);
#endif /* _LINUX_AFS_CMSERVICE_H */ #endif /* _LINUX_AFS_CMSERVICE_H */
This diff is collapsed.
...@@ -31,7 +31,8 @@ static int afs_file_readpage(struct file *file, struct page *page); ...@@ -31,7 +31,8 @@ static int afs_file_readpage(struct file *file, struct page *page);
static int afs_file_invalidatepage(struct page *page, unsigned long offset); static int afs_file_invalidatepage(struct page *page, unsigned long offset);
static int afs_file_releasepage(struct page *page, int gfp_flags); static int afs_file_releasepage(struct page *page, int gfp_flags);
static ssize_t afs_file_write(struct file *file, const char *buf, size_t size, loff_t *off); static ssize_t afs_file_write(struct file *file, const char *buf, size_t size,
loff_t *off);
struct inode_operations afs_file_inode_operations = { struct inode_operations afs_file_inode_operations = {
.getattr = afs_inode_getattr, .getattr = afs_inode_getattr,
...@@ -60,9 +61,10 @@ struct address_space_operations afs_fs_aops = { ...@@ -60,9 +61,10 @@ struct address_space_operations afs_fs_aops = {
/* /*
* AFS file write * AFS file write
*/ */
static ssize_t afs_file_write(struct file *file, const char *buf, size_t size, loff_t *off) static ssize_t afs_file_write(struct file *file, const char *buf, size_t size,
loff_t *off)
{ {
afs_vnode_t *vnode; struct afs_vnode *vnode;
vnode = AFS_FS_I(file->f_dentry->d_inode); vnode = AFS_FS_I(file->f_dentry->d_inode);
if (vnode->flags & AFS_VNODE_DELETED) if (vnode->flags & AFS_VNODE_DELETED)
...@@ -76,10 +78,12 @@ static ssize_t afs_file_write(struct file *file, const char *buf, size_t size, l ...@@ -76,10 +78,12 @@ static ssize_t afs_file_write(struct file *file, const char *buf, size_t size, l
* deal with notification that a page was read from the cache * deal with notification that a page was read from the cache
*/ */
#ifdef AFS_CACHING_SUPPORT #ifdef AFS_CACHING_SUPPORT
static void afs_file_readpage_read_complete(void *cookie_data, struct page *page, void *data, static void afs_file_readpage_read_complete(void *cookie_data,
struct page *page,
void *data,
int error) int error)
{ {
_enter("%p,%p,%p,%d",cookie_data,page,data,error); _enter("%p,%p,%p,%d", cookie_data, page, data, error);
if (error) if (error)
SetPageError(page); SetPageError(page);
...@@ -95,10 +99,12 @@ static void afs_file_readpage_read_complete(void *cookie_data, struct page *page ...@@ -95,10 +99,12 @@ static void afs_file_readpage_read_complete(void *cookie_data, struct page *page
* deal with notification that a page was written to the cache * deal with notification that a page was written to the cache
*/ */
#ifdef AFS_CACHING_SUPPORT #ifdef AFS_CACHING_SUPPORT
static void afs_file_readpage_write_complete(void *cookie_data, struct page *page, void *data, static void afs_file_readpage_write_complete(void *cookie_data,
struct page *page,
void *data,
int error) int error)
{ {
_enter("%p,%p,%p,%d",cookie_data,page,data,error); _enter("%p,%p,%p,%d", cookie_data, page, data, error);
unlock_page(page); unlock_page(page);
...@@ -115,13 +121,13 @@ static int afs_file_readpage(struct file *file, struct page *page) ...@@ -115,13 +121,13 @@ static int afs_file_readpage(struct file *file, struct page *page)
#ifdef AFS_CACHING_SUPPORT #ifdef AFS_CACHING_SUPPORT
struct cachefs_page *pageio; struct cachefs_page *pageio;
#endif #endif
struct afs_vnode *vnode;
struct inode *inode; struct inode *inode;
afs_vnode_t *vnode;
int ret; int ret;
inode = page->mapping->host; inode = page->mapping->host;
_enter("{%lu},{%lu}",inode->i_ino,page->index); _enter("{%lu},{%lu}", inode->i_ino, page->index);
vnode = AFS_FS_I(inode); vnode = AFS_FS_I(inode);
...@@ -133,8 +139,8 @@ static int afs_file_readpage(struct file *file, struct page *page) ...@@ -133,8 +139,8 @@ static int afs_file_readpage(struct file *file, struct page *page)
goto error; goto error;
#ifdef AFS_CACHING_SUPPORT #ifdef AFS_CACHING_SUPPORT
ret = cachefs_page_get_private(page,&pageio,GFP_NOIO); ret = cachefs_page_get_private(page, &pageio, GFP_NOIO);
if (ret<0) if (ret < 0)
goto error; goto error;
/* is it cached? */ /* is it cached? */
...@@ -162,23 +168,26 @@ static int afs_file_readpage(struct file *file, struct page *page) ...@@ -162,23 +168,26 @@ static int afs_file_readpage(struct file *file, struct page *page)
default: default:
desc.fid = vnode->fid; desc.fid = vnode->fid;
desc.offset = page->index << PAGE_CACHE_SHIFT; desc.offset = page->index << PAGE_CACHE_SHIFT;
desc.size = min((size_t)(inode->i_size - desc.offset),(size_t)PAGE_SIZE); desc.size = min((size_t) (inode->i_size - desc.offset),
(size_t) PAGE_SIZE);
desc.buffer = kmap(page); desc.buffer = kmap(page);
clear_page(desc.buffer); clear_page(desc.buffer);
/* read the contents of the file from the server into the page */ /* read the contents of the file from the server into the
ret = afs_vnode_fetch_data(vnode,&desc); * page */
ret = afs_vnode_fetch_data(vnode, &desc);
kunmap(page); kunmap(page);
if (ret<0) { if (ret < 0) {
if (ret==-ENOENT) { if (ret==-ENOENT) {
_debug("got NOENT from server - marking file deleted and stale"); _debug("got NOENT from server"
" - marking file deleted and stale");
vnode->flags |= AFS_VNODE_DELETED; vnode->flags |= AFS_VNODE_DELETED;
ret = -ESTALE; ret = -ESTALE;
} }
#ifdef AFS_CACHING_SUPPORT #ifdef AFS_CACHING_SUPPORT
cachefs_uncache_page(vnode->cache,page); cachefs_uncache_page(vnode->cache, page);
#endif #endif
goto error; goto error;
} }
...@@ -192,7 +201,7 @@ static int afs_file_readpage(struct file *file, struct page *page) ...@@ -192,7 +201,7 @@ static int afs_file_readpage(struct file *file, struct page *page)
NULL, NULL,
GFP_KERNEL) != 0 GFP_KERNEL) != 0
) { ) {
cachefs_uncache_page(vnode->cache,page); cachefs_uncache_page(vnode->cache, page);
unlock_page(page); unlock_page(page);
} }
#else #else
...@@ -207,7 +216,7 @@ static int afs_file_readpage(struct file *file, struct page *page) ...@@ -207,7 +216,7 @@ static int afs_file_readpage(struct file *file, struct page *page)
SetPageError(page); SetPageError(page);
unlock_page(page); unlock_page(page);
_leave(" = %d",ret); _leave(" = %d", ret);
return ret; return ret;
} /* end afs_file_readpage() */ } /* end afs_file_readpage() */
...@@ -217,14 +226,15 @@ static int afs_file_readpage(struct file *file, struct page *page) ...@@ -217,14 +226,15 @@ static int afs_file_readpage(struct file *file, struct page *page)
* get a page cookie for the specified page * get a page cookie for the specified page
*/ */
#ifdef AFS_CACHING_SUPPORT #ifdef AFS_CACHING_SUPPORT
int afs_cache_get_page_cookie(struct page *page, struct cachefs_page **_page_cookie) int afs_cache_get_page_cookie(struct page *page,
struct cachefs_page **_page_cookie)
{ {
int ret; int ret;
_enter(""); _enter("");
ret = cachefs_page_get_private(page,_page_cookie,GFP_NOIO); ret = cachefs_page_get_private(page,_page_cookie, GFP_NOIO);
_leave(" = %d",ret); _leave(" = %d", ret);
return ret; return ret;
} /* end afs_cache_get_page_cookie() */ } /* end afs_cache_get_page_cookie() */
#endif #endif
...@@ -237,30 +247,32 @@ static int afs_file_invalidatepage(struct page *page, unsigned long offset) ...@@ -237,30 +247,32 @@ static int afs_file_invalidatepage(struct page *page, unsigned long offset)
{ {
int ret = 1; int ret = 1;
_enter("{%lu},%lu",page->index,offset); _enter("{%lu},%lu", page->index, offset);
BUG_ON(!PageLocked(page)); BUG_ON(!PageLocked(page));
if (PagePrivate(page)) { if (PagePrivate(page)) {
#ifdef AFS_CACHING_SUPPORT #ifdef AFS_CACHING_SUPPORT
struct afs_vnode *vnode = AFS_FS_I(page->mapping->host); struct afs_vnode *vnode = AFS_FS_I(page->mapping->host);
cachefs_uncache_page(vnode->cache,page); cachefs_uncache_page(vnode->cache,page);
#endif #endif
/* /* We release buffers only if the entire page is being
* We release buffers only if the entire page is being invalidated. * invalidated.
* The get_block cached value has been unconditionally invalidated, * The get_block cached value has been unconditionally
* so real IO is not possible anymore. * invalidated, so real IO is not possible anymore.
*/ */
if (offset == 0) { if (offset == 0) {
BUG_ON(!PageLocked(page)); BUG_ON(!PageLocked(page));
ret = 0; ret = 0;
if (!PageWriteback(page)) if (!PageWriteback(page))
ret = page->mapping->a_ops->releasepage(page, 0); ret = page->mapping->a_ops->releasepage(page,
0);
} }
} }
_leave(" = %d",ret); _leave(" = %d", ret);
return ret; return ret;
} /* end afs_file_invalidatepage() */ } /* end afs_file_invalidatepage() */
...@@ -272,12 +284,12 @@ static int afs_file_releasepage(struct page *page, int gfp_flags) ...@@ -272,12 +284,12 @@ static int afs_file_releasepage(struct page *page, int gfp_flags)
{ {
struct cachefs_page *pageio; struct cachefs_page *pageio;
_enter("{%lu},%x",page->index,gfp_flags); _enter("{%lu},%x", page->index, gfp_flags);
if (PagePrivate(page)) { if (PagePrivate(page)) {
#ifdef AFS_CACHING_SUPPORT #ifdef AFS_CACHING_SUPPORT
struct afs_vnode *vnode = AFS_FS_I(page->mapping->host); struct afs_vnode *vnode = AFS_FS_I(page->mapping->host);
cachefs_uncache_page(vnode->cache,page); cachefs_uncache_page(vnode->cache, page);
#endif #endif
pageio = (struct cachefs_page *) page->private; pageio = (struct cachefs_page *) page->private;
......
This diff is collapsed.
...@@ -14,38 +14,39 @@ ...@@ -14,38 +14,39 @@
#include "server.h" #include "server.h"
extern int afs_rxfs_get_volume_info(afs_server_t *server, extern int afs_rxfs_get_volume_info(struct afs_server *server,
const char *name, const char *name,
afs_volume_info_t *vinfo); struct afs_volume_info *vinfo);
extern int afs_rxfs_fetch_file_status(afs_server_t *server, extern int afs_rxfs_fetch_file_status(struct afs_server *server,
afs_vnode_t *vnode, struct afs_vnode *vnode,
afs_volsync_t *volsync); struct afs_volsync *volsync);
struct afs_rxfs_fetch_descriptor { struct afs_rxfs_fetch_descriptor {
afs_fid_t fid; /* file ID to fetch */ struct afs_fid fid; /* file ID to fetch */
size_t size; /* total number of bytes to fetch */ size_t size; /* total number of bytes to fetch */
off_t offset; /* offset in file to start from */ off_t offset; /* offset in file to start from */
void *buffer; /* read buffer */ void *buffer; /* read buffer */
size_t actual; /* actual size sent back by server */ size_t actual; /* actual size sent back by server */
}; };
extern int afs_rxfs_fetch_file_data(afs_server_t *server, extern int afs_rxfs_fetch_file_data(struct afs_server *server,
afs_vnode_t *vnode, struct afs_vnode *vnode,
struct afs_rxfs_fetch_descriptor *desc, struct afs_rxfs_fetch_descriptor *desc,
afs_volsync_t *volsync); struct afs_volsync *volsync);
extern int afs_rxfs_give_up_callback(afs_server_t *server, afs_vnode_t *vnode); extern int afs_rxfs_give_up_callback(struct afs_server *server,
struct afs_vnode *vnode);
/* this doesn't appear to work in OpenAFS server */ /* this doesn't appear to work in OpenAFS server */
extern int afs_rxfs_lookup(afs_server_t *server, extern int afs_rxfs_lookup(struct afs_server *server,
afs_vnode_t *dir, struct afs_vnode *dir,
const char *filename, const char *filename,
afs_vnode_t *vnode, struct afs_vnode *vnode,
afs_volsync_t *volsync); struct afs_volsync *volsync);
/* this is apparently mis-implemented in OpenAFS server */ /* this is apparently mis-implemented in OpenAFS server */
extern int afs_rxfs_get_root_volume(afs_server_t *server, extern int afs_rxfs_get_root_volume(struct afs_server *server,
char *buf, char *buf,
size_t *buflen); size_t *buflen);
......
...@@ -26,15 +26,15 @@ ...@@ -26,15 +26,15 @@
#include "internal.h" #include "internal.h"
struct afs_iget_data { struct afs_iget_data {
afs_fid_t fid; struct afs_fid fid;
afs_volume_t *volume; /* volume on which resides */ struct afs_volume *volume; /* volume on which resides */
}; };
/*****************************************************************************/ /*****************************************************************************/
/* /*
* map the AFS file status to the inode member variables * map the AFS file status to the inode member variables
*/ */
static int afs_inode_map_status(afs_vnode_t *vnode) static int afs_inode_map_status(struct afs_vnode *vnode)
{ {
struct inode *inode = AFS_VNODE_TO_I(vnode); struct inode *inode = AFS_VNODE_TO_I(vnode);
...@@ -97,7 +97,7 @@ static int afs_inode_map_status(afs_vnode_t *vnode) ...@@ -97,7 +97,7 @@ static int afs_inode_map_status(afs_vnode_t *vnode)
*/ */
int afs_inode_fetch_status(struct inode *inode) int afs_inode_fetch_status(struct inode *inode)
{ {
afs_vnode_t *vnode; struct afs_vnode *vnode;
int ret; int ret;
vnode = AFS_FS_I(inode); vnode = AFS_FS_I(inode);
...@@ -130,7 +130,7 @@ static int afs_iget5_test(struct inode *inode, void *opaque) ...@@ -130,7 +130,7 @@ static int afs_iget5_test(struct inode *inode, void *opaque)
static int afs_iget5_set(struct inode *inode, void *opaque) static int afs_iget5_set(struct inode *inode, void *opaque)
{ {
struct afs_iget_data *data = opaque; struct afs_iget_data *data = opaque;
afs_vnode_t *vnode = AFS_FS_I(inode); struct afs_vnode *vnode = AFS_FS_I(inode);
inode->i_ino = data->fid.vnode; inode->i_ino = data->fid.vnode;
inode->i_version = data->fid.unique; inode->i_version = data->fid.unique;
...@@ -144,7 +144,7 @@ static int afs_iget5_set(struct inode *inode, void *opaque) ...@@ -144,7 +144,7 @@ static int afs_iget5_set(struct inode *inode, void *opaque)
/* /*
* inode retrieval * inode retrieval
*/ */
inline int afs_iget(struct super_block *sb, afs_fid_t *fid, inline int afs_iget(struct super_block *sb, struct afs_fid *fid,
struct inode **_inode) struct inode **_inode)
{ {
struct afs_iget_data data = { fid: *fid }; struct afs_iget_data data = { fid: *fid };
...@@ -201,7 +201,11 @@ inline int afs_iget(struct super_block *sb, afs_fid_t *fid, ...@@ -201,7 +201,11 @@ inline int afs_iget(struct super_block *sb, afs_fid_t *fid,
vnode->cb_version, vnode->cb_version,
vnode->cb_timeout.timo_jif, vnode->cb_timeout.timo_jif,
vnode->cb_type, vnode->cb_type,
#ifdef AFS_CACHING_SUPPORT
vnode->cache vnode->cache
#else
NULL
#endif
); );
return 0; return 0;
...@@ -222,8 +226,8 @@ inline int afs_iget(struct super_block *sb, afs_fid_t *fid, ...@@ -222,8 +226,8 @@ inline int afs_iget(struct super_block *sb, afs_fid_t *fid,
int afs_inode_getattr(struct vfsmount *mnt, struct dentry *dentry, int afs_inode_getattr(struct vfsmount *mnt, struct dentry *dentry,
struct kstat *stat) struct kstat *stat)
{ {
struct afs_vnode *vnode;
struct inode *inode; struct inode *inode;
afs_vnode_t *vnode;
int ret; int ret;
inode = dentry->d_inode; inode = dentry->d_inode;
...@@ -262,7 +266,7 @@ int afs_inode_getattr(struct vfsmount *mnt, struct dentry *dentry, ...@@ -262,7 +266,7 @@ int afs_inode_getattr(struct vfsmount *mnt, struct dentry *dentry,
*/ */
void afs_clear_inode(struct inode *inode) void afs_clear_inode(struct inode *inode)
{ {
afs_vnode_t *vnode; struct afs_vnode *vnode;
vnode = AFS_FS_I(inode); vnode = AFS_FS_I(inode);
......
...@@ -46,7 +46,7 @@ static inline void afs_discard_my_signals(void) ...@@ -46,7 +46,7 @@ static inline void afs_discard_my_signals(void)
siginfo_t sinfo; siginfo_t sinfo;
spin_lock_irq(&current->sighand->siglock); spin_lock_irq(&current->sighand->siglock);
dequeue_signal(current,&current->blocked,&sinfo); dequeue_signal(current,&current->blocked, &sinfo);
spin_unlock_irq(&current->sighand->siglock); spin_unlock_irq(&current->sighand->siglock);
} }
} }
...@@ -74,16 +74,27 @@ extern struct inode_operations afs_file_inode_operations; ...@@ -74,16 +74,27 @@ extern struct inode_operations afs_file_inode_operations;
extern struct file_operations afs_file_file_operations; extern struct file_operations afs_file_file_operations;
#ifdef AFS_CACHING_SUPPORT #ifdef AFS_CACHING_SUPPORT
extern int afs_cache_get_page_cookie(struct page *page, struct cachefs_page **_page_cookie); extern int afs_cache_get_page_cookie(struct page *page,
struct cachefs_page **_page_cookie);
#endif #endif
/* /*
* inode.c * inode.c
*/ */
extern int afs_iget(struct super_block *sb, afs_fid_t *fid, struct inode **_inode); extern int afs_iget(struct super_block *sb, struct afs_fid *fid,
extern int afs_inode_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat); 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); extern void afs_clear_inode(struct inode *inode);
/*
* key_afs.c
*/
#ifdef CONFIG_KEYS
extern int afs_key_register(void);
extern void afs_key_unregister(void);
#endif
/* /*
* main.c * main.c
*/ */
...@@ -102,7 +113,7 @@ extern struct afs_timer_ops afs_mntpt_expiry_timer_ops; ...@@ -102,7 +113,7 @@ extern struct afs_timer_ops afs_mntpt_expiry_timer_ops;
extern unsigned long afs_mntpt_expiry_timeout; extern unsigned long afs_mntpt_expiry_timeout;
#endif #endif
extern int afs_mntpt_check_symlink(afs_vnode_t *vnode); extern int afs_mntpt_check_symlink(struct afs_vnode *vnode);
/* /*
* super.c * super.c
...@@ -110,13 +121,14 @@ extern int afs_mntpt_check_symlink(afs_vnode_t *vnode); ...@@ -110,13 +121,14 @@ extern int afs_mntpt_check_symlink(afs_vnode_t *vnode);
extern int afs_fs_init(void); extern int afs_fs_init(void);
extern void afs_fs_exit(void); extern void afs_fs_exit(void);
#define AFS_CB_HASH_COUNT (PAGE_SIZE/sizeof(struct list_head)) #define AFS_CB_HASH_COUNT (PAGE_SIZE / sizeof(struct list_head))
extern struct list_head afs_cb_hash_tbl[]; extern struct list_head afs_cb_hash_tbl[];
extern spinlock_t afs_cb_hash_lock; extern spinlock_t afs_cb_hash_lock;
#define afs_cb_hash(SRV,FID) \ #define afs_cb_hash(SRV,FID) \
afs_cb_hash_tbl[((unsigned long)(SRV) + (FID)->vid + (FID)->vnode + (FID)->unique) % \ afs_cb_hash_tbl[((unsigned long)(SRV) + \
(FID)->vid + (FID)->vnode + (FID)->unique) % \
AFS_CB_HASH_COUNT] AFS_CB_HASH_COUNT]
/* /*
...@@ -124,7 +136,7 @@ extern spinlock_t afs_cb_hash_lock; ...@@ -124,7 +136,7 @@ extern spinlock_t afs_cb_hash_lock;
*/ */
extern int afs_proc_init(void); extern int afs_proc_init(void);
extern void afs_proc_cleanup(void); extern void afs_proc_cleanup(void);
extern int afs_proc_cell_setup(afs_cell_t *cell); extern int afs_proc_cell_setup(struct afs_cell *cell);
extern void afs_proc_cell_remove(afs_cell_t *cell); extern void afs_proc_cell_remove(struct afs_cell *cell);
#endif /* AFS_INTERNAL_H */ #endif /* AFS_INTERNAL_H */
...@@ -57,8 +57,8 @@ int afs_kafsasyncd_start(void) ...@@ -57,8 +57,8 @@ int afs_kafsasyncd_start(void)
{ {
int ret; int ret;
ret = kernel_thread(kafsasyncd,NULL,0); ret = kernel_thread(kafsasyncd, NULL, 0);
if (ret<0) if (ret < 0)
return ret; return ret;
wait_for_completion(&kafsasyncd_alive); wait_for_completion(&kafsasyncd_alive);
...@@ -85,14 +85,14 @@ void afs_kafsasyncd_stop(void) ...@@ -85,14 +85,14 @@ void afs_kafsasyncd_stop(void)
*/ */
static int kafsasyncd(void *arg) static int kafsasyncd(void *arg)
{ {
DECLARE_WAITQUEUE(myself,current); struct afs_async_op *op;
struct list_head *_p;
int die; int die;
DECLARE_WAITQUEUE(myself, current);
kafsasyncd_task = current; kafsasyncd_task = current;
printk("kAFS: Started kafsasyncd %d\n",current->pid); printk("kAFS: Started kafsasyncd %d\n", current->pid);
daemonize("kafsasyncd"); daemonize("kafsasyncd");
...@@ -101,7 +101,7 @@ static int kafsasyncd(void *arg) ...@@ -101,7 +101,7 @@ static int kafsasyncd(void *arg)
/* loop around looking for things to attend to */ /* loop around looking for things to attend to */
do { do {
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
add_wait_queue(&kafsasyncd_sleepq,&myself); add_wait_queue(&kafsasyncd_sleepq, &myself);
for (;;) { for (;;) {
if (!list_empty(&kafsasyncd_async_attnq) || if (!list_empty(&kafsasyncd_async_attnq) ||
...@@ -113,7 +113,7 @@ static int kafsasyncd(void *arg) ...@@ -113,7 +113,7 @@ static int kafsasyncd(void *arg)
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
} }
remove_wait_queue(&kafsasyncd_sleepq,&myself); remove_wait_queue(&kafsasyncd_sleepq, &myself);
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);
/* discard pending signals */ /* discard pending signals */
...@@ -121,7 +121,8 @@ static int kafsasyncd(void *arg) ...@@ -121,7 +121,8 @@ static int kafsasyncd(void *arg)
die = kafsasyncd_die; die = kafsasyncd_die;
/* deal with the next asynchronous operation requiring attention */ /* deal with the next asynchronous operation requiring
* attention */
if (!list_empty(&kafsasyncd_async_attnq)) { if (!list_empty(&kafsasyncd_async_attnq)) {
struct afs_async_op *op; struct afs_async_op *op;
...@@ -131,14 +132,17 @@ static int kafsasyncd(void *arg) ...@@ -131,14 +132,17 @@ static int kafsasyncd(void *arg)
spin_lock(&kafsasyncd_async_lock); spin_lock(&kafsasyncd_async_lock);
if (!list_empty(&kafsasyncd_async_attnq)) { if (!list_empty(&kafsasyncd_async_attnq)) {
op = list_entry(kafsasyncd_async_attnq.next,afs_async_op_t,link); op = list_entry(kafsasyncd_async_attnq.next,
struct afs_async_op, link);
list_del(&op->link); list_del(&op->link);
list_add_tail(&op->link,&kafsasyncd_async_busyq); list_add_tail(&op->link,
&kafsasyncd_async_busyq);
} }
spin_unlock(&kafsasyncd_async_lock); spin_unlock(&kafsasyncd_async_lock);
_debug("@@@ Operation %p {%p}\n",op,op?op->ops:NULL); _debug("@@@ Operation %p {%p}\n",
op, op ? op->ops : NULL);
if (op) if (op)
op->ops->attend(op); op->ops->attend(op);
...@@ -148,30 +152,30 @@ static int kafsasyncd(void *arg) ...@@ -148,30 +152,30 @@ static int kafsasyncd(void *arg)
} while(!die); } while(!die);
/* need to kill all outstanding asynchronous operations before exiting */ /* need to kill all outstanding asynchronous operations before
* exiting */
kafsasyncd_task = NULL; kafsasyncd_task = NULL;
spin_lock(&kafsasyncd_async_lock); spin_lock(&kafsasyncd_async_lock);
/* fold the busy and attention queues together */ /* fold the busy and attention queues together */
list_splice_init(&kafsasyncd_async_busyq,&kafsasyncd_async_attnq); list_splice_init(&kafsasyncd_async_busyq,
&kafsasyncd_async_attnq);
/* dequeue kafsasyncd from all their wait queues */ /* dequeue kafsasyncd from all their wait queues */
list_for_each(_p,&kafsasyncd_async_attnq) { list_for_each_entry(op, &kafsasyncd_async_attnq, link) {
afs_async_op_t *op = list_entry(_p,afs_async_op_t,link);
op->call->app_attn_func = kafsasyncd_null_call_attn_func; op->call->app_attn_func = kafsasyncd_null_call_attn_func;
op->call->app_error_func = kafsasyncd_null_call_error_func; op->call->app_error_func = kafsasyncd_null_call_error_func;
remove_wait_queue(&op->call->waitq,&op->waiter); remove_wait_queue(&op->call->waitq, &op->waiter);
} }
spin_unlock(&kafsasyncd_async_lock); spin_unlock(&kafsasyncd_async_lock);
/* abort all the operations */ /* abort all the operations */
while (!list_empty(&kafsasyncd_async_attnq)) { while (!list_empty(&kafsasyncd_async_attnq)) {
afs_async_op_t *op = list_entry(_p,afs_async_op_t,link); op = list_entry(kafsasyncd_async_attnq.next, struct afs_async_op, link);
list_del_init(&op->link); list_del_init(&op->link);
rxrpc_call_abort(op->call,-EIO); rxrpc_call_abort(op->call, -EIO);
rxrpc_put_call(op->call); rxrpc_put_call(op->call);
op->call = NULL; op->call = NULL;
...@@ -180,7 +184,7 @@ static int kafsasyncd(void *arg) ...@@ -180,7 +184,7 @@ static int kafsasyncd(void *arg)
/* and that's all */ /* and that's all */
_leave(""); _leave("");
complete_and_exit(&kafsasyncd_dead,0); complete_and_exit(&kafsasyncd_dead, 0);
} /* end kafsasyncd() */ } /* end kafsasyncd() */
...@@ -189,17 +193,17 @@ static int kafsasyncd(void *arg) ...@@ -189,17 +193,17 @@ static int kafsasyncd(void *arg)
* begin an operation * begin an operation
* - place operation on busy queue * - place operation on busy queue
*/ */
void afs_kafsasyncd_begin_op(afs_async_op_t *op) void afs_kafsasyncd_begin_op(struct afs_async_op *op)
{ {
_enter(""); _enter("");
spin_lock(&kafsasyncd_async_lock); spin_lock(&kafsasyncd_async_lock);
init_waitqueue_entry(&op->waiter,kafsasyncd_task); init_waitqueue_entry(&op->waiter, kafsasyncd_task);
add_wait_queue(&op->call->waitq,&op->waiter); add_wait_queue(&op->call->waitq, &op->waiter);
list_del(&op->link); list_del(&op->link);
list_add_tail(&op->link,&kafsasyncd_async_busyq); list_add_tail(&op->link, &kafsasyncd_async_busyq);
spin_unlock(&kafsasyncd_async_lock); spin_unlock(&kafsasyncd_async_lock);
...@@ -211,14 +215,14 @@ void afs_kafsasyncd_begin_op(afs_async_op_t *op) ...@@ -211,14 +215,14 @@ void afs_kafsasyncd_begin_op(afs_async_op_t *op)
* request attention for an operation * request attention for an operation
* - move to attention queue * - move to attention queue
*/ */
void afs_kafsasyncd_attend_op(afs_async_op_t *op) void afs_kafsasyncd_attend_op(struct afs_async_op *op)
{ {
_enter(""); _enter("");
spin_lock(&kafsasyncd_async_lock); spin_lock(&kafsasyncd_async_lock);
list_del(&op->link); list_del(&op->link);
list_add_tail(&op->link,&kafsasyncd_async_attnq); list_add_tail(&op->link, &kafsasyncd_async_attnq);
spin_unlock(&kafsasyncd_async_lock); spin_unlock(&kafsasyncd_async_lock);
...@@ -232,7 +236,7 @@ void afs_kafsasyncd_attend_op(afs_async_op_t *op) ...@@ -232,7 +236,7 @@ void afs_kafsasyncd_attend_op(afs_async_op_t *op)
* terminate an operation * terminate an operation
* - remove from either queue * - remove from either queue
*/ */
void afs_kafsasyncd_terminate_op(afs_async_op_t *op) void afs_kafsasyncd_terminate_op(struct afs_async_op *op)
{ {
_enter(""); _enter("");
...@@ -240,7 +244,7 @@ void afs_kafsasyncd_terminate_op(afs_async_op_t *op) ...@@ -240,7 +244,7 @@ void afs_kafsasyncd_terminate_op(afs_async_op_t *op)
if (!list_empty(&op->link)) { if (!list_empty(&op->link)) {
list_del_init(&op->link); list_del_init(&op->link);
remove_wait_queue(&op->call->waitq,&op->waiter); remove_wait_queue(&op->call->waitq, &op->waiter);
} }
spin_unlock(&kafsasyncd_async_lock); spin_unlock(&kafsasyncd_async_lock);
......
...@@ -14,9 +14,11 @@ ...@@ -14,9 +14,11 @@
#include "types.h" #include "types.h"
struct afs_async_op;
struct afs_async_op_ops { struct afs_async_op_ops {
void (*attend)(afs_async_op_t *op); void (*attend)(struct afs_async_op *op);
void (*discard)(afs_async_op_t *op); void (*discard)(struct afs_async_op *op);
}; };
/*****************************************************************************/ /*****************************************************************************/
...@@ -26,13 +28,14 @@ struct afs_async_op_ops { ...@@ -26,13 +28,14 @@ struct afs_async_op_ops {
struct afs_async_op struct afs_async_op
{ {
struct list_head link; struct list_head link;
afs_server_t *server; /* server being contacted */ struct afs_server *server; /* server being contacted */
struct rxrpc_call *call; /* RxRPC call performing op */ struct rxrpc_call *call; /* RxRPC call performing op */
wait_queue_t waiter; /* wait queue for kafsasyncd */ wait_queue_t waiter; /* wait queue for kafsasyncd */
const struct afs_async_op_ops *ops; /* operations */ const struct afs_async_op_ops *ops; /* operations */
}; };
static inline void afs_async_op_init(afs_async_op_t *op, const struct afs_async_op_ops *ops) static inline void afs_async_op_init(struct afs_async_op *op,
const struct afs_async_op_ops *ops)
{ {
INIT_LIST_HEAD(&op->link); INIT_LIST_HEAD(&op->link);
op->call = NULL; op->call = NULL;
...@@ -42,8 +45,8 @@ static inline void afs_async_op_init(afs_async_op_t *op, const struct afs_async_ ...@@ -42,8 +45,8 @@ static inline void afs_async_op_init(afs_async_op_t *op, const struct afs_async_
extern int afs_kafsasyncd_start(void); extern int afs_kafsasyncd_start(void);
extern void afs_kafsasyncd_stop(void); extern void afs_kafsasyncd_stop(void);
extern void afs_kafsasyncd_begin_op(afs_async_op_t *op); extern void afs_kafsasyncd_begin_op(struct afs_async_op *op);
extern void afs_kafsasyncd_attend_op(afs_async_op_t *op); extern void afs_kafsasyncd_attend_op(struct afs_async_op *op);
extern void afs_kafsasyncd_terminate_op(afs_async_op_t *op); extern void afs_kafsasyncd_terminate_op(struct afs_async_op *op);
#endif /* _LINUX_AFS_KAFSASYNCD_H */ #endif /* _LINUX_AFS_KAFSASYNCD_H */
...@@ -37,8 +37,8 @@ int afs_kafstimod_start(void) ...@@ -37,8 +37,8 @@ int afs_kafstimod_start(void)
{ {
int ret; int ret;
ret = kernel_thread(kafstimod,NULL,0); ret = kernel_thread(kafstimod, NULL, 0);
if (ret<0) if (ret < 0)
return ret; return ret;
wait_for_completion(&kafstimod_alive); wait_for_completion(&kafstimod_alive);
...@@ -65,11 +65,11 @@ void afs_kafstimod_stop(void) ...@@ -65,11 +65,11 @@ void afs_kafstimod_stop(void)
*/ */
static int kafstimod(void *arg) static int kafstimod(void *arg)
{ {
DECLARE_WAITQUEUE(myself,current); struct afs_timer *timer;
afs_timer_t *timer; DECLARE_WAITQUEUE(myself, current);
printk("kAFS: Started kafstimod %d\n",current->pid); printk("kAFS: Started kafstimod %d\n", current->pid);
daemonize("kafstimod"); daemonize("kafstimod");
...@@ -78,7 +78,7 @@ static int kafstimod(void *arg) ...@@ -78,7 +78,7 @@ static int kafstimod(void *arg)
/* loop around looking for things to attend to */ /* loop around looking for things to attend to */
loop: loop:
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
add_wait_queue(&kafstimod_sleepq,&myself); add_wait_queue(&kafstimod_sleepq, &myself);
for (;;) { for (;;) {
unsigned long jif; unsigned long jif;
...@@ -86,9 +86,9 @@ static int kafstimod(void *arg) ...@@ -86,9 +86,9 @@ static int kafstimod(void *arg)
/* deal with the server being asked to die */ /* deal with the server being asked to die */
if (kafstimod_die) { if (kafstimod_die) {
remove_wait_queue(&kafstimod_sleepq,&myself); remove_wait_queue(&kafstimod_sleepq, &myself);
_leave(""); _leave("");
complete_and_exit(&kafstimod_dead,0); complete_and_exit(&kafstimod_dead, 0);
} }
/* discard pending signals */ /* discard pending signals */
...@@ -100,15 +100,16 @@ static int kafstimod(void *arg) ...@@ -100,15 +100,16 @@ static int kafstimod(void *arg)
timeout = MAX_SCHEDULE_TIMEOUT; timeout = MAX_SCHEDULE_TIMEOUT;
} }
else { else {
timer = list_entry(kafstimod_list.next,afs_timer_t,link); timer = list_entry(kafstimod_list.next,
struct afs_timer, link);
timeout = timer->timo_jif; timeout = timer->timo_jif;
jif = jiffies; jif = jiffies;
if (time_before_eq((unsigned long)timeout,jif)) if (time_before_eq((unsigned long) timeout, jif))
goto immediate; goto immediate;
else { else {
timeout = (long)timeout - (long)jiffies; timeout = (long) timeout - (long) jiffies;
} }
} }
spin_unlock(&kafstimod_lock); spin_unlock(&kafstimod_lock);
...@@ -119,13 +120,14 @@ static int kafstimod(void *arg) ...@@ -119,13 +120,14 @@ static int kafstimod(void *arg)
} }
/* the thing on the front of the queue needs processing /* the thing on the front of the queue needs processing
* - we come here with the lock held and timer pointing to the expired entry * - we come here with the lock held and timer pointing to the expired
* entry
*/ */
immediate: immediate:
remove_wait_queue(&kafstimod_sleepq,&myself); remove_wait_queue(&kafstimod_sleepq, &myself);
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);
_debug("@@@ Begin Timeout of %p",timer); _debug("@@@ Begin Timeout of %p", timer);
/* dequeue the timer */ /* dequeue the timer */
list_del_init(&timer->link); list_del_init(&timer->link);
...@@ -143,27 +145,28 @@ static int kafstimod(void *arg) ...@@ -143,27 +145,28 @@ static int kafstimod(void *arg)
/* /*
* (re-)queue a timer * (re-)queue a timer
*/ */
void afs_kafstimod_add_timer(afs_timer_t *timer, unsigned long timeout) void afs_kafstimod_add_timer(struct afs_timer *timer, unsigned long timeout)
{ {
struct afs_timer *ptimer;
struct list_head *_p; struct list_head *_p;
afs_timer_t *ptimer;
_enter("%p,%lu",timer,timeout); _enter("%p,%lu", timer, timeout);
spin_lock(&kafstimod_lock); spin_lock(&kafstimod_lock);
list_del(&timer->link); list_del(&timer->link);
/* the timer was deferred or reset - put it back in the queue at the right place */ /* the timer was deferred or reset - put it back in the queue at the
* right place */
timer->timo_jif = jiffies + timeout; timer->timo_jif = jiffies + timeout;
list_for_each(_p,&kafstimod_list) { list_for_each(_p, &kafstimod_list) {
ptimer = list_entry(_p,afs_timer_t,link); ptimer = list_entry(_p, struct afs_timer, link);
if (time_before(timer->timo_jif,ptimer->timo_jif)) if (time_before(timer->timo_jif, ptimer->timo_jif))
break; break;
} }
list_add_tail(&timer->link,_p); /* insert before stopping point */ list_add_tail(&timer->link, _p); /* insert before stopping point */
spin_unlock(&kafstimod_lock); spin_unlock(&kafstimod_lock);
...@@ -177,11 +180,11 @@ void afs_kafstimod_add_timer(afs_timer_t *timer, unsigned long timeout) ...@@ -177,11 +180,11 @@ void afs_kafstimod_add_timer(afs_timer_t *timer, unsigned long timeout)
* dequeue a timer * dequeue a timer
* - returns 0 if the timer was deleted or -ENOENT if it wasn't queued * - returns 0 if the timer was deleted or -ENOENT if it wasn't queued
*/ */
int afs_kafstimod_del_timer(afs_timer_t *timer) int afs_kafstimod_del_timer(struct afs_timer *timer)
{ {
int ret = 0; int ret = 0;
_enter("%p",timer); _enter("%p", timer);
spin_lock(&kafstimod_lock); spin_lock(&kafstimod_lock);
...@@ -194,6 +197,6 @@ int afs_kafstimod_del_timer(afs_timer_t *timer) ...@@ -194,6 +197,6 @@ int afs_kafstimod_del_timer(afs_timer_t *timer)
wake_up(&kafstimod_sleepq); wake_up(&kafstimod_sleepq);
_leave(" = %d",ret); _leave(" = %d", ret);
return ret; return ret;
} /* end afs_kafstimod_del_timer() */ } /* end afs_kafstimod_del_timer() */
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "types.h" #include "types.h"
struct afs_timer;
struct afs_timer_ops { struct afs_timer_ops {
/* called when the front of the timer queue has timed out */ /* called when the front of the timer queue has timed out */
void (*timed_out)(struct afs_timer *timer); void (*timed_out)(struct afs_timer *timer);
...@@ -30,7 +32,8 @@ struct afs_timer ...@@ -30,7 +32,8 @@ struct afs_timer
const struct afs_timer_ops *ops; /* timeout expiry function */ const struct afs_timer_ops *ops; /* timeout expiry function */
}; };
static inline void afs_timer_init(afs_timer_t *timer, const struct afs_timer_ops *ops) static inline void afs_timer_init(struct afs_timer *timer,
const struct afs_timer_ops *ops)
{ {
INIT_LIST_HEAD(&timer->link); INIT_LIST_HEAD(&timer->link);
timer->ops = ops; timer->ops = ops;
...@@ -39,7 +42,8 @@ static inline void afs_timer_init(afs_timer_t *timer, const struct afs_timer_ops ...@@ -39,7 +42,8 @@ static inline void afs_timer_init(afs_timer_t *timer, const struct afs_timer_ops
extern int afs_kafstimod_start(void); extern int afs_kafstimod_start(void);
extern void afs_kafstimod_stop(void); extern void afs_kafstimod_stop(void);
extern void afs_kafstimod_add_timer(afs_timer_t *timer, unsigned long timeout); extern void afs_kafstimod_add_timer(struct afs_timer *timer,
extern int afs_kafstimod_del_timer(afs_timer_t *timer); unsigned long timeout);
extern int afs_kafstimod_del_timer(struct afs_timer *timer);
#endif /* _LINUX_AFS_KAFSTIMOD_H */ #endif /* _LINUX_AFS_KAFSTIMOD_H */
...@@ -33,13 +33,24 @@ static void afs_exit(void); ...@@ -33,13 +33,24 @@ static void afs_exit(void);
static int afs_adding_peer(struct rxrpc_peer *peer); static int afs_adding_peer(struct rxrpc_peer *peer);
static void afs_discarding_peer(struct rxrpc_peer *peer); static void afs_discarding_peer(struct rxrpc_peer *peer);
module_init(afs_init); /* XXX late_initcall is kludgy, but the only alternative seems to create
* a transport upon the first mount, which is worse. Or is it?
*/
/* module_init(afs_init); */
late_initcall(afs_init); /* must be called after net/ to create socket */
module_exit(afs_exit); module_exit(afs_exit);
MODULE_DESCRIPTION("AFS Client File System"); MODULE_DESCRIPTION("AFS Client File System");
MODULE_AUTHOR("Red Hat, Inc."); MODULE_AUTHOR("Red Hat, Inc.");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static char *rootcell;
MODULE_PARM(rootcell, "s");
MODULE_PARM_DESC(rootcell, "root AFS cell name and VL server IP addr list");
static struct rxrpc_peer_ops afs_peer_ops = { static struct rxrpc_peer_ops afs_peer_ops = {
.adding = afs_adding_peer, .adding = afs_adding_peer,
.discarding = afs_discarding_peer, .discarding = afs_discarding_peer,
...@@ -72,7 +83,7 @@ static int afs_init(void) ...@@ -72,7 +83,7 @@ static int afs_init(void)
/* initialise the callback hash table */ /* initialise the callback hash table */
spin_lock_init(&afs_cb_hash_lock); spin_lock_init(&afs_cb_hash_lock);
for (loop=AFS_CB_HASH_COUNT-1; loop>=0; loop--) for (loop = AFS_CB_HASH_COUNT - 1; loop >= 0; loop--)
INIT_LIST_HEAD(&afs_cb_hash_tbl[loop]); INIT_LIST_HEAD(&afs_cb_hash_tbl[loop]);
/* register the /proc stuff */ /* register the /proc stuff */
...@@ -82,20 +93,27 @@ static int afs_init(void) ...@@ -82,20 +93,27 @@ static int afs_init(void)
#ifdef AFS_CACHING_SUPPORT #ifdef AFS_CACHING_SUPPORT
/* we want to be able to cache */ /* we want to be able to cache */
ret = cachefs_register_netfs(&afs_cache_netfs,&afs_cache_cell_index_def); ret = cachefs_register_netfs(&afs_cache_netfs,
&afs_cache_cell_index_def);
if (ret < 0) if (ret < 0)
goto error; goto error;
#endif #endif
/* initialise the cell DB */ #ifdef CONFIG_KEYS
ret = afs_cell_init(); ret = afs_key_register();
if (ret < 0) if (ret < 0)
goto error_cache; goto error_cache;
#endif
/* initialise the cell DB */
ret = afs_cell_init(rootcell);
if (ret < 0)
goto error_keys;
/* start the timeout daemon */ /* start the timeout daemon */
ret = afs_kafstimod_start(); ret = afs_kafstimod_start();
if (ret < 0) if (ret < 0)
goto error_cache; goto error_keys;
/* start the async operation daemon */ /* start the async operation daemon */
ret = afs_kafsasyncd_start(); ret = afs_kafsasyncd_start();
...@@ -103,7 +121,7 @@ static int afs_init(void) ...@@ -103,7 +121,7 @@ static int afs_init(void)
goto error_kafstimod; goto error_kafstimod;
/* create the RxRPC transport */ /* create the RxRPC transport */
ret = rxrpc_create_transport(7001,&afs_transport); ret = rxrpc_create_transport(7001, &afs_transport);
if (ret < 0) if (ret < 0)
goto error_kafsasyncd; goto error_kafsasyncd;
...@@ -122,14 +140,18 @@ static int afs_init(void) ...@@ -122,14 +140,18 @@ static int afs_init(void)
afs_kafsasyncd_stop(); afs_kafsasyncd_stop();
error_kafstimod: error_kafstimod:
afs_kafstimod_stop(); afs_kafstimod_stop();
error_keys:
#ifdef CONFIG_KEYS
afs_key_unregister();
error_cache: error_cache:
#endif
#ifdef AFS_CACHING_SUPPORT #ifdef AFS_CACHING_SUPPORT
cachefs_unregister_netfs(&afs_cache_netfs); cachefs_unregister_netfs(&afs_cache_netfs);
error: error:
#endif #endif
afs_cell_purge(); afs_cell_purge();
afs_proc_cleanup(); afs_proc_cleanup();
printk(KERN_ERR "kAFS: failed to register: %d\n",ret); printk(KERN_ERR "kAFS: failed to register: %d\n", ret);
return ret; return ret;
} /* end afs_init() */ } /* end afs_init() */
...@@ -146,6 +168,9 @@ static void __exit afs_exit(void) ...@@ -146,6 +168,9 @@ static void __exit afs_exit(void)
afs_kafstimod_stop(); afs_kafstimod_stop();
afs_kafsasyncd_stop(); afs_kafsasyncd_stop();
afs_cell_purge(); afs_cell_purge();
#ifdef CONFIG_KEYS
afs_key_unregister();
#endif
#ifdef AFS_CACHING_SUPPORT #ifdef AFS_CACHING_SUPPORT
cachefs_unregister_netfs(&afs_cache_netfs); cachefs_unregister_netfs(&afs_cache_netfs);
#endif #endif
...@@ -162,19 +187,20 @@ static void __exit afs_exit(void) ...@@ -162,19 +187,20 @@ static void __exit afs_exit(void)
*/ */
static int afs_adding_peer(struct rxrpc_peer *peer) static int afs_adding_peer(struct rxrpc_peer *peer)
{ {
afs_server_t *server; struct afs_server *server;
int ret; int ret;
_debug("kAFS: Adding new peer %08x\n",ntohl(peer->addr.s_addr)); _debug("kAFS: Adding new peer %08x\n", ntohl(peer->addr.s_addr));
/* determine which server the peer resides in (if any) */ /* determine which server the peer resides in (if any) */
ret = afs_server_find_by_peer(peer,&server); ret = afs_server_find_by_peer(peer, &server);
if (ret < 0) if (ret < 0)
return ret; /* none that we recognise, so abort */ return ret; /* none that we recognise, so abort */
_debug("Server %p{u=%d}\n",server,atomic_read(&server->usage)); _debug("Server %p{u=%d}\n", server, atomic_read(&server->usage));
_debug("Cell %p{u=%d}\n",server->cell,atomic_read(&server->cell->usage)); _debug("Cell %p{u=%d}\n",
server->cell, atomic_read(&server->cell->usage));
/* cross-point the structs under a global lock */ /* cross-point the structs under a global lock */
spin_lock(&afs_server_peer_lock); spin_lock(&afs_server_peer_lock);
...@@ -194,14 +220,14 @@ static int afs_adding_peer(struct rxrpc_peer *peer) ...@@ -194,14 +220,14 @@ static int afs_adding_peer(struct rxrpc_peer *peer)
*/ */
static void afs_discarding_peer(struct rxrpc_peer *peer) static void afs_discarding_peer(struct rxrpc_peer *peer)
{ {
afs_server_t *server; struct afs_server *server;
_enter("%p",peer); _enter("%p",peer);
_debug("Discarding peer %08x (rtt=%lu.%lumS)\n", _debug("Discarding peer %08x (rtt=%lu.%lumS)\n",
ntohl(peer->addr.s_addr), ntohl(peer->addr.s_addr),
(long)(peer->rtt/1000), (long) (peer->rtt / 1000),
(long)(peer->rtt%1000)); (long) (peer->rtt % 1000));
/* uncross-point the structs under a global lock */ /* uncross-point the structs under a global lock */
spin_lock(&afs_server_peer_lock); spin_lock(&afs_server_peer_lock);
...@@ -209,9 +235,6 @@ static void afs_discarding_peer(struct rxrpc_peer *peer) ...@@ -209,9 +235,6 @@ static void afs_discarding_peer(struct rxrpc_peer *peer)
if (server) { if (server) {
peer->user = NULL; peer->user = NULL;
server->peer = NULL; server->peer = NULL;
//_debug("Server %p{u=%d}\n",server,atomic_read(&server->usage));
//_debug("Cell %p{u=%d}\n",server->cell,atomic_read(&server->cell->usage));
} }
spin_unlock(&afs_server_peer_lock); spin_unlock(&afs_server_peer_lock);
...@@ -239,7 +262,7 @@ void __cyg_profile_func_enter (void *this_fn, void *call_site) ...@@ -239,7 +262,7 @@ void __cyg_profile_func_enter (void *this_fn, void *call_site)
" movl $0xedededed,%%eax \n" " movl $0xedededed,%%eax \n"
" rep stosl \n" " rep stosl \n"
: :
: "i"(~(THREAD_SIZE-1)), "i"(sizeof(struct thread_info)) : "i"(~(THREAD_SIZE - 1)), "i"(sizeof(struct thread_info))
: "eax", "ecx", "edi", "memory", "cc" : "eax", "ecx", "edi", "memory", "cc"
); );
} }
...@@ -258,7 +281,7 @@ void __cyg_profile_func_exit(void *this_fn, void *call_site) ...@@ -258,7 +281,7 @@ void __cyg_profile_func_exit(void *this_fn, void *call_site)
" movl $0xdadadada,%%eax \n" " movl $0xdadadada,%%eax \n"
" rep stosl \n" " rep stosl \n"
: :
: "i"(~(THREAD_SIZE-1)), "i"(sizeof(struct thread_info)) : "i"(~(THREAD_SIZE - 1)), "i"(sizeof(struct thread_info))
: "eax", "ecx", "edi", "memory", "cc" : "eax", "ecx", "edi", "memory", "cc"
); );
} }
......
...@@ -67,18 +67,21 @@ unsigned long afs_mntpt_expiry_timeout = 20; ...@@ -67,18 +67,21 @@ unsigned long afs_mntpt_expiry_timeout = 20;
* check a symbolic link to see whether it actually encodes a mountpoint * check a symbolic link to see whether it actually encodes a mountpoint
* - sets the AFS_VNODE_MOUNTPOINT flag on the vnode appropriately * - sets the AFS_VNODE_MOUNTPOINT flag on the vnode appropriately
*/ */
int afs_mntpt_check_symlink(afs_vnode_t *vnode) int afs_mntpt_check_symlink(struct afs_vnode *vnode)
{ {
struct page *page; struct page *page;
filler_t *filler;
size_t size; size_t size;
char *buf; char *buf;
int ret; int ret;
_enter("{%u,%u}",vnode->fid.vnode,vnode->fid.unique); _enter("{%u,%u}", vnode->fid.vnode, vnode->fid.unique);
/* read the contents of the symlink into the pagecache */ /* read the contents of the symlink into the pagecache */
page = read_cache_page(AFS_VNODE_TO_I(vnode)->i_mapping,0, filler = (filler_t *) AFS_VNODE_TO_I(vnode)->i_mapping->a_ops->readpage;
(filler_t*)AFS_VNODE_TO_I(vnode)->i_mapping->a_ops->readpage,NULL);
page = read_cache_page(AFS_VNODE_TO_I(vnode)->i_mapping, 0,
filler, NULL);
if (IS_ERR(page)) { if (IS_ERR(page)) {
ret = PTR_ERR(page); ret = PTR_ERR(page);
goto out; goto out;
...@@ -94,11 +97,11 @@ int afs_mntpt_check_symlink(afs_vnode_t *vnode) ...@@ -94,11 +97,11 @@ int afs_mntpt_check_symlink(afs_vnode_t *vnode)
/* examine the symlink's contents */ /* examine the symlink's contents */
size = vnode->status.size; size = vnode->status.size;
_debug("symlink to %*.*s",size,(int)size,buf); _debug("symlink to %*.*s", size, (int) size, buf);
if (size>2 && if (size > 2 &&
(buf[0]=='%' || buf[0]=='#') && (buf[0] == '%' || buf[0] == '#') &&
buf[size-1]=='.' buf[size - 1] == '.'
) { ) {
_debug("symlink is a mountpoint"); _debug("symlink is a mountpoint");
spin_lock(&vnode->lock); spin_lock(&vnode->lock);
...@@ -112,7 +115,7 @@ int afs_mntpt_check_symlink(afs_vnode_t *vnode) ...@@ -112,7 +115,7 @@ int afs_mntpt_check_symlink(afs_vnode_t *vnode)
kunmap(page); kunmap(page);
page_cache_release(page); page_cache_release(page);
out: out:
_leave(" = %d",ret); _leave(" = %d", ret);
return ret; return ret;
} /* end afs_mntpt_check_symlink() */ } /* end afs_mntpt_check_symlink() */
...@@ -129,7 +132,8 @@ static struct dentry *afs_mntpt_lookup(struct inode *dir, ...@@ -129,7 +132,8 @@ static struct dentry *afs_mntpt_lookup(struct inode *dir,
dir, dir,
dentry, dentry,
dentry->d_parent, dentry->d_parent,
dentry->d_parent ? dentry->d_parent->d_name.name : (const unsigned char*)"", dentry->d_parent ?
dentry->d_parent->d_name.name : (const unsigned char *) "",
dentry->d_name.name); dentry->d_name.name);
return ERR_PTR(-EREMOTE); return ERR_PTR(-EREMOTE);
...@@ -144,7 +148,9 @@ static int afs_mntpt_open(struct inode *inode, struct file *file) ...@@ -144,7 +148,9 @@ static int afs_mntpt_open(struct inode *inode, struct file *file)
kenter("%p,%p{%p{%s},%s}", kenter("%p,%p{%p{%s},%s}",
inode, file, inode, file,
file->f_dentry->d_parent, file->f_dentry->d_parent,
file->f_dentry->d_parent ? file->f_dentry->d_parent->d_name.name : (const unsigned char*)"", file->f_dentry->d_parent ?
file->f_dentry->d_parent->d_name.name :
(const unsigned char *) "",
file->f_dentry->d_name.name); file->f_dentry->d_name.name);
return -EREMOTE; return -EREMOTE;
...@@ -183,10 +189,9 @@ static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt) ...@@ -183,10 +189,9 @@ static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt)
goto error; goto error;
/* read the contents of the AFS special symlink */ /* read the contents of the AFS special symlink */
page = read_cache_page(mntpt->d_inode->i_mapping, filler_t *filler = mntpt->d_inode->i_mapping->a_ops->readpage;
0,
(filler_t*)mntpt->d_inode->i_mapping->a_ops->readpage, page = read_cache_page(mntpt->d_inode->i_mapping, 0, filler, NULL);
NULL);
if (IS_ERR(page)) { if (IS_ERR(page)) {
ret = PTR_ERR(page); ret = PTR_ERR(page);
goto error; goto error;
...@@ -208,26 +213,26 @@ static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt) ...@@ -208,26 +213,26 @@ static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt)
memcpy(options, "cell=", 5); memcpy(options, "cell=", 5);
strcpy(options + 5, super->volume->cell->name); strcpy(options + 5, super->volume->cell->name);
if (super->volume->type == AFSVL_RWVOL) if (super->volume->type == AFSVL_RWVOL)
strcat(options,",rwpath"); strcat(options, ",rwpath");
/* try and do the mount */ /* try and do the mount */
kdebug("--- attempting mount %s -o %s ---", devname, options); kdebug("--- attempting mount %s -o %s ---", devname, options);
mnt = do_kern_mount("afs", 0, devname, options); mnt = do_kern_mount("afs", 0, devname, options);
kdebug("--- mount result %p ---", mnt); kdebug("--- mount result %p ---", mnt);
free_page((unsigned long)devname); free_page((unsigned long) devname);
free_page((unsigned long)options); free_page((unsigned long) options);
kleave(" = %p",mnt); kleave(" = %p", mnt);
return mnt; return mnt;
error: error:
if (page) if (page)
page_cache_release(page); page_cache_release(page);
if (devname) if (devname)
free_page((unsigned long)devname); free_page((unsigned long) devname);
if (options) if (options)
free_page((unsigned long)options); free_page((unsigned long) options);
kleave(" = %d",ret); kleave(" = %d", ret);
return ERR_PTR(ret); return ERR_PTR(ret);
} /* end afs_mntpt_do_automount() */ } /* end afs_mntpt_do_automount() */
...@@ -252,7 +257,7 @@ static int afs_mntpt_follow_link(struct dentry *dentry, struct nameidata *nd) ...@@ -252,7 +257,7 @@ static int afs_mntpt_follow_link(struct dentry *dentry, struct nameidata *nd)
if (IS_ERR(newmnt)) if (IS_ERR(newmnt))
return PTR_ERR(newmnt); return PTR_ERR(newmnt);
struct_cpy(&newnd,nd); struct_cpy(&newnd, nd);
newnd.dentry = dentry; newnd.dentry = dentry;
err = do_add_mount(newmnt, &newnd, 0, &afs_vfsmounts); err = do_add_mount(newmnt, &newnd, 0, &afs_vfsmounts);
......
This diff is collapsed.
This diff is collapsed.
...@@ -26,10 +26,10 @@ extern spinlock_t afs_server_peer_lock; ...@@ -26,10 +26,10 @@ extern spinlock_t afs_server_peer_lock;
struct afs_server struct afs_server
{ {
atomic_t usage; atomic_t usage;
afs_cell_t *cell; /* cell in which server resides */ struct afs_cell *cell; /* cell in which server resides */
struct list_head link; /* link in cell's server list */ struct list_head link; /* link in cell's server list */
struct rw_semaphore sem; /* access lock */ struct rw_semaphore sem; /* access lock */
afs_timer_t timeout; /* graveyard timeout */ struct afs_timer timeout; /* graveyard timeout */
struct in_addr addr; /* server address */ struct in_addr addr; /* server address */
struct rxrpc_peer *peer; /* peer record for this server */ struct rxrpc_peer *peer; /* peer record for this server */
struct rxrpc_connection *vlserver; /* connection to the volume location service */ struct rxrpc_connection *vlserver; /* connection to the volume location service */
...@@ -50,20 +50,25 @@ struct afs_server ...@@ -50,20 +50,25 @@ struct afs_server
spinlock_t cb_lock; /* access lock */ spinlock_t cb_lock; /* access lock */
}; };
extern int afs_server_lookup(afs_cell_t *cell, const struct in_addr *addr, afs_server_t **_server); extern int afs_server_lookup(struct afs_cell *cell,
const struct in_addr *addr,
struct afs_server **_server);
#define afs_get_server(S) do { atomic_inc(&(S)->usage); } while(0) #define afs_get_server(S) do { atomic_inc(&(S)->usage); } while(0)
extern void afs_put_server(afs_server_t *server); extern void afs_put_server(struct afs_server *server);
extern void afs_server_do_timeout(afs_server_t *server); extern void afs_server_do_timeout(struct afs_server *server);
extern int afs_server_find_by_peer(const struct rxrpc_peer *peer, afs_server_t **_server); extern int afs_server_find_by_peer(const struct rxrpc_peer *peer,
struct afs_server **_server);
extern int afs_server_get_vlconn(afs_server_t *server, struct rxrpc_connection **_conn); extern int afs_server_get_vlconn(struct afs_server *server,
struct rxrpc_connection **_conn);
static inline afs_server_t *afs_server_get_from_peer(struct rxrpc_peer *peer) static inline
struct afs_server *afs_server_get_from_peer(struct rxrpc_peer *peer)
{ {
afs_server_t *server; struct afs_server *server;
spin_lock(&afs_server_peer_lock); spin_lock(&afs_server_peer_lock);
server = peer->user; server = peer->user;
...@@ -88,10 +93,10 @@ struct afs_server_callslot ...@@ -88,10 +93,10 @@ struct afs_server_callslot
int errno; /* error number if nconn==-1 */ int errno; /* error number if nconn==-1 */
}; };
extern int afs_server_request_callslot(afs_server_t *server, extern int afs_server_request_callslot(struct afs_server *server,
struct afs_server_callslot *callslot); struct afs_server_callslot *callslot);
extern void afs_server_release_callslot(afs_server_t *server, extern void afs_server_release_callslot(struct afs_server *server,
struct afs_server_callslot *callslot); struct afs_server_callslot *callslot);
#endif /* _LINUX_AFS_SERVER_H */ #endif /* _LINUX_AFS_SERVER_H */
...@@ -86,7 +86,7 @@ int __init afs_fs_init(void) ...@@ -86,7 +86,7 @@ int __init afs_fs_init(void)
ret = -ENOMEM; ret = -ENOMEM;
afs_inode_cachep = kmem_cache_create("afs_inode_cache", afs_inode_cachep = kmem_cache_create("afs_inode_cache",
sizeof(afs_vnode_t), sizeof(struct afs_vnode),
0, 0,
SLAB_HWCACHE_ALIGN, SLAB_HWCACHE_ALIGN,
afs_i_init_once, afs_i_init_once,
...@@ -156,8 +156,8 @@ static int want_no_value(char *const *_value, const char *option) ...@@ -156,8 +156,8 @@ static int want_no_value(char *const *_value, const char *option)
/*****************************************************************************/ /*****************************************************************************/
/* /*
* parse the mount options * parse the mount options
* - this function has been shamelessly adapted from the ext3 fs which shamelessly adapted it from * - this function has been shamelessly adapted from the ext3 fs which
* the msdos fs * shamelessly adapted it from the msdos fs
*/ */
static int afs_super_parse_options(struct afs_mount_params *params, static int afs_super_parse_options(struct afs_mount_params *params,
char *options, char *options,
...@@ -235,9 +235,9 @@ static int afs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -235,9 +235,9 @@ static int afs_fill_super(struct super_block *sb, void *data, int silent)
{ {
struct afs_mount_params *params = data; struct afs_mount_params *params = data;
struct afs_super_info *as = NULL; struct afs_super_info *as = NULL;
struct afs_fid fid;
struct dentry *root = NULL; struct dentry *root = NULL;
struct inode *inode = NULL; struct inode *inode = NULL;
afs_fid_t fid;
int ret; int ret;
kenter(""); kenter("");
...@@ -387,7 +387,7 @@ static void afs_put_super(struct super_block *sb) ...@@ -387,7 +387,7 @@ static void afs_put_super(struct super_block *sb)
static void afs_i_init_once(void *_vnode, kmem_cache_t *cachep, static void afs_i_init_once(void *_vnode, kmem_cache_t *cachep,
unsigned long flags) unsigned long flags)
{ {
afs_vnode_t *vnode = (afs_vnode_t *) _vnode; struct afs_vnode *vnode = (struct afs_vnode *) _vnode;
if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
SLAB_CTOR_CONSTRUCTOR) { SLAB_CTOR_CONSTRUCTOR) {
...@@ -409,9 +409,9 @@ static void afs_i_init_once(void *_vnode, kmem_cache_t *cachep, ...@@ -409,9 +409,9 @@ static void afs_i_init_once(void *_vnode, kmem_cache_t *cachep,
*/ */
static struct inode *afs_alloc_inode(struct super_block *sb) static struct inode *afs_alloc_inode(struct super_block *sb)
{ {
afs_vnode_t *vnode; struct afs_vnode *vnode;
vnode = (afs_vnode_t *) vnode = (struct afs_vnode *)
kmem_cache_alloc(afs_inode_cachep, SLAB_KERNEL); kmem_cache_alloc(afs_inode_cachep, SLAB_KERNEL);
if (!vnode) if (!vnode)
return NULL; return NULL;
......
...@@ -20,21 +20,6 @@ typedef unsigned afs_volid_t; ...@@ -20,21 +20,6 @@ typedef unsigned afs_volid_t;
typedef unsigned afs_vnodeid_t; typedef unsigned afs_vnodeid_t;
typedef unsigned long long afs_dataversion_t; typedef unsigned long long afs_dataversion_t;
typedef struct afs_async_op afs_async_op_t;
typedef struct afs_callback afs_callback_t;
typedef struct afs_cell afs_cell_t;
typedef struct afs_fid afs_fid_t;
typedef struct afs_file_status afs_file_status_t;
typedef struct afs_server afs_server_t;
typedef struct afs_timer afs_timer_t;
typedef struct afs_vlocation afs_vlocation_t;
typedef struct afs_vnode afs_vnode_t;
typedef struct afs_volsync afs_volsync_t;
typedef struct afs_volume afs_volume_t;
typedef struct afs_volume_info afs_volume_info_t;
typedef struct afsvl_dbentry afsvl_dbentry_t;
typedef enum { typedef enum {
AFSVL_RWVOL, /* read/write volume */ AFSVL_RWVOL, /* read/write volume */
AFSVL_ROVOL, /* read-only volume */ AFSVL_ROVOL, /* read-only volume */
...@@ -52,6 +37,9 @@ typedef enum { ...@@ -52,6 +37,9 @@ typedef enum {
#ifdef __KERNEL__ #ifdef __KERNEL__
struct afs_cell;
struct afs_vnode;
/*****************************************************************************/ /*****************************************************************************/
/* /*
* AFS file identifier * AFS file identifier
...@@ -76,8 +64,8 @@ typedef enum { ...@@ -76,8 +64,8 @@ typedef enum {
struct afs_callback struct afs_callback
{ {
afs_server_t *server; /* server that made the promise */ struct afs_server *server; /* server that made the promise */
afs_fid_t fid; /* file identifier */ struct afs_fid fid; /* file identifier */
unsigned version; /* callback version */ unsigned version; /* callback version */
unsigned expiry; /* time at which expires */ unsigned expiry; /* time at which expires */
afs_callback_type_t type; /* type of callback */ afs_callback_type_t type; /* type of callback */
...@@ -120,7 +108,7 @@ struct afs_file_status ...@@ -120,7 +108,7 @@ struct afs_file_status
unsigned caller_access; /* access rights for authenticated caller */ unsigned caller_access; /* access rights for authenticated caller */
unsigned anon_access; /* access rights for unauthenticated caller */ unsigned anon_access; /* access rights for unauthenticated caller */
umode_t mode; /* UNIX mode */ umode_t mode; /* UNIX mode */
afs_fid_t parent; /* parent file ID */ struct afs_fid parent; /* parent file ID */
time_t mtime_client; /* last time client changed data */ time_t mtime_client; /* last time client changed data */
time_t mtime_server; /* last time server changed data */ time_t mtime_server; /* last time server changed data */
}; };
......
This diff is collapsed.
...@@ -72,25 +72,25 @@ struct afs_vldbentry { ...@@ -72,25 +72,25 @@ struct afs_vldbentry {
}; };
/* probe a volume location server to see if it is still alive */ /* probe a volume location server to see if it is still alive */
extern int afs_rxvl_probe(afs_server_t *server, int alloc_flags); extern int afs_rxvl_probe(struct afs_server *server, int alloc_flags);
/* look up a volume location database entry by name */ /* look up a volume location database entry by name */
extern int afs_rxvl_get_entry_by_name(afs_server_t *server, extern int afs_rxvl_get_entry_by_name(struct afs_server *server,
const char *volname, const char *volname,
unsigned volnamesz, unsigned volnamesz,
struct afs_cache_vlocation *entry); struct afs_cache_vlocation *entry);
/* look up a volume location database entry by ID */ /* look up a volume location database entry by ID */
extern int afs_rxvl_get_entry_by_id(afs_server_t *server, extern int afs_rxvl_get_entry_by_id(struct afs_server *server,
afs_volid_t volid, afs_volid_t volid,
afs_voltype_t voltype, afs_voltype_t voltype,
struct afs_cache_vlocation *entry); struct afs_cache_vlocation *entry);
extern int afs_rxvl_get_entry_by_id_async(afs_async_op_t *op, extern int afs_rxvl_get_entry_by_id_async(struct afs_async_op *op,
afs_volid_t volid, afs_volid_t volid,
afs_voltype_t voltype); afs_voltype_t voltype);
extern int afs_rxvl_get_entry_by_id_async2(afs_async_op_t *op, extern int afs_rxvl_get_entry_by_id_async2(struct afs_async_op *op,
struct afs_cache_vlocation *entry); struct afs_cache_vlocation *entry);
#endif /* _LINUX_AFS_VLCLIENT_H */ #endif /* _LINUX_AFS_VLCLIENT_H */
This diff is collapsed.
...@@ -30,7 +30,8 @@ struct afs_timer_ops afs_vnode_cb_timed_out_ops = { ...@@ -30,7 +30,8 @@ struct afs_timer_ops afs_vnode_cb_timed_out_ops = {
}; };
#ifdef AFS_CACHING_SUPPORT #ifdef AFS_CACHING_SUPPORT
static cachefs_match_val_t afs_vnode_cache_match(void *target, const void *entry); static cachefs_match_val_t afs_vnode_cache_match(void *target,
const void *entry);
static void afs_vnode_cache_update(void *source, void *entry); static void afs_vnode_cache_update(void *source, void *entry);
struct cachefs_index_def afs_vnode_cache_index_def = { struct cachefs_index_def afs_vnode_cache_index_def = {
...@@ -49,17 +50,17 @@ struct cachefs_index_def afs_vnode_cache_index_def = { ...@@ -49,17 +50,17 @@ struct cachefs_index_def afs_vnode_cache_index_def = {
*/ */
static void afs_vnode_cb_timed_out(struct afs_timer *timer) static void afs_vnode_cb_timed_out(struct afs_timer *timer)
{ {
afs_server_t *oldserver; struct afs_server *oldserver;
afs_vnode_t *vnode; struct afs_vnode *vnode;
vnode = list_entry(timer,afs_vnode_t,cb_timeout); vnode = list_entry(timer, struct afs_vnode, cb_timeout);
_enter("%p",vnode); _enter("%p", vnode);
/* set the changed flag in the vnode and release the server */ /* set the changed flag in the vnode and release the server */
spin_lock(&vnode->lock); spin_lock(&vnode->lock);
oldserver = xchg(&vnode->cb_server,NULL); oldserver = xchg(&vnode->cb_server, NULL);
if (oldserver) { if (oldserver) {
vnode->flags |= AFS_VNODE_CHANGED; vnode->flags |= AFS_VNODE_CHANGED;
...@@ -85,28 +86,33 @@ static void afs_vnode_cb_timed_out(struct afs_timer *timer) ...@@ -85,28 +86,33 @@ static void afs_vnode_cb_timed_out(struct afs_timer *timer)
* - starts callback expiry timer * - starts callback expiry timer
* - adds to server's callback list * - adds to server's callback list
*/ */
void afs_vnode_finalise_status_update(afs_vnode_t *vnode, afs_server_t *server, int ret) void afs_vnode_finalise_status_update(struct afs_vnode *vnode,
struct afs_server *server,
int ret)
{ {
afs_server_t *oldserver = NULL; struct afs_server *oldserver = NULL;
_enter("%p,%p,%d",vnode,server,ret); _enter("%p,%p,%d", vnode, server, ret);
spin_lock(&vnode->lock); spin_lock(&vnode->lock);
vnode->flags &= ~AFS_VNODE_CHANGED; vnode->flags &= ~AFS_VNODE_CHANGED;
if (ret==0) { if (ret == 0) {
/* adjust the callback timeout appropriately */ /* adjust the callback timeout appropriately */
afs_kafstimod_add_timer(&vnode->cb_timeout,vnode->cb_expiry*HZ); afs_kafstimod_add_timer(&vnode->cb_timeout,
vnode->cb_expiry * HZ);
spin_lock(&afs_cb_hash_lock); spin_lock(&afs_cb_hash_lock);
list_del(&vnode->cb_hash_link); list_del(&vnode->cb_hash_link);
list_add_tail(&vnode->cb_hash_link,&afs_cb_hash(server,&vnode->fid)); list_add_tail(&vnode->cb_hash_link,
&afs_cb_hash(server, &vnode->fid));
spin_unlock(&afs_cb_hash_lock); spin_unlock(&afs_cb_hash_lock);
/* swap ref to old callback server with that for new callback server */ /* swap ref to old callback server with that for new callback
oldserver = xchg(&vnode->cb_server,server); * server */
if (oldserver!=server) { oldserver = xchg(&vnode->cb_server, server);
if (oldserver != server) {
if (oldserver) { if (oldserver) {
spin_lock(&oldserver->cb_lock); spin_lock(&oldserver->cb_lock);
list_del_init(&vnode->cb_link); list_del_init(&vnode->cb_link);
...@@ -115,7 +121,7 @@ void afs_vnode_finalise_status_update(afs_vnode_t *vnode, afs_server_t *server, ...@@ -115,7 +121,7 @@ void afs_vnode_finalise_status_update(afs_vnode_t *vnode, afs_server_t *server,
afs_get_server(server); afs_get_server(server);
spin_lock(&server->cb_lock); spin_lock(&server->cb_lock);
list_add_tail(&vnode->cb_link,&server->cb_promises); list_add_tail(&vnode->cb_link, &server->cb_promises);
spin_unlock(&server->cb_lock); spin_unlock(&server->cb_lock);
} }
else { else {
...@@ -123,9 +129,9 @@ void afs_vnode_finalise_status_update(afs_vnode_t *vnode, afs_server_t *server, ...@@ -123,9 +129,9 @@ void afs_vnode_finalise_status_update(afs_vnode_t *vnode, afs_server_t *server,
oldserver = NULL; oldserver = NULL;
} }
} }
else if (ret==-ENOENT) { else if (ret == -ENOENT) {
/* the file was deleted - clear the callback timeout */ /* the file was deleted - clear the callback timeout */
oldserver = xchg(&vnode->cb_server,NULL); oldserver = xchg(&vnode->cb_server, NULL);
afs_kafstimod_del_timer(&vnode->cb_timeout); afs_kafstimod_del_timer(&vnode->cb_timeout);
_debug("got NOENT from server - marking file deleted"); _debug("got NOENT from server - marking file deleted");
...@@ -152,15 +158,16 @@ void afs_vnode_finalise_status_update(afs_vnode_t *vnode, afs_server_t *server, ...@@ -152,15 +158,16 @@ void afs_vnode_finalise_status_update(afs_vnode_t *vnode, afs_server_t *server,
* - there are any outstanding ops that will fetch the status * - there are any outstanding ops that will fetch the status
* - TODO implement local caching * - TODO implement local caching
*/ */
int afs_vnode_fetch_status(afs_vnode_t *vnode) int afs_vnode_fetch_status(struct afs_vnode *vnode)
{ {
afs_server_t *server; struct afs_server *server;
int ret; int ret;
DECLARE_WAITQUEUE(myself,current); DECLARE_WAITQUEUE(myself, current);
_enter("%s,{%u,%u,%u}",vnode->volume->vlocation->vldb.name, _enter("%s,{%u,%u,%u}",
vnode->fid.vid,vnode->fid.vnode,vnode->fid.unique); vnode->volume->vlocation->vldb.name,
vnode->fid.vid, vnode->fid.vnode, vnode->fid.unique);
if (!(vnode->flags & AFS_VNODE_CHANGED) && vnode->cb_server) { if (!(vnode->flags & AFS_VNODE_CHANGED) && vnode->cb_server) {
_leave(" [unchanged]"); _leave(" [unchanged]");
...@@ -180,19 +187,23 @@ int afs_vnode_fetch_status(afs_vnode_t *vnode) ...@@ -180,19 +187,23 @@ int afs_vnode_fetch_status(afs_vnode_t *vnode)
return 0; return 0;
} }
if (vnode->update_cnt>0) { if (vnode->update_cnt > 0) {
/* someone else started a fetch */ /* someone else started a fetch */
set_current_state(TASK_UNINTERRUPTIBLE); set_current_state(TASK_UNINTERRUPTIBLE);
add_wait_queue(&vnode->update_waitq,&myself); add_wait_queue(&vnode->update_waitq, &myself);
/* wait for the status to be updated */ /* wait for the status to be updated */
for (;;) { for (;;) {
if (!(vnode->flags & AFS_VNODE_CHANGED)) break; if (!(vnode->flags & AFS_VNODE_CHANGED))
if (vnode->flags & AFS_VNODE_DELETED) break; break;
if (vnode->flags & AFS_VNODE_DELETED)
/* it got updated and invalidated all before we saw it */ break;
if (vnode->update_cnt==0) {
remove_wait_queue(&vnode->update_waitq,&myself); /* it got updated and invalidated all before we saw
* it */
if (vnode->update_cnt == 0) {
remove_wait_queue(&vnode->update_waitq,
&myself);
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);
goto get_anyway; goto get_anyway;
} }
...@@ -205,7 +216,7 @@ int afs_vnode_fetch_status(afs_vnode_t *vnode) ...@@ -205,7 +216,7 @@ int afs_vnode_fetch_status(afs_vnode_t *vnode)
spin_lock(&vnode->lock); spin_lock(&vnode->lock);
} }
remove_wait_queue(&vnode->update_waitq,&myself); remove_wait_queue(&vnode->update_waitq, &myself);
spin_unlock(&vnode->lock); spin_unlock(&vnode->lock);
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);
...@@ -218,23 +229,24 @@ int afs_vnode_fetch_status(afs_vnode_t *vnode) ...@@ -218,23 +229,24 @@ int afs_vnode_fetch_status(afs_vnode_t *vnode)
spin_unlock(&vnode->lock); spin_unlock(&vnode->lock);
/* merge AFS status fetches and clear outstanding callback on this vnode */ /* merge AFS status fetches and clear outstanding callback on this
* vnode */
do { do {
/* pick a server to query */ /* pick a server to query */
ret = afs_volume_pick_fileserver(vnode->volume,&server); ret = afs_volume_pick_fileserver(vnode->volume, &server);
if (ret<0) if (ret<0)
return ret; return ret;
_debug("USING SERVER: %08x\n",ntohl(server->addr.s_addr)); _debug("USING SERVER: %08x\n", ntohl(server->addr.s_addr));
ret = afs_rxfs_fetch_file_status(server,vnode,NULL); ret = afs_rxfs_fetch_file_status(server, vnode, NULL);
} while (!afs_volume_release_fileserver(vnode->volume,server,ret)); } while (!afs_volume_release_fileserver(vnode->volume, server, ret));
/* adjust the flags */ /* adjust the flags */
afs_vnode_finalise_status_update(vnode,server,ret); afs_vnode_finalise_status_update(vnode, server, ret);
_leave(" = %d",ret); _leave(" = %d", ret);
return ret; return ret;
} /* end afs_vnode_fetch_status() */ } /* end afs_vnode_fetch_status() */
...@@ -243,9 +255,10 @@ int afs_vnode_fetch_status(afs_vnode_t *vnode) ...@@ -243,9 +255,10 @@ int afs_vnode_fetch_status(afs_vnode_t *vnode)
* fetch file data from the volume * fetch file data from the volume
* - TODO implement caching and server failover * - TODO implement caching and server failover
*/ */
int afs_vnode_fetch_data(afs_vnode_t *vnode, struct afs_rxfs_fetch_descriptor *desc) int afs_vnode_fetch_data(struct afs_vnode *vnode,
struct afs_rxfs_fetch_descriptor *desc)
{ {
afs_server_t *server; struct afs_server *server;
int ret; int ret;
_enter("%s,{%u,%u,%u}", _enter("%s,{%u,%u,%u}",
...@@ -259,23 +272,24 @@ int afs_vnode_fetch_data(afs_vnode_t *vnode, struct afs_rxfs_fetch_descriptor *d ...@@ -259,23 +272,24 @@ int afs_vnode_fetch_data(afs_vnode_t *vnode, struct afs_rxfs_fetch_descriptor *d
vnode->update_cnt++; vnode->update_cnt++;
spin_unlock(&vnode->lock); spin_unlock(&vnode->lock);
/* merge in AFS status fetches and clear outstanding callback on this vnode */ /* merge in AFS status fetches and clear outstanding callback on this
* vnode */
do { do {
/* pick a server to query */ /* pick a server to query */
ret = afs_volume_pick_fileserver(vnode->volume,&server); ret = afs_volume_pick_fileserver(vnode->volume, &server);
if (ret<0) if (ret < 0)
return ret; return ret;
_debug("USING SERVER: %08x\n",ntohl(server->addr.s_addr)); _debug("USING SERVER: %08x\n", ntohl(server->addr.s_addr));
ret = afs_rxfs_fetch_file_data(server,vnode,desc,NULL); ret = afs_rxfs_fetch_file_data(server, vnode, desc, NULL);
} while (!afs_volume_release_fileserver(vnode->volume,server,ret)); } while (!afs_volume_release_fileserver(vnode->volume, server, ret));
/* adjust the flags */ /* adjust the flags */
afs_vnode_finalise_status_update(vnode,server,ret); afs_vnode_finalise_status_update(vnode, server, ret);
_leave(" = %d",ret); _leave(" = %d", ret);
return ret; return ret;
} /* end afs_vnode_fetch_data() */ } /* end afs_vnode_fetch_data() */
...@@ -285,9 +299,9 @@ int afs_vnode_fetch_data(afs_vnode_t *vnode, struct afs_rxfs_fetch_descriptor *d ...@@ -285,9 +299,9 @@ int afs_vnode_fetch_data(afs_vnode_t *vnode, struct afs_rxfs_fetch_descriptor *d
* break any outstanding callback on a vnode * break any outstanding callback on a vnode
* - only relevent to server that issued it * - only relevent to server that issued it
*/ */
int afs_vnode_give_up_callback(afs_vnode_t *vnode) int afs_vnode_give_up_callback(struct afs_vnode *vnode)
{ {
afs_server_t *server; struct afs_server *server;
int ret; int ret;
_enter("%s,{%u,%u,%u}", _enter("%s,{%u,%u,%u}",
...@@ -305,7 +319,7 @@ int afs_vnode_give_up_callback(afs_vnode_t *vnode) ...@@ -305,7 +319,7 @@ int afs_vnode_give_up_callback(afs_vnode_t *vnode)
afs_kafstimod_del_timer(&vnode->cb_timeout); afs_kafstimod_del_timer(&vnode->cb_timeout);
server = xchg(&vnode->cb_server,NULL); server = xchg(&vnode->cb_server, NULL);
if (server) { if (server) {
vnode->flags |= AFS_VNODE_CHANGED; vnode->flags |= AFS_VNODE_CHANGED;
...@@ -318,11 +332,11 @@ int afs_vnode_give_up_callback(afs_vnode_t *vnode) ...@@ -318,11 +332,11 @@ int afs_vnode_give_up_callback(afs_vnode_t *vnode)
ret = 0; ret = 0;
if (server) { if (server) {
ret = afs_rxfs_give_up_callback(server,vnode); ret = afs_rxfs_give_up_callback(server, vnode);
afs_put_server(server); afs_put_server(server);
} }
_leave(" = %d",ret); _leave(" = %d", ret);
return ret; return ret;
} /* end afs_vnode_give_up_callback() */ } /* end afs_vnode_give_up_callback() */
...@@ -331,7 +345,8 @@ int afs_vnode_give_up_callback(afs_vnode_t *vnode) ...@@ -331,7 +345,8 @@ int afs_vnode_give_up_callback(afs_vnode_t *vnode)
* match a vnode record stored in the cache * match a vnode record stored in the cache
*/ */
#ifdef AFS_CACHING_SUPPORT #ifdef AFS_CACHING_SUPPORT
static cachefs_match_val_t afs_vnode_cache_match(void *target, const void *entry) static cachefs_match_val_t afs_vnode_cache_match(void *target,
const void *entry)
{ {
const struct afs_cache_vnode *cvnode = entry; const struct afs_cache_vnode *cvnode = entry;
struct afs_vnode *vnode = target; struct afs_vnode *vnode = target;
......
...@@ -70,21 +70,22 @@ struct afs_vnode ...@@ -70,21 +70,22 @@ struct afs_vnode
afs_callback_type_t cb_type; /* type of callback */ afs_callback_type_t cb_type; /* type of callback */
}; };
static inline afs_vnode_t *AFS_FS_I(struct inode *inode) static inline struct afs_vnode *AFS_FS_I(struct inode *inode)
{ {
return container_of(inode,afs_vnode_t,vfs_inode); return container_of(inode,struct afs_vnode,vfs_inode);
} }
static inline struct inode *AFS_VNODE_TO_I(afs_vnode_t *vnode) static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode)
{ {
return &vnode->vfs_inode; return &vnode->vfs_inode;
} }
extern int afs_vnode_fetch_status(afs_vnode_t *vnode); extern int afs_vnode_fetch_status(struct afs_vnode *vnode);
extern int afs_vnode_fetch_data(afs_vnode_t *vnode, struct afs_rxfs_fetch_descriptor *desc); extern int afs_vnode_fetch_data(struct afs_vnode *vnode,
struct afs_rxfs_fetch_descriptor *desc);
extern int afs_vnode_give_up_callback(afs_vnode_t *vnode); extern int afs_vnode_give_up_callback(struct afs_vnode *vnode);
extern struct afs_timer_ops afs_vnode_cb_timed_out_ops; extern struct afs_timer_ops afs_vnode_cb_timed_out_ops;
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment