Skip to content

Commit

Permalink
Implement network.lru-table-size which sets the size of the inode has…
Browse files Browse the repository at this point in the history
…h table.

This creates a new table and destroys the old.

Signed-off-by: Jaco Kroon <[email protected]>
  • Loading branch information
jkroonza committed Apr 19, 2024
1 parent a101a42 commit f64b7ef
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libglusterfs/src/glusterfs/xlator.h
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,9 @@ get_xlator_by_type(xlator_t *this, char *target);
void
xlator_set_inode_lru_limit(xlator_t *this, void *data);

void
xlator_set_inode_table_size(xlator_t *this, void *data);

int
loc_copy(loc_t *dst, loc_t *src);
int
Expand Down
1 change: 1 addition & 0 deletions libglusterfs/src/libglusterfs.sym
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,7 @@ xlator_option_validate
xlator_option_validate_addr_list
xlator_search_by_name
xlator_set_inode_lru_limit
xlator_set_inode_table_size
xlator_set_type
xlator_set_type_virtual
xlator_subvolume_count
Expand Down
30 changes: 30 additions & 0 deletions libglusterfs/src/xlator.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,36 @@ xlator_set_inode_lru_limit(xlator_t *this, void *data)
return;
}

void
xlator_set_inode_table_size(xlator_t *this, void *data)
{
int inode_table_size = 0;

if (this->itable) {
if (!data) {
gf_smsg(this->name, GF_LOG_WARNING, 0, LG_MSG_INPUT_DATA_NULL,
NULL);
goto out;
}
inode_table_size = *(int *)data;

if (inode_table_size != this->itable->inode_hashsize) {
inode_table_t* tmp = inode_table_with_invalidator(this->itable->lru_limit,
this, this->itable->invalidator_fn, this->itable->invalidator_xl,
this->itable->dentry_hashsize, inode_table_size);
if (tmp->inode_hashsize != this->itable->inode_hashsize) {
inode_table_destroy(this->itable);
this->itable = tmp;
} else {
inode_table_destroy(tmp);
}
}
}

out:
return;
}

void
xlator_foreach(xlator_t *this, void (*fn)(xlator_t *each, void *data),
void *data)
Expand Down
3 changes: 3 additions & 0 deletions xlators/mgmt/glusterd/src/glusterd-volume-set.c
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,9 @@ struct volopt_map_entry glusterd_volopt_map[] = {
{.key = "network.inode-lru-limit",
.voltype = "protocol/server",
.op_version = 1},
{.key = "network.inode-table-size",
.voltype = "protocol/server",
.op_version = GD_OP_VERSION_11_0}, /* is this right? */
{.key = AUTH_ALLOW_MAP_KEY,
.voltype = "protocol/server",
.option = "!server-auth",
Expand Down
6 changes: 6 additions & 0 deletions xlators/protocol/server/src/server-helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,12 @@ server_build_config(xlator_t *this, server_conf_t *conf)
conf->inode_lru_limit = 16384;
}

ret = dict_get_int32(this->options, "inode-table-size",
&conf->inode_table_size);
if (ret < 0) {
conf->inode_table_size = 65536;
}

data = dict_get(this->options, "trace");
if (data) {
ret = gf_string2boolean(data->data, &conf->trace);
Expand Down
26 changes: 26 additions & 0 deletions xlators/protocol/server/src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@ server_reconfigure(xlator_t *this, dict_t *options)
rpc_transport_t *xprt = NULL;
rpc_transport_t *xp_next = NULL;
int inode_lru_limit;
int inode_table_size;
gf_boolean_t trace;
data_t *data;
int ret = 0;
Expand Down Expand Up @@ -825,6 +826,22 @@ server_reconfigure(xlator_t *this, dict_t *options)
kid = this;
}

if (dict_get_int32_sizen(options, "inode-table-size", &inode_table_size) ==
0) {
conf->inode_table_size = inode_table_size;
gf_msg_trace(this->name, 0,
"Reconfigured inode-table-size to "
"%d",
conf->inode_table_size);

/* traverse through the xlator graph. For each xlator in the
graph check whether it is a bound_xl or not (bound_xl means
the xlator will have its itable pointer set). If so, then
set the lru limit for the itable.
*/
xlator_foreach(this, xlator_set_inode_table_size, &inode_table_size);
}

if (dict_get_int32_sizen(options, "inode-lru-limit", &inode_lru_limit) ==
0) {
conf->inode_lru_limit = inode_lru_limit;
Expand Down Expand Up @@ -1819,6 +1836,15 @@ struct volume_options server_options[] = {
"in the lru list of the inode cache.",
.op_version = {1},
.flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC},
{.key = {"inode-table-size"},
.type = GF_OPTION_TYPE_INT,
.min = 0,
.max = 67108864,
.default_value = "65536",
.description = "Specifies the size of the inode hash table, "
"must be a power of two.",
.op_version = {GD_OP_VERSION_10_0}, /* if possible */
.flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC},
{.key = {"trace"}, .type = GF_OPTION_TYPE_BOOL},
{
.key = {"config-directory", "conf-dir"},
Expand Down
1 change: 1 addition & 0 deletions xlators/protocol/server/src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ struct _child_status {
struct server_conf {
rpcsvc_t *rpc;
int inode_lru_limit;
int inode_table_size;
gf_boolean_t server_manage_gids; /* resolve gids on brick */
gf_boolean_t trace;
gf_boolean_t parent_up;
Expand Down

0 comments on commit f64b7ef

Please sign in to comment.