Lines Matching defs:clp

405 void sg_in_operation(Rq_coll * clp, Rq_elem * rep);
406 void sg_out_operation(Rq_coll * clp, Rq_elem * rep);
407 int normal_in_operation(Rq_coll * clp, Rq_elem * rep, int blocks);
408 void normal_out_operation(Rq_coll * clp, Rq_elem * rep, int blocks);
6740 static void guarded_stop_in(Rq_coll * clp)
6742 pthread_mutex_lock(&clp->in_mutex);
6743 clp->in_stop = 1;
6744 pthread_mutex_unlock(&clp->in_mutex);
6747 static void guarded_stop_out(Rq_coll * clp)
6749 pthread_mutex_lock(&clp->out_mutex);
6750 clp->out_stop = 1;
6751 pthread_mutex_unlock(&clp->out_mutex);
6754 static void guarded_stop_both(Rq_coll * clp)
6756 guarded_stop_in(clp);
6757 guarded_stop_out(clp);
6762 Rq_coll *clp = (Rq_coll *) v_clp;
6769 guarded_stop_both(clp);
6770 pthread_cond_broadcast(&clp->out_sync_cv);
6778 Rq_coll *clp = (Rq_coll *) v_clp;
6781 clp->in_stop = 1;
6782 pthread_mutex_unlock(&clp->in_mutex);
6783 guarded_stop_out(clp);
6784 pthread_cond_broadcast(&clp->out_sync_cv);
6789 Rq_coll *clp = (Rq_coll *) v_clp;
6792 clp->out_stop = 1;
6793 pthread_mutex_unlock(&clp->out_mutex);
6794 guarded_stop_in(clp);
6795 pthread_cond_broadcast(&clp->out_sync_cv);
6800 Rq_coll *clp = (Rq_coll *) v_clp;
6804 int sz = clp->bpt * clp->bs;
6806 int seek_skip = clp->seek - clp->skip;
6816 /* Follow clp members are constant during lifetime of thread */
6817 rep->bs = clp->bs;
6818 rep->fua_mode = clp->fua_mode;
6819 rep->dio = clp->dio;
6820 rep->infd = clp->infd;
6821 rep->outfd = clp->outfd;
6822 rep->debug = clp->debug;
6823 rep->in_scsi_type = clp->in_scsi_type;
6824 rep->out_scsi_type = clp->out_scsi_type;
6825 rep->cdbsz = clp->cdbsz;
6828 status = pthread_mutex_lock(&clp->in_mutex);
6831 if (clp->in_stop || (clp->in_count <= 0)) {
6833 status = pthread_mutex_unlock(&clp->in_mutex);
6838 blocks = (clp->in_count > clp->bpt) ? clp->bpt : clp->in_count;
6840 rep->blk = clp->in_blk;
6842 clp->in_blk += blocks;
6843 clp->in_count -= blocks;
6845 pthread_cleanup_push(cleanup_in, (void *)clp);
6846 if (FT_SG == clp->in_type)
6847 sg_in_operation(clp, rep); /* lets go of in_mutex mid operation */
6850 normal_in_operation(clp, rep, blocks);
6851 status = pthread_mutex_unlock(&clp->in_mutex);
6857 status = pthread_mutex_lock(&clp->out_mutex);
6860 if (FT_DEV_NULL != clp->out_type) {
6861 while ((!clp->out_stop) &&
6862 ((rep->blk + seek_skip) != clp->out_blk)) {
6864 pthread_cleanup_push(cleanup_out, (void *)clp);
6866 pthread_cond_wait(&clp->out_sync_cv,
6867 &clp->out_mutex);
6874 if (clp->out_stop || (clp->out_count <= 0)) {
6875 if (!clp->out_stop)
6876 clp->out_stop = 1;
6877 status = pthread_mutex_unlock(&clp->out_mutex);
6883 clp->out_stop = 1;
6885 rep->blk = clp->out_blk;
6887 clp->out_blk += blocks;
6888 clp->out_count -= blocks;
6890 pthread_cleanup_push(cleanup_out, (void *)clp);
6891 if (FT_SG == clp->out_type)
6892 sg_out_operation(clp, rep); /* releases out_mutex mid operation */
6893 else if (FT_DEV_NULL == clp->out_type) {
6895 clp->out_done_count -= blocks;
6896 status = pthread_mutex_unlock(&clp->out_mutex);
6900 normal_out_operation(clp, rep, blocks);
6901 status = pthread_mutex_unlock(&clp->out_mutex);
6909 pthread_cond_broadcast(&clp->out_sync_cv);
6913 status = pthread_mutex_lock(&clp->in_mutex);
6916 if (!clp->in_stop)
6917 clp->in_stop = 1; /* flag other workers to stop */
6918 status = pthread_mutex_unlock(&clp->in_mutex);
6921 pthread_cond_broadcast(&clp->out_sync_cv);
6925 int normal_in_operation(Rq_coll * clp, Rq_elem * rep, int blocks)
6931 while (((res = read(clp->infd, rep->buffp,
6932 blocks * clp->bs)) < 0) && (EINTR == errno)) ;
6934 if (clp->coe) {
6940 res = rep->num_blks * clp->bs;
6944 clp->in_stop = 1;
6945 guarded_stop_out(clp);
6949 if (res < blocks * clp->bs) {
6952 blocks = res / clp->bs;
6953 if ((res % clp->bs) > 0) {
6955 clp->in_partial++;
6957 /* Reverse out + re-apply blocks on clp */
6958 clp->in_blk -= o_blocks;
6959 clp->in_count += o_blocks;
6961 clp->in_blk += blocks;
6962 clp->in_count -= blocks;
6964 clp->in_done_count -= blocks;
6968 void normal_out_operation(Rq_coll * clp, Rq_elem * rep, int blocks)
6973 while (((res = write(clp->outfd, rep->buffp,
6974 rep->num_blks * clp->bs)) < 0)
6977 if (clp->coe) {
6981 res = rep->num_blks * clp->bs;
6985 guarded_stop_in(clp);
6986 clp->out_stop = 1;
6990 if (res < blocks * clp->bs) {
6991 blocks = res / clp->bs;
6992 if ((res % clp->bs) > 0) {
6994 clp->out_partial++;
6998 clp->out_done_count -= blocks;
7001 void sg_in_operation(Rq_coll * clp, Rq_elem * rep)
7014 status = pthread_mutex_unlock(&clp->in_mutex);
7017 guarded_stop_both(clp);
7021 status = pthread_mutex_unlock(&clp->in_mutex);
7025 res = sg_finish_io(rep->wr, rep, &clp->aux_mutex);
7027 if (clp->coe) {
7036 guarded_stop_both(clp);
7042 status = pthread_mutex_lock(&clp->aux_mutex);
7045 clp->dio_incomplete += rep->dio_incomplete;
7046 clp->sum_of_resids += rep->resid;
7047 status = pthread_mutex_unlock(&clp->aux_mutex);
7051 status = pthread_mutex_lock(&clp->in_mutex);
7054 clp->in_done_count -= rep->num_blks;
7055 status = pthread_mutex_unlock(&clp->in_mutex);
7063 status = pthread_mutex_lock(&clp->in_mutex);
7069 void sg_out_operation(Rq_coll * clp, Rq_elem * rep)
7083 status = pthread_mutex_unlock(&clp->out_mutex);
7086 guarded_stop_both(clp);
7090 status = pthread_mutex_unlock(&clp->out_mutex);
7094 res = sg_finish_io(rep->wr, rep, &clp->aux_mutex);
7096 if (clp->coe)
7104 guarded_stop_both(clp);
7110 status = pthread_mutex_lock(&clp->aux_mutex);
7113 clp->dio_incomplete += rep->dio_incomplete;
7114 clp->sum_of_resids += rep->resid;
7115 status = pthread_mutex_unlock(&clp->aux_mutex);
7119 status = pthread_mutex_lock(&clp->out_mutex);
7122 clp->out_done_count -= rep->num_blks;
7123 status = pthread_mutex_unlock(&clp->out_mutex);
7131 status = pthread_mutex_lock(&clp->out_mutex);