Whamcloud - gitweb
Branch b1_4
authoryangsheng <yangsheng>
Tue, 25 Dec 2007 13:00:13 +0000 (13:00 +0000)
committeryangsheng <yangsheng>
Tue, 25 Dec 2007 13:00:13 +0000 (13:00 +0000)
b=13752
i=adilger
i=shadow

Add 2.4 kernel support for lnet.

lnet/include/libcfs/linux/kp30.h
lnet/include/libcfs/linux/linux-prim.h
lnet/selftest/conrpc.c
lnet/selftest/timer.c

index 46bab8b..fb1ae3e 100644 (file)
@@ -173,6 +173,13 @@ static inline void our_cond_resched(void)
 # define printf(format, b...) CDEBUG(D_OTHER, format , ## b)
 # define time(a) CURRENT_TIME
 
 # define printf(format, b...) CDEBUG(D_OTHER, format , ## b)
 # define time(a) CURRENT_TIME
 
+#ifndef num_possible_cpus
+#define num_possible_cpus() NR_CPUS
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+#define i_size_read(a) ((a)->i_size)
+#endif
+
 #else  /* !__KERNEL__ */
 # include <stdio.h>
 # include <stdlib.h>
 #else  /* !__KERNEL__ */
 # include <stdio.h>
 # include <stdlib.h>
index a8153dd..9ae57cd 100644 (file)
@@ -201,6 +201,94 @@ static inline void cfs_pause(cfs_duration_t ticks)
         schedule_timeout(ticks);
 }
 
         schedule_timeout(ticks);
 }
 
+#ifndef wait_event_timeout /* Only for RHEL3 2.4.21 kernel */
+#define __wait_event_timeout(wq, condition, timeout, ret)        \
+do {                                                             \
+       int __ret = 0;                                           \
+       if (!(condition)) {                                      \
+               wait_queue_t __wait;                             \
+               unsigned long expire;                            \
+                                                                 \
+               init_waitqueue_entry(&__wait, current);          \
+               expire = timeout + jiffies;                      \
+               add_wait_queue(&wq, &__wait);                    \
+               for (;;) {                                       \
+                       set_current_state(TASK_UNINTERRUPTIBLE); \
+                       if (condition)                           \
+                               break;                           \
+                       if (jiffies > expire) {                  \
+                               ret = jiffies - expire;          \
+                               break;                           \
+                       }                                        \
+                       schedule_timeout(timeout);               \
+               }                                                \
+               current->state = TASK_RUNNING;                   \
+               remove_wait_queue(&wq, &__wait);                 \
+       }                                                        \
+} while (0)
+/*
+   retval == 0; condition met; we're good.
+   retval > 0; timed out.
+*/
+#define cfs_waitq_wait_event_timeout(wq, condition, timeout)         \
+({                                                                   \
+       int __ret = 0;                                               \
+       if (!(condition))                                            \
+               __wait_event_timeout(wq, condition, timeout, __ret); \
+       __ret;                                                       \
+})
+#else
+#define cfs_waitq_wait_event_timeout  wait_event_timeout
+#endif
+
+#ifndef wait_event_interruptible_timeout /* Only for RHEL3 2.4.21 kernel */
+#define __wait_event_interruptible_timeout(wq, condition, timeout, ret)   \
+do {                                                           \
+       int __ret = 0;                                         \
+       if (!(condition)) {                                    \
+               wait_queue_t __wait;                           \
+               unsigned long expire;                          \
+                                                               \
+               init_waitqueue_entry(&__wait, current);        \
+               expire = timeout + jiffies;                    \
+               add_wait_queue(&wq, &__wait);                  \
+               for (;;) {                                     \
+                       set_current_state(TASK_INTERRUPTIBLE); \
+                       if (condition)                         \
+                               break;                         \
+                       if (jiffies > expire) {                \
+                               ret = jiffies - expire;        \
+                               break;                         \
+                       }                                      \
+                       if (!signal_pending(current)) {        \
+                               schedule_timeout(timeout);     \
+                               continue;                      \
+                       }                                      \
+                       ret = -ERESTARTSYS;                    \
+                       break;                                 \
+               }                                              \
+               current->state = TASK_RUNNING;                 \
+               remove_wait_queue(&wq, &__wait);               \
+       }                                                      \
+} while (0)
+
+/*
+   retval == 0; condition met; we're good.
+   retval < 0; interrupted by signal.
+   retval > 0; timed out.
+*/
+#define cfs_waitq_wait_event_interruptible_timeout(wq, condition, timeout) \
+({                                                                \
+       int __ret = 0;                                            \
+       if (!(condition))                                         \
+               __wait_event_interruptible_timeout(wq, condition, \
+                                               timeout, __ret);  \
+       __ret;                                                    \
+})
+#else
+#define cfs_waitq_wait_event_interruptible_timeout wait_event_interruptible_timeout
+#endif
+
 #else   /* !__KERNEL__ */
 
 typedef struct proc_dir_entry           cfs_proc_dir_entry_t;
 #else   /* !__KERNEL__ */
 
 typedef struct proc_dir_entry           cfs_proc_dir_entry_t;
index 45c8031..b47fbe1 100644 (file)
@@ -318,7 +318,7 @@ lstcon_rpc_trans_postwait(lstcon_rpc_trans_t *trans, int timeout)
 
         mutex_up(&console_session.ses_mutex);
 
 
         mutex_up(&console_session.ses_mutex);
 
-        rc = wait_event_interruptible_timeout(trans->tas_waitq,
+        rc = cfs_waitq_wait_event_interruptible_timeout(trans->tas_waitq,
                                               lstcon_rpc_trans_check(trans),
                                               timeout * HZ);
 
                                               lstcon_rpc_trans_check(trans),
                                               timeout * HZ);
 
index eb72a78..e847e48 100644 (file)
@@ -154,7 +154,7 @@ stt_timer_main (void *arg)
         while (!stt_data.stt_shuttingdown) {
                 stt_check_timers(&stt_data.stt_prev_slot);
 
         while (!stt_data.stt_shuttingdown) {
                 stt_check_timers(&stt_data.stt_prev_slot);
 
-                wait_event_timeout(stt_data.stt_waitq,
+                cfs_waitq_wait_event_timeout(stt_data.stt_waitq,
                                    stt_data.stt_shuttingdown,
                                    cfs_time_seconds(STTIMER_SLOTTIME));
         }
                                    stt_data.stt_shuttingdown,
                                    cfs_time_seconds(STTIMER_SLOTTIME));
         }