Lines Matching +full:mem +full:- +full:base
1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 2007-2009 Google Inc. and Amit Singh
141 struct fuse_data *data = tick->tk_data; in fuse_interrupt_callback()
144 fii = (struct fuse_interrupt_in*)((char*)tick->tk_ms_fiov.base + in fuse_interrupt_callback()
147 fuse_lck_mtx_lock(data->aw_mtx); in fuse_interrupt_callback()
148 TAILQ_FOREACH_SAFE(otick, &data->aw_head, tk_aw_link, x_tick) { in fuse_interrupt_callback()
149 if (otick->tk_unique == fii->unique) { in fuse_interrupt_callback()
154 fuse_lck_mtx_unlock(data->aw_mtx); in fuse_interrupt_callback()
162 otick->irq_unique = 0; in fuse_interrupt_callback()
164 if (tick->tk_aw_ohead.error == ENOSYS) { in fuse_interrupt_callback()
165 fsess_set_notimpl(data->mp, FUSE_INTERRUPT); in fuse_interrupt_callback()
167 } else if (tick->tk_aw_ohead.error == EAGAIN) { in fuse_interrupt_callback()
174 * In the first case we should re-send the INTERRUPT. In the in fuse_interrupt_callback()
193 struct fuse_data *data = otick->tk_data; in fuse_interrupt_send()
198 if (otick->irq_unique == 0) { in fuse_interrupt_send()
203 fuse_lck_mtx_lock(data->ms_mtx); in fuse_interrupt_send()
204 STAILQ_FOREACH_SAFE(tick, &otick->tk_data->ms_head, tk_ms_link, in fuse_interrupt_send()
207 STAILQ_REMOVE(&otick->tk_data->ms_head, tick, in fuse_interrupt_send()
209 otick->tk_data->ms_count--; in fuse_interrupt_send()
210 otick->tk_ms_link.stqe_next = NULL; in fuse_interrupt_send()
211 fuse_lck_mtx_unlock(data->ms_mtx); in fuse_interrupt_send()
213 fuse_lck_mtx_lock(otick->tk_aw_mtx); in fuse_interrupt_send()
216 otick->tk_aw_errno = err; in fuse_interrupt_send()
219 fuse_lck_mtx_unlock(otick->tk_aw_mtx); in fuse_interrupt_send()
225 fuse_lck_mtx_unlock(data->ms_mtx); in fuse_interrupt_send()
231 if (fsess_not_impl(data->mp, FUSE_INTERRUPT)) in fuse_interrupt_send()
239 reused_creds.cr_uid = ftick_hdr->uid; in fuse_interrupt_send()
240 reused_groups[0] = ftick_hdr->gid; in fuse_interrupt_send()
243 fdisp_make_pid(&fdi, FUSE_INTERRUPT, data, ftick_hdr->nodeid, in fuse_interrupt_send()
244 ftick_hdr->pid, &reused_creds); in fuse_interrupt_send()
247 fii->unique = otick->tk_unique; in fuse_interrupt_send()
250 otick->irq_unique = fdi.tick->tk_unique; in fuse_interrupt_send()
264 fiov->len = 0; in fiov_init()
266 fiov->base = malloc(msize, M_FUSEMSG, M_WAITOK | M_ZERO); in fiov_init()
268 fiov->allocated_size = msize; in fiov_init()
269 fiov->credit = fuse_iov_credit; in fiov_init()
275 MPASS(fiov->base != NULL); in fiov_teardown()
276 free(fiov->base, M_FUSEMSG); in fiov_teardown()
282 if (fiov->allocated_size < size || in fiov_adjust()
284 fiov->allocated_size - size > fuse_iov_permanent_bufsize && in fiov_adjust()
285 --fiov->credit < 0)) { in fiov_adjust()
286 fiov->base = realloc(fiov->base, FU_AT_LEAST(size), M_FUSEMSG, in fiov_adjust()
288 if (!fiov->base) { in fiov_adjust()
291 fiov->allocated_size = FU_AT_LEAST(size); in fiov_adjust()
292 fiov->credit = fuse_iov_credit; in fiov_adjust()
294 bzero(fiov->base, size); in fiov_adjust()
295 } else if (size > fiov->len) { in fiov_adjust()
297 bzero((char*)fiov->base + fiov->len, size - fiov->len); in fiov_adjust()
299 fiov->len = size; in fiov_adjust()
310 fticket_ctor(void *mem, int size, void *arg, int flags) in fticket_ctor() argument
312 struct fuse_ticket *ftick = mem; in fticket_ctor()
318 ftick->tk_data = data; in fticket_ctor()
319 ftick->irq_unique = 0; in fticket_ctor()
320 refcount_init(&ftick->tk_refcount, 1); in fticket_ctor()
329 fticket_dtor(void *mem, int size, void *arg) in fticket_dtor() argument
332 struct fuse_ticket *ftick = mem; in fticket_dtor()
338 counter_u64_add(fuse_ticket_count, -1); in fticket_dtor()
342 fticket_init(void *mem, int size, int flags) in fticket_init() argument
344 struct fuse_ticket *ftick = mem; in fticket_init()
348 fiov_init(&ftick->tk_ms_fiov, sizeof(struct fuse_in_header)); in fticket_init()
350 mtx_init(&ftick->tk_aw_mtx, "fuse answer delivery mutex", NULL, MTX_DEF); in fticket_init()
351 fiov_init(&ftick->tk_aw_fiov, 0); in fticket_init()
357 fticket_fini(void *mem, int size) in fticket_fini() argument
359 struct fuse_ticket *ftick = mem; in fticket_fini()
361 fiov_teardown(&ftick->tk_ms_fiov); in fticket_fini()
362 fiov_teardown(&ftick->tk_aw_fiov); in fticket_fini()
363 mtx_destroy(&ftick->tk_aw_mtx); in fticket_fini()
384 fiov_refresh(&ftick->tk_ms_fiov); in fticket_refresh()
385 fiov_refresh(&ftick->tk_aw_fiov); in fticket_refresh()
392 struct fuse_data *data = ftick->tk_data; in fticket_reset()
397 bzero(&ftick->tk_aw_ohead, sizeof(struct fuse_out_header)); in fticket_reset()
399 ftick->tk_aw_errno = 0; in fticket_reset()
400 ftick->tk_flag = 0; in fticket_reset()
403 ftick->tk_unique = atomic_fetchadd_long(&data->ticketer, 1); in fticket_reset()
404 if (ftick->tk_unique == 0) in fticket_reset()
405 ftick->tk_unique = atomic_fetchadd_long(&data->ticketer, 1); in fticket_reset()
414 struct fuse_data *data = ftick->tk_data; in fticket_wait_answer()
417 if (fsess_maybe_impl(ftick->tk_data->mp, FUSE_INTERRUPT) && in fticket_wait_answer()
418 data->dataflags & FSESS_INTR) { in fticket_wait_answer()
427 fuse_lck_mtx_lock(ftick->tk_aw_mtx); in fticket_wait_answer()
440 err = msleep(ftick, &ftick->tk_aw_mtx, PCATCH, "fu_ans", in fticket_wait_answer()
441 data->daemon_timeout * hz); in fticket_wait_answer()
469 fuse_lck_mtx_unlock(ftick->tk_aw_mtx); in fticket_wait_answer()
472 PROC_LOCK(td->td_proc); in fticket_wait_answer()
473 mtx_lock(&td->td_proc->p_sigacts->ps_mtx); in fticket_wait_answer()
474 tmpset = td->td_proc->p_siglist; in fticket_wait_answer()
475 SIGSETOR(tmpset, td->td_siglist); in fticket_wait_answer()
476 mtx_unlock(&td->td_proc->p_sigacts->ps_mtx); in fticket_wait_answer()
477 PROC_UNLOCK(td->td_proc); in fticket_wait_answer()
479 fuse_lck_mtx_lock(ftick->tk_aw_mtx); in fticket_wait_answer()
509 fuse_lck_mtx_unlock(ftick->tk_aw_mtx); in fticket_wait_answer()
524 err = uiomove(fticket_resp(ftick)->base, len, uio); in fticket_aw_pull_uio()
534 if (ftick->tk_aw_ohead.error) { in fticket_pull()
551 data->fdev = fdev; in fdata_alloc()
552 mtx_init(&data->ms_mtx, "fuse message list mutex", NULL, MTX_DEF); in fdata_alloc()
553 STAILQ_INIT(&data->ms_head); in fdata_alloc()
554 data->ms_count = 0; in fdata_alloc()
555 knlist_init_mtx(&data->ks_rsel.si_note, &data->ms_mtx); in fdata_alloc()
556 mtx_init(&data->aw_mtx, "fuse answer list mutex", NULL, MTX_DEF); in fdata_alloc()
557 TAILQ_INIT(&data->aw_head); in fdata_alloc()
558 data->daemoncred = crhold(cred); in fdata_alloc()
559 data->daemon_timeout = FUSE_DEFAULT_DAEMON_TIMEOUT; in fdata_alloc()
560 sx_init(&data->rename_lock, "fuse rename lock"); in fdata_alloc()
561 data->ref = 1; in fdata_alloc()
569 data->ref--; in fdata_trydestroy()
570 MPASS(data->ref >= 0); in fdata_trydestroy()
571 if (data->ref != 0) in fdata_trydestroy()
575 sx_destroy(&data->rename_lock); in fdata_trydestroy()
576 crfree(data->daemoncred); in fdata_trydestroy()
577 mtx_destroy(&data->aw_mtx); in fdata_trydestroy()
578 knlist_delete(&data->ks_rsel.si_note, curthread, 0); in fdata_trydestroy()
579 knlist_destroy(&data->ks_rsel.si_note); in fdata_trydestroy()
580 mtx_destroy(&data->ms_mtx); in fdata_trydestroy()
593 fuse_lck_mtx_lock(data->ms_mtx); in fdata_set_dead()
594 data->dataflags |= FSESS_DEAD; in fdata_set_dead()
596 selwakeuppri(&data->ks_rsel, PZERO + 1); in fdata_set_dead()
597 wakeup(&data->ticketer); in fdata_set_dead()
598 fuse_lck_mtx_unlock(data->ms_mtx); in fdata_set_dead()
610 if (!(data->dataflags & FSESS_INITED)) { in fuse_ticket_fetch()
613 if (!(data->dataflags & FSESS_INITED) && data->ticketer > 2) { in fuse_ticket_fetch()
614 err = msleep(&data->ticketer, &fuse_mtx, PCATCH | PDROP, in fuse_ticket_fetch()
629 die = refcount_release(&ftick->tk_refcount); in fuse_ticket_drop()
639 if (fdata_get_dead(ftick->tk_data)) { in fuse_insert_callback()
642 ftick->tk_aw_handler = handler; in fuse_insert_callback()
644 fuse_lck_mtx_lock(ftick->tk_data->aw_mtx); in fuse_insert_callback()
646 fuse_lck_mtx_unlock(ftick->tk_data->aw_mtx); in fuse_insert_callback()
658 if (ftick->tk_flag & FT_DIRTY) { in fuse_insert_message()
661 ftick->tk_flag |= FT_DIRTY; in fuse_insert_message()
663 if (fdata_get_dead(ftick->tk_data)) { in fuse_insert_message()
666 fuse_lck_mtx_lock(ftick->tk_data->ms_mtx); in fuse_insert_message()
671 wakeup_one(ftick->tk_data); in fuse_insert_message()
672 selwakeuppri(&ftick->tk_data->ks_rsel, PZERO + 1); in fuse_insert_message()
673 KNOTE_LOCKED(&ftick->tk_data->ks_rsel.si_note, 0); in fuse_insert_message()
674 fuse_lck_mtx_unlock(ftick->tk_data->ms_mtx); in fuse_insert_message()
695 if (fuse_libabi_geq(ftick->tk_data, 7, 9)) { in fuse_body_audit()
709 if (fuse_libabi_geq(ftick->tk_data, 7, 9)) { in fuse_body_audit()
739 (char *)ftick->tk_ms_fiov.base + in fuse_body_audit()
741 ))->size >= blen) ? 0 : EINVAL; in fuse_body_audit()
749 if (fuse_libabi_geq(ftick->tk_data, 7, 4)) { in fuse_body_audit()
802 (char *)ftick->tk_ms_fiov.base + in fuse_body_audit()
804 ))->size >= blen) ? 0 : EINVAL; in fuse_body_audit()
832 if (fuse_libabi_geq(ftick->tk_data, 7, 9)) { in fuse_body_audit()
869 ihead->len = sizeof(*ihead) + blen; in fuse_setup_ihead()
870 ihead->unique = ftick->tk_unique; in fuse_setup_ihead()
871 ihead->nodeid = nid; in fuse_setup_ihead()
872 ihead->opcode = op; in fuse_setup_ihead()
874 ihead->pid = pid; in fuse_setup_ihead()
875 ihead->uid = cred->cr_uid; in fuse_setup_ihead()
876 ihead->gid = cred->cr_groups[0]; in fuse_setup_ihead()
882 * Though might do a basic size verification before the pull-in takes place
892 fuse_lck_mtx_lock(ftick->tk_aw_mtx); in fuse_standard_handler()
896 ftick->tk_aw_errno = err; in fuse_standard_handler()
899 fuse_lck_mtx_unlock(ftick->tk_aw_mtx); in fuse_standard_handler()
912 MPASS(fdip->tick); in fdisp_refresh_pid()
913 MPASS2(sizeof(fdip->finh) + fdip->iosize <= fdip->tick->tk_ms_fiov.len, in fdisp_refresh_pid()
915 fticket_reset(fdip->tick); in fdisp_refresh_pid()
917 FUSE_DIMALLOC(&fdip->tick->tk_ms_fiov, fdip->finh, in fdisp_refresh_pid()
918 fdip->indata, fdip->iosize); in fdisp_refresh_pid()
920 fuse_setup_ihead(fdip->finh, fdip->tick, nid, op, fdip->iosize, pid, in fdisp_refresh_pid()
929 if (fdip->tick) { in fdisp_make_pid()
930 fticket_refresh(fdip->tick); in fdisp_make_pid()
932 fdip->tick = fuse_ticket_fetch(data); in fdisp_make_pid()
936 FUSE_DIMALLOC(&fdip->tick->tk_ms_fiov, fdip->finh, in fdisp_make_pid()
937 fdip->indata, fdip->iosize); in fdisp_make_pid()
939 fuse_setup_ihead(fdip->finh, fdip->tick, nid, op, fdip->iosize, pid, cred); in fdisp_make_pid()
949 return fdisp_make_pid(fdip, op, data, nid, td->td_proc->p_pid, cred); in fdisp_make()
961 td->td_proc->p_pid, cred); in fdisp_make_vp()
971 td->td_proc->p_pid, cred); in fdisp_refresh_vp()
981 fdip->answ_stat = 0; in fdisp_wait_answ()
982 fuse_insert_callback(fdip->tick, fuse_standard_handler); in fdisp_wait_answ()
983 fuse_insert_message(fdip->tick, false); in fdisp_wait_answ()
985 if ((err = fticket_wait_answer(fdip->tick))) { in fdisp_wait_answ()
986 fuse_lck_mtx_lock(fdip->tick->tk_aw_mtx); in fdisp_wait_answ()
988 if (fticket_answered(fdip->tick)) { in fdisp_wait_answ()
996 fuse_lck_mtx_unlock(fdip->tick->tk_aw_mtx); in fdisp_wait_answ()
1006 fticket_set_answered(fdip->tick); in fdisp_wait_answ()
1007 fuse_lck_mtx_unlock(fdip->tick->tk_aw_mtx); in fdisp_wait_answ()
1012 if (fdip->tick->tk_aw_errno == ENOTCONN) { in fdisp_wait_answ()
1016 } else if (fdip->tick->tk_aw_errno) { in fdisp_wait_answ()
1022 "IPC: explicit EIO-ing", fdip->tick->tk_aw_errno); in fdisp_wait_answ()
1026 if ((err = fdip->tick->tk_aw_ohead.error)) { in fdisp_wait_answ()
1028 "IPC: setting status", fdip->tick->tk_aw_ohead.error); in fdisp_wait_answ()
1038 fdip->answ_stat = err; in fdisp_wait_answ()
1041 fdip->answ = fticket_resp(fdip->tick)->base; in fdisp_wait_answ()
1042 fdip->iosize = fticket_resp(fdip->tick)->len; in fdisp_wait_answ()
1071 if (!(data->dataflags & flag)) { in fuse_warn()
1075 data->mp->mnt_stat.f_mntonname, msg); in fuse_warn()
1076 data->dataflags |= flag; in fuse_warn()