From 5c78de6933cc3784c77f925b90e92a65d6c30710 Mon Sep 17 00:00:00 2001 From: nikita Date: Mon, 1 Sep 2008 16:44:34 +0000 Subject: [PATCH] undo erroenous commit to HEAD lnet and libcfs. --- libcfs/include/libcfs/posix/libcfs.h | 80 +++++++++++++----------------------- libcfs/include/libcfs/user-lock.h | 25 ++--------- libcfs/libcfs/linux/linux-prim.c | 25 ++++++----- libcfs/libcfs/tracefile.c | 8 ++-- libcfs/libcfs/user-lock.c | 19 --------- lnet/utils/wirecheck.c | 2 +- 6 files changed, 48 insertions(+), 111 deletions(-) diff --git a/libcfs/include/libcfs/posix/libcfs.h b/libcfs/include/libcfs/posix/libcfs.h index b50554f..8509eb4 100644 --- a/libcfs/include/libcfs/posix/libcfs.h +++ b/libcfs/include/libcfs/posix/libcfs.h @@ -221,7 +221,7 @@ static inline void MODULE_AUTHOR(char *name) #define MODULE_DESCRIPTION(name) MODULE_AUTHOR(name) #define MODULE_LICENSE(name) MODULE_AUTHOR(name) -#define THIS_MODULE (void *)0x11111 +#define THIS_MODULE NULL #define __init #define __exit @@ -265,7 +265,7 @@ typedef int (*shrinker_t)(int, unsigned int); static inline struct shrinker *set_shrinker(int seeks, shrinker_t shrinkert) { - return (struct shrinker *)0xdeadbea1; // Cannot return NULL here + return NULL; } static inline void remove_shrinker(struct shrinker *shrinker) @@ -283,87 +283,63 @@ static inline void remove_shrinker(struct shrinker *shrinker) ***************************************************************************/ struct radix_tree_root { - struct list_head list; - void *rnode; + struct list_head *rnode; }; -struct radix_tree_node { - struct list_head _node; - unsigned long index; - void *item; -}; - #define RADIX_TREE_INIT(mask) { \ - NOT_IMPLEMENTED \ + .rnode = NULL, \ } #define RADIX_TREE(name, mask) \ struct radix_tree_root name = RADIX_TREE_INIT(mask) - -#define INIT_RADIX_TREE(root, mask) \ -do { \ - CFS_INIT_LIST_HEAD(&((struct radix_tree_root *)root)->list); \ - ((struct radix_tree_root *)root)->rnode = NULL; \ +#define INIT_RADIX_TREE(root, mask) \ +do { \ + (root)->rnode = NULL; \ } while (0) static inline int radix_tree_insert(struct radix_tree_root *root, - unsigned long idx, void *item) + unsigned long idx, struct page *page) { - struct radix_tree_node *node; - node = malloc(sizeof(*node)); - if (!node) - return -ENOMEM; - - CFS_INIT_LIST_HEAD(&node->_node); - node->index = idx; - node->item = item; - list_add_tail(&node->_node, &root->list); - root->rnode = (void *)1001; + if (root->rnode == NULL) + root->rnode = &page->_node; + else + list_add_tail(&page->_node, root->rnode); return 0; } -static inline struct radix_tree_node *radix_tree_lookup0(struct radix_tree_root *root, +static inline void *radix_tree_lookup(struct radix_tree_root *root, unsigned long idx) { - struct radix_tree_node *node; + struct page *p; - if (list_empty(&root->list)) + if (root->rnode == NULL) return NULL; - list_for_each_entry(node, &root->list, _node) - if (node->index == idx) - return node; + p = list_entry(root->rnode, struct page, _node); + if (p->index == idx) + return p; - return NULL; -} + list_for_each_entry(p, root->rnode, _node) + if (p->index == idx) + return p; -static inline void *radix_tree_lookup(struct radix_tree_root *root, - unsigned long idx) -{ - struct radix_tree_node *node = radix_tree_lookup0(root, idx); - - if (node) - return node->item; - return node; + return NULL; } static inline void *radix_tree_delete(struct radix_tree_root *root, unsigned long idx) { - struct radix_tree_node *p = radix_tree_lookup0(root, idx); - void *item; + struct page *p = radix_tree_lookup(root, idx); if (p == NULL) return NULL; - - list_del_init(&p->_node); - item = p->item; - free(p); - if (list_empty(&root->list)) + if (list_empty(root->rnode)) root->rnode = NULL; - - return item; + else if (root->rnode == &p->_node) + root->rnode = p->_node.next; + list_del_init(&p->_node); + return p; } static inline unsigned int diff --git a/libcfs/include/libcfs/user-lock.h b/libcfs/include/libcfs/user-lock.h index 2561381..6f4e145 100644 --- a/libcfs/include/libcfs/user-lock.h +++ b/libcfs/include/libcfs/user-lock.h @@ -146,8 +146,7 @@ struct completion { unsigned int done; cfs_waitq_t wait; }; -typedef int (cfs_wait_handler) (int timeout); -void set_completion_wait_handler(cfs_wait_handler *handler); + void init_completion(struct completion *c); void complete(struct completion *c); void wait_for_completion(struct completion *c); @@ -280,8 +279,6 @@ struct mutex { struct semaphore m_sem; }; -#define DEFINE_MUTEX(m) struct mutex m - static inline void mutex_init(struct mutex *mutex) { init_mutex(&mutex->m_sem); @@ -300,27 +297,13 @@ static inline void mutex_unlock(struct mutex *mutex) /** * Try-lock this mutex. * + * \retval 1 try-lock succeeded. * - * \retval 0 try-lock succeeded (lock acquired). - * \retval errno indicates lock contention. - */ -static inline int mutex_down_trylock(struct mutex *mutex) -{ - return 0; -} - -/** - * Try-lock this mutex. - * - * Note, return values are negation of what is expected from down_trylock() or - * pthread_mutex_trylock(). - * - * \retval 1 try-lock succeeded (lock acquired). - * \retval 0 indicates lock contention. + * \retval 0 try-lock failed. */ static inline int mutex_trylock(struct mutex *mutex) { - return !mutex_down_trylock(mutex); + return 1; } static inline void mutex_destroy(struct mutex *lock) diff --git a/libcfs/libcfs/linux/linux-prim.c b/libcfs/libcfs/linux/linux-prim.c index e92aacc..f8cdf81 100644 --- a/libcfs/libcfs/linux/linux-prim.c +++ b/libcfs/libcfs/linux/linux-prim.c @@ -58,71 +58,71 @@ cfs_waitq_init(cfs_waitq_t *waitq) } EXPORT_SYMBOL(cfs_waitq_init); -void +void cfs_waitlink_init(cfs_waitlink_t *link) { init_waitqueue_entry(LINUX_WAITQ(link), current); } EXPORT_SYMBOL(cfs_waitlink_init); -void +void cfs_waitq_add(cfs_waitq_t *waitq, cfs_waitlink_t *link) { add_wait_queue(LINUX_WAITQ_HEAD(waitq), LINUX_WAITQ(link)); } EXPORT_SYMBOL(cfs_waitq_add); -void -cfs_waitq_add_exclusive(cfs_waitq_t *waitq, +void +cfs_waitq_add_exclusive(cfs_waitq_t *waitq, cfs_waitlink_t *link) { add_wait_queue_exclusive(LINUX_WAITQ_HEAD(waitq), LINUX_WAITQ(link)); } EXPORT_SYMBOL(cfs_waitq_add_exclusive); -void +void cfs_waitq_del(cfs_waitq_t *waitq, cfs_waitlink_t *link) { remove_wait_queue(LINUX_WAITQ_HEAD(waitq), LINUX_WAITQ(link)); } EXPORT_SYMBOL(cfs_waitq_del); -int +int cfs_waitq_active(cfs_waitq_t *waitq) { return waitqueue_active(LINUX_WAITQ_HEAD(waitq)); } EXPORT_SYMBOL(cfs_waitq_active); -void +void cfs_waitq_signal(cfs_waitq_t *waitq) { wake_up(LINUX_WAITQ_HEAD(waitq)); } EXPORT_SYMBOL(cfs_waitq_signal); -void +void cfs_waitq_signal_nr(cfs_waitq_t *waitq, int nr) { wake_up_nr(LINUX_WAITQ_HEAD(waitq), nr); } EXPORT_SYMBOL(cfs_waitq_signal_nr); -void +void cfs_waitq_broadcast(cfs_waitq_t *waitq) { wake_up_all(LINUX_WAITQ_HEAD(waitq)); } EXPORT_SYMBOL(cfs_waitq_broadcast); -void +void cfs_waitq_wait(cfs_waitlink_t *link, cfs_task_state_t state) { schedule(); } EXPORT_SYMBOL(cfs_waitq_wait); -int64_t +int64_t cfs_waitq_timedwait(cfs_waitlink_t *link, cfs_task_state_t state, int64_t timeout) { return schedule_timeout(timeout); @@ -145,7 +145,7 @@ cfs_schedule(void) EXPORT_SYMBOL(cfs_schedule); /* deschedule for a bit... */ -void +void cfs_pause(cfs_duration_t ticks) { set_current_state(TASK_UNINTERRUPTIBLE); @@ -323,7 +323,6 @@ libcfs_arch_cleanup(void) EXPORT_SYMBOL(libcfs_arch_init); EXPORT_SYMBOL(libcfs_arch_cleanup); -EXPORT_SYMBOL(cfs_enter_debugger); EXPORT_SYMBOL(cfs_daemonize); EXPORT_SYMBOL(cfs_daemonize_ctxt); EXPORT_SYMBOL(cfs_block_allsigs); diff --git a/libcfs/libcfs/tracefile.c b/libcfs/libcfs/tracefile.c index f32ba75..20df843 100644 --- a/libcfs/libcfs/tracefile.c +++ b/libcfs/libcfs/tracefile.c @@ -150,10 +150,9 @@ static struct trace_page *trace_get_tage_try(struct trace_cpu_data *tcd, } else { tage = tage_alloc(CFS_ALLOC_ATOMIC); if (tage == NULL) { - if (printk_ratelimit()) - printk(KERN_WARNING - "cannot allocate a tage (%ld)\n", - tcd->tcd_cur_pages); + printk(KERN_WARNING + "failure to allocate a tage (%ld)\n", + tcd->tcd_cur_pages); return NULL; } } @@ -449,7 +448,6 @@ libcfs_assertion_failed(const char *expr, const char *file, { libcfs_debug_msg(NULL, 0, D_EMERG, file, func, line, "ASSERTION(%s) failed\n", expr); - cfs_enter_debugger(); lbug_with_loc(file, func, line); } EXPORT_SYMBOL(libcfs_assertion_failed); diff --git a/libcfs/libcfs/user-lock.c b/libcfs/libcfs/user-lock.c index ab4447c..1f392f6 100644 --- a/libcfs/libcfs/user-lock.c +++ b/libcfs/libcfs/user-lock.c @@ -147,13 +147,6 @@ void __up(struct semaphore *s) * - wait_for_completion(c) */ -static cfs_wait_handler *wait_handler; - -void init_completion_module(cfs_wait_handler *handler) -{ - wait_handler = handler; -} - void init_completion(struct completion *c) { LASSERT(c != NULL); @@ -171,23 +164,11 @@ void complete(struct completion *c) void wait_for_completion(struct completion *c) { LASSERT(c != NULL); - do { - if (wait_handler) - wait_handler(1000); - else - break; - } while (c->done == 0); } int wait_for_completion_interruptible(struct completion *c) { LASSERT(c != NULL); - do { - if (wait_handler) - wait_handler(1000); - else - break; - } while (c->done == 0); return 0; } diff --git a/lnet/utils/wirecheck.c b/lnet/utils/wirecheck.c index 17c57aa..6d44ea1 100644 --- a/lnet/utils/wirecheck.c +++ b/lnet/utils/wirecheck.c @@ -193,7 +193,7 @@ system_string (char *cmdline, char *str, int len) WEXITSTATUS(rc) != 0) abort(); - if (strlen(str) == len) + if (strnlen(str, len) == len) str[len - 1] = 0; if (str[strlen(str) - 1] == '\n') -- 1.8.3.1