/* Run through a list for as long as possible. Returns the count of successful jobs.  */
static int process_jobs(struct list_head *jobs, struct dm_kcopyd_client *kc, int(*fn)(struct kcopyd_job *))
/* Run through a list for as long as possible. Returns the count of successful jobs.  */
static int process_jobs(struct list_head *jobs, struct dm_kcopyd_client *kc, int(*fn)(struct kcopyd_job *))
{
	struct kcopyd_job *job;
	int r, count = 0;
	while ((job = pop(jobs, kc))) {
		r = fn(job);
		if (r < 0) {
			if (job->rw == WRITE)
				job->write_err = (unsigned long) -1L;
			else
				job->read_err = 1;
			push(&kc->complete_jobs, job);
			break;
		}
		if (r > 0) {
			push_head(jobs, job);
			break;
		}
		count++;
	}
	return count;
}