conf->mirrors[i].rdev->faulty) { 
test_bit(Faulty, &conf->mirrors[i].rdev->flags)) { 
static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, int go_faster){	conf_t *conf = mddev_to_conf(mddev);	mirror_info_t *mirror;	r1bio_t *r1_bio;	struct bio *bio;	sector_t max_sector, nr_sectors;	int disk;	int i;	int wonly;	int write_targets = 0;	int sync_blocks;	int still_degraded = 0;	if (!conf->r1buf_pool)	{/*		printk("sync start - bitmap %p\n", mddev->bitmap);*/		if (init_resync(conf))			return 0;	}	max_sector = mddev->size << 1;	if (sector_nr >= max_sector) {		/* If we aborted, we need to abort the		 * sync on the 'current' bitmap chunk (there will		 * only be one in raid1 resync.		 * We can find the current addess in mddev->curr_resync		 */		if (mddev->curr_resync < max_sector) /* aborted */			bitmap_end_sync(mddev->bitmap, mddev->curr_resync,						&sync_blocks, 1);		else /* completed sync */			conf->fullsync = 0;		bitmap_close_sync(mddev->bitmap);		close_sync(conf);		return 0;	}	/* before building a request, check if we can skip these blocks..	 * This call the bitmap_start_sync doesn't actually record anything	 */	if (!bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 1) &&	    !conf->fullsync) {		/* We can skip this block, and probably several more */		*skipped = 1;		return sync_blocks;	}	/*	 * If there is non-resync activity waiting for us then	 * put in a delay to throttle resync.	 */	if (!go_faster && waitqueue_active(&conf->wait_resume))		msleep_interruptible(1000);	device_barrier(conf, sector_nr + RESYNC_SECTORS);	/*	 * If reconstructing, and >1 working disc,	 * could dedicate one to rebuild and others to	 * service read requests ..	 */	disk = conf->last_used;	/* make sure disk is operational */	wonly = disk;	while (conf->mirrors[disk].rdev == NULL ||	       !conf->mirrors[disk].rdev->in_sync ||	       test_bit(WriteMostly, &conf->mirrors[disk].rdev->flags)		) {		if (conf->mirrors[disk].rdev  &&		    conf->mirrors[disk].rdev->in_sync)			wonly = disk;		if (disk <= 0)			disk = conf->raid_disks;		disk--;		if (disk == conf->last_used) {			disk = wonly;			break;		}	}	conf->last_used = disk;	atomic_inc(&conf->mirrors[disk].rdev->nr_pending);	mirror = conf->mirrors + disk;	r1_bio = mempool_alloc(conf->r1buf_pool, GFP_NOIO);	spin_lock_irq(&conf->resync_lock);	conf->nr_pending++;	spin_unlock_irq(&conf->resync_lock);	r1_bio->mddev = mddev;	r1_bio->sector = sector_nr;	r1_bio->state = 0;	set_bit(R1BIO_IsSync, &r1_bio->state);	r1_bio->read_disk = disk;	for (i=0; i < conf->raid_disks; i++) {		bio = r1_bio->bios[i];		/* take from bio_init */		bio->bi_next = NULL;		bio->bi_flags |= 1 << BIO_UPTODATE;		bio->bi_rw = 0;		bio->bi_vcnt = 0;		bio->bi_idx = 0;		bio->bi_phys_segments = 0;		bio->bi_hw_segments = 0;		bio->bi_size = 0;		bio->bi_end_io = NULL;		bio->bi_private = NULL;		if (i == disk) {			bio->bi_rw = READ;			bio->bi_end_io = end_sync_read;		} else if (conf->mirrors[i].rdev == NULL ||			   conf->mirrors[i].rdev->faulty) {			still_degraded = 1;			continue;		} else if (!conf->mirrors[i].rdev->in_sync ||			   sector_nr + RESYNC_SECTORS > mddev->recovery_cp) {			bio->bi_rw = WRITE;			bio->bi_end_io = end_sync_write;			write_targets ++;		} else			/* no need to read or write here */			continue;		bio->bi_sector = sector_nr + conf->mirrors[i].rdev->data_offset;		bio->bi_bdev = conf->mirrors[i].rdev->bdev;		bio->bi_private = r1_bio;	}	if (write_targets == 0) {		/* There is nowhere to write, so all non-sync		 * drives must be failed - so we are finished		 */		sector_t rv = max_sector - sector_nr;		*skipped = 1;		put_buf(r1_bio);		rdev_dec_pending(conf->mirrors[disk].rdev, mddev);		return rv;	}	nr_sectors = 0;	sync_blocks = 0;	do {		struct page *page;		int len = PAGE_SIZE;		if (sector_nr + (len>>9) > max_sector)			len = (max_sector - sector_nr) << 9;		if (len == 0)			break;		if (sync_blocks == 0) {			if (!bitmap_start_sync(mddev->bitmap, sector_nr,					&sync_blocks, still_degraded) &&					!conf->fullsync)				break;			if (sync_blocks < (PAGE_SIZE>>9))				BUG();			if (len > (sync_blocks<<9))				len = sync_blocks<<9;		}		for (i=0 ; i < conf->raid_disks; i++) {			bio = r1_bio->bios[i];			if (bio->bi_end_io) {				page = r1_bio->bios[0]->bi_io_vec[bio->bi_vcnt].bv_page;				if (bio_add_page(bio, page, len, 0) == 0) {					/* stop here */					r1_bio->bios[0]->bi_io_vec[bio->bi_vcnt].bv_page = page;					while (i > 0) {						i--;						bio = r1_bio->bios[i];						if (bio->bi_end_io==NULL)							continue;						/* remove last page from this bio */						bio->bi_vcnt--;						bio->bi_size -= len;						bio->bi_flags &= ~(1<< BIO_SEG_VALID);					}					goto bio_full;				}			}		}		nr_sectors += len>>9;		sector_nr += len>>9;		sync_blocks -= (len>>9);	} while (r1_bio->bios[disk]->bi_vcnt < RESYNC_PAGES); bio_full:	bio = r1_bio->bios[disk];	r1_bio->sectors = nr_sectors;	md_sync_acct(mirror->rdev->bdev, nr_sectors);	generic_make_request(bio);	return nr_sectors;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/b2d444d7ad975d555bb919601bcdc0e58975a40e/raid1.c/buggy/drivers/md/raid1.c