Lines Matching refs:qtree

229 	smb_quota_tree_t *qtree, *qtree_next;
246 qtree = list_head(&smb_quota_fs_list);
247 while (qtree != NULL) {
248 qtree_next = list_next(&smb_quota_fs_list, qtree);
250 (void) mutex_lock(&qtree->qt_mutex);
251 remove = (qtree->qt_refcnt == 1);
253 list_remove(&smb_quota_fs_list, qtree);
254 --qtree->qt_refcnt;
256 (void) mutex_unlock(&qtree->qt_mutex);
259 smb_quota_tree_delete(qtree);
261 qtree = qtree_next;
291 smb_quota_tree_t *qtree;
300 qtree = list_head(&smb_quota_fs_list);
301 while (qtree != NULL) {
302 if (smb_quota_tree_match(qtree, path)) {
303 (void) mutex_lock(&qtree->qt_mutex);
304 ++qtree->qt_sharecnt;
305 (void) mutex_unlock(&qtree->qt_mutex);
308 qtree = list_next(&smb_quota_fs_list, qtree);
311 if (qtree == NULL) {
312 qtree = smb_quota_tree_create(path);
313 if (qtree)
314 list_insert_head(&smb_quota_fs_list, (void *)qtree);
317 if (qtree)
327 * (qtree->qt_sharecnt == 0) remove the qtree from the list.
328 * The qtree will be deleted if/when there is nobody using it
329 * (qtree->qt_refcnt == 0).
334 smb_quota_tree_t *qtree;
344 qtree = list_head(&smb_quota_fs_list);
345 while (qtree != NULL) {
346 assert(qtree->qt_refcnt > 0);
347 if (smb_quota_tree_match(qtree, path)) {
348 (void) mutex_lock(&qtree->qt_mutex);
349 --qtree->qt_sharecnt;
350 if (qtree->qt_sharecnt == 0) {
351 list_remove(&smb_quota_fs_list, (void *)qtree);
352 smb_quota_remove_ctrldir(qtree->qt_path);
353 --(qtree->qt_refcnt);
354 delete = (qtree->qt_refcnt == 0);
356 (void) mutex_unlock(&qtree->qt_mutex);
358 smb_quota_tree_delete(qtree);
361 qtree = list_next(&smb_quota_fs_list, qtree);
380 smb_quota_tree_t *qtree;
386 qtree = smb_quota_tree_lookup(request->qq_root_path);
387 if (qtree == NULL)
390 /* If NOT resuming a previous query all, refresh qtree if required */
392 status = smb_quota_tree_populate(qtree);
394 smb_quota_tree_release(qtree);
401 status = smb_quota_query_list(qtree, request, reply);
405 status = smb_quota_query_all(qtree, request, reply);
413 smb_quota_tree_release(qtree);
427 smb_quota_tree_t *qtree;
429 qtree = smb_quota_tree_lookup(request->qs_root_path);
430 if (qtree == NULL)
433 status = smb_quota_zfs_set_quotas(qtree, request);
435 smb_quota_tree_set_expired(qtree);
436 smb_quota_tree_release(qtree);
481 smb_quota_query_all(smb_quota_tree_t *qtree, smb_quota_query_t *request,
484 avl_tree_t *avl_tree = &qtree->qt_avl;
547 smb_quota_query_list(smb_quota_tree_t *qtree, smb_quota_query_t *request,
550 avl_tree_t *avl_tree = &qtree->qt_avl;
594 smb_quota_zfs_set_quotas(smb_quota_tree_t *qtree, smb_quota_set_t *request)
620 sidtype = smb_quota_sidtype(qtree, quota->q_sidstr);
666 * the qtree get its type from there, otherwise do an
670 smb_quota_sidtype(smb_quota_tree_t *qtree, char *sidstr)
679 quota = avl_find(&qtree->qt_avl, &key, &where);
744 smb_quota_tree_t *qtree = NULL;
749 qtree = list_head(&smb_quota_fs_list);
750 while (qtree != NULL) {
756 (void) mutex_lock(&qtree->qt_mutex);
757 assert(qtree->qt_refcnt > 0);
759 if (!smb_quota_tree_match(qtree, path)) {
760 (void) mutex_unlock(&qtree->qt_mutex);
761 qtree = list_next(&smb_quota_fs_list, qtree);
765 if (qtree->qt_locked) {
766 (void) mutex_unlock(&qtree->qt_mutex);
769 qtree = list_head(&smb_quota_fs_list);
773 ++(qtree->qt_refcnt);
774 qtree->qt_locked = B_TRUE;
775 (void) mutex_unlock(&qtree->qt_mutex);
780 return (qtree);
787 smb_quota_tree_release(smb_quota_tree_t *qtree)
791 (void) mutex_lock(&qtree->qt_mutex);
792 assert(qtree->qt_locked);
793 assert(qtree->qt_refcnt > 0);
795 --(qtree->qt_refcnt);
796 qtree->qt_locked = B_FALSE;
797 delete = (qtree->qt_refcnt == 0);
798 (void) mutex_unlock(&qtree->qt_mutex);
802 smb_quota_tree_delete(qtree);
810 * Determine if qtree represents the file system identified by path
813 smb_quota_tree_match(smb_quota_tree_t *qtree, const char *path)
815 return (strncmp(qtree->qt_path, path, MAXPATHLEN) == 0);
826 smb_quota_tree_t *qtree;
830 qtree = calloc(sizeof (smb_quota_tree_t), 1);
831 if (qtree == NULL)
834 qtree->qt_path = strdup(path);
835 if (qtree->qt_path == NULL) {
836 free(qtree);
840 qtree->qt_timestamp = 0;
841 qtree->qt_locked = B_FALSE;
842 qtree->qt_refcnt = 1;
843 qtree->qt_sharecnt = 1;
845 avl_create(&qtree->qt_avl, smb_quota_sid_cmp,
849 return (qtree);
856 * qtree must have no users (refcnt == 0).
859 smb_quota_tree_delete(smb_quota_tree_t *qtree)
865 assert(qtree->qt_refcnt == 0);
867 while ((node = avl_destroy_nodes(&qtree->qt_avl, &cookie)) != NULL)
869 avl_destroy(&qtree->qt_avl);
871 free(qtree->qt_path);
872 free(qtree);
903 * - delete the qtree's contents
904 * - repopulate the qtree from zfs
905 * - set the qtree's timestamp.
908 smb_quota_tree_populate(smb_quota_tree_t *qtree)
914 assert(qtree->qt_locked);
916 if (!smb_quota_tree_expired(qtree))
919 while ((node = avl_destroy_nodes(&qtree->qt_avl, &cookie)) != NULL)
922 status = smb_quota_zfs_get_quotas(qtree);
926 qtree->qt_timestamp = time(NULL);
932 smb_quota_tree_expired(smb_quota_tree_t *qtree)
935 return ((tnow - qtree->qt_timestamp) > SMB_QUOTA_REFRESH);
939 smb_quota_tree_set_expired(smb_quota_tree_t *qtree)
941 qtree->qt_timestamp = 0;
951 smb_quota_zfs_get_quotas(smb_quota_tree_t *qtree)
958 status = smb_quota_zfs_init(qtree->qt_path, &zfs_hdl);
962 arg.qa_avl = &qtree->qt_avl;