Lines Matching refs:shp

34 shadow_add_entry(shadow_handle_t *shp, const char *path, const char *entry,
65 if (shp->sh_fsid != NODEV &&
67 vstat.f_fsid != shp->sh_fsid) {
78 (void) pthread_mutex_lock(&shp->sh_lock);
79 if (shadow_pq_enqueue(&shp->sh_queue, sep) != 0) {
80 (void) pthread_mutex_unlock(&shp->sh_lock);
85 shadow_status_enqueue(shp, sep);
86 (void) pthread_mutex_unlock(&shp->sh_lock);
216 shadow_load_fidlist(shadow_handle_t *shp, shadow_hash_t *seen, int idx)
229 if ((fids = shadow_read_fidlist(shp->sh_mountpoint, idx,
233 if ((fd = open(shp->sh_mountpoint, O_RDONLY)) < 0) {
244 mountptlen = strlen(shp->sh_mountpoint);
250 mountlen = strlen(shp->sh_mountpoint);
300 if (strlen(shp->sh_mountpoint) +
315 (void) memcpy(buf, shp->sh_mountpoint, mountlen);
319 if (strncmp(buf, shp->sh_mountpoint, mountlen) != 0)
350 if (shadow_add_entry(shp, buf, NULL, type, depth,
378 shadow_begin(shadow_handle_t *shp)
392 search.mnt_mountp = shp->sh_mountpoint;
398 shp->sh_mountpoint));
416 if (shadow_load_fidlist(shp, seen, 0) != 0 ||
417 shadow_load_fidlist(shp, seen, 1) != 0)
426 if (shadow_pq_peek(&shp->sh_queue) == NULL)
427 (void) shadow_add_entry(shp, shp->sh_mountpoint, NULL,
438 shadow_check_begin(shadow_handle_t *shp)
440 (void) pthread_mutex_lock(&shp->sh_lock);
441 if (!shp->sh_loaded) {
442 if (shp->sh_loading) {
443 (void) pthread_mutex_unlock(&shp->sh_lock);
449 shp->sh_loading = B_TRUE;
450 (void) pthread_mutex_unlock(&shp->sh_lock);
452 if (shadow_begin(shp) != 0) {
453 (void) pthread_mutex_lock(&shp->sh_lock);
454 shp->sh_loading = B_FALSE;
455 (void) pthread_mutex_unlock(&shp->sh_lock);
459 (void) pthread_mutex_lock(&shp->sh_lock);
462 shp->sh_loaded = B_TRUE;
463 shp->sh_loading = B_FALSE;
473 shadow_end(shadow_handle_t *shp)
478 while ((sep = shadow_pq_dequeue(&shp->sh_queue)) != NULL) {
483 while ((srp = shp->sh_errors) != NULL) {
484 shp->sh_errors = srp->se_next;
495 shadow_error_record(shadow_handle_t *shp, const char *path, int err)
499 (void) pthread_mutex_lock(&shp->sh_errlock);
500 for (sep = shp->sh_errors; sep != NULL; sep = sep->se_next) {
509 (void) pthread_mutex_unlock(&shp->sh_errlock);
514 (void) pthread_mutex_unlock(&shp->sh_errlock);
520 sep->se_next = shp->sh_errors;
521 shp->sh_errors = sep;
522 shp->sh_errcount++;
525 (void) pthread_mutex_unlock(&shp->sh_errlock);
537 shadow_error_check(shadow_handle_t *shp, const char *localpath, int err)
555 if (shadow_error_record(shp, path, err) != 0) {
626 shadow_migrate_dir(shadow_handle_t *shp, shadow_entry_t *sep, int *errp)
655 if (strcmp(sep->se_path, shp->sh_mountpoint) == 0) {
666 if (shp->sh_dataset != NULL &&
686 if (shadow_add_entry(shp, sep->se_path, dp->d_name,
696 (void) pthread_mutex_lock(&shp->sh_lock);
697 shadow_status_update(shp, sep, size, subdirs);
698 (void) pthread_mutex_unlock(&shp->sh_lock);
709 shadow_migrate_file(shadow_handle_t *shp, shadow_entry_t *sep, int *errp)
724 (void) pthread_mutex_lock(&shp->sh_lock);
725 shadow_status_update(shp, sep, size, 0);
726 (void) pthread_mutex_unlock(&shp->sh_lock);
737 shadow_process_pending(shadow_handle_t *shp)
743 if (shp->sh_complete)
746 shp->sh_active++;
747 (void) pthread_mutex_unlock(&shp->sh_lock);
753 if ((fd = open(shp->sh_mountpoint, O_RDONLY)) < 0)
765 (void) pthread_mutex_lock(&shp->sh_lock);
766 shp->sh_active--;
767 shp->sh_onlyerrors = (boolean_t)ioc.si_onlyerrors;
769 shp->sh_complete = B_TRUE;
772 shadow_status_update(shp, NULL, ioc.si_size, 0);
778 return (shadow_error_record(shp, path, ioc.si_error));
782 (void) pthread_mutex_lock(&shp->sh_lock);
783 shp->sh_active--;
798 shadow_handle_t *shp = sca->sca_hdl;
801 (void) pthread_mutex_lock(&shp->sh_lock);
809 if (shadow_pq_enqueue(&shp->sh_queue, sep) == 0)
810 shadow_status_enqueue(shp, sep);
812 shp->sh_active--;
813 (void) pthread_mutex_unlock(&shp->sh_lock);
827 shadow_migrate_one(shadow_handle_t *shp)
834 if (shadow_check_begin(shp) != 0)
837 sep = shadow_pq_dequeue(&shp->sh_queue);
839 if (shp->sh_active != 0) {
840 (void) pthread_mutex_unlock(&shp->sh_lock);
845 ret = shadow_process_pending(shp);
846 (void) pthread_mutex_unlock(&shp->sh_lock);
850 shp->sh_active++;
851 (void) pthread_mutex_unlock(&shp->sh_lock);
853 arg.sca_hdl = shp;
862 if (shp->sh_delay != 0) {
863 ts.tv_sec = shp->sh_delay / 1000;
864 ts.tv_sec = (shp->sh_delay % 1000) * 1000 * 1000;
872 ret = shadow_migrate_dir(shp, sep, &err);
876 ret = shadow_migrate_file(shp, sep, &err);
883 (void) pthread_mutex_lock(&shp->sh_lock);
892 (void) shadow_pq_enqueue(&shp->sh_queue, sep);
893 (void) pthread_mutex_unlock(&shp->sh_lock);
900 shadow_status_dequeue(shp, sep);
901 (void) pthread_mutex_unlock(&shp->sh_lock);
912 ret = shadow_error_check(shp, sep->se_path, err);
930 shadow_migrate_done(shadow_handle_t *shp)
932 return (shp->sh_complete);
941 shadow_migrate_only_errors(shadow_handle_t *shp)
943 return (shp->sh_onlyerrors);
953 shadow_migrate_iter(shadow_handle_t *shp, void (*func)(const char *, void *),
959 if (shadow_check_begin(shp) != 0)
963 (void) pthread_mutex_unlock(&shp->sh_lock);
967 while ((sep = shadow_pq_dequeue(&shp->sh_queue)) != NULL) {
979 if (shadow_pq_enqueue(&shp->sh_queue, sep) != 0) {
985 (void) pthread_mutex_unlock(&shp->sh_lock);
995 shadow_migrate_finalize(shadow_handle_t *shp)
997 if (!shadow_migrate_done(shp))
1001 return (shadow_cancel(shp));
1013 shadow_migrate_delay(shadow_handle_t *shp, uint32_t delay)
1015 shp->sh_delay = delay;