gluster使用基于epoll的event_pool,由slot(可以理解为槽位),最大可以创建1024X1024个slot,每个slot中关键数据为:fd,events,handler,分别对应文件描述符,epoll事件(EPOLLIN/EPOLLPRI/EPOLLOUT等)事件处理函数。

// event-epoll.c
29 struct event_slot_epoll {
30 int fd;
31 int events;
32 int gen;
33 int idx;
34 gf_atomic_t ref;
35 int do_close;
36 int in_handler;
37 int handled_error;
38 void *data;
39 event_handler_t handler;
40 gf_lock_t lock;
41 struct list_head poller_death;
42 };
该数据结构,最终在:
// libglusterfs/src/glusterfs/gf-event.h
struct event_pool {
...
struct event_slot_epoll *ereg[EVENT_EPOLL_TABLES];
int slots_used[EVENT_EPOLL_TABLES];
...
}
由ereg成员组成一个二维slot表, 而slots_used记录已被使用的slot. 注意slots_used是一个一维表,而ereg为二维表.
504

被折叠的 条评论
为什么被折叠?



