LVS
lvs-users
Google
 
Web LinuxVirtualServer.org

[lvs-users] for help

To: lvs-users@xxxxxxxxxxxxxxxxxxxxxx
Subject: [lvs-users] for help
From: 张松涛 <zst_007139@xxxxxxx>
Date: Tue, 22 Nov 2011 16:30:03 +0800 (CST)
我编写了一个sr(最短响应时间)负载均衡器调度算法,编译后出现如下错误
    错误:隐式声明函数 ‘time’
请求帮助,谢谢!
代码如下:
/*
 * IPVS:        Shortest Response Time scheduling module
 */
 
#include <linux/module.h>
#include <linux/kernel.h>
 
#include <net/ip_vs.h>
#include <linux/time.h>
 
static int
ip_vs_sr_init_svc(struct ip_vs_service *svc)
{
        return 0;
}
 
 
static int
ip_vs_sr_done_svc(struct ip_vs_service *svc)
{
        return 0;
}
 
 
static int
ip_vs_sr_update_svc(struct ip_vs_service *svc)
{
        return 0;
}
 
 
static inline unsigned int
ip_vs_sr_dest_overhead(struct ip_vs_dest *dest)
{
 
 
  return (atomic_read(&dest->activeconns) << 8) +
                atomic_read(&dest->inactconns) + 1;
  
}
 
 
 
/*
 *      Shortest Response Time scheduling
 */
static struct ip_vs_dest *
ip_vs_sr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
{
        struct ip_vs_dest *dest, *least;
        unsigned int loh, doh;
       
        IP_VS_DBG(6, "ip_vs_sr_schedule(): Scheduling...\n");
 
 
        list_for_each_entry(dest, &svc->destinations, n_list) {
          if (!(dest->flags & IP_VS_DEST_F_OVERLOAD) &&
              atomic_read(&dest->weight) > 0) {
            least = dest;
            loh = ip_vs_sr_dest_overhead(least);
            goto nextstage;
          }
        }
        return NULL;
 
        /*
         *    Find the destination with the least load.
         */
        nextstage:
        list_for_each_entry_continue(dest, &svc->destinations, n_list) {
          if (dest->flags & IP_VS_DEST_F_OVERLOAD)
            continue;
          doh = ip_vs_sr_dest_overhead(dest);
         
          time_t lasttime;
          time_t nowtime;
          time_t rt;
 
          int refcnt1;
          int refcnt2;
          int refcnt3;
 
          time(&lasttime);
          refcnt1 = atomic_read(&dest->refcnt);
          while(1){
          time(&nowtime);
          if(nowtime - lasttime == 10*60)
          {
           refcnt2 = atomic_read(&dest->refcnt);
           break;
          }
          }
           refcnt3 = refcnt2 - refcnt1;
           rt = 10*60/(refcnt3 - atomic_read(&dest->activeconns) - 
atomic_read(&dest-
>inactconns));
         
          if (loh * rt >
              doh * rt) {
            least = dest;
            loh = doh;
          }
        }
 
        IP_VS_DBG(6, "SR: server %u.%u.%u.%u:%u "
                  "activeconns %d refcnt %d weight %d overhead %d\n",
                  NIPQUAD(least->addr), ntohs(least->port),
                  atomic_read(&least->activeconns),
                  atomic_read(&least->refcnt),
                  atomic_read(&least->weight), loh);
 
        return least;
}
 
 
 
static struct ip_vs_scheduler ip_vs_sr_scheduler =
{
        .name =                 "sr",
        .refcnt =               ATOMIC_INIT(0),
        .module =               THIS_MODULE,
        .init_service =         ip_vs_sr_init_svc,
        .done_service =         ip_vs_sr_done_svc,
        .update_service =       ip_vs_sr_update_svc,
        .schedule =             ip_vs_sr_schedule,
};
 
 
static int __init ip_vs_sr_init(void)
{
        INIT_LIST_HEAD(&ip_vs_sr_scheduler.n_list);
        return register_ip_vs_scheduler(&ip_vs_sr_scheduler);
}
 
static void __exit ip_vs_sr_cleanup(void)
{
        unregister_ip_vs_scheduler(&ip_vs_sr_scheduler);
}
 
module_init(ip_vs_sr_init);
module_exit(ip_vs_sr_cleanup);
MODULE_LICENSE("GPL");
_______________________________________________
Please read the documentation before posting - it's available at:
http://www.linuxvirtualserver.org/

LinuxVirtualServer.org mailing list - lvs-users@xxxxxxxxxxxxxxxxxxxxxx
Send requests to lvs-users-request@xxxxxxxxxxxxxxxxxxxxxx
or go to http://lists.graemef.net/mailman/listinfo/lvs-users
<Prev in Thread] Current Thread [Next in Thread>