if (md_write_start(mddev, bio) == 0) return 0; 
md_write_start(mddev, bio); 
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;	r10bio_t *r10_bio;	struct bio *read_bio;	int i;	int chunk_sects = conf->chunk_mask + 1;	/* If this request crosses a chunk boundary, we need to	 * split it.  This will only happen for 1 PAGE (or less) requests.	 */	if (unlikely( (bio->bi_sector & conf->chunk_mask) + (bio->bi_size >> 9)		      > chunk_sects &&		    conf->near_copies < conf->raid_disks)) {		struct bio_pair *bp;		/* Sanity check -- queue functions should prevent this happening */		if (bio->bi_vcnt != 1 ||		    bio->bi_idx != 0)			goto bad_map;		/* This is a one page bio that upper layers		 * refuse to split for us, so we need to split it.		 */		bp = bio_split(bio, bio_split_pool,			       chunk_sects - (bio->bi_sector & (chunk_sects - 1)) );		if (make_request(q, &bp->bio1))			generic_make_request(&bp->bio1);		if (make_request(q, &bp->bio2))			generic_make_request(&bp->bio2);		bio_pair_release(bp);		return 0;	bad_map:		printk("raid10_make_request bug: can't convert block across chunks"		       " or bigger than %dk %llu %d\n", chunk_sects/2,		       (unsigned long long)bio->bi_sector, bio->bi_size >> 10);		bio_io_error(bio, bio->bi_size);		return 0;	}	if (md_write_start(mddev, bio) == 0)		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.	 */	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));	}	r10_bio = mempool_alloc(conf->r10bio_pool, GFP_NOIO);	r10_bio->master_bio = bio;	r10_bio->sectors = bio->bi_size >> 9;	r10_bio->mddev = mddev;	r10_bio->sector = bio->bi_sector;	if (bio_data_dir(bio) == READ) {		/*		 * read balancing logic:		 */		int disk = read_balance(conf, r10_bio);		int slot = r10_bio->read_slot;		if (disk < 0) {			raid_end_bio_io(r10_bio);			return 0;		}		mirror = conf->mirrors + disk;		read_bio = bio_clone(bio, GFP_NOIO);		r10_bio->devs[slot].bio = read_bio;		read_bio->bi_sector = r10_bio->devs[slot].addr +			mirror->rdev->data_offset;		read_bio->bi_bdev = mirror->rdev->bdev;		read_bio->bi_end_io = raid10_end_read_request;		read_bio->bi_rw = READ;		read_bio->bi_private = r10_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	 */	raid10_find_phys(conf, r10_bio);	rcu_read_lock();	for (i = 0;  i < conf->copies; i++) {		int d = r10_bio->devs[i].devnum;		if (conf->mirrors[d].rdev &&		    !conf->mirrors[d].rdev->faulty) {			atomic_inc(&conf->mirrors[d].rdev->nr_pending);			r10_bio->devs[i].bio = bio;		} else			r10_bio->devs[i].bio = NULL;	}	rcu_read_unlock();	atomic_set(&r10_bio->remaining, 1);	for (i = 0; i < conf->copies; i++) {		struct bio *mbio;		int d = r10_bio->devs[i].devnum;		if (!r10_bio->devs[i].bio)			continue;		mbio = bio_clone(bio, GFP_NOIO);		r10_bio->devs[i].bio = mbio;		mbio->bi_sector	= r10_bio->devs[i].addr+			conf->mirrors[d].rdev->data_offset;		mbio->bi_bdev = conf->mirrors[d].rdev->bdev;		mbio->bi_end_io	= raid10_end_write_request;		mbio->bi_rw = WRITE;		mbio->bi_private = r10_bio;		atomic_inc(&r10_bio->remaining);		generic_make_request(mbio);	}	if (atomic_dec_and_test(&r10_bio->remaining)) {		md_write_end(mddev);		raid_end_bio_io(r10_bio);	}	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/3d310eb7b3df1252e8595d059d982b0a9825a137/raid10.c/clean/drivers/md/raid10.c