Lines Matching full:fc

70 void fuse_set_initialized(struct fuse_conn *fc)  in fuse_set_initialized()  argument
74 fc->initialized = 1; in fuse_set_initialized()
77 static bool fuse_block_alloc(struct fuse_conn *fc, bool for_background) in fuse_block_alloc() argument
79 return !fc->initialized || (for_background && fc->blocked) || in fuse_block_alloc()
80 (fc->io_uring && fc->connected && !fuse_uring_ready(fc)); in fuse_block_alloc()
83 static void fuse_drop_waiting(struct fuse_conn *fc) in fuse_drop_waiting() argument
86 * lockess check of fc->connected is okay, because atomic_dec_and_test() in fuse_drop_waiting()
90 if (atomic_dec_and_test(&fc->num_waiting) && in fuse_drop_waiting()
91 !READ_ONCE(fc->connected)) { in fuse_drop_waiting()
93 wake_up_all(&fc->blocked_waitq); in fuse_drop_waiting()
103 struct fuse_conn *fc = fm->fc; in fuse_get_req() local
110 atomic_inc(&fc->num_waiting); in fuse_get_req()
112 if (fuse_block_alloc(fc, for_background)) { in fuse_get_req()
114 if (wait_event_killable_exclusive(fc->blocked_waitq, in fuse_get_req()
115 !fuse_block_alloc(fc, for_background))) in fuse_get_req()
122 if (!fc->connected) in fuse_get_req()
126 if (fc->conn_error) in fuse_get_req()
133 wake_up(&fc->blocked_waitq); in fuse_get_req()
137 req->in.h.pid = pid_nr_ns(task_pid(current), fc->pid_ns); in fuse_get_req()
152 fsuid = no_idmap ? current_fsuid() : mapped_fsuid(idmap, fc->user_ns); in fuse_get_req()
153 fsgid = no_idmap ? current_fsgid() : mapped_fsgid(idmap, fc->user_ns); in fuse_get_req()
154 req->in.h.uid = from_kuid(fc->user_ns, fsuid); in fuse_get_req()
155 req->in.h.gid = from_kgid(fc->user_ns, fsgid); in fuse_get_req()
166 fuse_drop_waiting(fc); in fuse_get_req()
172 struct fuse_conn *fc = req->fm->fc; in fuse_put_request() local
180 spin_lock(&fc->bg_lock); in fuse_put_request()
181 if (!fc->blocked) in fuse_put_request()
182 wake_up(&fc->blocked_waitq); in fuse_put_request()
183 spin_unlock(&fc->bg_lock); in fuse_put_request()
188 fuse_drop_waiting(fc); in fuse_put_request()
308 void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget, in fuse_queue_forget() argument
311 struct fuse_iqueue *fiq = &fc->iq; in fuse_queue_forget()
319 static void flush_bg_queue(struct fuse_conn *fc) in flush_bg_queue() argument
321 struct fuse_iqueue *fiq = &fc->iq; in flush_bg_queue()
323 while (fc->active_background < fc->max_background && in flush_bg_queue()
324 !list_empty(&fc->bg_queue)) { in flush_bg_queue()
327 req = list_first_entry(&fc->bg_queue, struct fuse_req, list); in flush_bg_queue()
329 fc->active_background++; in flush_bg_queue()
345 struct fuse_conn *fc = fm->fc; in fuse_request_end() local
346 struct fuse_iqueue *fiq = &fc->iq; in fuse_request_end()
365 spin_lock(&fc->bg_lock); in fuse_request_end()
367 if (fc->num_background == fc->max_background) { in fuse_request_end()
368 fc->blocked = 0; in fuse_request_end()
369 wake_up(&fc->blocked_waitq); in fuse_request_end()
370 } else if (!fc->blocked) { in fuse_request_end()
374 * fc->blocked with waiters with the wake_up() call in fuse_request_end()
377 if (waitqueue_active(&fc->blocked_waitq)) in fuse_request_end()
378 wake_up(&fc->blocked_waitq); in fuse_request_end()
381 fc->num_background--; in fuse_request_end()
382 fc->active_background--; in fuse_request_end()
383 flush_bg_queue(fc); in fuse_request_end()
384 spin_unlock(&fc->bg_lock); in fuse_request_end()
399 struct fuse_iqueue *fiq = &req->fm->fc->iq; in queue_interrupt()
430 struct fuse_conn *fc = req->fm->fc; in request_wait_answer() local
431 struct fuse_iqueue *fiq = &fc->iq; in request_wait_answer()
434 if (!fc->no_interrupt) { in request_wait_answer()
474 struct fuse_iqueue *fiq = &req->fm->fc->iq; in __fuse_request_send()
488 static void fuse_adjust_compat(struct fuse_conn *fc, struct fuse_args *args) in fuse_adjust_compat() argument
490 if (fc->minor < 4 && args->opcode == FUSE_STATFS) in fuse_adjust_compat()
493 if (fc->minor < 9) { in fuse_adjust_compat()
509 if (fc->minor < 12) { in fuse_adjust_compat()
523 struct fuse_conn *fc = req->fm->fc; in fuse_force_creds() local
526 req->in.h.uid = from_kuid_munged(fc->user_ns, current_fsuid()); in fuse_force_creds()
527 req->in.h.gid = from_kgid_munged(fc->user_ns, current_fsgid()); in fuse_force_creds()
533 req->in.h.pid = pid_nr_ns(task_pid(current), fc->pid_ns); in fuse_force_creds()
551 struct fuse_conn *fc = fm->fc; in __fuse_simple_request() local
556 atomic_inc(&fc->num_waiting); in __fuse_simple_request()
571 /* Needs to be done after fuse_get_req() so that fc->minor is valid */ in __fuse_simple_request()
572 fuse_adjust_compat(fc, args); in __fuse_simple_request()
589 static bool fuse_request_queue_background_uring(struct fuse_conn *fc, in fuse_request_queue_background_uring() argument
592 struct fuse_iqueue *fiq = &fc->iq; in fuse_request_queue_background_uring()
609 struct fuse_conn *fc = fm->fc; in fuse_request_queue_background() local
615 atomic_inc(&fc->num_waiting); in fuse_request_queue_background()
620 if (fuse_uring_ready(fc)) in fuse_request_queue_background()
621 return fuse_request_queue_background_uring(fc, req); in fuse_request_queue_background()
624 spin_lock(&fc->bg_lock); in fuse_request_queue_background()
625 if (likely(fc->connected)) { in fuse_request_queue_background()
626 fc->num_background++; in fuse_request_queue_background()
627 if (fc->num_background == fc->max_background) in fuse_request_queue_background()
628 fc->blocked = 1; in fuse_request_queue_background()
629 list_add_tail(&req->list, &fc->bg_queue); in fuse_request_queue_background()
630 flush_bg_queue(fc); in fuse_request_queue_background()
633 spin_unlock(&fc->bg_lock); in fuse_request_queue_background()
671 struct fuse_iqueue *fiq = &fm->fc->iq; in fuse_simple_notify_reply()
1265 static int fuse_read_forget(struct fuse_conn *fc, struct fuse_iqueue *fiq, in fuse_read_forget() argument
1270 if (fc->minor < 16 || fiq->forget_list_head.next->next == NULL) in fuse_read_forget()
1289 struct fuse_conn *fc = fud->fc; in fuse_dev_do_read() local
1290 struct fuse_iqueue *fiq = &fc->iq; in fuse_dev_do_read()
1312 fc->max_write)) in fuse_dev_do_read()
1331 err = fc->aborted ? -ECONNABORTED : -ENODEV; in fuse_dev_do_read()
1343 return fuse_read_forget(fc, fiq, cs, nbytes); in fuse_dev_do_read()
1387 err = fc->aborted ? -ECONNABORTED : -ENODEV; in fuse_dev_do_read()
1502 static int fuse_notify_poll(struct fuse_conn *fc, unsigned int size, in fuse_notify_poll() argument
1516 return fuse_notify_poll_wakeup(fc, &outarg); in fuse_notify_poll()
1523 static int fuse_notify_inval_inode(struct fuse_conn *fc, unsigned int size, in fuse_notify_inval_inode() argument
1537 down_read(&fc->killsb); in fuse_notify_inval_inode()
1538 err = fuse_reverse_inval_inode(fc, outarg.ino, in fuse_notify_inval_inode()
1540 up_read(&fc->killsb); in fuse_notify_inval_inode()
1548 static int fuse_notify_inval_entry(struct fuse_conn *fc, unsigned int size, in fuse_notify_inval_entry() argument
1584 down_read(&fc->killsb); in fuse_notify_inval_entry()
1585 err = fuse_reverse_inval_entry(fc, outarg.parent, 0, &name, outarg.flags); in fuse_notify_inval_entry()
1586 up_read(&fc->killsb); in fuse_notify_inval_entry()
1596 static int fuse_notify_delete(struct fuse_conn *fc, unsigned int size, in fuse_notify_delete() argument
1632 down_read(&fc->killsb); in fuse_notify_delete()
1633 err = fuse_reverse_inval_entry(fc, outarg.parent, outarg.child, &name, 0); in fuse_notify_delete()
1634 up_read(&fc->killsb); in fuse_notify_delete()
1644 static int fuse_notify_store(struct fuse_conn *fc, unsigned int size, in fuse_notify_store() argument
1672 down_read(&fc->killsb); in fuse_notify_store()
1675 inode = fuse_ilookup(fc, nodeid, NULL); in fuse_notify_store()
1724 up_read(&fc->killsb); in fuse_notify_store()
1756 struct fuse_conn *fc = fm->fc; in fuse_retrieve() local
1765 num = min(outarg->size, fc->max_write); in fuse_retrieve()
1772 num_pages = min(num_pages, fc->max_pages); in fuse_retrieve()
1827 static int fuse_notify_retrieve(struct fuse_conn *fc, unsigned int size, in fuse_notify_retrieve() argument
1846 down_read(&fc->killsb); in fuse_notify_retrieve()
1850 inode = fuse_ilookup(fc, nodeid, &fm); in fuse_notify_retrieve()
1855 up_read(&fc->killsb); in fuse_notify_retrieve()
1877 static void fuse_resend(struct fuse_conn *fc) in fuse_resend() argument
1881 struct fuse_iqueue *fiq = &fc->iq; in fuse_resend()
1885 spin_lock(&fc->lock); in fuse_resend()
1886 if (!fc->connected) { in fuse_resend()
1887 spin_unlock(&fc->lock); in fuse_resend()
1891 list_for_each_entry(fud, &fc->devices, entry) { in fuse_resend()
1899 spin_unlock(&fc->lock); in fuse_resend()
1921 static int fuse_notify_resend(struct fuse_conn *fc) in fuse_notify_resend() argument
1923 fuse_resend(fc); in fuse_notify_resend()
1927 static int fuse_notify(struct fuse_conn *fc, enum fuse_notify_code code, in fuse_notify() argument
1935 return fuse_notify_poll(fc, size, cs); in fuse_notify()
1938 return fuse_notify_inval_inode(fc, size, cs); in fuse_notify()
1941 return fuse_notify_inval_entry(fc, size, cs); in fuse_notify()
1944 return fuse_notify_store(fc, size, cs); in fuse_notify()
1947 return fuse_notify_retrieve(fc, size, cs); in fuse_notify()
1950 return fuse_notify_delete(fc, size, cs); in fuse_notify()
1953 return fuse_notify_resend(fc); in fuse_notify()
2013 struct fuse_conn *fc = fud->fc; in fuse_dev_do_write() local
2035 err = fuse_notify(fc, oh.error, nbytes - sizeof(oh), cs); in fuse_dev_do_write()
2063 fc->no_interrupt = 1; in fuse_dev_do_write()
2224 fiq = &fud->fc->iq; in fuse_dev_poll()
2250 static void end_polls(struct fuse_conn *fc) in end_polls() argument
2254 p = rb_first(&fc->polled_files); in end_polls()
2283 void fuse_abort_conn(struct fuse_conn *fc) in fuse_abort_conn() argument
2285 struct fuse_iqueue *fiq = &fc->iq; in fuse_abort_conn()
2287 spin_lock(&fc->lock); in fuse_abort_conn()
2288 if (fc->connected) { in fuse_abort_conn()
2294 /* Background queuing checks fc->connected under bg_lock */ in fuse_abort_conn()
2295 spin_lock(&fc->bg_lock); in fuse_abort_conn()
2296 fc->connected = 0; in fuse_abort_conn()
2297 spin_unlock(&fc->bg_lock); in fuse_abort_conn()
2299 fuse_set_initialized(fc); in fuse_abort_conn()
2300 list_for_each_entry(fud, &fc->devices, entry) { in fuse_abort_conn()
2321 spin_lock(&fc->bg_lock); in fuse_abort_conn()
2322 fc->blocked = 0; in fuse_abort_conn()
2323 fc->max_background = UINT_MAX; in fuse_abort_conn()
2324 flush_bg_queue(fc); in fuse_abort_conn()
2325 spin_unlock(&fc->bg_lock); in fuse_abort_conn()
2337 end_polls(fc); in fuse_abort_conn()
2338 wake_up_all(&fc->blocked_waitq); in fuse_abort_conn()
2339 spin_unlock(&fc->lock); in fuse_abort_conn()
2344 * fc->lock must not be taken to avoid conflicts with io-uring in fuse_abort_conn()
2347 fuse_uring_abort(fc); in fuse_abort_conn()
2349 spin_unlock(&fc->lock); in fuse_abort_conn()
2354 void fuse_wait_aborted(struct fuse_conn *fc) in fuse_wait_aborted() argument
2358 wait_event(fc->blocked_waitq, atomic_read(&fc->num_waiting) == 0); in fuse_wait_aborted()
2360 fuse_uring_wait_stopped_queues(fc); in fuse_wait_aborted()
2368 struct fuse_conn *fc = fud->fc; in fuse_dev_release() local
2382 if (atomic_dec_and_test(&fc->dev_count)) { in fuse_dev_release()
2383 WARN_ON(fc->iq.fasync != NULL); in fuse_dev_release()
2384 fuse_abort_conn(fc); in fuse_dev_release()
2400 return fasync_helper(fd, file, on, &fud->fc->iq.fasync); in fuse_dev_fasync()
2403 static int fuse_device_clone(struct fuse_conn *fc, struct file *new) in fuse_device_clone() argument
2410 fud = fuse_dev_alloc_install(fc); in fuse_device_clone()
2415 atomic_inc(&fc->dev_count); in fuse_device_clone()
2443 res = fuse_device_clone(fud->fc, file); in fuse_dev_ioctl_clone()
2465 return fuse_backing_open(fud->fc, &map); in fuse_dev_ioctl_backing_open()
2482 return fuse_backing_close(fud->fc, backing_id); in fuse_dev_ioctl_backing_close()