!rdev->faulty) { 
!test_bit(Faulty, &rdev->flags)) { 
static int make_request(request_queue_t *q, struct bio * bio){	mddev_t *mddev = q->queuedata;	conf_t *conf = mddev_to_conf(mddev);	mirror_info_t *mirror;	r1bio_t *r1_bio;	struct bio *read_bio;	int i, targets = 0, disks;	mdk_rdev_t *rdev;	struct bitmap *bitmap = mddev->bitmap;	unsigned long flags;	struct bio_list bl;	struct page **behind_pages = NULL;	const int rw = bio_data_dir(bio);	if (unlikely(bio_barrier(bio))) {		bio_endio(bio, bio->bi_size, -EOPNOTSUPP);		return 0;	}	/*	 * Register the new request and wait if the reconstruction	 * thread has put up a bar for new requests.	 * Continue immediately if no resync is active currently.	 */	md_write_start(mddev, bio); /* wait on superblock update early */	spin_lock_irq(&conf->resync_lock);	wait_event_lock_irq(conf->wait_resume, !conf->barrier, conf->resync_lock, );	conf->nr_pending++;	spin_unlock_irq(&conf->resync_lock);	disk_stat_inc(mddev->gendisk, ios[rw]);	disk_stat_add(mddev->gendisk, sectors[rw], bio_sectors(bio));	/*	 * make_request() can abort the operation when READA is being	 * used and no empty request is available.	 *	 */	r1_bio = mempool_alloc(conf->r1bio_pool, GFP_NOIO);	r1_bio->master_bio = bio;	r1_bio->sectors = bio->bi_size >> 9;	r1_bio->state = 0;	r1_bio->mddev = mddev;	r1_bio->sector = bio->bi_sector;	if (rw == READ) {		/*		 * read balancing logic:		 */		int rdisk = read_balance(conf, r1_bio);		if (rdisk < 0) {			/* couldn't find anywhere to read from */			raid_end_bio_io(r1_bio);			return 0;		}		mirror = conf->mirrors + rdisk;		r1_bio->read_disk = rdisk;		read_bio = bio_clone(bio, GFP_NOIO);		r1_bio->bios[rdisk] = read_bio;		read_bio->bi_sector = r1_bio->sector + mirror->rdev->data_offset;		read_bio->bi_bdev = mirror->rdev->bdev;		read_bio->bi_end_io = raid1_end_read_request;		read_bio->bi_rw = READ;		read_bio->bi_private = r1_bio;		generic_make_request(read_bio);		return 0;	}	/*	 * WRITE:	 */	/* first select target devices under spinlock and	 * inc refcount on their rdev.  Record them by setting	 * bios[x] to bio	 */	disks = conf->raid_disks;#if 0	{ static int first=1;	if (first) printk("First Write sector %llu disks %d\n",			  (unsigned long long)r1_bio->sector, disks);	first = 0;	}#endif	rcu_read_lock();	for (i = 0;  i < disks; i++) {		if ((rdev=rcu_dereference(conf->mirrors[i].rdev)) != NULL &&		    !rdev->faulty) {			atomic_inc(&rdev->nr_pending);			if (rdev->faulty) {				atomic_dec(&rdev->nr_pending);				r1_bio->bios[i] = NULL;			} else				r1_bio->bios[i] = bio;			targets++;		} else			r1_bio->bios[i] = NULL;	}	rcu_read_unlock();	BUG_ON(targets == 0); /* we never fail the last device */	if (targets < conf->raid_disks) {		/* array is degraded, we will not clear the bitmap		 * on I/O completion (see raid1_end_write_request) */		set_bit(R1BIO_Degraded, &r1_bio->state);	}	/* do behind I/O ? */	if (bitmap &&	    atomic_read(&bitmap->behind_writes) < bitmap->max_write_behind &&	    (behind_pages = alloc_behind_pages(bio)) != NULL)		set_bit(R1BIO_BehindIO, &r1_bio->state);	atomic_set(&r1_bio->remaining, 0);	atomic_set(&r1_bio->behind_remaining, 0);	bio_list_init(&bl);	for (i = 0; i < disks; i++) {		struct bio *mbio;		if (!r1_bio->bios[i])			continue;		mbio = bio_clone(bio, GFP_NOIO);		r1_bio->bios[i] = mbio;		mbio->bi_sector	= r1_bio->sector + conf->mirrors[i].rdev->data_offset;		mbio->bi_bdev = conf->mirrors[i].rdev->bdev;		mbio->bi_end_io	= raid1_end_write_request;		mbio->bi_rw = WRITE;		mbio->bi_private = r1_bio;		if (behind_pages) {			struct bio_vec *bvec;			int j;			/* Yes, I really want the '__' version so that			 * we clear any unused pointer in the io_vec, rather			 * than leave them unchanged.  This is important			 * because when we come to free the pages, we won't			 * know the originial bi_idx, so we just free			 * them all			 */			__bio_for_each_segment(bvec, mbio, j, 0)				bvec->bv_page = behind_pages[j];			if (test_bit(WriteMostly, &conf->mirrors[i].rdev->flags))				atomic_inc(&r1_bio->behind_remaining);		}		atomic_inc(&r1_bio->remaining);		bio_list_add(&bl, mbio);	}	kfree(behind_pages); /* the behind pages are attached to the bios now */	bitmap_startwrite(bitmap, bio->bi_sector, r1_bio->sectors,				test_bit(R1BIO_BehindIO, &r1_bio->state));	spin_lock_irqsave(&conf->device_lock, flags);	bio_list_merge(&conf->pending_bio_list, &bl);	bio_list_init(&bl);	blk_plug_device(mddev->queue);	spin_unlock_irqrestore(&conf->device_lock, flags);#if 0	while ((bio = bio_list_pop(&bl)) != NULL)		generic_make_request(bio);#endif	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/b2d444d7ad975d555bb919601bcdc0e58975a40e/raid1.c/clean/drivers/md/raid1.c