Lines Matching refs:clp
408 void sg_in_operation(Rq_coll * clp, Rq_elem * rep);
409 void sg_out_operation(Rq_coll * clp, Rq_elem * rep);
410 int normal_in_operation(Rq_coll * clp, Rq_elem * rep, int blocks);
411 void normal_out_operation(Rq_coll * clp, Rq_elem * rep, int blocks);
6743 static void guarded_stop_in(Rq_coll * clp) in guarded_stop_in() argument
6745 pthread_mutex_lock(&clp->in_mutex); in guarded_stop_in()
6746 clp->in_stop = 1; in guarded_stop_in()
6747 pthread_mutex_unlock(&clp->in_mutex); in guarded_stop_in()
6750 static void guarded_stop_out(Rq_coll * clp) in guarded_stop_out() argument
6752 pthread_mutex_lock(&clp->out_mutex); in guarded_stop_out()
6753 clp->out_stop = 1; in guarded_stop_out()
6754 pthread_mutex_unlock(&clp->out_mutex); in guarded_stop_out()
6757 static void guarded_stop_both(Rq_coll * clp) in guarded_stop_both() argument
6759 guarded_stop_in(clp); in guarded_stop_both()
6760 guarded_stop_out(clp); in guarded_stop_both()
6765 Rq_coll *clp = (Rq_coll *) v_clp; in sig_listen_thread() local
6772 guarded_stop_both(clp); in sig_listen_thread()
6773 pthread_cond_broadcast(&clp->out_sync_cv); in sig_listen_thread()
6781 Rq_coll *clp = (Rq_coll *) v_clp; in cleanup_in() local
6784 clp->in_stop = 1; in cleanup_in()
6785 pthread_mutex_unlock(&clp->in_mutex); in cleanup_in()
6786 guarded_stop_out(clp); in cleanup_in()
6787 pthread_cond_broadcast(&clp->out_sync_cv); in cleanup_in()
6792 Rq_coll *clp = (Rq_coll *) v_clp; in cleanup_out() local
6795 clp->out_stop = 1; in cleanup_out()
6796 pthread_mutex_unlock(&clp->out_mutex); in cleanup_out()
6797 guarded_stop_in(clp); in cleanup_out()
6798 pthread_cond_broadcast(&clp->out_sync_cv); in cleanup_out()
6803 Rq_coll *clp = (Rq_coll *) v_clp; in read_write_thread() local
6807 int sz = clp->bpt * clp->bs; in read_write_thread()
6809 int seek_skip = clp->seek - clp->skip; in read_write_thread()
6820 rep->bs = clp->bs; in read_write_thread()
6821 rep->fua_mode = clp->fua_mode; in read_write_thread()
6822 rep->dio = clp->dio; in read_write_thread()
6823 rep->infd = clp->infd; in read_write_thread()
6824 rep->outfd = clp->outfd; in read_write_thread()
6825 rep->debug = clp->debug; in read_write_thread()
6826 rep->in_scsi_type = clp->in_scsi_type; in read_write_thread()
6827 rep->out_scsi_type = clp->out_scsi_type; in read_write_thread()
6828 rep->cdbsz = clp->cdbsz; in read_write_thread()
6831 status = pthread_mutex_lock(&clp->in_mutex); in read_write_thread()
6834 if (clp->in_stop || (clp->in_count <= 0)) { in read_write_thread()
6836 status = pthread_mutex_unlock(&clp->in_mutex); in read_write_thread()
6841 blocks = (clp->in_count > clp->bpt) ? clp->bpt : clp->in_count; in read_write_thread()
6843 rep->blk = clp->in_blk; in read_write_thread()
6845 clp->in_blk += blocks; in read_write_thread()
6846 clp->in_count -= blocks; in read_write_thread()
6848 pthread_cleanup_push(cleanup_in, (void *)clp); in read_write_thread()
6849 if (FT_SG == clp->in_type) in read_write_thread()
6850 sg_in_operation(clp, rep); /* lets go of in_mutex mid operation */ in read_write_thread()
6853 normal_in_operation(clp, rep, blocks); in read_write_thread()
6854 status = pthread_mutex_unlock(&clp->in_mutex); in read_write_thread()
6860 status = pthread_mutex_lock(&clp->out_mutex); in read_write_thread()
6863 if (FT_DEV_NULL != clp->out_type) { in read_write_thread()
6864 while ((!clp->out_stop) && in read_write_thread()
6865 ((rep->blk + seek_skip) != clp->out_blk)) { in read_write_thread()
6867 pthread_cleanup_push(cleanup_out, (void *)clp); in read_write_thread()
6869 pthread_cond_wait(&clp->out_sync_cv, in read_write_thread()
6870 &clp->out_mutex); in read_write_thread()
6877 if (clp->out_stop || (clp->out_count <= 0)) { in read_write_thread()
6878 if (!clp->out_stop) in read_write_thread()
6879 clp->out_stop = 1; in read_write_thread()
6880 status = pthread_mutex_unlock(&clp->out_mutex); in read_write_thread()
6886 clp->out_stop = 1; in read_write_thread()
6888 rep->blk = clp->out_blk; in read_write_thread()
6890 clp->out_blk += blocks; in read_write_thread()
6891 clp->out_count -= blocks; in read_write_thread()
6893 pthread_cleanup_push(cleanup_out, (void *)clp); in read_write_thread()
6894 if (FT_SG == clp->out_type) in read_write_thread()
6895 sg_out_operation(clp, rep); /* releases out_mutex mid operation */ in read_write_thread()
6896 else if (FT_DEV_NULL == clp->out_type) { in read_write_thread()
6898 clp->out_done_count -= blocks; in read_write_thread()
6899 status = pthread_mutex_unlock(&clp->out_mutex); in read_write_thread()
6903 normal_out_operation(clp, rep, blocks); in read_write_thread()
6904 status = pthread_mutex_unlock(&clp->out_mutex); in read_write_thread()
6912 pthread_cond_broadcast(&clp->out_sync_cv); in read_write_thread()
6916 status = pthread_mutex_lock(&clp->in_mutex); in read_write_thread()
6919 if (!clp->in_stop) in read_write_thread()
6920 clp->in_stop = 1; /* flag other workers to stop */ in read_write_thread()
6921 status = pthread_mutex_unlock(&clp->in_mutex); in read_write_thread()
6924 pthread_cond_broadcast(&clp->out_sync_cv); in read_write_thread()
6928 int normal_in_operation(Rq_coll * clp, Rq_elem * rep, int blocks) in normal_in_operation() argument
6934 while (((res = read(clp->infd, rep->buffp, in normal_in_operation()
6935 blocks * clp->bs)) < 0) && (EINTR == errno)) ; in normal_in_operation()
6937 if (clp->coe) { in normal_in_operation()
6943 res = rep->num_blks * clp->bs; in normal_in_operation()
6947 clp->in_stop = 1; in normal_in_operation()
6948 guarded_stop_out(clp); in normal_in_operation()
6952 if (res < blocks * clp->bs) { in normal_in_operation()
6955 blocks = res / clp->bs; in normal_in_operation()
6956 if ((res % clp->bs) > 0) { in normal_in_operation()
6958 clp->in_partial++; in normal_in_operation()
6961 clp->in_blk -= o_blocks; in normal_in_operation()
6962 clp->in_count += o_blocks; in normal_in_operation()
6964 clp->in_blk += blocks; in normal_in_operation()
6965 clp->in_count -= blocks; in normal_in_operation()
6967 clp->in_done_count -= blocks; in normal_in_operation()
6971 void normal_out_operation(Rq_coll * clp, Rq_elem * rep, int blocks) in normal_out_operation() argument
6976 while (((res = write(clp->outfd, rep->buffp, in normal_out_operation()
6977 rep->num_blks * clp->bs)) < 0) in normal_out_operation()
6980 if (clp->coe) { in normal_out_operation()
6984 res = rep->num_blks * clp->bs; in normal_out_operation()
6988 guarded_stop_in(clp); in normal_out_operation()
6989 clp->out_stop = 1; in normal_out_operation()
6993 if (res < blocks * clp->bs) { in normal_out_operation()
6994 blocks = res / clp->bs; in normal_out_operation()
6995 if ((res % clp->bs) > 0) { in normal_out_operation()
6997 clp->out_partial++; in normal_out_operation()
7001 clp->out_done_count -= blocks; in normal_out_operation()
7004 void sg_in_operation(Rq_coll * clp, Rq_elem * rep) in sg_in_operation() argument
7017 status = pthread_mutex_unlock(&clp->in_mutex); in sg_in_operation()
7020 guarded_stop_both(clp); in sg_in_operation()
7024 status = pthread_mutex_unlock(&clp->in_mutex); in sg_in_operation()
7028 res = sg_finish_io(rep->wr, rep, &clp->aux_mutex); in sg_in_operation()
7030 if (clp->coe) { in sg_in_operation()
7039 guarded_stop_both(clp); in sg_in_operation()
7045 status = pthread_mutex_lock(&clp->aux_mutex); in sg_in_operation()
7048 clp->dio_incomplete += rep->dio_incomplete; in sg_in_operation()
7049 clp->sum_of_resids += rep->resid; in sg_in_operation()
7050 status = pthread_mutex_unlock(&clp->aux_mutex); in sg_in_operation()
7054 status = pthread_mutex_lock(&clp->in_mutex); in sg_in_operation()
7057 clp->in_done_count -= rep->num_blks; in sg_in_operation()
7058 status = pthread_mutex_unlock(&clp->in_mutex); in sg_in_operation()
7066 status = pthread_mutex_lock(&clp->in_mutex); in sg_in_operation()
7072 void sg_out_operation(Rq_coll * clp, Rq_elem * rep) in sg_out_operation() argument
7086 status = pthread_mutex_unlock(&clp->out_mutex); in sg_out_operation()
7089 guarded_stop_both(clp); in sg_out_operation()
7093 status = pthread_mutex_unlock(&clp->out_mutex); in sg_out_operation()
7097 res = sg_finish_io(rep->wr, rep, &clp->aux_mutex); in sg_out_operation()
7099 if (clp->coe) in sg_out_operation()
7107 guarded_stop_both(clp); in sg_out_operation()
7113 status = pthread_mutex_lock(&clp->aux_mutex); in sg_out_operation()
7116 clp->dio_incomplete += rep->dio_incomplete; in sg_out_operation()
7117 clp->sum_of_resids += rep->resid; in sg_out_operation()
7118 status = pthread_mutex_unlock(&clp->aux_mutex); in sg_out_operation()
7122 status = pthread_mutex_lock(&clp->out_mutex); in sg_out_operation()
7125 clp->out_done_count -= rep->num_blks; in sg_out_operation()
7126 status = pthread_mutex_unlock(&clp->out_mutex); in sg_out_operation()
7134 status = pthread_mutex_lock(&clp->out_mutex); in sg_out_operation()