!rdev->in_sync || 
!test_bit(In_sync, &rdev->flags) || 
static int read_balance(conf_t *conf, r1bio_t *r1_bio){	const unsigned long this_sector = r1_bio->sector;	int new_disk = conf->last_used, disk = new_disk;	int wonly_disk = -1;	const int sectors = r1_bio->sectors;	sector_t new_distance, current_distance;	mdk_rdev_t *rdev;	rcu_read_lock();	/*	 * Check if we can balance. We can balance on the whole	 * device if no resync is going on, or below the resync window.	 * We take the first readable disk when above the resync window.	 */ retry:	if (conf->mddev->recovery_cp < MaxSector &&	    (this_sector + sectors >= conf->next_resync)) {		/* Choose the first operation device, for consistancy */		new_disk = 0;		for (rdev = rcu_dereference(conf->mirrors[new_disk].rdev);		     !rdev || !rdev->in_sync			     || test_bit(WriteMostly, &rdev->flags);		     rdev = rcu_dereference(conf->mirrors[++new_disk].rdev)) {			if (rdev && rdev->in_sync)				wonly_disk = new_disk;			if (new_disk == conf->raid_disks - 1) {				new_disk = wonly_disk;				break;			}		}		goto rb_out;	}	/* make sure the disk is operational */	for (rdev = rcu_dereference(conf->mirrors[new_disk].rdev);	     !rdev || !rdev->in_sync ||		     test_bit(WriteMostly, &rdev->flags);	     rdev = rcu_dereference(conf->mirrors[new_disk].rdev)) {		if (rdev && rdev->in_sync)			wonly_disk = new_disk;		if (new_disk <= 0)			new_disk = conf->raid_disks;		new_disk--;		if (new_disk == disk) {			new_disk = wonly_disk;			break;		}	}	if (new_disk < 0)		goto rb_out;	disk = new_disk;	/* now disk == new_disk == starting point for search */	/*	 * Don't change to another disk for sequential reads:	 */	if (conf->next_seq_sect == this_sector)		goto rb_out;	if (this_sector == conf->mirrors[new_disk].head_position)		goto rb_out;	current_distance = abs(this_sector - conf->mirrors[disk].head_position);	/* Find the disk whose head is closest */	do {		if (disk <= 0)			disk = conf->raid_disks;		disk--;		rdev = rcu_dereference(conf->mirrors[disk].rdev);		if (!rdev ||		    !rdev->in_sync ||		    test_bit(WriteMostly, &rdev->flags))			continue;		if (!atomic_read(&rdev->nr_pending)) {			new_disk = disk;			break;		}		new_distance = abs(this_sector - conf->mirrors[disk].head_position);		if (new_distance < current_distance) {			current_distance = new_distance;			new_disk = disk;		}	} while (disk != conf->last_used); rb_out:	if (new_disk >= 0) {		rdev = rcu_dereference(conf->mirrors[new_disk].rdev);		if (!rdev)			goto retry;		atomic_inc(&rdev->nr_pending);		if (!rdev->in_sync) {			/* cannot risk returning a device that failed			 * before we inc'ed nr_pending			 */			atomic_dec(&rdev->nr_pending);			goto retry;		}		conf->next_seq_sect = this_sector + sectors;		conf->last_used = new_disk;	}	rcu_read_unlock();	return new_disk;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/b2d444d7ad975d555bb919601bcdc0e58975a40e/raid1.c/clean/drivers/md/raid1.c