From: Eric Van Hensbergen This part of the patch contains debug and other misc routine changes related to hch's comments. Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton --- dev/null | 194 ---------------------------------------------------------- fs/9p/error.c | 3 fs/9p/error.h | 3 fs/9p/fid.c | 14 ++-- 4 files changed, 14 insertions(+), 200 deletions(-) diff -puN fs/9p/error.c~v9fs-debug-and-support-routines-resend-take-2 fs/9p/error.c --- devel/fs/9p/error.c~v9fs-debug-and-support-routines-resend-take-2 2005-07-14 16:23:41.000000000 -0700 +++ devel-akpm/fs/9p/error.c 2005-07-14 16:23:41.000000000 -0700 @@ -75,8 +75,7 @@ int v9fs_errstr2errno(char *errstr) struct errormap *c = NULL; int bucket = jhash(errstr, strlen(errstr), 0) % ERRHASHSZ; - hlist_for_each(p, &hash_errmap[bucket]) { - c = hlist_entry(p, struct errormap, list); + hlist_for_each_entry(c, p, &hash_errmap[bucket], list) { if (!strcmp(c->name, errstr)) { errno = c->val; break; diff -puN fs/9p/error.h~v9fs-debug-and-support-routines-resend-take-2 fs/9p/error.h --- devel/fs/9p/error.h~v9fs-debug-and-support-routines-resend-take-2 2005-07-14 16:23:41.000000000 -0700 +++ devel-akpm/fs/9p/error.h 2005-07-14 16:23:41.000000000 -0700 @@ -176,3 +176,6 @@ static struct errormap errmap[] = { {"u9fs authnone: no authentication required", 0}, {NULL, -1} }; + +extern int v9fs_error_init(void); +extern int v9fs_errstr2errno(char *errstr); diff -puN fs/9p/fid.c~v9fs-debug-and-support-routines-resend-take-2 fs/9p/fid.c --- devel/fs/9p/fid.c~v9fs-debug-and-support-routines-resend-take-2 2005-07-14 16:23:41.000000000 -0700 +++ devel-akpm/fs/9p/fid.c 2005-07-14 16:23:41.000000000 -0700 @@ -25,9 +25,9 @@ #include #include #include +#include #include "debug.h" -#include "idpool.h" #include "v9fs.h" #include "9p.h" #include "v9fs_vfs.h" @@ -123,7 +123,7 @@ struct v9fs_fid *v9fs_fid_lookup(struct { struct list_head *fid_list = (struct list_head *)dentry->d_fsdata; struct v9fs_fid *current_fid = NULL; - struct list_head *p, *temp; + struct v9fs_fid *temp = NULL; struct v9fs_fid *return_fid = NULL; int found_parent = 0; int found_user = 0; @@ -132,8 +132,7 @@ struct v9fs_fid *v9fs_fid_lookup(struct type); if (fid_list && !list_empty(fid_list)) { - list_for_each_safe(p, temp, fid_list) { - current_fid = list_entry(p, struct v9fs_fid, list); + list_for_each_entry_safe(current_fid, temp, fid_list, list) { if (current_fid->uid == current->uid) { if (return_fid == NULL) { if ((type == FID_OP) @@ -205,7 +204,14 @@ struct v9fs_fid *v9fs_fid_lookup(struct oldfid = current_fid->fid; par = current->fs->pwd; /* TODO: take advantage of multiwalk */ + fidnum = v9fs_get_idpool(&v9ses->fidpool); + if (fidnum < 0) { + dprintk(DEBUG_ERROR, + "could not get a new fid num\n"); + return return_fid; + } + while (par != dentry) { result = v9fs_t_walk(v9ses, oldfid, fidnum, "..", diff -L fs/9p/idpool.c -puN fs/9p/idpool.c~v9fs-debug-and-support-routines-resend-take-2 /dev/null --- devel/fs/9p/idpool.c +++ /dev/null 2003-09-15 06:40:47.000000000 -0700 @@ -1,152 +0,0 @@ -/* - * linux/fs/9p/idpool.c - * - * Copyright (C) 2004 by Eric Van Hensbergen - * Copyright (C) 2002 by Ron Minnich - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to: - * Free Software Foundation - * 51 Franklin Street, Fifth Floor - * Boston, MA 02111-1301 USA - * - */ - -#include -#include -#include -#include -#include -#include "idpool.h" -#include "debug.h" - -/** - * grow_idpool - increase the size of an id pool - * @i: pointer to idpool to initialize - * @size: size (in bits) of idpool - * - */ - -static int grow_idpool(struct idpool *i, int newsize) -{ - unsigned long *newpool; - - newpool = kmalloc((newsize / 8), GFP_KERNEL); - if (!newpool) { - eprintk(KERN_WARNING, - "Couldn't allocate memory to grow idpool\n"); - return 0; - } - - memset(newpool, 0, newsize / 8); - if (i->idlist) { - memcpy(newpool, i->idlist, (i->maxalloc) / 8); - kfree(i->idlist); - } - - i->idlist = newpool; - i->maxalloc = newsize; - - return newsize; -} - -/** - * v9fs_alloc_idpool - allocate an id pool - * @i: pointer to idpool to initialize - * @size: size of idpool - * - */ - -int v9fs_alloc_idpool(struct idpool *i, int size) -{ - int newsize; - - init_MUTEX(&i->sem); - i->maxalloc = 0; - i->numalloc = 0; - i->lastfree = 0; - i->idlist = NULL; - newsize = grow_idpool(i, size); - return newsize; -} - -/** - * v9fs_free_idpool - deallocate an id pool - * @i: pointer to idpool to free - * - */ - -void v9fs_free_idpool(struct idpool *i) -{ - kfree(i->idlist); -} - -/** - * v9fs_get_idpool - get a new id from the pool - * @i: pointer to idpool - * - */ - -int v9fs_get_idpool(struct idpool *i) -{ - int nextbit; - - if (down_interruptible(&i->sem) == -EINTR) { - eprintk(KERN_WARNING, "Interrupted while locking\n"); - return -1; - } - - nextbit = find_next_zero_bit(i->idlist, i->maxalloc, i->lastfree); - if (nextbit > i->maxalloc) { - if (grow_idpool(i, i->maxalloc * 2) == 0) { - up(&i->sem); - return -1; - } else { - nextbit = - find_next_zero_bit(i->idlist, i->maxalloc, - i->lastfree); - } - } - - set_bit(nextbit, i->idlist); - if (i->lastfree == nextbit) - i->lastfree = nextbit + 1; - - up(&i->sem); - return nextbit; -} - -/** - * v9fs_put_idpool - get a new id from the pool - * @which: which id to put - * @i: pointer to idpool - * - */ - -void v9fs_put_idpool(int which, struct idpool *i) -{ - if ((which < 0) || (which > i->maxalloc)) { - return; - } - - if (down_interruptible(&i->sem) == -EINTR) { - eprintk(KERN_WARNING, "Interrupted while locking\n"); - return; - } - - clear_bit(which, i->idlist); - if (which < i->lastfree) - i->lastfree = which; - - up(&i->sem); -} diff -L fs/9p/idpool.h -puN fs/9p/idpool.h~v9fs-debug-and-support-routines-resend-take-2 /dev/null --- devel/fs/9p/idpool.h +++ /dev/null 2003-09-15 06:40:47.000000000 -0700 @@ -1,42 +0,0 @@ -/* - * linux/fs/9p/idpool.h - * - * Copyright (C) 2004 by Eric Van Hensbergen - * Copyright (C) 2002 by Ron Minnich - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to: - * Free Software Foundation - * 51 Franklin Street, Fifth Floor - * Boston, MA 02111-1301 USA - * - */ - -/* - * This is for getting unique IDs. - * 0 means free, non-zero means used. - * - */ - -struct idpool { - struct semaphore sem; - int maxalloc; - int numalloc; - int lastfree; - unsigned long *idlist; -}; - -int v9fs_alloc_idpool(struct idpool *, int); -void v9fs_free_idpool(struct idpool *); -int v9fs_get_idpool(struct idpool *i); -void v9fs_put_idpool(int which, struct idpool *i); _