@@ -340,7 +340,6 @@ void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget,
340340 forget -> forget_one .nodeid = nodeid ;
341341 forget -> forget_one .nlookup = nlookup ;
342342
343- spin_lock (& fc -> lock );
344343 spin_lock (& fiq -> waitq .lock );
345344 if (fiq -> connected ) {
346345 fiq -> forget_list_tail -> next = forget ;
@@ -351,7 +350,6 @@ void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget,
351350 kfree (forget );
352351 }
353352 spin_unlock (& fiq -> waitq .lock );
354- spin_unlock (& fc -> lock );
355353}
356354
357355static void flush_bg_queue (struct fuse_conn * fc )
@@ -443,13 +441,11 @@ static void request_wait_answer(struct fuse_conn *fc, struct fuse_req *req)
443441 if (!err )
444442 return ;
445443
446- spin_lock (& fc -> lock );
447444 set_bit (FR_INTERRUPTED , & req -> flags );
448445 /* matches barrier in fuse_dev_do_read() */
449446 smp_mb__after_atomic ();
450447 if (test_bit (FR_SENT , & req -> flags ))
451448 queue_interrupt (fiq , req );
452- spin_unlock (& fc -> lock );
453449 }
454450
455451 if (!test_bit (FR_FORCE , & req -> flags )) {
@@ -464,19 +460,16 @@ static void request_wait_answer(struct fuse_conn *fc, struct fuse_req *req)
464460 if (!err )
465461 return ;
466462
467- spin_lock (& fc -> lock );
468463 spin_lock (& fiq -> waitq .lock );
469464 /* Request is not yet in userspace, bail out */
470465 if (test_bit (FR_PENDING , & req -> flags )) {
471466 list_del (& req -> list );
472467 spin_unlock (& fiq -> waitq .lock );
473- spin_unlock (& fc -> lock );
474468 __fuse_put_request (req );
475469 req -> out .h .error = - EINTR ;
476470 return ;
477471 }
478472 spin_unlock (& fiq -> waitq .lock );
479- spin_unlock (& fc -> lock );
480473 }
481474
482475 /*
@@ -491,10 +484,8 @@ static void __fuse_request_send(struct fuse_conn *fc, struct fuse_req *req)
491484 struct fuse_iqueue * fiq = & fc -> iq ;
492485
493486 BUG_ON (test_bit (FR_BACKGROUND , & req -> flags ));
494- spin_lock (& fc -> lock );
495487 spin_lock (& fiq -> waitq .lock );
496488 if (!fiq -> connected ) {
497- spin_unlock (& fc -> lock );
498489 spin_unlock (& fiq -> waitq .lock );
499490 req -> out .h .error = - ENOTCONN ;
500491 } else {
@@ -504,7 +495,6 @@ static void __fuse_request_send(struct fuse_conn *fc, struct fuse_req *req)
504495 after request_end() */
505496 __fuse_get_request (req );
506497 spin_unlock (& fiq -> waitq .lock );
507- spin_unlock (& fc -> lock );
508498
509499 request_wait_answer (fc , req );
510500 /* Pairs with smp_wmb() in request_end() */
@@ -638,14 +628,12 @@ static int fuse_request_send_notify_reply(struct fuse_conn *fc,
638628
639629 __clear_bit (FR_ISREPLY , & req -> flags );
640630 req -> in .h .unique = unique ;
641- spin_lock (& fc -> lock );
642631 spin_lock (& fiq -> waitq .lock );
643632 if (fiq -> connected ) {
644633 queue_request (fiq , req );
645634 err = 0 ;
646635 }
647636 spin_unlock (& fiq -> waitq .lock );
648- spin_unlock (& fc -> lock );
649637
650638 return err ;
651639}
@@ -1085,13 +1073,10 @@ static int request_pending(struct fuse_iqueue *fiq)
10851073}
10861074
10871075/* Wait until a request is available on the pending list */
1088- static void request_wait (struct fuse_conn * fc )
1089- __releases (fc - > iq .waitq .lock )
1090- __releases (fc - > lock )
1091- __acquires (fc - > lock )
1092- __acquires (fc - > iq .waitq .lock )
1076+ static void request_wait (struct fuse_iqueue * fiq )
1077+ __releases (fiq - > waitq .lock )
1078+ __acquires (fiq - > waitq .lock )
10931079{
1094- struct fuse_iqueue * fiq = & fc -> iq ;
10951080 DECLARE_WAITQUEUE (wait , current );
10961081
10971082 add_wait_queue_exclusive (& fiq -> waitq , & wait );
@@ -1101,9 +1086,7 @@ __acquires(fc->iq.waitq.lock)
11011086 break ;
11021087
11031088 spin_unlock (& fiq -> waitq .lock );
1104- spin_unlock (& fc -> lock );
11051089 schedule ();
1106- spin_lock (& fc -> lock );
11071090 spin_lock (& fiq -> waitq .lock );
11081091 }
11091092 set_current_state (TASK_RUNNING );
@@ -1116,14 +1099,13 @@ __acquires(fc->iq.waitq.lock)
11161099 * Unlike other requests this is assembled on demand, without a need
11171100 * to allocate a separate fuse_req structure.
11181101 *
1119- * Called with fc-> lock held, releases it
1102+ * Called with fiq->waitq. lock held, releases it
11201103 */
1121- static int fuse_read_interrupt (struct fuse_conn * fc , struct fuse_copy_state * cs ,
1104+ static int fuse_read_interrupt (struct fuse_iqueue * fiq ,
1105+ struct fuse_copy_state * cs ,
11221106 size_t nbytes , struct fuse_req * req )
1123- __releases (fc - > iq .waitq .lock )
1124- __releases (fc - > lock )
1107+ __releases (fiq - > waitq .lock )
11251108{
1126- struct fuse_iqueue * fiq = & fc -> iq ;
11271109 struct fuse_in_header ih ;
11281110 struct fuse_interrupt_in arg ;
11291111 unsigned reqsize = sizeof (ih ) + sizeof (arg );
@@ -1139,7 +1121,6 @@ __releases(fc->lock)
11391121 arg .unique = req -> in .h .unique ;
11401122
11411123 spin_unlock (& fiq -> waitq .lock );
1142- spin_unlock (& fc -> lock );
11431124 if (nbytes < reqsize )
11441125 return - EINVAL ;
11451126
@@ -1173,14 +1154,12 @@ static struct fuse_forget_link *dequeue_forget(struct fuse_iqueue *fiq,
11731154 return head ;
11741155}
11751156
1176- static int fuse_read_single_forget (struct fuse_conn * fc ,
1157+ static int fuse_read_single_forget (struct fuse_iqueue * fiq ,
11771158 struct fuse_copy_state * cs ,
11781159 size_t nbytes )
1179- __releases (fc - > iq .waitq .lock )
1180- __releases (fc - > lock )
1160+ __releases (fiq - > waitq .lock )
11811161{
11821162 int err ;
1183- struct fuse_iqueue * fiq = & fc -> iq ;
11841163 struct fuse_forget_link * forget = dequeue_forget (fiq , 1 , NULL );
11851164 struct fuse_forget_in arg = {
11861165 .nlookup = forget -> forget_one .nlookup ,
@@ -1193,7 +1172,6 @@ __releases(fc->lock)
11931172 };
11941173
11951174 spin_unlock (& fiq -> waitq .lock );
1196- spin_unlock (& fc -> lock );
11971175 kfree (forget );
11981176 if (nbytes < ih .len )
11991177 return - EINVAL ;
@@ -1209,16 +1187,14 @@ __releases(fc->lock)
12091187 return ih .len ;
12101188}
12111189
1212- static int fuse_read_batch_forget (struct fuse_conn * fc ,
1190+ static int fuse_read_batch_forget (struct fuse_iqueue * fiq ,
12131191 struct fuse_copy_state * cs , size_t nbytes )
1214- __releases (fc - > iq .waitq .lock )
1215- __releases (fc - > lock )
1192+ __releases (fiq - > waitq .lock )
12161193{
12171194 int err ;
12181195 unsigned max_forgets ;
12191196 unsigned count ;
12201197 struct fuse_forget_link * head ;
1221- struct fuse_iqueue * fiq = & fc -> iq ;
12221198 struct fuse_batch_forget_in arg = { .count = 0 };
12231199 struct fuse_in_header ih = {
12241200 .opcode = FUSE_BATCH_FORGET ,
@@ -1228,14 +1204,12 @@ __releases(fc->lock)
12281204
12291205 if (nbytes < ih .len ) {
12301206 spin_unlock (& fiq -> waitq .lock );
1231- spin_unlock (& fc -> lock );
12321207 return - EINVAL ;
12331208 }
12341209
12351210 max_forgets = (nbytes - ih .len ) / sizeof (struct fuse_forget_one );
12361211 head = dequeue_forget (fiq , max_forgets , & count );
12371212 spin_unlock (& fiq -> waitq .lock );
1238- spin_unlock (& fc -> lock );
12391213
12401214 arg .count = count ;
12411215 ih .len += count * sizeof (struct fuse_forget_one );
@@ -1262,17 +1236,15 @@ __releases(fc->lock)
12621236 return ih .len ;
12631237}
12641238
1265- static int fuse_read_forget (struct fuse_conn * fc , struct fuse_copy_state * cs ,
1239+ static int fuse_read_forget (struct fuse_conn * fc , struct fuse_iqueue * fiq ,
1240+ struct fuse_copy_state * cs ,
12661241 size_t nbytes )
1267- __releases (fc - > iq .waitq .lock )
1268- __releases (fc - > lock )
1242+ __releases (fiq - > waitq .lock )
12691243{
1270- struct fuse_iqueue * fiq = & fc -> iq ;
1271-
12721244 if (fc -> minor < 16 || fiq -> forget_list_head .next -> next == NULL )
1273- return fuse_read_single_forget (fc , cs , nbytes );
1245+ return fuse_read_single_forget (fiq , cs , nbytes );
12741246 else
1275- return fuse_read_batch_forget (fc , cs , nbytes );
1247+ return fuse_read_batch_forget (fiq , cs , nbytes );
12761248}
12771249
12781250/*
@@ -1294,14 +1266,13 @@ static ssize_t fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
12941266 unsigned reqsize ;
12951267
12961268 restart :
1297- spin_lock (& fc -> lock );
12981269 spin_lock (& fiq -> waitq .lock );
12991270 err = - EAGAIN ;
13001271 if ((file -> f_flags & O_NONBLOCK ) && fiq -> connected &&
13011272 !request_pending (fiq ))
13021273 goto err_unlock ;
13031274
1304- request_wait (fc );
1275+ request_wait (fiq );
13051276 err = - ENODEV ;
13061277 if (!fiq -> connected )
13071278 goto err_unlock ;
@@ -1312,12 +1283,12 @@ static ssize_t fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
13121283 if (!list_empty (& fiq -> interrupts )) {
13131284 req = list_entry (fiq -> interrupts .next , struct fuse_req ,
13141285 intr_entry );
1315- return fuse_read_interrupt (fc , cs , nbytes , req );
1286+ return fuse_read_interrupt (fiq , cs , nbytes , req );
13161287 }
13171288
13181289 if (forget_pending (fiq )) {
13191290 if (list_empty (& fiq -> pending ) || fiq -> forget_batch -- > 0 )
1320- return fuse_read_forget (fc , cs , nbytes );
1291+ return fuse_read_forget (fc , fiq , cs , nbytes );
13211292
13221293 if (fiq -> forget_batch <= -8 )
13231294 fiq -> forget_batch = 16 ;
@@ -1328,6 +1299,7 @@ static ssize_t fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
13281299 list_del_init (& req -> list );
13291300 spin_unlock (& fiq -> waitq .lock );
13301301
1302+ spin_lock (& fc -> lock );
13311303 list_add (& req -> list , & fc -> io );
13321304
13331305 in = & req -> in ;
@@ -1374,7 +1346,6 @@ static ssize_t fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
13741346
13751347 err_unlock :
13761348 spin_unlock (& fiq -> waitq .lock );
1377- spin_unlock (& fc -> lock );
13781349 return err ;
13791350}
13801351
@@ -2095,14 +2066,12 @@ static unsigned fuse_dev_poll(struct file *file, poll_table *wait)
20952066 fiq = & fc -> iq ;
20962067 poll_wait (file , & fiq -> waitq , wait );
20972068
2098- spin_lock (& fc -> lock );
20992069 spin_lock (& fiq -> waitq .lock );
21002070 if (!fiq -> connected )
21012071 mask = POLLERR ;
21022072 else if (request_pending (fiq ))
21032073 mask |= POLLIN | POLLRDNORM ;
21042074 spin_unlock (& fiq -> waitq .lock );
2105- spin_unlock (& fc -> lock );
21062075
21072076 return mask ;
21082077}
0 commit comments