aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fuse
diff options
context:
space:
mode:
authorMaxim Patlasov <mpatlasov@parallels.com>2013-03-21 10:02:28 -0400
committerMiklos Szeredi <mszeredi@suse.cz>2013-04-17 06:31:45 -0400
commit0aada88476a33690c9569b094191ce92a38e6541 (patch)
tree4aef3365654d4751154dc825731af721661fcef2 /fs/fuse
parent796523fb24028639c007f71e02ca21730f7c0af6 (diff)
fuse: skip blocking on allocations of synchronous requests
A task may have at most one synchronous request allocated. So these requests need not be otherwise limited. The patch re-works fuse_get_req() to follow this idea. Signed-off-by: Maxim Patlasov <mpatlasov@parallels.com> Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Diffstat (limited to 'fs/fuse')
-rw-r--r--fs/fuse/cuse.c1
-rw-r--r--fs/fuse/dev.c30
-rw-r--r--fs/fuse/inode.c3
3 files changed, 21 insertions, 13 deletions
diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
index f563e78852b7..c59c097eb2e9 100644
--- a/fs/fuse/cuse.c
+++ b/fs/fuse/cuse.c
@@ -504,7 +504,6 @@ static int cuse_channel_open(struct inode *inode, struct file *file)
504 cc->fc.release = cuse_fc_release; 504 cc->fc.release = cuse_fc_release;
505 505
506 cc->fc.connected = 1; 506 cc->fc.connected = 1;
507 cc->fc.blocked = 0;
508 cc->fc.initialized = 1; 507 cc->fc.initialized = 1;
509 rc = cuse_send_init(cc); 508 rc = cuse_send_init(cc);
510 if (rc) { 509 if (rc) {
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 39c2fe3ba93d..d692b85115bd 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -130,21 +130,30 @@ static void fuse_req_init_context(struct fuse_req *req)
130 req->in.h.pid = current->pid; 130 req->in.h.pid = current->pid;
131} 131}
132 132
133static bool fuse_block_alloc(struct fuse_conn *fc, bool for_background)
134{
135 return !fc->initialized || (for_background && fc->blocked);
136}
137
133static struct fuse_req *__fuse_get_req(struct fuse_conn *fc, unsigned npages, 138static struct fuse_req *__fuse_get_req(struct fuse_conn *fc, unsigned npages,
134 bool for_background) 139 bool for_background)
135{ 140{
136 struct fuse_req *req; 141 struct fuse_req *req;
137 sigset_t oldset;
138 int intr;
139 int err; 142 int err;
140
141 atomic_inc(&fc->num_waiting); 143 atomic_inc(&fc->num_waiting);
142 block_sigs(&oldset); 144
143 intr = wait_event_interruptible(fc->blocked_waitq, !fc->blocked); 145 if (fuse_block_alloc(fc, for_background)) {
144 restore_sigs(&oldset); 146 sigset_t oldset;
145 err = -EINTR; 147 int intr;
146 if (intr) 148
147 goto out; 149 block_sigs(&oldset);
150 intr = wait_event_interruptible(fc->blocked_waitq,
151 !fuse_block_alloc(fc, for_background));
152 restore_sigs(&oldset);
153 err = -EINTR;
154 if (intr)
155 goto out;
156 }
148 157
149 err = -ENOTCONN; 158 err = -ENOTCONN;
150 if (!fc->connected) 159 if (!fc->connected)
@@ -239,7 +248,7 @@ struct fuse_req *fuse_get_req_nofail_nopages(struct fuse_conn *fc,
239 struct fuse_req *req; 248 struct fuse_req *req;
240 249
241 atomic_inc(&fc->num_waiting); 250 atomic_inc(&fc->num_waiting);
242 wait_event(fc->blocked_waitq, !fc->blocked); 251 wait_event(fc->blocked_waitq, fc->initialized);
243 req = fuse_request_alloc(0); 252 req = fuse_request_alloc(0);
244 if (!req) 253 if (!req)
245 req = get_reserved_req(fc, file); 254 req = get_reserved_req(fc, file);
@@ -2106,6 +2115,7 @@ int fuse_dev_release(struct inode *inode, struct file *file)
2106 spin_lock(&fc->lock); 2115 spin_lock(&fc->lock);
2107 fc->connected = 0; 2116 fc->connected = 0;
2108 fc->blocked = 0; 2117 fc->blocked = 0;
2118 fc->initialized = 1;
2109 end_queued_requests(fc); 2119 end_queued_requests(fc);
2110 end_polls(fc); 2120 end_polls(fc);
2111 wake_up_all(&fc->blocked_waitq); 2121 wake_up_all(&fc->blocked_waitq);
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 4958f8099f16..17ec1f70524d 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -583,7 +583,7 @@ void fuse_conn_init(struct fuse_conn *fc)
583 fc->khctr = 0; 583 fc->khctr = 0;
584 fc->polled_files = RB_ROOT; 584 fc->polled_files = RB_ROOT;
585 fc->reqctr = 0; 585 fc->reqctr = 0;
586 fc->blocked = 1; 586 fc->blocked = 0;
587 fc->initialized = 0; 587 fc->initialized = 0;
588 fc->attr_version = 1; 588 fc->attr_version = 1;
589 get_random_bytes(&fc->scramble_key, sizeof(fc->scramble_key)); 589 get_random_bytes(&fc->scramble_key, sizeof(fc->scramble_key));
@@ -883,7 +883,6 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
883 fc->max_write = max_t(unsigned, 4096, fc->max_write); 883 fc->max_write = max_t(unsigned, 4096, fc->max_write);
884 fc->conn_init = 1; 884 fc->conn_init = 1;
885 } 885 }
886 fc->blocked = 0;
887 fc->initialized = 1; 886 fc->initialized = 1;
888 wake_up_all(&fc->blocked_waitq); 887 wake_up_all(&fc->blocked_waitq);
889} 888}