summaryrefslogtreecommitdiffstats
path: root/xlators/protocol
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@gluster.com>2009-06-15 13:05:39 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-06-15 23:44:36 -0700
commitefcce990960fb91d422630fc7b310b216a500fed (patch)
tree7c417d43464c26476d9dfd541c13c2bf05f9b2bf /xlators/protocol
parent7006ae207c9e8ab9685d8e2e7455bd4e3b217c97 (diff)
libglusterfs: Turn fd-table O(1)
This commit reduces CPU usage of gf_fd_unused_get drastically by making it O(1) instead of O(n). Related to: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=16 Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
Diffstat (limited to 'xlators/protocol')
-rw-r--r--xlators/protocol/server/src/server-helpers.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c
index f496735467c..759a9ec82c0 100644
--- a/xlators/protocol/server/src/server-helpers.c
+++ b/xlators/protocol/server/src/server-helpers.c
@@ -516,7 +516,7 @@ server_connection_cleanup_flush_cbk (call_frame_t *frame,
int
do_fd_cleanup (xlator_t *this, server_connection_t *conn, call_frame_t *frame,
- fd_t **fds, int fd_count)
+ fdentry_t *fdentries, int fd_count)
{
fd_t *fd = NULL;
int i = 0, ret = -1;
@@ -525,7 +525,7 @@ do_fd_cleanup (xlator_t *this, server_connection_t *conn, call_frame_t *frame,
bound_xl = conn->bound_xl;
for (i = 0;i < fd_count; i++) {
- fd = fds[i];
+ fd = fdentries[i].fd;
if (fd != NULL) {
tmp_frame = copy_frame (frame);
@@ -545,7 +545,7 @@ do_fd_cleanup (xlator_t *this, server_connection_t *conn, call_frame_t *frame,
fd);
}
}
- FREE (fds);
+ FREE (fdentries);
ret = 0;
out:
@@ -554,7 +554,7 @@ out:
int
do_connection_cleanup (xlator_t *this, server_connection_t *conn,
- struct _lock_table *ltable, fd_t **fds, int fd_count)
+ struct _lock_table *ltable, fdentry_t *fdentries, int fd_count)
{
int32_t ret = 0, saved_ret = 0;
call_frame_t *frame = NULL;
@@ -568,8 +568,8 @@ do_connection_cleanup (xlator_t *this, server_connection_t *conn,
saved_ret = do_lock_table_cleanup (this, conn, frame, ltable);
- if (fds != NULL) {
- ret = do_fd_cleanup (this, conn, frame, fds, fd_count);
+ if (fdentries != NULL) {
+ ret = do_fd_cleanup (this, conn, frame, fdentries, fd_count);
}
state = CALL_STATE (frame);
@@ -591,7 +591,7 @@ server_connection_cleanup (xlator_t *this, server_connection_t *conn)
{
char do_cleanup = 0;
struct _lock_table *ltable = NULL;
- fd_t **fds = NULL;
+ fdentry_t *fdentries = NULL;
uint32_t fd_count = 0;
int ret = 0;
@@ -609,8 +609,8 @@ server_connection_cleanup (xlator_t *this, server_connection_t *conn)
}
if (conn->fdtable) {
- fds = gf_fd_fdtable_get_all_fds (conn->fdtable,
- &fd_count);
+ fdentries = gf_fd_fdtable_get_all_fds (conn->fdtable,
+ &fd_count);
}
do_cleanup = 1;
}
@@ -618,7 +618,7 @@ server_connection_cleanup (xlator_t *this, server_connection_t *conn)
pthread_mutex_unlock (&conn->lock);
if (do_cleanup && conn->bound_xl)
- ret = do_connection_cleanup (this, conn, ltable, fds, fd_count);
+ ret = do_connection_cleanup (this, conn, ltable, fdentries, fd_count);
out:
return ret;
@@ -639,7 +639,7 @@ server_connection_destroy (xlator_t *this, server_connection_t *conn)
struct flock flock = {0,};
fd_t *fd = NULL;
int32_t i = 0;
- fd_t **fds = NULL;
+ fdentry_t *fdentries = NULL;
uint32_t fd_count = 0;
if (conn == NULL) {
@@ -752,17 +752,17 @@ server_connection_destroy (xlator_t *this, server_connection_t *conn)
pthread_mutex_lock (&(conn->lock));
{
if (conn->fdtable) {
- fds = gf_fd_fdtable_get_all_fds (conn->fdtable,
- &fd_count);
+ fdentries = gf_fd_fdtable_get_all_fds (conn->fdtable,
+ &fd_count);
gf_fd_fdtable_destroy (conn->fdtable);
conn->fdtable = NULL;
}
}
pthread_mutex_unlock (&conn->lock);
- if (fds != NULL) {
+ if (fdentries != NULL) {
for (i = 0; i < fd_count; i++) {
- fd = fds[i];
+ fd = fdentries[i].fd;
if (fd != NULL) {
tmp_frame = copy_frame (frame);
tmp_frame->local = fd;
@@ -774,7 +774,7 @@ server_connection_destroy (xlator_t *this, server_connection_t *conn)
fd);
}
}
- FREE (fds);
+ FREE (fdentries);
}
}