Lines Matching +full:fiq +full:- +full:index

3   Copyright (C) 2001-2008  Miklos Szeredi <miklos@szeredi.hu>
42 * Lockless access is OK, because file->private data is set in fuse_get_dev()
45 return READ_ONCE(file->private_data); in fuse_get_dev()
50 INIT_LIST_HEAD(&req->list); in fuse_request_init()
51 INIT_LIST_HEAD(&req->intr_entry); in fuse_request_init()
52 init_waitqueue_head(&req->waitq); in fuse_request_init()
53 refcount_set(&req->count, 1); in fuse_request_init()
54 __set_bit(FR_PENDING, &req->flags); in fuse_request_init()
55 req->fm = fm; in fuse_request_init()
74 refcount_inc(&req->count); in __fuse_get_request()
80 refcount_dec(&req->count); in __fuse_put_request()
87 fc->initialized = 1; in fuse_set_initialized()
92 return !fc->initialized || (for_background && fc->blocked); in fuse_block_alloc()
98 * lockess check of fc->connected is okay, because atomic_dec_and_test() in fuse_drop_waiting()
100 * to ensure no wake-up is missed. in fuse_drop_waiting()
102 if (atomic_dec_and_test(&fc->num_waiting) && in fuse_drop_waiting()
103 !READ_ONCE(fc->connected)) { in fuse_drop_waiting()
105 wake_up_all(&fc->blocked_waitq); in fuse_drop_waiting()
115 struct fuse_conn *fc = fm->fc; in fuse_get_req()
117 bool no_idmap = !fm->sb || (fm->sb->s_iflags & SB_I_NOIDMAP); in fuse_get_req()
122 atomic_inc(&fc->num_waiting); in fuse_get_req()
125 err = -EINTR; in fuse_get_req()
126 if (wait_event_killable_exclusive(fc->blocked_waitq, in fuse_get_req()
133 err = -ENOTCONN; in fuse_get_req()
134 if (!fc->connected) in fuse_get_req()
137 err = -ECONNREFUSED; in fuse_get_req()
138 if (fc->conn_error) in fuse_get_req()
142 err = -ENOMEM; in fuse_get_req()
145 wake_up(&fc->blocked_waitq); in fuse_get_req()
149 req->in.h.pid = pid_nr_ns(task_pid(current), fc->pid_ns); in fuse_get_req()
151 __set_bit(FR_WAITING, &req->flags); in fuse_get_req()
153 __set_bit(FR_BACKGROUND, &req->flags); in fuse_get_req()
162 * req->in.h.{u,g}id will be equal to FUSE_INVALID_UIDGID. in fuse_get_req()
164 fsuid = no_idmap ? current_fsuid() : mapped_fsuid(idmap, fc->user_ns); in fuse_get_req()
165 fsgid = no_idmap ? current_fsgid() : mapped_fsgid(idmap, fc->user_ns); in fuse_get_req()
166 req->in.h.uid = from_kuid(fc->user_ns, fsuid); in fuse_get_req()
167 req->in.h.gid = from_kgid(fc->user_ns, fsgid); in fuse_get_req()
169 if (no_idmap && unlikely(req->in.h.uid == ((uid_t)-1) || in fuse_get_req()
170 req->in.h.gid == ((gid_t)-1))) { in fuse_get_req()
172 return ERR_PTR(-EOVERFLOW); in fuse_get_req()
184 struct fuse_conn *fc = req->fm->fc; in fuse_put_request()
186 if (refcount_dec_and_test(&req->count)) { in fuse_put_request()
187 if (test_bit(FR_BACKGROUND, &req->flags)) { in fuse_put_request()
192 spin_lock(&fc->bg_lock); in fuse_put_request()
193 if (!fc->blocked) in fuse_put_request()
194 wake_up(&fc->blocked_waitq); in fuse_put_request()
195 spin_unlock(&fc->bg_lock); in fuse_put_request()
198 if (test_bit(FR_WAITING, &req->flags)) { in fuse_put_request()
199 __clear_bit(FR_WAITING, &req->flags); in fuse_put_request()
219 static u64 fuse_get_unique_locked(struct fuse_iqueue *fiq) in fuse_get_unique_locked() argument
221 fiq->reqctr += FUSE_REQ_ID_STEP; in fuse_get_unique_locked()
222 return fiq->reqctr; in fuse_get_unique_locked()
225 u64 fuse_get_unique(struct fuse_iqueue *fiq) in fuse_get_unique() argument
229 spin_lock(&fiq->lock); in fuse_get_unique()
230 ret = fuse_get_unique_locked(fiq); in fuse_get_unique()
231 spin_unlock(&fiq->lock); in fuse_get_unique()
243 * A new request is available, wake fiq->waitq
245 static void fuse_dev_wake_and_unlock(struct fuse_iqueue *fiq) in fuse_dev_wake_and_unlock() argument
246 __releases(fiq->lock) in fuse_dev_wake_and_unlock()
248 wake_up(&fiq->waitq); in fuse_dev_wake_and_unlock()
249 kill_fasync(&fiq->fasync, SIGIO, POLL_IN); in fuse_dev_wake_and_unlock()
250 spin_unlock(&fiq->lock); in fuse_dev_wake_and_unlock()
253 static void fuse_dev_queue_forget(struct fuse_iqueue *fiq, struct fuse_forget_link *forget) in fuse_dev_queue_forget() argument
255 spin_lock(&fiq->lock); in fuse_dev_queue_forget()
256 if (fiq->connected) { in fuse_dev_queue_forget()
257 fiq->forget_list_tail->next = forget; in fuse_dev_queue_forget()
258 fiq->forget_list_tail = forget; in fuse_dev_queue_forget()
259 fuse_dev_wake_and_unlock(fiq); in fuse_dev_queue_forget()
262 spin_unlock(&fiq->lock); in fuse_dev_queue_forget()
266 static void fuse_dev_queue_interrupt(struct fuse_iqueue *fiq, struct fuse_req *req) in fuse_dev_queue_interrupt() argument
268 spin_lock(&fiq->lock); in fuse_dev_queue_interrupt()
269 if (list_empty(&req->intr_entry)) { in fuse_dev_queue_interrupt()
270 list_add_tail(&req->intr_entry, &fiq->interrupts); in fuse_dev_queue_interrupt()
276 if (test_bit(FR_FINISHED, &req->flags)) { in fuse_dev_queue_interrupt()
277 list_del_init(&req->intr_entry); in fuse_dev_queue_interrupt()
278 spin_unlock(&fiq->lock); in fuse_dev_queue_interrupt()
280 fuse_dev_wake_and_unlock(fiq); in fuse_dev_queue_interrupt()
283 spin_unlock(&fiq->lock); in fuse_dev_queue_interrupt()
287 static void fuse_dev_queue_req(struct fuse_iqueue *fiq, struct fuse_req *req) in fuse_dev_queue_req() argument
289 spin_lock(&fiq->lock); in fuse_dev_queue_req()
290 if (fiq->connected) { in fuse_dev_queue_req()
291 if (req->in.h.opcode != FUSE_NOTIFY_REPLY) in fuse_dev_queue_req()
292 req->in.h.unique = fuse_get_unique_locked(fiq); in fuse_dev_queue_req()
293 list_add_tail(&req->list, &fiq->pending); in fuse_dev_queue_req()
294 fuse_dev_wake_and_unlock(fiq); in fuse_dev_queue_req()
296 spin_unlock(&fiq->lock); in fuse_dev_queue_req()
297 req->out.h.error = -ENOTCONN; in fuse_dev_queue_req()
298 clear_bit(FR_PENDING, &req->flags); in fuse_dev_queue_req()
310 static void fuse_send_one(struct fuse_iqueue *fiq, struct fuse_req *req) in fuse_send_one() argument
312 req->in.h.len = sizeof(struct fuse_in_header) + in fuse_send_one()
313 fuse_len_args(req->args->in_numargs, in fuse_send_one()
314 (struct fuse_arg *) req->args->in_args); in fuse_send_one()
316 fiq->ops->send_req(fiq, req); in fuse_send_one()
322 struct fuse_iqueue *fiq = &fc->iq; in fuse_queue_forget() local
324 forget->forget_one.nodeid = nodeid; in fuse_queue_forget()
325 forget->forget_one.nlookup = nlookup; in fuse_queue_forget()
327 fiq->ops->send_forget(fiq, forget); in fuse_queue_forget()
332 struct fuse_iqueue *fiq = &fc->iq; in flush_bg_queue() local
334 while (fc->active_background < fc->max_background && in flush_bg_queue()
335 !list_empty(&fc->bg_queue)) { in flush_bg_queue()
338 req = list_first_entry(&fc->bg_queue, struct fuse_req, list); in flush_bg_queue()
339 list_del(&req->list); in flush_bg_queue()
340 fc->active_background++; in flush_bg_queue()
341 fuse_send_one(fiq, req); in flush_bg_queue()
355 struct fuse_mount *fm = req->fm; in fuse_request_end()
356 struct fuse_conn *fc = fm->fc; in fuse_request_end()
357 struct fuse_iqueue *fiq = &fc->iq; in fuse_request_end() local
359 if (test_and_set_bit(FR_FINISHED, &req->flags)) in fuse_request_end()
368 if (test_bit(FR_INTERRUPTED, &req->flags)) { in fuse_request_end()
369 spin_lock(&fiq->lock); in fuse_request_end()
370 list_del_init(&req->intr_entry); in fuse_request_end()
371 spin_unlock(&fiq->lock); in fuse_request_end()
373 WARN_ON(test_bit(FR_PENDING, &req->flags)); in fuse_request_end()
374 WARN_ON(test_bit(FR_SENT, &req->flags)); in fuse_request_end()
375 if (test_bit(FR_BACKGROUND, &req->flags)) { in fuse_request_end()
376 spin_lock(&fc->bg_lock); in fuse_request_end()
377 clear_bit(FR_BACKGROUND, &req->flags); in fuse_request_end()
378 if (fc->num_background == fc->max_background) { in fuse_request_end()
379 fc->blocked = 0; in fuse_request_end()
380 wake_up(&fc->blocked_waitq); in fuse_request_end()
381 } else if (!fc->blocked) { in fuse_request_end()
385 * fc->blocked with waiters with the wake_up() call in fuse_request_end()
388 if (waitqueue_active(&fc->blocked_waitq)) in fuse_request_end()
389 wake_up(&fc->blocked_waitq); in fuse_request_end()
392 fc->num_background--; in fuse_request_end()
393 fc->active_background--; in fuse_request_end()
395 spin_unlock(&fc->bg_lock); in fuse_request_end()
398 wake_up(&req->waitq); in fuse_request_end()
401 if (test_bit(FR_ASYNC, &req->flags)) in fuse_request_end()
402 req->args->end(fm, req->args, req->out.h.error); in fuse_request_end()
410 struct fuse_iqueue *fiq = &req->fm->fc->iq; in queue_interrupt() local
413 if (unlikely(!test_bit(FR_INTERRUPTED, &req->flags))) in queue_interrupt()
414 return -EINVAL; in queue_interrupt()
416 fiq->ops->send_interrupt(fiq, req); in queue_interrupt()
423 struct fuse_conn *fc = req->fm->fc; in request_wait_answer()
424 struct fuse_iqueue *fiq = &fc->iq; in request_wait_answer() local
427 if (!fc->no_interrupt) { in request_wait_answer()
429 err = wait_event_interruptible(req->waitq, in request_wait_answer()
430 test_bit(FR_FINISHED, &req->flags)); in request_wait_answer()
434 set_bit(FR_INTERRUPTED, &req->flags); in request_wait_answer()
437 if (test_bit(FR_SENT, &req->flags)) in request_wait_answer()
441 if (!test_bit(FR_FORCE, &req->flags)) { in request_wait_answer()
443 err = wait_event_killable(req->waitq, in request_wait_answer()
444 test_bit(FR_FINISHED, &req->flags)); in request_wait_answer()
448 spin_lock(&fiq->lock); in request_wait_answer()
450 if (test_bit(FR_PENDING, &req->flags)) { in request_wait_answer()
451 list_del(&req->list); in request_wait_answer()
452 spin_unlock(&fiq->lock); in request_wait_answer()
454 req->out.h.error = -EINTR; in request_wait_answer()
457 spin_unlock(&fiq->lock); in request_wait_answer()
464 wait_event(req->waitq, test_bit(FR_FINISHED, &req->flags)); in request_wait_answer()
469 struct fuse_iqueue *fiq = &req->fm->fc->iq; in __fuse_request_send() local
471 BUG_ON(test_bit(FR_BACKGROUND, &req->flags)); in __fuse_request_send()
476 fuse_send_one(fiq, req); in __fuse_request_send()
485 if (fc->minor < 4 && args->opcode == FUSE_STATFS) in fuse_adjust_compat()
486 args->out_args[0].size = FUSE_COMPAT_STATFS_SIZE; in fuse_adjust_compat()
488 if (fc->minor < 9) { in fuse_adjust_compat()
489 switch (args->opcode) { in fuse_adjust_compat()
496 args->out_args[0].size = FUSE_COMPAT_ENTRY_OUT_SIZE; in fuse_adjust_compat()
500 args->out_args[0].size = FUSE_COMPAT_ATTR_OUT_SIZE; in fuse_adjust_compat()
504 if (fc->minor < 12) { in fuse_adjust_compat()
505 switch (args->opcode) { in fuse_adjust_compat()
507 args->in_args[0].size = sizeof(struct fuse_open_in); in fuse_adjust_compat()
510 args->in_args[0].size = FUSE_COMPAT_MKNOD_IN_SIZE; in fuse_adjust_compat()
518 struct fuse_conn *fc = req->fm->fc; in fuse_force_creds()
520 if (!req->fm->sb || req->fm->sb->s_iflags & SB_I_NOIDMAP) { in fuse_force_creds()
521 req->in.h.uid = from_kuid_munged(fc->user_ns, current_fsuid()); in fuse_force_creds()
522 req->in.h.gid = from_kgid_munged(fc->user_ns, current_fsgid()); in fuse_force_creds()
524 req->in.h.uid = FUSE_INVALID_UIDGID; in fuse_force_creds()
525 req->in.h.gid = FUSE_INVALID_UIDGID; in fuse_force_creds()
528 req->in.h.pid = pid_nr_ns(task_pid(current), fc->pid_ns); in fuse_force_creds()
533 req->in.h.opcode = args->opcode; in fuse_args_to_req()
534 req->in.h.nodeid = args->nodeid; in fuse_args_to_req()
535 req->args = args; in fuse_args_to_req()
536 if (args->is_ext) in fuse_args_to_req()
537 req->in.h.total_extlen = args->in_args[args->ext_idx].size / 8; in fuse_args_to_req()
538 if (args->end) in fuse_args_to_req()
539 __set_bit(FR_ASYNC, &req->flags); in fuse_args_to_req()
546 struct fuse_conn *fc = fm->fc; in __fuse_simple_request()
550 if (args->force) { in __fuse_simple_request()
551 atomic_inc(&fc->num_waiting); in __fuse_simple_request()
554 if (!args->nocreds) in __fuse_simple_request()
557 __set_bit(FR_WAITING, &req->flags); in __fuse_simple_request()
558 __set_bit(FR_FORCE, &req->flags); in __fuse_simple_request()
560 WARN_ON(args->nocreds); in __fuse_simple_request()
566 /* Needs to be done after fuse_get_req() so that fc->minor is valid */ in __fuse_simple_request()
570 if (!args->noreply) in __fuse_simple_request()
571 __set_bit(FR_ISREPLY, &req->flags); in __fuse_simple_request()
573 ret = req->out.h.error; in __fuse_simple_request()
574 if (!ret && args->out_argvar) { in __fuse_simple_request()
575 BUG_ON(args->out_numargs == 0); in __fuse_simple_request()
576 ret = args->out_args[args->out_numargs - 1].size; in __fuse_simple_request()
585 struct fuse_mount *fm = req->fm; in fuse_request_queue_background()
586 struct fuse_conn *fc = fm->fc; in fuse_request_queue_background()
589 WARN_ON(!test_bit(FR_BACKGROUND, &req->flags)); in fuse_request_queue_background()
590 if (!test_bit(FR_WAITING, &req->flags)) { in fuse_request_queue_background()
591 __set_bit(FR_WAITING, &req->flags); in fuse_request_queue_background()
592 atomic_inc(&fc->num_waiting); in fuse_request_queue_background()
594 __set_bit(FR_ISREPLY, &req->flags); in fuse_request_queue_background()
595 spin_lock(&fc->bg_lock); in fuse_request_queue_background()
596 if (likely(fc->connected)) { in fuse_request_queue_background()
597 fc->num_background++; in fuse_request_queue_background()
598 if (fc->num_background == fc->max_background) in fuse_request_queue_background()
599 fc->blocked = 1; in fuse_request_queue_background()
600 list_add_tail(&req->list, &fc->bg_queue); in fuse_request_queue_background()
604 spin_unlock(&fc->bg_lock); in fuse_request_queue_background()
614 if (args->force) { in fuse_simple_background()
615 WARN_ON(!args->nocreds); in fuse_simple_background()
618 return -ENOMEM; in fuse_simple_background()
619 __set_bit(FR_BACKGROUND, &req->flags); in fuse_simple_background()
621 WARN_ON(args->nocreds); in fuse_simple_background()
631 return -ENOTCONN; in fuse_simple_background()
642 struct fuse_iqueue *fiq = &fm->fc->iq; in fuse_simple_notify_reply() local
648 __clear_bit(FR_ISREPLY, &req->flags); in fuse_simple_notify_reply()
649 req->in.h.unique = unique; in fuse_simple_notify_reply()
653 fuse_send_one(fiq, req); in fuse_simple_notify_reply()
660 * anything that could cause a page-fault. If the request was already
667 spin_lock(&req->waitq.lock); in lock_request()
668 if (test_bit(FR_ABORTED, &req->flags)) in lock_request()
669 err = -ENOENT; in lock_request()
671 set_bit(FR_LOCKED, &req->flags); in lock_request()
672 spin_unlock(&req->waitq.lock); in lock_request()
685 spin_lock(&req->waitq.lock); in unlock_request()
686 if (test_bit(FR_ABORTED, &req->flags)) in unlock_request()
687 err = -ENOENT; in unlock_request()
689 clear_bit(FR_LOCKED, &req->flags); in unlock_request()
690 spin_unlock(&req->waitq.lock); in unlock_request()
713 cs->write = write; in fuse_copy_init()
714 cs->iter = iter; in fuse_copy_init()
720 if (cs->currbuf) { in fuse_copy_finish()
721 struct pipe_buffer *buf = cs->currbuf; in fuse_copy_finish()
723 if (cs->write) in fuse_copy_finish()
724 buf->len = PAGE_SIZE - cs->len; in fuse_copy_finish()
725 cs->currbuf = NULL; in fuse_copy_finish()
726 } else if (cs->pg) { in fuse_copy_finish()
727 if (cs->write) { in fuse_copy_finish()
728 flush_dcache_page(cs->pg); in fuse_copy_finish()
729 set_page_dirty_lock(cs->pg); in fuse_copy_finish()
731 put_page(cs->pg); in fuse_copy_finish()
733 cs->pg = NULL; in fuse_copy_finish()
745 err = unlock_request(cs->req); in fuse_copy_fill()
750 if (cs->pipebufs) { in fuse_copy_fill()
751 struct pipe_buffer *buf = cs->pipebufs; in fuse_copy_fill()
753 if (!cs->write) { in fuse_copy_fill()
754 err = pipe_buf_confirm(cs->pipe, buf); in fuse_copy_fill()
758 BUG_ON(!cs->nr_segs); in fuse_copy_fill()
759 cs->currbuf = buf; in fuse_copy_fill()
760 cs->pg = buf->page; in fuse_copy_fill()
761 cs->offset = buf->offset; in fuse_copy_fill()
762 cs->len = buf->len; in fuse_copy_fill()
763 cs->pipebufs++; in fuse_copy_fill()
764 cs->nr_segs--; in fuse_copy_fill()
766 if (cs->nr_segs >= cs->pipe->max_usage) in fuse_copy_fill()
767 return -EIO; in fuse_copy_fill()
771 return -ENOMEM; in fuse_copy_fill()
773 buf->page = page; in fuse_copy_fill()
774 buf->offset = 0; in fuse_copy_fill()
775 buf->len = 0; in fuse_copy_fill()
777 cs->currbuf = buf; in fuse_copy_fill()
778 cs->pg = page; in fuse_copy_fill()
779 cs->offset = 0; in fuse_copy_fill()
780 cs->len = PAGE_SIZE; in fuse_copy_fill()
781 cs->pipebufs++; in fuse_copy_fill()
782 cs->nr_segs++; in fuse_copy_fill()
786 err = iov_iter_get_pages2(cs->iter, &page, PAGE_SIZE, 1, &off); in fuse_copy_fill()
790 cs->len = err; in fuse_copy_fill()
791 cs->offset = off; in fuse_copy_fill()
792 cs->pg = page; in fuse_copy_fill()
795 return lock_request(cs->req); in fuse_copy_fill()
801 unsigned ncpy = min(*size, cs->len); in fuse_copy_do()
803 void *pgaddr = kmap_local_page(cs->pg); in fuse_copy_do()
804 void *buf = pgaddr + cs->offset; in fuse_copy_do()
806 if (cs->write) in fuse_copy_do()
814 *size -= ncpy; in fuse_copy_do()
815 cs->len -= ncpy; in fuse_copy_do()
816 cs->offset += ncpy; in fuse_copy_do()
823 folio->mapping != NULL || in fuse_check_folio()
824 (folio->flags & PAGE_FLAGS_CHECK_AT_PREP & in fuse_check_folio()
833 dump_page(&folio->page, "fuse: trying to steal weird page"); in fuse_check_folio()
844 struct pipe_buffer *buf = cs->pipebufs; in fuse_try_move_page()
847 err = unlock_request(cs->req); in fuse_try_move_page()
853 err = pipe_buf_confirm(cs->pipe, buf); in fuse_try_move_page()
857 BUG_ON(!cs->nr_segs); in fuse_try_move_page()
858 cs->currbuf = buf; in fuse_try_move_page()
859 cs->len = buf->len; in fuse_try_move_page()
860 cs->pipebufs++; in fuse_try_move_page()
861 cs->nr_segs--; in fuse_try_move_page()
863 if (cs->len != PAGE_SIZE) in fuse_try_move_page()
866 if (!pipe_buf_try_steal(cs->pipe, buf)) in fuse_try_move_page()
869 newfolio = page_folio(buf->page); in fuse_try_move_page()
895 if (!(buf->flags & PIPE_BUF_FLAG_LRU)) in fuse_try_move_page()
902 pipe_buf_release(cs->pipe, buf); in fuse_try_move_page()
905 spin_lock(&cs->req->waitq.lock); in fuse_try_move_page()
906 if (test_bit(FR_ABORTED, &cs->req->flags)) in fuse_try_move_page()
907 err = -ENOENT; in fuse_try_move_page()
909 *pagep = &newfolio->page; in fuse_try_move_page()
910 spin_unlock(&cs->req->waitq.lock); in fuse_try_move_page()
919 /* Drop ref for ap->pages[] array */ in fuse_try_move_page()
921 cs->len = 0; in fuse_try_move_page()
932 cs->pg = buf->page; in fuse_try_move_page()
933 cs->offset = buf->offset; in fuse_try_move_page()
935 err = lock_request(cs->req); in fuse_try_move_page()
948 if (cs->nr_segs >= cs->pipe->max_usage) in fuse_ref_page()
949 return -EIO; in fuse_ref_page()
952 err = unlock_request(cs->req); in fuse_ref_page()
960 buf = cs->pipebufs; in fuse_ref_page()
961 buf->page = page; in fuse_ref_page()
962 buf->offset = offset; in fuse_ref_page()
963 buf->len = count; in fuse_ref_page()
965 cs->pipebufs++; in fuse_ref_page()
966 cs->nr_segs++; in fuse_ref_page()
967 cs->len = 0; in fuse_ref_page()
986 if (cs->write && cs->pipebufs && page) { in fuse_copy_page()
991 if (cs->req->args->user_pages) { in fuse_copy_page()
998 } else if (!cs->len) { in fuse_copy_page()
999 if (cs->move_pages && page && in fuse_copy_page()
1018 if (page && !cs->write) in fuse_copy_page()
1028 struct fuse_req *req = cs->req; in fuse_copy_pages()
1029 struct fuse_args_pages *ap = container_of(req->args, typeof(*ap), args); in fuse_copy_pages()
1032 for (i = 0; i < ap->num_pages && (nbytes || zeroing); i++) { in fuse_copy_pages()
1034 unsigned int offset = ap->descs[i].offset; in fuse_copy_pages()
1035 unsigned int count = min(nbytes, ap->descs[i].length); in fuse_copy_pages()
1037 err = fuse_copy_page(cs, &ap->pages[i], offset, count, zeroing); in fuse_copy_pages()
1041 nbytes -= count; in fuse_copy_pages()
1050 if (!cs->len) { in fuse_copy_one()
1070 if (i == numargs - 1 && argpages) in fuse_copy_args()
1071 err = fuse_copy_pages(cs, arg->size, zeroing); in fuse_copy_args()
1073 err = fuse_copy_one(cs, arg->value, arg->size); in fuse_copy_args()
1078 static int forget_pending(struct fuse_iqueue *fiq) in forget_pending() argument
1080 return fiq->forget_list_head.next != NULL; in forget_pending()
1083 static int request_pending(struct fuse_iqueue *fiq) in request_pending() argument
1085 return !list_empty(&fiq->pending) || !list_empty(&fiq->interrupts) || in request_pending()
1086 forget_pending(fiq); in request_pending()
1095 * Called with fiq->lock held, releases it
1097 static int fuse_read_interrupt(struct fuse_iqueue *fiq, in fuse_read_interrupt() argument
1100 __releases(fiq->lock) in fuse_read_interrupt()
1107 list_del_init(&req->intr_entry); in fuse_read_interrupt()
1112 ih.unique = (req->in.h.unique | FUSE_INT_REQ_BIT); in fuse_read_interrupt()
1113 arg.unique = req->in.h.unique; in fuse_read_interrupt()
1115 spin_unlock(&fiq->lock); in fuse_read_interrupt()
1117 return -EINVAL; in fuse_read_interrupt()
1127 static struct fuse_forget_link *fuse_dequeue_forget(struct fuse_iqueue *fiq, in fuse_dequeue_forget() argument
1131 struct fuse_forget_link *head = fiq->forget_list_head.next; in fuse_dequeue_forget()
1136 newhead = &(*newhead)->next; in fuse_dequeue_forget()
1138 fiq->forget_list_head.next = *newhead; in fuse_dequeue_forget()
1140 if (fiq->forget_list_head.next == NULL) in fuse_dequeue_forget()
1141 fiq->forget_list_tail = &fiq->forget_list_head; in fuse_dequeue_forget()
1149 static int fuse_read_single_forget(struct fuse_iqueue *fiq, in fuse_read_single_forget() argument
1152 __releases(fiq->lock) in fuse_read_single_forget()
1155 struct fuse_forget_link *forget = fuse_dequeue_forget(fiq, 1, NULL); in fuse_read_single_forget()
1157 .nlookup = forget->forget_one.nlookup, in fuse_read_single_forget()
1161 .nodeid = forget->forget_one.nodeid, in fuse_read_single_forget()
1162 .unique = fuse_get_unique_locked(fiq), in fuse_read_single_forget()
1166 spin_unlock(&fiq->lock); in fuse_read_single_forget()
1169 return -EINVAL; in fuse_read_single_forget()
1182 static int fuse_read_batch_forget(struct fuse_iqueue *fiq, in fuse_read_batch_forget() argument
1184 __releases(fiq->lock) in fuse_read_batch_forget()
1193 .unique = fuse_get_unique_locked(fiq), in fuse_read_batch_forget()
1198 spin_unlock(&fiq->lock); in fuse_read_batch_forget()
1199 return -EINVAL; in fuse_read_batch_forget()
1202 max_forgets = (nbytes - ih.len) / sizeof(struct fuse_forget_one); in fuse_read_batch_forget()
1203 head = fuse_dequeue_forget(fiq, max_forgets, &count); in fuse_read_batch_forget()
1204 spin_unlock(&fiq->lock); in fuse_read_batch_forget()
1216 err = fuse_copy_one(cs, &forget->forget_one, in fuse_read_batch_forget()
1217 sizeof(forget->forget_one)); in fuse_read_batch_forget()
1219 head = forget->next; in fuse_read_batch_forget()
1231 static int fuse_read_forget(struct fuse_conn *fc, struct fuse_iqueue *fiq, in fuse_read_forget() argument
1234 __releases(fiq->lock) in fuse_read_forget()
1236 if (fc->minor < 16 || fiq->forget_list_head.next->next == NULL) in fuse_read_forget()
1237 return fuse_read_single_forget(fiq, cs, nbytes); in fuse_read_forget()
1239 return fuse_read_batch_forget(fiq, cs, nbytes); in fuse_read_forget()
1255 struct fuse_conn *fc = fud->fc; in fuse_dev_do_read()
1256 struct fuse_iqueue *fiq = &fc->iq; in fuse_dev_do_read() local
1257 struct fuse_pqueue *fpq = &fud->pq; in fuse_dev_do_read()
1264 * Require sane minimum read buffer - that has capacity for fixed part in fuse_dev_do_read()
1278 fc->max_write)) in fuse_dev_do_read()
1279 return -EINVAL; in fuse_dev_do_read()
1283 spin_lock(&fiq->lock); in fuse_dev_do_read()
1284 if (!fiq->connected || request_pending(fiq)) in fuse_dev_do_read()
1286 spin_unlock(&fiq->lock); in fuse_dev_do_read()
1288 if (file->f_flags & O_NONBLOCK) in fuse_dev_do_read()
1289 return -EAGAIN; in fuse_dev_do_read()
1290 err = wait_event_interruptible_exclusive(fiq->waitq, in fuse_dev_do_read()
1291 !fiq->connected || request_pending(fiq)); in fuse_dev_do_read()
1296 if (!fiq->connected) { in fuse_dev_do_read()
1297 err = fc->aborted ? -ECONNABORTED : -ENODEV; in fuse_dev_do_read()
1301 if (!list_empty(&fiq->interrupts)) { in fuse_dev_do_read()
1302 req = list_entry(fiq->interrupts.next, struct fuse_req, in fuse_dev_do_read()
1304 return fuse_read_interrupt(fiq, cs, nbytes, req); in fuse_dev_do_read()
1307 if (forget_pending(fiq)) { in fuse_dev_do_read()
1308 if (list_empty(&fiq->pending) || fiq->forget_batch-- > 0) in fuse_dev_do_read()
1309 return fuse_read_forget(fc, fiq, cs, nbytes); in fuse_dev_do_read()
1311 if (fiq->forget_batch <= -8) in fuse_dev_do_read()
1312 fiq->forget_batch = 16; in fuse_dev_do_read()
1315 req = list_entry(fiq->pending.next, struct fuse_req, list); in fuse_dev_do_read()
1316 clear_bit(FR_PENDING, &req->flags); in fuse_dev_do_read()
1317 list_del_init(&req->list); in fuse_dev_do_read()
1318 spin_unlock(&fiq->lock); in fuse_dev_do_read()
1320 args = req->args; in fuse_dev_do_read()
1321 reqsize = req->in.h.len; in fuse_dev_do_read()
1325 req->out.h.error = -EIO; in fuse_dev_do_read()
1327 if (args->opcode == FUSE_SETXATTR) in fuse_dev_do_read()
1328 req->out.h.error = -E2BIG; in fuse_dev_do_read()
1332 spin_lock(&fpq->lock); in fuse_dev_do_read()
1334 * Must not put request on fpq->io queue after having been shut down by in fuse_dev_do_read()
1337 if (!fpq->connected) { in fuse_dev_do_read()
1338 req->out.h.error = err = -ECONNABORTED; in fuse_dev_do_read()
1342 list_add(&req->list, &fpq->io); in fuse_dev_do_read()
1343 spin_unlock(&fpq->lock); in fuse_dev_do_read()
1344 cs->req = req; in fuse_dev_do_read()
1345 err = fuse_copy_one(cs, &req->in.h, sizeof(req->in.h)); in fuse_dev_do_read()
1347 err = fuse_copy_args(cs, args->in_numargs, args->in_pages, in fuse_dev_do_read()
1348 (struct fuse_arg *) args->in_args, 0); in fuse_dev_do_read()
1350 spin_lock(&fpq->lock); in fuse_dev_do_read()
1351 clear_bit(FR_LOCKED, &req->flags); in fuse_dev_do_read()
1352 if (!fpq->connected) { in fuse_dev_do_read()
1353 err = fc->aborted ? -ECONNABORTED : -ENODEV; in fuse_dev_do_read()
1357 req->out.h.error = -EIO; in fuse_dev_do_read()
1360 if (!test_bit(FR_ISREPLY, &req->flags)) { in fuse_dev_do_read()
1364 hash = fuse_req_hash(req->in.h.unique); in fuse_dev_do_read()
1365 list_move_tail(&req->list, &fpq->processing[hash]); in fuse_dev_do_read()
1367 set_bit(FR_SENT, &req->flags); in fuse_dev_do_read()
1368 spin_unlock(&fpq->lock); in fuse_dev_do_read()
1371 if (test_bit(FR_INTERRUPTED, &req->flags)) in fuse_dev_do_read()
1378 if (!test_bit(FR_PRIVATE, &req->flags)) in fuse_dev_do_read()
1379 list_del_init(&req->list); in fuse_dev_do_read()
1380 spin_unlock(&fpq->lock); in fuse_dev_do_read()
1385 spin_unlock(&fiq->lock); in fuse_dev_do_read()
1396 file->private_data = NULL; in fuse_dev_open()
1403 struct file *file = iocb->ki_filp; in fuse_dev_read()
1407 return -EPERM; in fuse_dev_read()
1410 return -EINVAL; in fuse_dev_read()
1428 return -EPERM; in fuse_dev_splice_read()
1430 bufs = kvmalloc_array(pipe->max_usage, sizeof(struct pipe_buffer), in fuse_dev_splice_read()
1433 return -ENOMEM; in fuse_dev_splice_read()
1442 if (pipe_occupancy(pipe->head, pipe->tail) + cs.nr_segs > pipe->max_usage) { in fuse_dev_splice_read()
1443 ret = -EIO; in fuse_dev_splice_read()
1449 * Need to be careful about this. Having buf->ops in module in fuse_dev_splice_read()
1472 int err = -EINVAL; in fuse_notify_poll()
1493 int err = -EINVAL; in fuse_notify_inval_inode()
1503 down_read(&fc->killsb); in fuse_notify_inval_inode()
1506 up_read(&fc->killsb); in fuse_notify_inval_inode()
1518 int err = -ENOMEM; in fuse_notify_inval_entry()
1526 err = -EINVAL; in fuse_notify_inval_entry()
1534 err = -ENAMETOOLONG; in fuse_notify_inval_entry()
1538 err = -EINVAL; in fuse_notify_inval_entry()
1550 down_read(&fc->killsb); in fuse_notify_inval_entry()
1552 up_read(&fc->killsb); in fuse_notify_inval_entry()
1566 int err = -ENOMEM; in fuse_notify_delete()
1574 err = -EINVAL; in fuse_notify_delete()
1582 err = -ENAMETOOLONG; in fuse_notify_delete()
1586 err = -EINVAL; in fuse_notify_delete()
1598 down_read(&fc->killsb); in fuse_notify_delete()
1600 up_read(&fc->killsb); in fuse_notify_delete()
1618 pgoff_t index; in fuse_notify_store() local
1624 err = -EINVAL; in fuse_notify_store()
1632 err = -EINVAL; in fuse_notify_store()
1633 if (size - sizeof(outarg) != outarg.size) in fuse_notify_store()
1638 down_read(&fc->killsb); in fuse_notify_store()
1640 err = -ENOENT; in fuse_notify_store()
1645 mapping = inode->i_mapping; in fuse_notify_store()
1646 index = outarg.offset >> PAGE_SHIFT; in fuse_notify_store()
1660 err = -ENOMEM; in fuse_notify_store()
1661 page = find_or_create_page(mapping, index, in fuse_notify_store()
1666 this_num = min_t(unsigned, num, PAGE_SIZE - offset); in fuse_notify_store()
1679 num -= this_num; in fuse_notify_store()
1681 index++; in fuse_notify_store()
1689 up_read(&fc->killsb); in fuse_notify_store()
1706 release_pages(ra->ap.pages, ra->ap.num_pages); in fuse_retrieve_end()
1714 struct address_space *mapping = inode->i_mapping; in fuse_retrieve()
1715 pgoff_t index; in fuse_retrieve() local
1721 struct fuse_conn *fc = fm->fc; in fuse_retrieve()
1727 offset = outarg->offset & ~PAGE_MASK; in fuse_retrieve()
1730 num = min(outarg->size, fc->max_write); in fuse_retrieve()
1731 if (outarg->offset > file_size) in fuse_retrieve()
1733 else if (outarg->offset + num > file_size) in fuse_retrieve()
1734 num = file_size - outarg->offset; in fuse_retrieve()
1736 num_pages = (num + offset + PAGE_SIZE - 1) >> PAGE_SHIFT; in fuse_retrieve()
1737 num_pages = min(num_pages, fc->max_pages); in fuse_retrieve()
1739 args_size += num_pages * (sizeof(ap->pages[0]) + sizeof(ap->descs[0])); in fuse_retrieve()
1743 return -ENOMEM; in fuse_retrieve()
1745 ap = &ra->ap; in fuse_retrieve()
1746 ap->pages = (void *) (ra + 1); in fuse_retrieve()
1747 ap->descs = (void *) (ap->pages + num_pages); in fuse_retrieve()
1749 args = &ap->args; in fuse_retrieve()
1750 args->nodeid = outarg->nodeid; in fuse_retrieve()
1751 args->opcode = FUSE_NOTIFY_REPLY; in fuse_retrieve()
1752 args->in_numargs = 2; in fuse_retrieve()
1753 args->in_pages = true; in fuse_retrieve()
1754 args->end = fuse_retrieve_end; in fuse_retrieve()
1756 index = outarg->offset >> PAGE_SHIFT; in fuse_retrieve()
1758 while (num && ap->num_pages < num_pages) { in fuse_retrieve()
1762 page = find_get_page(mapping, index); in fuse_retrieve()
1766 this_num = min_t(unsigned, num, PAGE_SIZE - offset); in fuse_retrieve()
1767 ap->pages[ap->num_pages] = page; in fuse_retrieve()
1768 ap->descs[ap->num_pages].offset = offset; in fuse_retrieve()
1769 ap->descs[ap->num_pages].length = this_num; in fuse_retrieve()
1770 ap->num_pages++; in fuse_retrieve()
1773 num -= this_num; in fuse_retrieve()
1775 index++; in fuse_retrieve()
1777 ra->inarg.offset = outarg->offset; in fuse_retrieve()
1778 ra->inarg.size = total_len; in fuse_retrieve()
1779 args->in_args[0].size = sizeof(ra->inarg); in fuse_retrieve()
1780 args->in_args[0].value = &ra->inarg; in fuse_retrieve()
1781 args->in_args[1].size = total_len; in fuse_retrieve()
1783 err = fuse_simple_notify_reply(fm, args, outarg->notify_unique); in fuse_retrieve()
1799 err = -EINVAL; in fuse_notify_retrieve()
1809 down_read(&fc->killsb); in fuse_notify_retrieve()
1810 err = -ENOENT; in fuse_notify_retrieve()
1818 up_read(&fc->killsb); in fuse_notify_retrieve()
1838 * non-idempotent requests.
1844 struct fuse_iqueue *fiq = &fc->iq; in fuse_resend() local
1848 spin_lock(&fc->lock); in fuse_resend()
1849 if (!fc->connected) { in fuse_resend()
1850 spin_unlock(&fc->lock); in fuse_resend()
1854 list_for_each_entry(fud, &fc->devices, entry) { in fuse_resend()
1855 struct fuse_pqueue *fpq = &fud->pq; in fuse_resend()
1857 spin_lock(&fpq->lock); in fuse_resend()
1859 list_splice_tail_init(&fpq->processing[i], &to_queue); in fuse_resend()
1860 spin_unlock(&fpq->lock); in fuse_resend()
1862 spin_unlock(&fc->lock); in fuse_resend()
1865 set_bit(FR_PENDING, &req->flags); in fuse_resend()
1866 clear_bit(FR_SENT, &req->flags); in fuse_resend()
1868 req->in.h.unique |= FUSE_UNIQUE_RESEND; in fuse_resend()
1871 spin_lock(&fiq->lock); in fuse_resend()
1872 if (!fiq->connected) { in fuse_resend()
1873 spin_unlock(&fiq->lock); in fuse_resend()
1875 clear_bit(FR_PENDING, &req->flags); in fuse_resend()
1880 list_splice(&to_queue, &fiq->pending); in fuse_resend()
1881 fuse_dev_wake_and_unlock(fiq); in fuse_resend()
1894 cs->move_pages = 0; in fuse_notify()
1920 return -EINVAL; in fuse_notify()
1930 list_for_each_entry(req, &fpq->processing[hash], list) { in request_find()
1931 if (req->in.h.unique == unique) in request_find()
1942 reqsize += fuse_len_args(args->out_numargs, args->out_args); in copy_out_args()
1944 if (reqsize < nbytes || (reqsize > nbytes && !args->out_argvar)) in copy_out_args()
1945 return -EINVAL; in copy_out_args()
1947 struct fuse_arg *lastarg = &args->out_args[args->out_numargs-1]; in copy_out_args()
1948 unsigned diffsize = reqsize - nbytes; in copy_out_args()
1950 if (diffsize > lastarg->size) in copy_out_args()
1951 return -EINVAL; in copy_out_args()
1952 lastarg->size -= diffsize; in copy_out_args()
1954 return fuse_copy_args(cs, args->out_numargs, args->out_pages, in copy_out_args()
1955 args->out_args, args->page_zeroing); in copy_out_args()
1969 struct fuse_conn *fc = fud->fc; in fuse_dev_do_write()
1970 struct fuse_pqueue *fpq = &fud->pq; in fuse_dev_do_write()
1974 err = -EINVAL; in fuse_dev_do_write()
1982 err = -EINVAL; in fuse_dev_do_write()
1991 err = fuse_notify(fc, oh.error, nbytes - sizeof(oh), cs); in fuse_dev_do_write()
1995 err = -EINVAL; in fuse_dev_do_write()
1996 if (oh.error <= -512 || oh.error > 0) in fuse_dev_do_write()
1999 spin_lock(&fpq->lock); in fuse_dev_do_write()
2001 if (fpq->connected) in fuse_dev_do_write()
2004 err = -ENOENT; in fuse_dev_do_write()
2006 spin_unlock(&fpq->lock); in fuse_dev_do_write()
2013 spin_unlock(&fpq->lock); in fuse_dev_do_write()
2017 err = -EINVAL; in fuse_dev_do_write()
2018 else if (oh.error == -ENOSYS) in fuse_dev_do_write()
2019 fc->no_interrupt = 1; in fuse_dev_do_write()
2020 else if (oh.error == -EAGAIN) in fuse_dev_do_write()
2028 clear_bit(FR_SENT, &req->flags); in fuse_dev_do_write()
2029 list_move(&req->list, &fpq->io); in fuse_dev_do_write()
2030 req->out.h = oh; in fuse_dev_do_write()
2031 set_bit(FR_LOCKED, &req->flags); in fuse_dev_do_write()
2032 spin_unlock(&fpq->lock); in fuse_dev_do_write()
2033 cs->req = req; in fuse_dev_do_write()
2034 if (!req->args->page_replace) in fuse_dev_do_write()
2035 cs->move_pages = 0; in fuse_dev_do_write()
2038 err = nbytes != sizeof(oh) ? -EINVAL : 0; in fuse_dev_do_write()
2040 err = copy_out_args(cs, req->args, nbytes); in fuse_dev_do_write()
2043 spin_lock(&fpq->lock); in fuse_dev_do_write()
2044 clear_bit(FR_LOCKED, &req->flags); in fuse_dev_do_write()
2045 if (!fpq->connected) in fuse_dev_do_write()
2046 err = -ENOENT; in fuse_dev_do_write()
2048 req->out.h.error = -EIO; in fuse_dev_do_write()
2049 if (!test_bit(FR_PRIVATE, &req->flags)) in fuse_dev_do_write()
2050 list_del_init(&req->list); in fuse_dev_do_write()
2051 spin_unlock(&fpq->lock); in fuse_dev_do_write()
2065 struct fuse_dev *fud = fuse_get_dev(iocb->ki_filp); in fuse_dev_write()
2068 return -EPERM; in fuse_dev_write()
2071 return -EINVAL; in fuse_dev_write()
2093 return -EPERM; in fuse_dev_splice_write()
2097 head = pipe->head; in fuse_dev_splice_write()
2098 tail = pipe->tail; in fuse_dev_splice_write()
2099 mask = pipe->ring_size - 1; in fuse_dev_splice_write()
2100 count = head - tail; in fuse_dev_splice_write()
2105 return -ENOMEM; in fuse_dev_splice_write()
2111 rem += pipe->bufs[idx & mask].len; in fuse_dev_splice_write()
2113 ret = -EINVAL; in fuse_dev_splice_write()
2125 ibuf = &pipe->bufs[tail & mask]; in fuse_dev_splice_write()
2128 if (rem >= ibuf->len) { in fuse_dev_splice_write()
2130 ibuf->ops = NULL; in fuse_dev_splice_write()
2132 pipe->tail = tail; in fuse_dev_splice_write()
2138 obuf->flags &= ~PIPE_BUF_FLAG_GIFT; in fuse_dev_splice_write()
2139 obuf->len = rem; in fuse_dev_splice_write()
2140 ibuf->offset += obuf->len; in fuse_dev_splice_write()
2141 ibuf->len -= obuf->len; in fuse_dev_splice_write()
2144 rem -= obuf->len; in fuse_dev_splice_write()
2163 if (buf->ops) in fuse_dev_splice_write()
2175 struct fuse_iqueue *fiq; in fuse_dev_poll() local
2181 fiq = &fud->fc->iq; in fuse_dev_poll()
2182 poll_wait(file, &fiq->waitq, wait); in fuse_dev_poll()
2184 spin_lock(&fiq->lock); in fuse_dev_poll()
2185 if (!fiq->connected) in fuse_dev_poll()
2187 else if (request_pending(fiq)) in fuse_dev_poll()
2189 spin_unlock(&fiq->lock); in fuse_dev_poll()
2199 req = list_entry(head->next, struct fuse_req, list); in end_requests()
2200 req->out.h.error = -ECONNABORTED; in end_requests()
2201 clear_bit(FR_SENT, &req->flags); in end_requests()
2202 list_del_init(&req->list); in end_requests()
2211 p = rb_first(&fc->polled_files); in end_polls()
2216 wake_up_interruptible_all(&ff->poll_wait); in end_polls()
2242 struct fuse_iqueue *fiq = &fc->iq; in fuse_abort_conn() local
2244 spin_lock(&fc->lock); in fuse_abort_conn()
2245 if (fc->connected) { in fuse_abort_conn()
2251 /* Background queuing checks fc->connected under bg_lock */ in fuse_abort_conn()
2252 spin_lock(&fc->bg_lock); in fuse_abort_conn()
2253 fc->connected = 0; in fuse_abort_conn()
2254 spin_unlock(&fc->bg_lock); in fuse_abort_conn()
2257 list_for_each_entry(fud, &fc->devices, entry) { in fuse_abort_conn()
2258 struct fuse_pqueue *fpq = &fud->pq; in fuse_abort_conn()
2260 spin_lock(&fpq->lock); in fuse_abort_conn()
2261 fpq->connected = 0; in fuse_abort_conn()
2262 list_for_each_entry_safe(req, next, &fpq->io, list) { in fuse_abort_conn()
2263 req->out.h.error = -ECONNABORTED; in fuse_abort_conn()
2264 spin_lock(&req->waitq.lock); in fuse_abort_conn()
2265 set_bit(FR_ABORTED, &req->flags); in fuse_abort_conn()
2266 if (!test_bit(FR_LOCKED, &req->flags)) { in fuse_abort_conn()
2267 set_bit(FR_PRIVATE, &req->flags); in fuse_abort_conn()
2269 list_move(&req->list, &to_end); in fuse_abort_conn()
2271 spin_unlock(&req->waitq.lock); in fuse_abort_conn()
2274 list_splice_tail_init(&fpq->processing[i], in fuse_abort_conn()
2276 spin_unlock(&fpq->lock); in fuse_abort_conn()
2278 spin_lock(&fc->bg_lock); in fuse_abort_conn()
2279 fc->blocked = 0; in fuse_abort_conn()
2280 fc->max_background = UINT_MAX; in fuse_abort_conn()
2282 spin_unlock(&fc->bg_lock); in fuse_abort_conn()
2284 spin_lock(&fiq->lock); in fuse_abort_conn()
2285 fiq->connected = 0; in fuse_abort_conn()
2286 list_for_each_entry(req, &fiq->pending, list) in fuse_abort_conn()
2287 clear_bit(FR_PENDING, &req->flags); in fuse_abort_conn()
2288 list_splice_tail_init(&fiq->pending, &to_end); in fuse_abort_conn()
2289 while (forget_pending(fiq)) in fuse_abort_conn()
2290 kfree(fuse_dequeue_forget(fiq, 1, NULL)); in fuse_abort_conn()
2291 wake_up_all(&fiq->waitq); in fuse_abort_conn()
2292 spin_unlock(&fiq->lock); in fuse_abort_conn()
2293 kill_fasync(&fiq->fasync, SIGIO, POLL_IN); in fuse_abort_conn()
2295 wake_up_all(&fc->blocked_waitq); in fuse_abort_conn()
2296 spin_unlock(&fc->lock); in fuse_abort_conn()
2300 spin_unlock(&fc->lock); in fuse_abort_conn()
2309 wait_event(fc->blocked_waitq, atomic_read(&fc->num_waiting) == 0); in fuse_wait_aborted()
2317 struct fuse_conn *fc = fud->fc; in fuse_dev_release()
2318 struct fuse_pqueue *fpq = &fud->pq; in fuse_dev_release()
2322 spin_lock(&fpq->lock); in fuse_dev_release()
2323 WARN_ON(!list_empty(&fpq->io)); in fuse_dev_release()
2325 list_splice_init(&fpq->processing[i], &to_end); in fuse_dev_release()
2326 spin_unlock(&fpq->lock); in fuse_dev_release()
2331 if (atomic_dec_and_test(&fc->dev_count)) { in fuse_dev_release()
2332 WARN_ON(fc->iq.fasync != NULL); in fuse_dev_release()
2346 return -EPERM; in fuse_dev_fasync()
2348 /* No locking - fasync_helper does its own locking */ in fuse_dev_fasync()
2349 return fasync_helper(fd, file, on, &fud->fc->iq.fasync); in fuse_dev_fasync()
2356 if (new->private_data) in fuse_device_clone()
2357 return -EINVAL; in fuse_device_clone()
2361 return -ENOMEM; in fuse_device_clone()
2363 new->private_data = fud; in fuse_device_clone()
2364 atomic_inc(&fc->dev_count); in fuse_device_clone()
2377 return -EFAULT; in fuse_dev_ioctl_clone()
2381 return -EINVAL; in fuse_dev_ioctl_clone()
2384 * Check against file->f_op because CUSE in fuse_dev_ioctl_clone()
2387 if (fd_file(f)->f_op == file->f_op) in fuse_dev_ioctl_clone()
2390 res = -EINVAL; in fuse_dev_ioctl_clone()
2393 res = fuse_device_clone(fud->fc, file); in fuse_dev_ioctl_clone()
2408 return -EPERM; in fuse_dev_ioctl_backing_open()
2411 return -EOPNOTSUPP; in fuse_dev_ioctl_backing_open()
2414 return -EFAULT; in fuse_dev_ioctl_backing_open()
2416 return fuse_backing_open(fud->fc, &map); in fuse_dev_ioctl_backing_open()
2425 return -EPERM; in fuse_dev_ioctl_backing_close()
2428 return -EOPNOTSUPP; in fuse_dev_ioctl_backing_close()
2431 return -EFAULT; in fuse_dev_ioctl_backing_close()
2433 return fuse_backing_close(fud->fc, backing_id); in fuse_dev_ioctl_backing_close()
2452 return -ENOTTY; in fuse_dev_ioctl()
2479 int err = -ENOMEM; in fuse_dev_init()