Commit 7cfb5e64 authored by Chen Yang's avatar Chen Yang Committed by Linus Torvalds

[PATCH] InterMezzo maintainence patch

I have tested these patches and can atteste that they work.

 - rwhron@earthlink.net:
	include cleanup of fs/intermezzo
 - kdw@neowiz.com:
	memory leakage problem,race condition report
 - Domen Puncer:
	Use list_for_each() where applicable
 - Chen Yang:
	include file modification for more platforms to compile intermezzo
	fix an oops problem
parent d154c8f0
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/smp_lock.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/init.h> #include <linux/init.h>
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/smp_lock.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <asm/segment.h> #include <asm/segment.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
......
...@@ -23,10 +23,9 @@ ...@@ -23,10 +23,9 @@
*/ */
#include <asm/bitops.h> #include <asm/bitops.h>
#include <asm/ioctls.h> #include <asm/termios.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/system.h> #include <asm/system.h>
#include <linux/smp_lock.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/fs.h> #include <linux/fs.h>
...@@ -55,7 +54,7 @@ static inline void presto_relock_other(struct inode *dir) ...@@ -55,7 +54,7 @@ static inline void presto_relock_other(struct inode *dir)
{ {
/* vfs_mkdir locks */ /* vfs_mkdir locks */
// down(&dir->i_zombie); // down(&dir->i_zombie);
lock_kernel(); //lock_kernel();
} }
static inline void presto_fulllock(struct inode *dir) static inline void presto_fulllock(struct inode *dir)
...@@ -64,13 +63,13 @@ static inline void presto_fulllock(struct inode *dir) ...@@ -64,13 +63,13 @@ static inline void presto_fulllock(struct inode *dir)
down(&dir->i_sem); down(&dir->i_sem);
/* vfs_mkdir locks */ /* vfs_mkdir locks */
// down(&dir->i_zombie); // down(&dir->i_zombie);
lock_kernel(); //lock_kernel();
} }
static inline void presto_unlock(struct inode *dir) static inline void presto_unlock(struct inode *dir)
{ {
/* vfs_mkdir locks */ /* vfs_mkdir locks */
unlock_kernel(); //unlock_kernel();
// up(&dir->i_zombie); // up(&dir->i_zombie);
/* the lock from sys_mkdir / lookup_create */ /* the lock from sys_mkdir / lookup_create */
up(&dir->i_sem); up(&dir->i_sem);
......
...@@ -28,14 +28,12 @@ ...@@ -28,14 +28,12 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/smp_lock.h>
#include <linux/unistd.h> #include <linux/unistd.h>
#include <asm/system.h> #include <asm/system.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/smp_lock.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <asm/segment.h> #include <asm/segment.h>
......
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/smp_lock.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/smp_lock.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/smp_lock.h>
#include <linux/unistd.h> #include <linux/unistd.h>
#include <asm/system.h> #include <asm/system.h>
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/time.h> #include <linux/time.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/smp_lock.h>
#include <asm/segment.h> #include <asm/segment.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/string.h> #include <linux/string.h>
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/smp_lock.h>
#include <asm/segment.h> #include <asm/segment.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/string.h> #include <linux/string.h>
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/smp_lock.h>
#include <asm/segment.h> #include <asm/segment.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/string.h> #include <linux/string.h>
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/smp_lock.h>
#include <asm/segment.h> #include <asm/segment.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/string.h> #include <linux/string.h>
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/smp_lock.h>
#include <asm/segment.h> #include <asm/segment.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/string.h> #include <linux/string.h>
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/smp_lock.h>
#include <asm/segment.h> #include <asm/segment.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/string.h> #include <linux/string.h>
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/smp_lock.h>
#include <asm/segment.h> #include <asm/segment.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/string.h> #include <linux/string.h>
......
#include <linux/list.h> #include <linux/list.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/smp_lock.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/smp_lock.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/smp_lock.h>
#include <asm/segment.h> #include <asm/segment.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/string.h> #include <linux/string.h>
......
...@@ -102,8 +102,7 @@ int izo_psdev_setpid(int minor) ...@@ -102,8 +102,7 @@ int izo_psdev_setpid(int minor)
struct list_head *lh; struct list_head *lh;
struct upc_req *req; struct upc_req *req;
CERROR("WARNING: setpid & processing not empty!\n"); CERROR("WARNING: setpid & processing not empty!\n");
lh = &channel->uc_processing; list_for_each(lh, &channel->uc_processing) {
while ( (lh = lh->next) != &channel->uc_processing) {
req = list_entry(lh, struct upc_req, rq_chain); req = list_entry(lh, struct upc_req, rq_chain);
/* freeing of req and data is done by the sleeper */ /* freeing of req and data is done by the sleeper */
wake_up(&req->rq_sleep); wake_up(&req->rq_sleep);
...@@ -208,8 +207,7 @@ static ssize_t presto_psdev_write(struct file *file, const char *buf, ...@@ -208,8 +207,7 @@ static ssize_t presto_psdev_write(struct file *file, const char *buf,
spin_lock(&channel->uc_lock); spin_lock(&channel->uc_lock);
/* Look for the message on the processing queue. */ /* Look for the message on the processing queue. */
lh = &channel->uc_processing; list_for_each(lh, &channel->uc_processing) {
while ( (lh = lh->next) != &channel->uc_processing ) {
tmp = list_entry(lh, struct upc_req , rq_chain); tmp = list_entry(lh, struct upc_req , rq_chain);
if (tmp->rq_unique == hdr.unique) { if (tmp->rq_unique == hdr.unique) {
req = tmp; req = tmp;
...@@ -337,8 +335,7 @@ static int presto_psdev_release(struct inode * inode, struct file * file) ...@@ -337,8 +335,7 @@ static int presto_psdev_release(struct inode * inode, struct file * file)
/* Wake up clients so they can return. */ /* Wake up clients so they can return. */
CDEBUG(D_PSDEV, "Wake up clients sleeping for pending.\n"); CDEBUG(D_PSDEV, "Wake up clients sleeping for pending.\n");
spin_lock(&channel->uc_lock); spin_lock(&channel->uc_lock);
lh = &channel->uc_pending; list_for_each(lh, &channel->uc_pending) {
while ( (lh = lh->next) != &channel->uc_pending) {
req = list_entry(lh, struct upc_req, rq_chain); req = list_entry(lh, struct upc_req, rq_chain);
/* Async requests stay around for a new lento */ /* Async requests stay around for a new lento */
...@@ -351,8 +348,7 @@ static int presto_psdev_release(struct inode * inode, struct file * file) ...@@ -351,8 +348,7 @@ static int presto_psdev_release(struct inode * inode, struct file * file)
} }
CDEBUG(D_PSDEV, "Wake up clients sleeping for processing\n"); CDEBUG(D_PSDEV, "Wake up clients sleeping for processing\n");
lh = &channel->uc_processing; list_for_each(lh, &channel->uc_processing) {
while ( (lh = lh->next) != &channel->uc_processing) {
req = list_entry(lh, struct upc_req, rq_chain); req = list_entry(lh, struct upc_req, rq_chain);
/* freeing of req and data is done by the sleeper */ /* freeing of req and data is done by the sleeper */
req->rq_flags |= REQ_DEAD; req->rq_flags |= REQ_DEAD;
...@@ -419,7 +415,7 @@ void presto_psdev_cleanup(void) ...@@ -419,7 +415,7 @@ void presto_psdev_cleanup(void)
for ( i = 0 ; i < MAX_CHANNEL ; i++ ) { for ( i = 0 ; i < MAX_CHANNEL ; i++ ) {
struct upc_channel *channel = &(izo_channels[i]); struct upc_channel *channel = &(izo_channels[i]);
struct list_head *lh; struct list_head *lh, *next;
spin_lock(&channel->uc_lock); spin_lock(&channel->uc_lock);
if ( ! list_empty(&channel->uc_pending)) { if ( ! list_empty(&channel->uc_pending)) {
...@@ -431,12 +427,10 @@ void presto_psdev_cleanup(void) ...@@ -431,12 +427,10 @@ void presto_psdev_cleanup(void)
if ( ! list_empty(&channel->uc_cache_list)) { if ( ! list_empty(&channel->uc_cache_list)) {
CERROR("Weird, tell Peter: module cleanup and cache listnot empty dev %d\n", i); CERROR("Weird, tell Peter: module cleanup and cache listnot empty dev %d\n", i);
} }
lh = channel->uc_pending.next; list_for_each_safe(lh, next, &channel->uc_pending) {
while ( lh != &channel->uc_pending) {
struct upc_req *req; struct upc_req *req;
req = list_entry(lh, struct upc_req, rq_chain); req = list_entry(lh, struct upc_req, rq_chain);
lh = lh->next;
if ( req->rq_flags & REQ_ASYNC ) { if ( req->rq_flags & REQ_ASYNC ) {
list_del(&(req->rq_chain)); list_del(&(req->rq_chain));
CDEBUG(D_UPCALL, "free pending upcall type %d\n", CDEBUG(D_UPCALL, "free pending upcall type %d\n",
...@@ -448,8 +442,7 @@ void presto_psdev_cleanup(void) ...@@ -448,8 +442,7 @@ void presto_psdev_cleanup(void)
wake_up(&req->rq_sleep); wake_up(&req->rq_sleep);
} }
} }
lh = &channel->uc_processing; list_for_each(lh, &channel->uc_processing) {
while ( (lh = lh->next) != &channel->uc_processing ) {
struct upc_req *req; struct upc_req *req;
req = list_entry(lh, struct upc_req, rq_chain); req = list_entry(lh, struct upc_req, rq_chain);
list_del(&(req->rq_chain)); list_del(&(req->rq_chain));
...@@ -562,6 +555,10 @@ int izo_upc_upcall(int minor, int *size, struct izo_upcall_hdr *buffer, ...@@ -562,6 +555,10 @@ int izo_upc_upcall(int minor, int *size, struct izo_upcall_hdr *buffer,
buffer->u_uniq = req->rq_unique; buffer->u_uniq = req->rq_unique;
buffer->u_async = async; buffer->u_async = async;
/* Remove potential datarace possibility*/
if ( async )
req->rq_flags = REQ_ASYNC;
spin_lock(&channel->uc_lock); spin_lock(&channel->uc_lock);
/* Append msg to pending queue and poke Lento. */ /* Append msg to pending queue and poke Lento. */
list_add(&req->rq_chain, channel->uc_pending.prev); list_add(&req->rq_chain, channel->uc_pending.prev);
...@@ -574,7 +571,7 @@ int izo_upc_upcall(int minor, int *size, struct izo_upcall_hdr *buffer, ...@@ -574,7 +571,7 @@ int izo_upc_upcall(int minor, int *size, struct izo_upcall_hdr *buffer,
if ( async ) { if ( async ) {
/* req, rq_data are freed in presto_psdev_read for async */ /* req, rq_data are freed in presto_psdev_read for async */
req->rq_flags = REQ_ASYNC; /* req->rq_flags = REQ_ASYNC;*/
EXIT; EXIT;
return 0; return 0;
} }
...@@ -645,5 +642,6 @@ int izo_upc_upcall(int minor, int *size, struct izo_upcall_hdr *buffer, ...@@ -645,5 +642,6 @@ int izo_upc_upcall(int minor, int *size, struct izo_upcall_hdr *buffer,
exit_req: exit_req:
PRESTO_FREE(req, sizeof(struct upc_req)); PRESTO_FREE(req, sizeof(struct upc_req));
exit_buf: exit_buf:
PRESTO_FREE(buffer,*size);
return error; return error;
} }
...@@ -97,11 +97,10 @@ izo_rep_cache_clean(struct presto_file_set *fset) ...@@ -97,11 +97,10 @@ izo_rep_cache_clean(struct presto_file_set *fset)
struct izo_offset_rec * struct izo_offset_rec *
izo_rep_cache_find(struct presto_file_set *fset, char *uuid) izo_rep_cache_find(struct presto_file_set *fset, char *uuid)
{ {
struct list_head *buck = izo_rep_hash(fset->fset_clients, uuid); struct list_head *tmp, *buck = izo_rep_hash(fset->fset_clients, uuid);
struct list_head *tmp = buck;
struct izo_offset_rec *rec = NULL; struct izo_offset_rec *rec = NULL;
while ( (tmp = tmp->next) != buck ) { list_for_each(tmp, buck) {
rec = list_entry(tmp, struct izo_offset_rec, or_list); rec = list_entry(tmp, struct izo_offset_rec, or_list);
if ( memcmp(rec->or_uuid, uuid, sizeof(rec->or_uuid)) == 0 ) if ( memcmp(rec->or_uuid, uuid, sizeof(rec->or_uuid)) == 0 )
return rec; return rec;
......
...@@ -38,7 +38,6 @@ static char rcsid[] __attribute ((unused)) = "$Id: super.c,v 1.4 2002/10/12 02:1 ...@@ -38,7 +38,6 @@ static char rcsid[] __attribute ((unused)) = "$Id: super.c,v 1.4 2002/10/12 02:1
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/smp_lock.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/devfs_fs_kernel.h> #include <linux/devfs_fs_kernel.h>
......
...@@ -39,7 +39,6 @@ ...@@ -39,7 +39,6 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/smp_lock.h>
#include <linux/string.h> #include <linux/string.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
......
...@@ -55,7 +55,6 @@ ...@@ -55,7 +55,6 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/smp_lock.h>
#include <linux/quotaops.h> #include <linux/quotaops.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
......
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