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