From 7cfb5e644cfee5093648001198aedf1fdbf6631a Mon Sep 17 00:00:00 2001 From: Chen Yang Date: Mon, 6 Oct 2003 19:15:15 -0700 Subject: [PATCH] [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 --- fs/intermezzo/cache.c | 1 - fs/intermezzo/dcache.c | 1 - fs/intermezzo/dir.c | 9 ++++----- fs/intermezzo/ext_attr.c | 2 -- fs/intermezzo/file.c | 1 - fs/intermezzo/fileset.c | 1 - fs/intermezzo/inode.c | 1 - fs/intermezzo/journal.c | 1 - fs/intermezzo/journal_ext2.c | 1 - fs/intermezzo/journal_ext3.c | 1 - fs/intermezzo/journal_obdfs.c | 1 - fs/intermezzo/journal_reiserfs.c | 1 - fs/intermezzo/journal_tmpfs.c | 1 - fs/intermezzo/journal_xfs.c | 1 - fs/intermezzo/kml_utils.c | 1 - fs/intermezzo/methods.c | 1 - fs/intermezzo/presto.c | 1 - fs/intermezzo/psdev.c | 28 +++++++++++++--------------- fs/intermezzo/replicator.c | 5 ++--- fs/intermezzo/super.c | 1 - fs/intermezzo/upcall.c | 1 - fs/intermezzo/vfs.c | 1 - 22 files changed, 19 insertions(+), 43 deletions(-) diff --git a/fs/intermezzo/cache.c b/fs/intermezzo/cache.c index 02665709a0cd9..de49fe94c2993 100644 --- a/fs/intermezzo/cache.c +++ b/fs/intermezzo/cache.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include diff --git a/fs/intermezzo/dcache.c b/fs/intermezzo/dcache.c index 9d62e71526679..8f8e2c5161715 100644 --- a/fs/intermezzo/dcache.c +++ b/fs/intermezzo/dcache.c @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include diff --git a/fs/intermezzo/dir.c b/fs/intermezzo/dir.c index ac6fe686e05ec..d747fb8c80d4f 100644 --- a/fs/intermezzo/dir.c +++ b/fs/intermezzo/dir.c @@ -23,10 +23,9 @@ */ #include -#include +#include #include #include -#include #include #include @@ -55,7 +54,7 @@ static inline void presto_relock_other(struct inode *dir) { /* vfs_mkdir locks */ // down(&dir->i_zombie); - lock_kernel(); + //lock_kernel(); } static inline void presto_fulllock(struct inode *dir) @@ -64,13 +63,13 @@ static inline void presto_fulllock(struct inode *dir) down(&dir->i_sem); /* vfs_mkdir locks */ // down(&dir->i_zombie); - lock_kernel(); + //lock_kernel(); } static inline void presto_unlock(struct inode *dir) { /* vfs_mkdir locks */ - unlock_kernel(); + //unlock_kernel(); // up(&dir->i_zombie); /* the lock from sys_mkdir / lookup_create */ up(&dir->i_sem); diff --git a/fs/intermezzo/ext_attr.c b/fs/intermezzo/ext_attr.c index 14f0c4ca49d34..be91417c1db10 100644 --- a/fs/intermezzo/ext_attr.c +++ b/fs/intermezzo/ext_attr.c @@ -28,14 +28,12 @@ #include #include #include -#include #include #include #include #include -#include #include #include #include diff --git a/fs/intermezzo/file.c b/fs/intermezzo/file.c index c8e6ab1166d97..3bf9959221993 100644 --- a/fs/intermezzo/file.c +++ b/fs/intermezzo/file.c @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include diff --git a/fs/intermezzo/fileset.c b/fs/intermezzo/fileset.c index 615d37b6318e2..e0bb4c219a2a5 100644 --- a/fs/intermezzo/fileset.c +++ b/fs/intermezzo/fileset.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include diff --git a/fs/intermezzo/inode.c b/fs/intermezzo/inode.c index f4721f1034a0c..fda188bab541d 100644 --- a/fs/intermezzo/inode.c +++ b/fs/intermezzo/inode.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include diff --git a/fs/intermezzo/journal.c b/fs/intermezzo/journal.c index 3a077cf099a36..ca18696d8afb2 100644 --- a/fs/intermezzo/journal.c +++ b/fs/intermezzo/journal.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include diff --git a/fs/intermezzo/journal_ext2.c b/fs/intermezzo/journal_ext2.c index 2adb47f8b6765..d1cb293c21e63 100644 --- a/fs/intermezzo/journal_ext2.c +++ b/fs/intermezzo/journal_ext2.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include diff --git a/fs/intermezzo/journal_ext3.c b/fs/intermezzo/journal_ext3.c index edaab249c916b..b847b61983cdc 100644 --- a/fs/intermezzo/journal_ext3.c +++ b/fs/intermezzo/journal_ext3.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include diff --git a/fs/intermezzo/journal_obdfs.c b/fs/intermezzo/journal_obdfs.c index 42f4228519796..702ee8b6478f9 100644 --- a/fs/intermezzo/journal_obdfs.c +++ b/fs/intermezzo/journal_obdfs.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include diff --git a/fs/intermezzo/journal_reiserfs.c b/fs/intermezzo/journal_reiserfs.c index 2a1d6c8c21ce5..93fc148452bb8 100644 --- a/fs/intermezzo/journal_reiserfs.c +++ b/fs/intermezzo/journal_reiserfs.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include diff --git a/fs/intermezzo/journal_tmpfs.c b/fs/intermezzo/journal_tmpfs.c index f2a81917cc490..4f3c463f0981f 100644 --- a/fs/intermezzo/journal_tmpfs.c +++ b/fs/intermezzo/journal_tmpfs.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include diff --git a/fs/intermezzo/journal_xfs.c b/fs/intermezzo/journal_xfs.c index c12d265525951..e065896c3db38 100644 --- a/fs/intermezzo/journal_xfs.c +++ b/fs/intermezzo/journal_xfs.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include diff --git a/fs/intermezzo/kml_utils.c b/fs/intermezzo/kml_utils.c index ed0dd39b6d920..5062e2d71df58 100644 --- a/fs/intermezzo/kml_utils.c +++ b/fs/intermezzo/kml_utils.c @@ -1,6 +1,5 @@ #include #include -#include #include #include diff --git a/fs/intermezzo/methods.c b/fs/intermezzo/methods.c index f6dc7bab3c832..8950efc8c2a34 100644 --- a/fs/intermezzo/methods.c +++ b/fs/intermezzo/methods.c @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include diff --git a/fs/intermezzo/presto.c b/fs/intermezzo/presto.c index a843df4ef9040..d161a7ba694e4 100644 --- a/fs/intermezzo/presto.c +++ b/fs/intermezzo/presto.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include diff --git a/fs/intermezzo/psdev.c b/fs/intermezzo/psdev.c index 3c25ec595ffed..ec650c324e198 100644 --- a/fs/intermezzo/psdev.c +++ b/fs/intermezzo/psdev.c @@ -102,8 +102,7 @@ int izo_psdev_setpid(int minor) struct list_head *lh; struct upc_req *req; CERROR("WARNING: setpid & processing not empty!\n"); - lh = &channel->uc_processing; - while ( (lh = lh->next) != &channel->uc_processing) { + list_for_each(lh, &channel->uc_processing) { req = list_entry(lh, struct upc_req, rq_chain); /* freeing of req and data is done by the sleeper */ wake_up(&req->rq_sleep); @@ -208,8 +207,7 @@ static ssize_t presto_psdev_write(struct file *file, const char *buf, spin_lock(&channel->uc_lock); /* Look for the message on the processing queue. */ - lh = &channel->uc_processing; - while ( (lh = lh->next) != &channel->uc_processing ) { + list_for_each(lh, &channel->uc_processing) { tmp = list_entry(lh, struct upc_req , rq_chain); if (tmp->rq_unique == hdr.unique) { req = tmp; @@ -337,8 +335,7 @@ static int presto_psdev_release(struct inode * inode, struct file * file) /* Wake up clients so they can return. */ CDEBUG(D_PSDEV, "Wake up clients sleeping for pending.\n"); spin_lock(&channel->uc_lock); - lh = &channel->uc_pending; - while ( (lh = lh->next) != &channel->uc_pending) { + list_for_each(lh, &channel->uc_pending) { req = list_entry(lh, struct upc_req, rq_chain); /* Async requests stay around for a new lento */ @@ -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"); - lh = &channel->uc_processing; - while ( (lh = lh->next) != &channel->uc_processing) { + list_for_each(lh, &channel->uc_processing) { req = list_entry(lh, struct upc_req, rq_chain); /* freeing of req and data is done by the sleeper */ req->rq_flags |= REQ_DEAD; @@ -419,7 +415,7 @@ void presto_psdev_cleanup(void) for ( i = 0 ; i < MAX_CHANNEL ; i++ ) { struct upc_channel *channel = &(izo_channels[i]); - struct list_head *lh; + struct list_head *lh, *next; spin_lock(&channel->uc_lock); if ( ! list_empty(&channel->uc_pending)) { @@ -431,12 +427,10 @@ void presto_psdev_cleanup(void) if ( ! list_empty(&channel->uc_cache_list)) { CERROR("Weird, tell Peter: module cleanup and cache listnot empty dev %d\n", i); } - lh = channel->uc_pending.next; - while ( lh != &channel->uc_pending) { + list_for_each_safe(lh, next, &channel->uc_pending) { struct upc_req *req; req = list_entry(lh, struct upc_req, rq_chain); - lh = lh->next; if ( req->rq_flags & REQ_ASYNC ) { list_del(&(req->rq_chain)); CDEBUG(D_UPCALL, "free pending upcall type %d\n", @@ -448,8 +442,7 @@ void presto_psdev_cleanup(void) wake_up(&req->rq_sleep); } } - lh = &channel->uc_processing; - while ( (lh = lh->next) != &channel->uc_processing ) { + list_for_each(lh, &channel->uc_processing) { struct upc_req *req; req = list_entry(lh, struct upc_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, buffer->u_uniq = req->rq_unique; buffer->u_async = async; + /* Remove potential datarace possibility*/ + if ( async ) + req->rq_flags = REQ_ASYNC; + spin_lock(&channel->uc_lock); /* Append msg to pending queue and poke Lento. */ 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, if ( async ) { /* req, rq_data are freed in presto_psdev_read for async */ - req->rq_flags = REQ_ASYNC; + /* req->rq_flags = REQ_ASYNC;*/ EXIT; return 0; } @@ -645,5 +642,6 @@ int izo_upc_upcall(int minor, int *size, struct izo_upcall_hdr *buffer, exit_req: PRESTO_FREE(req, sizeof(struct upc_req)); exit_buf: + PRESTO_FREE(buffer,*size); return error; } diff --git a/fs/intermezzo/replicator.c b/fs/intermezzo/replicator.c index de70c8d69f9a1..e7a0c5c17eabd 100644 --- a/fs/intermezzo/replicator.c +++ b/fs/intermezzo/replicator.c @@ -97,11 +97,10 @@ izo_rep_cache_clean(struct presto_file_set *fset) struct izo_offset_rec * 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; + struct list_head *tmp, *buck = izo_rep_hash(fset->fset_clients, uuid); 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); if ( memcmp(rec->or_uuid, uuid, sizeof(rec->or_uuid)) == 0 ) return rec; diff --git a/fs/intermezzo/super.c b/fs/intermezzo/super.c index 82104dd3093cf..9993ef2bf743e 100644 --- a/fs/intermezzo/super.c +++ b/fs/intermezzo/super.c @@ -38,7 +38,6 @@ static char rcsid[] __attribute ((unused)) = "$Id: super.c,v 1.4 2002/10/12 02:1 #include #include #include -#include #include #include #include diff --git a/fs/intermezzo/upcall.c b/fs/intermezzo/upcall.c index df86732f0208e..e8b6730a3ed7c 100644 --- a/fs/intermezzo/upcall.c +++ b/fs/intermezzo/upcall.c @@ -39,7 +39,6 @@ #include #include #include -#include #include #include diff --git a/fs/intermezzo/vfs.c b/fs/intermezzo/vfs.c index 40b08d332d258..fa0159bab5930 100644 --- a/fs/intermezzo/vfs.c +++ b/fs/intermezzo/vfs.c @@ -55,7 +55,6 @@ #include #include -#include #include #include -- 2.53.0