Lines Matching +full:device +full:- +full:unique

1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 2007-2009 Google Inc.
99 SDT_PROBE_DEFINE2(fusefs, , device, trace, "int", "char*");
136 * >>> Fuse device op defs
153 fuse_lck_mtx_lock(fdata->aw_mtx); in fdata_dtor()
155 selwakeuppri(&fdata->ks_rsel, PZERO + 1); in fdata_dtor()
158 fuse_lck_mtx_lock(tick->tk_aw_mtx); in fdata_dtor()
160 tick->tk_aw_errno = ENOTCONN; in fdata_dtor()
162 fuse_lck_mtx_unlock(tick->tk_aw_mtx); in fdata_dtor()
166 fuse_lck_mtx_unlock(fdata->aw_mtx); in fdata_dtor()
169 fuse_lck_mtx_lock(fdata->ms_mtx); in fdata_dtor()
173 fuse_lck_mtx_unlock(fdata->ms_mtx); in fdata_dtor()
187 if (error == 0 && kn->kn_filter == EVFILT_READ) { in fuse_device_filter()
188 kn->kn_fop = &fuse_device_rfiltops; in fuse_device_filter()
189 kn->kn_hook = data; in fuse_device_filter()
190 knlist_add(&data->ks_rsel.si_note, kn, 0); in fuse_device_filter()
192 } else if (error == 0 && kn->kn_filter == EVFILT_WRITE) { in fuse_device_filter()
193 kn->kn_fop = &fuse_device_wfiltops; in fuse_device_filter()
197 kn->kn_data = error; in fuse_device_filter()
208 data = (struct fuse_data*)kn->kn_hook; in fuse_device_filt_detach()
210 knlist_remove(&data->ks_rsel.si_note, kn, 0); in fuse_device_filt_detach()
211 kn->kn_hook = NULL; in fuse_device_filt_detach()
220 data = (struct fuse_data*)kn->kn_hook; in fuse_device_filt_read()
223 mtx_assert(&data->ms_mtx, MA_OWNED); in fuse_device_filt_read()
225 kn->kn_flags |= EV_EOF; in fuse_device_filt_read()
226 kn->kn_fflags = ENODEV; in fuse_device_filt_read()
227 kn->kn_data = 1; in fuse_device_filt_read()
229 } else if (STAILQ_FIRST(&data->ms_head)) { in fuse_device_filt_read()
230 MPASS(data->ms_count >= 1); in fuse_device_filt_read()
231 kn->kn_data = data->ms_count; in fuse_device_filt_read()
244 kn->kn_data = 0; in fuse_device_filt_write()
246 /* The device is always ready to write, so we return 1*/ in fuse_device_filt_write()
251 * Resources are set up on a per-open basis
259 SDT_PROBE2(fusefs, , device, trace, 1, "device open"); in fuse_device_open()
261 fdata = fdata_alloc(dev, td->td_ucred); in fuse_device_open()
266 SDT_PROBE2(fusefs, , device, trace, 1, "device open success"); in fuse_device_open()
282 fuse_lck_mtx_lock(data->ms_mtx); in fuse_device_poll()
283 if (fdata_get_dead(data) || STAILQ_FIRST(&data->ms_head)) in fuse_device_poll()
286 selrecord(td, &data->ks_rsel); in fuse_device_poll()
287 fuse_lck_mtx_unlock(data->ms_mtx); in fuse_device_poll()
309 SDT_PROBE2(fusefs, , device, trace, 1, "fuse device read"); in fuse_device_read()
315 fuse_lck_mtx_lock(data->ms_mtx); in fuse_device_read()
318 SDT_PROBE2(fusefs, , device, trace, 2, in fuse_device_read()
321 fuse_lck_mtx_unlock(data->ms_mtx); in fuse_device_read()
328 fuse_lck_mtx_unlock(data->ms_mtx); in fuse_device_read()
331 err = msleep(data, &data->ms_mtx, PCATCH, "fu_msg", 0); in fuse_device_read()
333 fuse_lck_mtx_unlock(data->ms_mtx); in fuse_device_read()
343 * -- and some other cases, too, tho not totally clear, when in fuse_device_read()
346 SDT_PROBE2(fusefs, , device, trace, 1, "no message on thread"); in fuse_device_read()
349 fuse_lck_mtx_unlock(data->ms_mtx); in fuse_device_read()
353 * somebody somewhere -- eg., umount routine -- in fuse_device_read()
356 SDT_PROBE2(fusefs, , device, trace, 2, in fuse_device_read()
359 SDT_PROBE2(fusefs, , device, trace, 2, "weird -- " in fuse_device_read()
367 SDT_PROBE2(fusefs, , device, trace, 1, in fuse_device_read()
368 "fuse device read message successfully"); in fuse_device_read()
370 buf = tick->tk_ms_fiov.base; in fuse_device_read()
371 buflen = tick->tk_ms_fiov.len; in fuse_device_read()
384 if (uio->uio_resid < buflen) { in fuse_device_read()
386 SDT_PROBE2(fusefs, , device, trace, 2, in fuse_device_read()
402 if (uio->uio_resid + sizeof(struct fuse_out_header) != ohead->len) { in fuse_ohead_audit()
403 SDT_PROBE2(fusefs, , device, trace, 1, in fuse_ohead_audit()
408 if (uio->uio_resid && ohead->unique != 0 && ohead->error) { in fuse_ohead_audit()
409 SDT_PROBE2(fusefs, , device, trace, 1, in fuse_ohead_audit()
417 SDT_PROBE_DEFINE1(fusefs, , device, fuse_device_write_notify,
419 SDT_PROBE_DEFINE1(fusefs, , device, fuse_device_write_missing_ticket,
421 SDT_PROBE_DEFINE1(fusefs, , device, fuse_device_write_found,
425 * If that's OK, looks up ticket/callback node by the unique id seen in header.
443 if (uio->uio_resid < sizeof(struct fuse_out_header)) { in fuse_device_write()
444 SDT_PROBE2(fusefs, , device, trace, 1, in fuse_device_write()
452 if (data->linux_errnos != 0 && ohead.error != 0) { in fuse_device_write()
453 err = -ohead.error; in fuse_device_write()
457 /* '-', because it will get flipped again below */ in fuse_device_write()
458 ohead.error = -linux_to_bsd_errtbl[err]; in fuse_device_write()
466 * "unique" value in the header. in fuse_device_write()
474 /* Looking for ticket with the unique id of header */ in fuse_device_write()
475 fuse_lck_mtx_lock(data->aw_mtx); in fuse_device_write()
476 TAILQ_FOREACH_SAFE(tick, &data->aw_head, tk_aw_link, in fuse_device_write()
478 if (tick->tk_unique == ohead.unique) { in fuse_device_write()
479 SDT_PROBE1(fusefs, , device, fuse_device_write_found, in fuse_device_write()
486 if (found && tick->irq_unique > 0) { in fuse_device_write()
491 TAILQ_FOREACH_SAFE(itick, &data->aw_head, tk_aw_link, in fuse_device_write()
493 if (itick->tk_unique == tick->irq_unique) { in fuse_device_write()
499 tick->irq_unique = 0; in fuse_device_write()
501 fuse_lck_mtx_unlock(data->aw_mtx); in fuse_device_write()
504 if (tick->tk_aw_handler) { in fuse_device_write()
513 SDT_PROBE2(fusefs, , device, trace, 1, in fuse_device_write()
516 ohead.error *= -1; in fuse_device_write()
520 memcpy(&tick->tk_aw_ohead, &ohead, in fuse_device_write()
522 tick->tk_aw_handler(tick, uio); in fuse_device_write()
525 memcpy(&tick->tk_aw_ohead, &ohead, in fuse_device_write()
527 err = tick->tk_aw_handler(tick, uio); in fuse_device_write()
531 SDT_PROBE2(fusefs, , device, trace, 1, in fuse_device_write()
541 } else if (ohead.unique == 0){ in fuse_device_write()
542 /* unique == 0 means asynchronous notification */ in fuse_device_write()
543 SDT_PROBE1(fusefs, , device, fuse_device_write_notify, &ohead); in fuse_device_write()
544 mp = data->mp; in fuse_device_write()
578 SDT_PROBE1(fusefs, , device, fuse_device_write_missing_ticket, in fuse_device_write()
579 ohead.unique); in fuse_device_write()
580 if (ohead.error == -EAGAIN) { in fuse_device_write()