Lines Matching refs:pcs
188 static void cuse_server_wakeup_all_client_locked(struct cuse_server *pcs);
266 cuse_server_lock(struct cuse_server *pcs)
268 mtx_lock(&pcs->mtx);
272 cuse_server_unlock(struct cuse_server *pcs)
274 mtx_unlock(&pcs->mtx);
278 cuse_server_is_locked(struct cuse_server *pcs)
280 return (mtx_owned(&pcs->mtx));
340 struct cuse_server *pcs;
343 error = devfs_get_cdevpriv((void **)&pcs);
348 if (pcs->is_closing) {
352 *ppcs = pcs;
357 cuse_server_is_closing(struct cuse_server *pcs)
361 if (pcs->is_closing)
364 pcs->is_closing = 1;
366 TAILQ_FOREACH(pcc, &pcs->hcli, entry) {
372 cuse_server_find_command(struct cuse_server *pcs, struct thread *td)
377 if (pcs->is_closing)
380 TAILQ_FOREACH(pcc, &pcs->hcli, entry) {
457 cuse_server_alloc_memory(struct cuse_server *pcs, uint32_t alloc_nr,
474 cuse_server_lock(pcs);
476 TAILQ_FOREACH(temp, &pcs->hmem, entry) {
481 cuse_server_unlock(pcs);
488 TAILQ_INSERT_TAIL(&pcs->hmem, mem, entry);
489 cuse_server_unlock(pcs);
501 cuse_server_free_memory(struct cuse_server *pcs, uint32_t alloc_nr)
505 cuse_server_lock(pcs);
506 TAILQ_FOREACH(mem, &pcs->hmem, entry) {
511 cuse_server_unlock(pcs);
514 TAILQ_REMOVE(&pcs->hmem, mem, entry);
515 cuse_server_unlock(pcs);
570 struct cuse_server *pcs;
588 pcs = pccmd->client->server;
592 (pcs->is_closing == 0)) {
593 TAILQ_INSERT_TAIL(&pcs->head, pccmd, entry);
594 cv_signal(&pcs->cv);
601 struct cuse_server *pcs;
607 pcs = pccmd->client->server;
611 (pcs->is_closing == 0)) {
612 TAILQ_INSERT_TAIL(&pcs->head, pccmd, entry);
613 cv_signal(&pcs->cv);
621 struct cuse_server *pcs;
624 pcs = pccmd->client->server;
629 if (CUSE_CLIENT_CLOSING(pccmd->client) || pcs->is_closing) {
635 cv_wait(&pccmd->cv, &pcs->mtx);
637 error = cv_wait_sig(&pccmd->cv, &pcs->mtx);
642 if (CUSE_CLIENT_CLOSING(pccmd->client) || pcs->is_closing) {
659 cv_wait(&pccmd->cv, &pcs->mtx);
671 struct cuse_server *pcs;
675 pcs = pcsd->server;
678 cuse_server_lock(pcs);
682 TAILQ_FOREACH(pcc, &pcs->hcli, entry) {
686 cuse_server_unlock(pcs);
697 cuse_server_unref(struct cuse_server *pcs)
702 cuse_server_lock(pcs);
703 if (--(pcs->refs) != 0) {
704 cuse_server_unlock(pcs);
707 cuse_server_is_closing(pcs);
709 cuse_server_wakeup_all_client_locked(pcs);
712 TAILQ_REMOVE(&cuse_server_head, pcs, entry);
715 while ((pcsd = TAILQ_FIRST(&pcs->hdev)) != NULL) {
716 TAILQ_REMOVE(&pcs->hdev, pcsd, entry);
717 cuse_server_unlock(pcs);
719 cuse_server_lock(pcs);
722 cuse_free_unit_by_id_locked(pcs, -1);
724 while ((mem = TAILQ_FIRST(&pcs->hmem)) != NULL) {
725 TAILQ_REMOVE(&pcs->hmem, mem, entry);
726 cuse_server_unlock(pcs);
728 cuse_server_lock(pcs);
731 knlist_clear(&pcs->selinfo.si_note, 1);
732 knlist_destroy(&pcs->selinfo.si_note);
734 cuse_server_unlock(pcs);
736 seldrain(&pcs->selinfo);
738 cv_destroy(&pcs->cv);
740 mtx_destroy(&pcs->mtx);
742 free(pcs, M_CUSE);
746 cuse_server_do_close(struct cuse_server *pcs)
750 cuse_server_lock(pcs);
751 cuse_server_is_closing(pcs);
753 cuse_server_wakeup_all_client_locked(pcs);
755 knlist_clear(&pcs->selinfo.si_note, 1);
757 retval = pcs->refs;
758 cuse_server_unlock(pcs);
766 struct cuse_server *pcs = arg;
773 while (cuse_server_do_close(pcs) != 1)
777 cuse_server_unref(pcs);
783 struct cuse_server *pcs;
785 pcs = malloc(sizeof(*pcs), M_CUSE, M_WAITOK | M_ZERO);
787 if (devfs_set_cdevpriv(pcs, &cuse_server_free)) {
789 free(pcs, M_CUSE);
793 pcs->pid = curproc->p_pid;
795 TAILQ_INIT(&pcs->head);
796 TAILQ_INIT(&pcs->hdev);
797 TAILQ_INIT(&pcs->hcli);
798 TAILQ_INIT(&pcs->hmem);
800 cv_init(&pcs->cv, "cuse-server-cv");
802 mtx_init(&pcs->mtx, "cuse-server-mtx", NULL, MTX_DEF);
804 knlist_init_mtx(&pcs->selinfo.si_note, &pcs->mtx);
807 pcs->refs++;
808 TAILQ_INSERT_TAIL(&cuse_server_head, pcs, entry);
817 struct cuse_server *pcs;
819 if (cuse_server_get(&pcs) == 0)
820 cuse_server_do_close(pcs);
838 cuse_server_ioctl_copy_locked(struct cuse_server *pcs,
866 cuse_server_unlock(pcs);
880 cuse_server_lock(pcs);
945 cuse_server_data_copy_locked(struct cuse_server *pcs,
961 cuse_server_unlock(pcs);
975 cuse_server_lock(pcs);
986 cuse_server_data_copy_optimized_locked(struct cuse_server *pcs,
1003 cuse_server_unlock(pcs);
1014 cuse_server_unlock(pcs);
1022 error = cuse_server_data_copy_locked(pcs, pccmd, pchk, isread);
1028 cuse_alloc_unit_by_id_locked(struct cuse_server *pcs, int id)
1050 cuse_alloc_unit[n] = pcs;
1060 cuse_server_wakeup_locked(struct cuse_server *pcs)
1062 selwakeup(&pcs->selinfo);
1063 KNOTE_LOCKED(&pcs->selinfo.si_note, 0);
1067 cuse_server_wakeup_all_client_locked(struct cuse_server *pcs)
1071 TAILQ_FOREACH(pcc, &pcs->hcli, entry) {
1075 cuse_server_wakeup_locked(pcs);
1079 cuse_free_unit_by_id_locked(struct cuse_server *pcs, int id)
1085 if (cuse_alloc_unit[n] == pcs) {
1101 struct cuse_server *pcs;
1104 error = cuse_server_get(&pcs);
1121 cuse_server_lock(pcs);
1123 while ((pccmd = TAILQ_FIRST(&pcs->head)) == NULL) {
1124 error = cv_wait_sig(&pcs->cv, &pcs->mtx);
1126 if (pcs->is_closing)
1130 cuse_server_unlock(pcs);
1135 TAILQ_REMOVE(&pcs->head, pccmd, entry);
1142 cuse_server_unlock(pcs);
1148 cuse_server_lock(pcs);
1149 while ((pccmd = cuse_server_find_command(pcs, curthread)) != NULL) {
1158 cuse_server_unlock(pcs);
1164 cuse_server_lock(pcs);
1165 n = cuse_alloc_unit_by_id_locked(pcs,
1167 cuse_server_unlock(pcs);
1181 cuse_server_lock(pcs);
1182 n = cuse_alloc_unit_by_id_locked(pcs, n);
1183 cuse_server_unlock(pcs);
1197 cuse_server_lock(pcs);
1198 error = cuse_free_unit_by_id_locked(pcs, n);
1199 cuse_server_unlock(pcs);
1206 cuse_server_lock(pcs);
1207 error = cuse_free_unit_by_id_locked(pcs, n);
1208 cuse_server_unlock(pcs);
1223 error = cuse_server_alloc_memory(pcs,
1234 error = cuse_server_free_memory(pcs, pai->alloc_nr);
1239 cuse_server_lock(pcs);
1240 pccmd = cuse_server_find_command(pcs, curthread);
1248 cuse_server_unlock(pcs);
1256 cuse_server_lock(pcs);
1257 pccmd = cuse_server_find_command(pcs, curthread);
1267 cuse_server_unlock(pcs);
1294 pcsd->server = pcs;
1309 cuse_server_lock(pcs);
1310 TAILQ_INSERT_TAIL(&pcs->hdev, pcsd, entry);
1311 cuse_server_unlock(pcs);
1321 cuse_server_lock(pcs);
1325 pcsd = TAILQ_FIRST(&pcs->hdev);
1328 TAILQ_REMOVE(&pcs->hdev, pcsd, entry);
1329 cuse_server_unlock(pcs);
1331 cuse_server_lock(pcs);
1333 pcsd = TAILQ_FIRST(&pcs->hdev);
1339 cuse_server_unlock(pcs);
1345 cuse_server_lock(pcs);
1348 pccmd = cuse_server_find_command(pcs, curthread);
1357 error = cuse_server_ioctl_copy_locked(pcs, pccmd,
1361 pcs, pccmd, pchk, cmd == CUSE_IOCTL_READ_DATA);
1368 if (cuse_server_is_locked(pcs))
1369 cuse_server_unlock(pcs);
1373 cuse_server_lock(pcs);
1378 cuse_server_wakeup_all_client_locked(pcs);
1379 cuse_server_unlock(pcs);
1397 cuse_common_mmap_single(struct cuse_server *pcs,
1407 cuse_server_lock(pcs);
1411 TAILQ_FOREACH(mem, &pcs->hmem, entry) {
1432 cuse_server_unlock(pcs);
1440 struct cuse_server *pcs;
1443 error = cuse_server_get(&pcs);
1447 return (cuse_common_mmap_single(pcs, offset, size, object));
1458 struct cuse_server *pcs;
1461 pcs = pcc->server;
1463 cuse_server_lock(pcs);
1465 TAILQ_REMOVE(&pcs->hcli, pcc, entry);
1466 cuse_server_unlock(pcs);
1478 cuse_server_unref(pcs);
1487 struct cuse_server *pcs;
1494 pcs = pcsd->server;
1497 cuse_server_lock(pcs);
1504 pcs->refs++;
1505 if (pcs->refs < 0 || pcs->pid == curproc->p_pid) {
1507 pcs->refs--;
1508 cuse_server_unlock(pcs);
1511 cuse_server_unlock(pcs);
1520 cuse_server_unref(pcs);
1526 pcc->server = pcs;
1539 cuse_server_lock(pcs);
1544 TAILQ_INSERT_TAIL(&pcs->hcli, pcc, entry);
1547 if ((pcs->is_closing != 0) || (dev->si_drv1 == NULL)) {
1552 cuse_server_unlock(pcs);
1562 cuse_server_lock(pcs);
1566 cuse_server_unlock(pcs);
1587 struct cuse_server *pcs;
1595 pcs = pcc->server;
1599 cuse_server_lock(pcs);
1606 cuse_server_unlock(pcs);
1614 struct cuse_server *pcs = pcc->server;
1617 cuse_server_lock(pcs);
1622 cuse_server_unlock(pcs);
1629 cuse_server_lock(pcs);
1637 cuse_server_unlock(pcs);
1647 struct cuse_server *pcs;
1657 pcs = pcc->server;
1673 cuse_server_lock(pcs);
1691 cuse_server_unlock(pcs);
1736 struct cuse_server *pcs;
1745 pcs = pcc->server;
1768 cuse_server_lock(pcs);
1787 cuse_server_unlock(pcs);
1826 struct cuse_server *pcs;
1839 pcs = pcc->server;
1852 cuse_server_lock(pcs);
1859 cuse_server_unlock(pcs);
1883 struct cuse_server *pcs;
1893 pcs = pcc->server;
1910 selrecord(td, &pcs->selinfo);
1912 cuse_server_lock(pcs);
1917 cuse_server_unlock(pcs);
1958 struct cuse_server *pcs;
1961 pcs = pcc->server;
1963 cuse_server_lock(pcs);
1964 knlist_remove(&pcs->selinfo.si_note, kn, 1);
1965 cuse_server_unlock(pcs);
1972 struct cuse_server *pcs;
1975 pcs = pcc->server;
1977 cuse_server_lock(pcs);
1978 knlist_remove(&pcs->selinfo.si_note, kn, 1);
1979 cuse_server_unlock(pcs);
2010 struct cuse_server *pcs;
2017 pcs = pcc->server;
2019 cuse_server_lock(pcs);
2025 knlist_add(&pcs->selinfo.si_note, kn, 1);
2031 knlist_add(&pcs->selinfo.si_note, kn, 1);
2037 cuse_server_unlock(pcs);