if (md_write_start(mddev, bio)==0) return 0; 
md_write_start(mddev, bio); /* wait on superblock update early */  
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;	/*	 * 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.	 */	if (md_write_start(mddev, bio)==0)		return 0;	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);	if (bio_data_dir(bio)==WRITE) {		disk_stat_inc(mddev->gendisk, writes);		disk_stat_add(mddev->gendisk, write_sectors, bio_sectors(bio));	} else {		disk_stat_inc(mddev->gendisk, reads);		disk_stat_add(mddev->gendisk, read_sectors, 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;	r1_bio->state = 0;	if (bio_data_dir(bio) == 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=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();	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);	}	atomic_set(&r1_bio->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;		atomic_inc(&r1_bio->remaining);		bio_list_add(&bl, mbio);	}	bitmap_startwrite(bitmap, bio->bi_sector, r1_bio->sectors);	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/3d310eb7b3df1252e8595d059d982b0a9825a137/raid1.c/buggy/drivers/md/raid1.c