Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core[WIP] Readdir improvement for fuse #4207

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions glusterfsd/src/glusterfsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ static struct argp_option gf_options[] = {
{"use-readdirp", ARGP_FUSE_USE_READDIRP_KEY, "BOOL", OPTION_ARG_OPTIONAL,
"Use readdirp mode in fuse kernel module"
" [default: \"yes\"]"},
{"readdir-optimize", ARGP_FUSE_USE_READDIR_OPTIMIZE, "BOOL", OPTION_ARG_OPTIONAL,
"Enable readdir optimize mode for fuse "
" [default: \"no\"]"},
{"secure-mgmt", ARGP_SECURE_MGMT_KEY, "BOOL", OPTION_ARG_OPTIONAL,
"Override default for secure (SSL) management connections"},
{"localtime-logging", ARGP_LOCALTIME_LOGGING_KEY, 0, 0,
Expand Down Expand Up @@ -494,6 +497,12 @@ set_fuse_mount_options(glusterfs_ctx_t *ctx, dict_t *options)
DICT_SET_VAL(dict_set_static_ptr, options, "use-readdirp",
cmd_args->use_readdirp, glusterfsd_msg_3);
}

if (cmd_args->readdir_optimize) {
DICT_SET_VAL(dict_set_static_ptr, options, "readdir-optimize",
cmd_args->readdir_optimize, glusterfsd_msg_3);
}

if (cmd_args->event_history) {
ret = dict_set_str(options, "event-history", cmd_args->event_history);
DICT_SET_VAL(dict_set_static_ptr, options, "event-history",
Expand Down Expand Up @@ -1231,6 +1240,24 @@ parse_opts(int key, char *arg, struct argp_state *state)
arg);
break;

case ARGP_FUSE_USE_READDIR_OPTIMIZE:
if (!arg)
arg = "no";

if (gf_string2boolean(arg, &b) == 0) {
if (b) {
cmd_args->readdir_optimize = "yes";
} else {
cmd_args->readdir_optimize = "no";
}

break;
}

argp_failure(state, -1, 0, "unknown readdir-optimize setting \"%s\"",
arg);
break;

case ARGP_LOGGER:
if (strcasecmp(arg, GF_LOGGER_GLUSTER_LOG) == 0)
cmd_args->logger = gf_logger_glusterlog;
Expand Down
1 change: 1 addition & 0 deletions glusterfsd/src/glusterfsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ enum argp_option_keys {
ARGP_FUSE_INODE_TABLESIZE_KEY = 198,
ARGP_FUSE_SETLK_HANDLE_INTERRUPT_KEY = 199,
ARGP_FUSE_HANDLE_COPY_FILE_RANGE = 200,
ARGP_FUSE_USE_READDIR_OPTIMIZE = 201,
};

int
Expand Down
1 change: 1 addition & 0 deletions libglusterfs/src/glusterfs/glusterfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ struct _cmd_args {
int fuse_direct_io_mode;
int congestion_threshold;
char *use_readdirp;
char *readdir_optimize;
int no_root_squash;
int volfile_check;
double fuse_entry_timeout;
Expand Down
33 changes: 33 additions & 0 deletions xlators/features/upcall/src/upcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <glusterfs/common-utils.h>

#include <glusterfs/statedump.h>
#include <glusterfs/timer.h>

#include "upcall.h"
#include "upcall-mem-types.h"
Expand Down Expand Up @@ -744,11 +745,27 @@ up_lookup_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
return 0;
}

static void
up_inode_unref(void *data)
{
inode_t *inode = data;

if (inode)
inode_unref(inode);

}

static int32_t
up_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr_req)
{
int32_t op_errno = ENOMEM;
upcall_local_t *local = NULL;
struct timespec delay = {
0,
};
inode_t *inode = NULL;
inode_table_t *table = NULL;
int32_t delay_time = 0;

EXIT_IF_UPCALL_OFF(this, out);

Expand All @@ -757,6 +774,22 @@ up_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr_req)
goto err;
}

//delay.tv_sec = 600;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: debug leftovers?

//delay.tv_nsec = 0;
if (!dict_get_int32_sizen(xattr_req, "inode-unref-delay", &delay_time)) {
delay.tv_sec = delay_time;
delay.tv_nsec = 0;
}

if (delay_time) {
table = local->inode->table;
if (table->active_size < 1000000) {
inode = inode_ref(local->inode);
gf_timer_call_after(this->ctx, delay, up_inode_unref, inode);
}
dict_del(xattr_req, "inode-unref-delay");
}

out:
STACK_WIND(frame, up_lookup_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->lookup, loc, xattr_req);
Expand Down
Loading