Lines Matching refs:fc
38 bool fuse_request_expired(struct fuse_conn *fc, struct list_head *list) in fuse_request_expired() argument
45 return time_is_before_jiffies(req->create_time + fc->timeout.req_timeout); in fuse_request_expired()
48 static bool fuse_fpq_processing_expired(struct fuse_conn *fc, struct list_head *processing) in fuse_fpq_processing_expired() argument
53 if (fuse_request_expired(fc, &processing[i])) in fuse_fpq_processing_expired()
76 struct fuse_conn *fc = container_of(dwork, struct fuse_conn, in fuse_check_timeout() local
78 struct fuse_iqueue *fiq = &fc->iq; in fuse_check_timeout()
83 if (!atomic_read(&fc->num_waiting)) in fuse_check_timeout()
87 expired = fuse_request_expired(fc, &fiq->pending); in fuse_check_timeout()
92 spin_lock(&fc->bg_lock); in fuse_check_timeout()
93 expired = fuse_request_expired(fc, &fc->bg_queue); in fuse_check_timeout()
94 spin_unlock(&fc->bg_lock); in fuse_check_timeout()
98 spin_lock(&fc->lock); in fuse_check_timeout()
99 if (!fc->connected) { in fuse_check_timeout()
100 spin_unlock(&fc->lock); in fuse_check_timeout()
103 list_for_each_entry(fud, &fc->devices, entry) { in fuse_check_timeout()
106 if (fuse_request_expired(fc, &fpq->io) || in fuse_check_timeout()
107 fuse_fpq_processing_expired(fc, fpq->processing)) { in fuse_check_timeout()
109 spin_unlock(&fc->lock); in fuse_check_timeout()
115 spin_unlock(&fc->lock); in fuse_check_timeout()
117 if (fuse_uring_request_expired(fc)) in fuse_check_timeout()
121 queue_delayed_work(system_percpu_wq, &fc->timeout.work, in fuse_check_timeout()
126 fuse_abort_conn(fc); in fuse_check_timeout()
165 void fuse_set_initialized(struct fuse_conn *fc) in fuse_set_initialized() argument
169 fc->initialized = 1; in fuse_set_initialized()
172 static bool fuse_block_alloc(struct fuse_conn *fc, bool for_background) in fuse_block_alloc() argument
174 return !fc->initialized || (for_background && fc->blocked) || in fuse_block_alloc()
175 (fc->io_uring && fc->connected && !fuse_uring_ready(fc)); in fuse_block_alloc()
178 static void fuse_drop_waiting(struct fuse_conn *fc) in fuse_drop_waiting() argument
185 if (atomic_dec_and_test(&fc->num_waiting) && in fuse_drop_waiting()
186 !READ_ONCE(fc->connected)) { in fuse_drop_waiting()
188 wake_up_all(&fc->blocked_waitq); in fuse_drop_waiting()
198 struct fuse_conn *fc = fm->fc; in fuse_get_req() local
205 atomic_inc(&fc->num_waiting); in fuse_get_req()
207 if (fuse_block_alloc(fc, for_background)) { in fuse_get_req()
209 if (wait_event_state_exclusive(fc->blocked_waitq, in fuse_get_req()
210 !fuse_block_alloc(fc, for_background), in fuse_get_req()
218 if (!fc->connected) in fuse_get_req()
222 if (fc->conn_error) in fuse_get_req()
229 wake_up(&fc->blocked_waitq); in fuse_get_req()
233 req->in.h.pid = pid_nr_ns(task_pid(current), fc->pid_ns); in fuse_get_req()
248 fsuid = no_idmap ? current_fsuid() : mapped_fsuid(idmap, fc->user_ns); in fuse_get_req()
249 fsgid = no_idmap ? current_fsgid() : mapped_fsgid(idmap, fc->user_ns); in fuse_get_req()
250 req->in.h.uid = from_kuid(fc->user_ns, fsuid); in fuse_get_req()
251 req->in.h.gid = from_kgid(fc->user_ns, fsgid); in fuse_get_req()
262 fuse_drop_waiting(fc); in fuse_get_req()
268 struct fuse_conn *fc = req->fm->fc; in fuse_put_request() local
276 spin_lock(&fc->bg_lock); in fuse_put_request()
277 if (!fc->blocked) in fuse_put_request()
278 wake_up(&fc->blocked_waitq); in fuse_put_request()
279 spin_unlock(&fc->bg_lock); in fuse_put_request()
284 fuse_drop_waiting(fc); in fuse_put_request()
424 void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget, in fuse_queue_forget() argument
427 struct fuse_iqueue *fiq = &fc->iq; in fuse_queue_forget()
435 static void flush_bg_queue(struct fuse_conn *fc) in flush_bg_queue() argument
437 struct fuse_iqueue *fiq = &fc->iq; in flush_bg_queue()
439 while (fc->active_background < fc->max_background && in flush_bg_queue()
440 !list_empty(&fc->bg_queue)) { in flush_bg_queue()
443 req = list_first_entry(&fc->bg_queue, struct fuse_req, list); in flush_bg_queue()
445 fc->active_background++; in flush_bg_queue()
461 struct fuse_conn *fc = fm->fc; in fuse_request_end() local
462 struct fuse_iqueue *fiq = &fc->iq; in fuse_request_end()
481 spin_lock(&fc->bg_lock); in fuse_request_end()
483 if (fc->num_background == fc->max_background) { in fuse_request_end()
484 fc->blocked = 0; in fuse_request_end()
485 wake_up(&fc->blocked_waitq); in fuse_request_end()
486 } else if (!fc->blocked) { in fuse_request_end()
493 if (waitqueue_active(&fc->blocked_waitq)) in fuse_request_end()
494 wake_up(&fc->blocked_waitq); in fuse_request_end()
497 fc->num_background--; in fuse_request_end()
498 fc->active_background--; in fuse_request_end()
499 flush_bg_queue(fc); in fuse_request_end()
500 spin_unlock(&fc->bg_lock); in fuse_request_end()
515 struct fuse_iqueue *fiq = &req->fm->fc->iq; in queue_interrupt()
546 struct fuse_conn *fc = req->fm->fc; in request_wait_answer() local
547 struct fuse_iqueue *fiq = &fc->iq; in request_wait_answer()
550 if (!fc->no_interrupt) { in request_wait_answer()
590 struct fuse_iqueue *fiq = &req->fm->fc->iq; in __fuse_request_send()
604 static void fuse_adjust_compat(struct fuse_conn *fc, struct fuse_args *args) in fuse_adjust_compat() argument
606 if (fc->minor < 4 && args->opcode == FUSE_STATFS) in fuse_adjust_compat()
609 if (fc->minor < 9) { in fuse_adjust_compat()
625 if (fc->minor < 12) { in fuse_adjust_compat()
639 struct fuse_conn *fc = req->fm->fc; in fuse_force_creds() local
642 req->in.h.uid = from_kuid_munged(fc->user_ns, current_fsuid()); in fuse_force_creds()
643 req->in.h.gid = from_kgid_munged(fc->user_ns, current_fsgid()); in fuse_force_creds()
649 req->in.h.pid = pid_nr_ns(task_pid(current), fc->pid_ns); in fuse_force_creds()
667 struct fuse_conn *fc = fm->fc; in __fuse_simple_request() local
672 atomic_inc(&fc->num_waiting); in __fuse_simple_request()
688 fuse_adjust_compat(fc, args); in __fuse_simple_request()
705 static bool fuse_request_queue_background_uring(struct fuse_conn *fc, in fuse_request_queue_background_uring() argument
708 struct fuse_iqueue *fiq = &fc->iq; in fuse_request_queue_background_uring()
725 struct fuse_conn *fc = fm->fc; in fuse_request_queue_background() local
731 atomic_inc(&fc->num_waiting); in fuse_request_queue_background()
736 if (fuse_uring_ready(fc)) in fuse_request_queue_background()
737 return fuse_request_queue_background_uring(fc, req); in fuse_request_queue_background()
740 spin_lock(&fc->bg_lock); in fuse_request_queue_background()
741 if (likely(fc->connected)) { in fuse_request_queue_background()
742 fc->num_background++; in fuse_request_queue_background()
743 if (fc->num_background == fc->max_background) in fuse_request_queue_background()
744 fc->blocked = 1; in fuse_request_queue_background()
745 list_add_tail(&req->list, &fc->bg_queue); in fuse_request_queue_background()
746 flush_bg_queue(fc); in fuse_request_queue_background()
749 spin_unlock(&fc->bg_lock); in fuse_request_queue_background()
787 struct fuse_iqueue *fiq = &fm->fc->iq; in fuse_simple_notify_reply()
1382 static int fuse_read_forget(struct fuse_conn *fc, struct fuse_iqueue *fiq, in fuse_read_forget() argument
1387 if (fc->minor < 16 || fiq->forget_list_head.next->next == NULL) in fuse_read_forget()
1406 struct fuse_conn *fc = fud->fc; in fuse_dev_do_read() local
1407 struct fuse_iqueue *fiq = &fc->iq; in fuse_dev_do_read()
1429 fc->max_write)) in fuse_dev_do_read()
1448 err = fc->aborted ? -ECONNABORTED : -ENODEV; in fuse_dev_do_read()
1460 return fuse_read_forget(fc, fiq, cs, nbytes); in fuse_dev_do_read()
1504 err = fc->aborted ? -ECONNABORTED : -ENODEV; in fuse_dev_do_read()
1639 static int fuse_notify_poll(struct fuse_conn *fc, unsigned int size, in fuse_notify_poll() argument
1653 return fuse_notify_poll_wakeup(fc, &outarg); in fuse_notify_poll()
1656 static int fuse_notify_inval_inode(struct fuse_conn *fc, unsigned int size, in fuse_notify_inval_inode() argument
1670 down_read(&fc->killsb); in fuse_notify_inval_inode()
1671 err = fuse_reverse_inval_inode(fc, outarg.ino, in fuse_notify_inval_inode()
1673 up_read(&fc->killsb); in fuse_notify_inval_inode()
1677 static int fuse_notify_inval_entry(struct fuse_conn *fc, unsigned int size, in fuse_notify_inval_entry() argument
1692 if (outarg.namelen > fc->name_max) in fuse_notify_inval_entry()
1711 down_read(&fc->killsb); in fuse_notify_inval_entry()
1712 err = fuse_reverse_inval_entry(fc, outarg.parent, 0, &name, outarg.flags); in fuse_notify_inval_entry()
1713 up_read(&fc->killsb); in fuse_notify_inval_entry()
1719 static int fuse_notify_delete(struct fuse_conn *fc, unsigned int size, in fuse_notify_delete() argument
1734 if (outarg.namelen > fc->name_max) in fuse_notify_delete()
1752 down_read(&fc->killsb); in fuse_notify_delete()
1753 err = fuse_reverse_inval_entry(fc, outarg.parent, outarg.child, &name, 0); in fuse_notify_delete()
1754 up_read(&fc->killsb); in fuse_notify_delete()
1760 static int fuse_notify_store(struct fuse_conn *fc, unsigned int size, in fuse_notify_store() argument
1786 down_read(&fc->killsb); in fuse_notify_store()
1789 inode = fuse_ilookup(fc, nodeid, NULL); in fuse_notify_store()
1841 up_read(&fc->killsb); in fuse_notify_store()
1871 struct fuse_conn *fc = fm->fc; in fuse_retrieve() local
1880 num = min(outarg->size, fc->max_write); in fuse_retrieve()
1887 num_pages = min(num_pages, fc->max_pages); in fuse_retrieve()
1947 static int fuse_notify_retrieve(struct fuse_conn *fc, unsigned int size, in fuse_notify_retrieve() argument
1965 down_read(&fc->killsb); in fuse_notify_retrieve()
1969 inode = fuse_ilookup(fc, nodeid, &fm); in fuse_notify_retrieve()
1974 up_read(&fc->killsb); in fuse_notify_retrieve()
1992 static void fuse_resend(struct fuse_conn *fc) in fuse_resend() argument
1996 struct fuse_iqueue *fiq = &fc->iq; in fuse_resend()
2000 spin_lock(&fc->lock); in fuse_resend()
2001 if (!fc->connected) { in fuse_resend()
2002 spin_unlock(&fc->lock); in fuse_resend()
2006 list_for_each_entry(fud, &fc->devices, entry) { in fuse_resend()
2014 spin_unlock(&fc->lock); in fuse_resend()
2036 static int fuse_notify_resend(struct fuse_conn *fc) in fuse_notify_resend() argument
2038 fuse_resend(fc); in fuse_notify_resend()
2047 static int fuse_notify_inc_epoch(struct fuse_conn *fc) in fuse_notify_inc_epoch() argument
2049 atomic_inc(&fc->epoch); in fuse_notify_inc_epoch()
2051 schedule_work(&fc->epoch_work); in fuse_notify_inc_epoch()
2056 static int fuse_notify_prune(struct fuse_conn *fc, unsigned int size, in fuse_notify_prune() argument
2084 scoped_guard(rwsem_read, &fc->killsb) { in fuse_notify_prune()
2086 fuse_try_prune_one_inode(fc, nodeids[i]); in fuse_notify_prune()
2092 static int fuse_notify(struct fuse_conn *fc, enum fuse_notify_code code, in fuse_notify() argument
2100 return fuse_notify_poll(fc, size, cs); in fuse_notify()
2103 return fuse_notify_inval_inode(fc, size, cs); in fuse_notify()
2106 return fuse_notify_inval_entry(fc, size, cs); in fuse_notify()
2109 return fuse_notify_store(fc, size, cs); in fuse_notify()
2112 return fuse_notify_retrieve(fc, size, cs); in fuse_notify()
2115 return fuse_notify_delete(fc, size, cs); in fuse_notify()
2118 return fuse_notify_resend(fc); in fuse_notify()
2121 return fuse_notify_inc_epoch(fc); in fuse_notify()
2124 return fuse_notify_prune(fc, size, cs); in fuse_notify()
2183 struct fuse_conn *fc = fud->fc; in fuse_dev_do_write() local
2205 err = fuse_notify(fc, oh.error, nbytes - sizeof(oh), cs); in fuse_dev_do_write()
2233 fc->no_interrupt = 1; in fuse_dev_do_write()
2393 fiq = &fud->fc->iq; in fuse_dev_poll()
2419 static void end_polls(struct fuse_conn *fc) in end_polls() argument
2423 p = rb_first(&fc->polled_files); in end_polls()
2452 void fuse_abort_conn(struct fuse_conn *fc) in fuse_abort_conn() argument
2454 struct fuse_iqueue *fiq = &fc->iq; in fuse_abort_conn()
2456 spin_lock(&fc->lock); in fuse_abort_conn()
2457 if (fc->connected) { in fuse_abort_conn()
2463 if (fc->timeout.req_timeout) in fuse_abort_conn()
2464 cancel_delayed_work(&fc->timeout.work); in fuse_abort_conn()
2467 spin_lock(&fc->bg_lock); in fuse_abort_conn()
2468 fc->connected = 0; in fuse_abort_conn()
2469 spin_unlock(&fc->bg_lock); in fuse_abort_conn()
2471 fuse_set_initialized(fc); in fuse_abort_conn()
2472 list_for_each_entry(fud, &fc->devices, entry) { in fuse_abort_conn()
2493 spin_lock(&fc->bg_lock); in fuse_abort_conn()
2494 fc->blocked = 0; in fuse_abort_conn()
2495 fc->max_background = UINT_MAX; in fuse_abort_conn()
2496 flush_bg_queue(fc); in fuse_abort_conn()
2497 spin_unlock(&fc->bg_lock); in fuse_abort_conn()
2509 end_polls(fc); in fuse_abort_conn()
2510 wake_up_all(&fc->blocked_waitq); in fuse_abort_conn()
2511 spin_unlock(&fc->lock); in fuse_abort_conn()
2519 fuse_uring_abort(fc); in fuse_abort_conn()
2521 spin_unlock(&fc->lock); in fuse_abort_conn()
2526 void fuse_wait_aborted(struct fuse_conn *fc) in fuse_wait_aborted() argument
2530 wait_event(fc->blocked_waitq, atomic_read(&fc->num_waiting) == 0); in fuse_wait_aborted()
2532 fuse_uring_wait_stopped_queues(fc); in fuse_wait_aborted()
2540 struct fuse_conn *fc = fud->fc; in fuse_dev_release() local
2554 if (atomic_dec_and_test(&fc->dev_count)) { in fuse_dev_release()
2555 WARN_ON(fc->iq.fasync != NULL); in fuse_dev_release()
2556 fuse_abort_conn(fc); in fuse_dev_release()
2572 return fasync_helper(fd, file, on, &fud->fc->iq.fasync); in fuse_dev_fasync()
2575 static int fuse_device_clone(struct fuse_conn *fc, struct file *new) in fuse_device_clone() argument
2582 fud = fuse_dev_alloc_install(fc); in fuse_device_clone()
2587 atomic_inc(&fc->dev_count); in fuse_device_clone()
2615 res = fuse_device_clone(fud->fc, file); in fuse_dev_ioctl_clone()
2637 return fuse_backing_open(fud->fc, &map); in fuse_dev_ioctl_backing_open()
2654 return fuse_backing_close(fud->fc, backing_id); in fuse_dev_ioctl_backing_close()
2700 seq_printf(seq, "fuse_connection:\t%u\n", fud->fc->dev); in fuse_dev_show_fdinfo()