201 lines
6.1 KiB
Diff
201 lines
6.1 KiB
Diff
|
|
From 4028ca2038bab675b8464b71e038c28adfdb739f Mon Sep 17 00:00:00 2001
|
||
|
|
From: <mashimiao@huawei.com>
|
||
|
|
Date: Wed, 5 Sep 2018 21:27:38 +0800
|
||
|
|
Subject: [PATCH] increase idle thread
|
||
|
|
|
||
|
|
Signed-off-by: <mashimiao@huawei.com>
|
||
|
|
---
|
||
|
|
libfuse-fuse-2.9.7/lib/fuse.c | 8 ++++++--
|
||
|
|
libfuse-fuse-2.9.7/lib/fuse_kern_chan.c | 6 +++++-
|
||
|
|
libfuse-fuse-2.9.7/lib/fuse_loop_mt.c | 9 ++++++++-
|
||
|
|
libfuse-fuse-2.9.7/lib/fuse_lowlevel.c | 26 +++++++++++++++++++-------
|
||
|
|
4 files changed, 38 insertions(+), 11 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/libfuse-fuse-2.9.7/lib/fuse.c b/libfuse-fuse-2.9.7/lib/fuse.c
|
||
|
|
index 6a7c307..9f8c8a2 100644
|
||
|
|
--- a/libfuse-fuse-2.9.7/lib/fuse.c
|
||
|
|
+++ b/libfuse-fuse-2.9.7/lib/fuse.c
|
||
|
|
@@ -1261,6 +1261,7 @@ static void free_path_wrlock(struct fuse *f, fuse_ino_t nodeid,
|
||
|
|
wake_up_queued(f);
|
||
|
|
pthread_mutex_unlock(&f->lock);
|
||
|
|
free(path);
|
||
|
|
+ path = NULL;
|
||
|
|
}
|
||
|
|
|
||
|
|
static void free_path(struct fuse *f, fuse_ino_t nodeid, char *path)
|
||
|
|
@@ -3085,8 +3086,11 @@ static void fuse_do_release(struct fuse *f, fuse_ino_t ino, const char *path,
|
||
|
|
|
||
|
|
pthread_mutex_lock(&f->lock);
|
||
|
|
node = get_node(f, ino);
|
||
|
|
- assert(node->open_count > 0);
|
||
|
|
- --node->open_count;
|
||
|
|
+ if (node->open_count > 0) {
|
||
|
|
+ --node->open_count;
|
||
|
|
+ } else {
|
||
|
|
+ fprintf(stderr, "fuse: open_count is invalid: %d\n", node->open_count);
|
||
|
|
+ }
|
||
|
|
if (node->is_hidden && !node->open_count) {
|
||
|
|
unlink_hidden = 1;
|
||
|
|
node->is_hidden = 0;
|
||
|
|
diff --git a/libfuse-fuse-2.9.7/lib/fuse_kern_chan.c b/libfuse-fuse-2.9.7/lib/fuse_kern_chan.c
|
||
|
|
index 4cc9b73..b891568 100644
|
||
|
|
--- a/libfuse-fuse-2.9.7/lib/fuse_kern_chan.c
|
||
|
|
+++ b/libfuse-fuse-2.9.7/lib/fuse_kern_chan.c
|
||
|
|
@@ -30,7 +30,9 @@ restart:
|
||
|
|
|
||
|
|
if (fuse_session_exited(se))
|
||
|
|
return 0;
|
||
|
|
+
|
||
|
|
if (res == -1) {
|
||
|
|
+ perror("fuse: read from chan error");
|
||
|
|
/* ENOENT means the operation was interrupted, it's safe
|
||
|
|
to restart */
|
||
|
|
if (err == ENOENT)
|
||
|
|
diff --git a/libfuse-fuse-2.9.7/lib/fuse_loop_mt.c b/libfuse-fuse-2.9.7/lib/fuse_loop_mt.c
|
||
|
|
index 2f2521f..f88f339 100644
|
||
|
|
--- a/libfuse-fuse-2.9.7/lib/fuse_loop_mt.c
|
||
|
|
+++ b/libfuse-fuse-2.9.7/lib/fuse_loop_mt.c
|
||
|
|
@@ -121,7 +121,7 @@ static void *fuse_do_work(void *data)
|
||
|
|
pthread_mutex_lock(&mt->lock);
|
||
|
|
if (!isforget)
|
||
|
|
mt->numavail++;
|
||
|
|
- if (mt->numavail > 10) {
|
||
|
|
+ if (mt->numavail > 20) {
|
||
|
|
if (mt->exit) {
|
||
|
|
pthread_mutex_unlock(&mt->lock);
|
||
|
|
return NULL;
|
||
|
|
@@ -133,7 +133,9 @@ static void *fuse_do_work(void *data)
|
||
|
|
|
||
|
|
pthread_detach(w->thread_id);
|
||
|
|
free(w->buf);
|
||
|
|
+ w->buf = NULL;
|
||
|
|
free(w);
|
||
|
|
+ w = NULL;
|
||
|
|
return NULL;
|
||
|
|
}
|
||
|
|
pthread_mutex_unlock(&mt->lock);
|
||
|
|
@@ -229,13 +231,16 @@ static int fuse_loop_start_thread(struct fuse_mt *mt)
|
||
|
|
if (!w->buf) {
|
||
|
|
fprintf(stderr, "fuse: failed to allocate read buffer\n");
|
||
|
|
free(w);
|
||
|
|
+ w = NULL;
|
||
|
|
return -1;
|
||
|
|
}
|
||
|
|
|
||
|
|
res = fuse_start_thread(&w->thread_id, fuse_do_work, w);
|
||
|
|
if (res == -1) {
|
||
|
|
free(w->buf);
|
||
|
|
+ w->buf = NULL;
|
||
|
|
free(w);
|
||
|
|
+ w = NULL;
|
||
|
|
return -1;
|
||
|
|
}
|
||
|
|
list_add_worker(w, &mt->main);
|
||
|
|
@@ -252,7 +257,9 @@ static void fuse_join_worker(struct fuse_mt *mt, struct fuse_worker *w)
|
||
|
|
list_del_worker(w);
|
||
|
|
pthread_mutex_unlock(&mt->lock);
|
||
|
|
free(w->buf);
|
||
|
|
+ w->buf = NULL;
|
||
|
|
free(w);
|
||
|
|
+ w = NULL;
|
||
|
|
}
|
||
|
|
|
||
|
|
int fuse_session_loop_mt(struct fuse_session *se)
|
||
|
|
diff --git a/libfuse-fuse-2.9.7/lib/fuse_lowlevel.c b/libfuse-fuse-2.9.7/lib/fuse_lowlevel.c
|
||
|
|
index 35d0204..4dda646 100644
|
||
|
|
--- a/libfuse-fuse-2.9.7/lib/fuse_lowlevel.c
|
||
|
|
+++ b/libfuse-fuse-2.9.7/lib/fuse_lowlevel.c
|
||
|
|
@@ -42,8 +42,8 @@
|
||
|
|
|
||
|
|
struct fuse_pollhandle {
|
||
|
|
uint64_t kh;
|
||
|
|
- struct fuse_chan *ch;
|
||
|
|
struct fuse_ll *f;
|
||
|
|
+ struct fuse_session *se;
|
||
|
|
};
|
||
|
|
|
||
|
|
static size_t pagesize;
|
||
|
|
@@ -738,6 +738,7 @@ static int fuse_send_data_iov(struct fuse_ll *f, struct fuse_chan *ch,
|
||
|
|
return 0;
|
||
|
|
|
||
|
|
clear_pipe:
|
||
|
|
+ perror("fuse: reach clear_pipe");
|
||
|
|
fuse_ll_clear_pipe(f);
|
||
|
|
return res;
|
||
|
|
|
||
|
|
@@ -1708,8 +1709,8 @@ static void do_poll(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
ph->kh = arg->kh;
|
||
|
|
- ph->ch = req->ch;
|
||
|
|
ph->f = req->f;
|
||
|
|
+ ph->se = fuse_chan_session(req->ch);
|
||
|
|
}
|
||
|
|
|
||
|
|
req->f->op.poll(req, nodeid, &fi, ph);
|
||
|
|
@@ -1972,7 +1973,8 @@ int fuse_lowlevel_notify_poll(struct fuse_pollhandle *ph)
|
||
|
|
iov[1].iov_base = &outarg;
|
||
|
|
iov[1].iov_len = sizeof(outarg);
|
||
|
|
|
||
|
|
- return send_notify_iov(ph->f, ph->ch, FUSE_NOTIFY_POLL, iov, 2);
|
||
|
|
+ return send_notify_iov(ph->f, ph->se->ch,
|
||
|
|
+ FUSE_NOTIFY_POLL, iov, 2);
|
||
|
|
} else {
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
@@ -2342,6 +2344,7 @@ static void fuse_ll_process_buf(void *data, const struct fuse_buf *buf,
|
||
|
|
|
||
|
|
res = fuse_ll_copy_from_pipe(&tmpbuf, &bufv);
|
||
|
|
if (res < 0)
|
||
|
|
+ fprintf(stderr, "fuse: failed to copy from pipe\n");
|
||
|
|
goto clear_pipe;
|
||
|
|
|
||
|
|
in = mbuf;
|
||
|
|
@@ -2359,6 +2362,7 @@ static void fuse_ll_process_buf(void *data, const struct fuse_buf *buf,
|
||
|
|
|
||
|
|
req = fuse_ll_alloc_req(f);
|
||
|
|
if (req == NULL) {
|
||
|
|
+ fprintf(stderr, "fuse: req is NULL\n");
|
||
|
|
struct fuse_out_header out = {
|
||
|
|
.unique = in->unique,
|
||
|
|
.error = -ENOMEM,
|
||
|
|
@@ -2383,10 +2387,14 @@ static void fuse_ll_process_buf(void *data, const struct fuse_buf *buf,
|
||
|
|
enum fuse_opcode expected;
|
||
|
|
|
||
|
|
expected = f->cuse_data ? CUSE_INIT : FUSE_INIT;
|
||
|
|
- if (in->opcode != expected)
|
||
|
|
+ if (in->opcode != expected) {
|
||
|
|
+ fprintf(stderr, "fuse: opcode is not as expected\n");
|
||
|
|
goto reply_err;
|
||
|
|
- } else if (in->opcode == FUSE_INIT || in->opcode == CUSE_INIT)
|
||
|
|
+ }
|
||
|
|
+ } else if (in->opcode == FUSE_INIT || in->opcode == CUSE_INIT) {
|
||
|
|
+ fprintf(stderr, "fuse: opcode is *_INIT\n");
|
||
|
|
goto reply_err;
|
||
|
|
+ }
|
||
|
|
|
||
|
|
err = EACCES;
|
||
|
|
if (f->allow_root && in->uid != f->owner && in->uid != 0 &&
|
||
|
|
@@ -2394,12 +2402,16 @@ static void fuse_ll_process_buf(void *data, const struct fuse_buf *buf,
|
||
|
|
in->opcode != FUSE_WRITE && in->opcode != FUSE_FSYNC &&
|
||
|
|
in->opcode != FUSE_RELEASE && in->opcode != FUSE_READDIR &&
|
||
|
|
in->opcode != FUSE_FSYNCDIR && in->opcode != FUSE_RELEASEDIR &&
|
||
|
|
- in->opcode != FUSE_NOTIFY_REPLY)
|
||
|
|
+ in->opcode != FUSE_NOTIFY_REPLY) {
|
||
|
|
+ fprintf(stderr, "fuse: opcode is not allowed\n");
|
||
|
|
goto reply_err;
|
||
|
|
+ }
|
||
|
|
|
||
|
|
err = ENOSYS;
|
||
|
|
- if (in->opcode >= FUSE_MAXOP || !fuse_ll_ops[in->opcode].func)
|
||
|
|
+ if (in->opcode >= FUSE_MAXOP || !fuse_ll_ops[in->opcode].func) {
|
||
|
|
+ fprintf(stderr, "fuse: opcode is invalid\n");
|
||
|
|
goto reply_err;
|
||
|
|
+ }
|
||
|
|
if (in->opcode != FUSE_INTERRUPT) {
|
||
|
|
struct fuse_req *intr;
|
||
|
|
pthread_mutex_lock(&f->lock);
|
||
|
|
--
|
||
|
|
1.8.3.1
|
||
|
|
|