if (conf->mirrors) kfree(conf->mirrors); 
kfree(conf->mirrors); 
static int run(mddev_t *mddev){	conf_t *conf;	int i, disk_idx;	mirror_info_t *disk;	mdk_rdev_t *rdev;	struct list_head *tmp;	int nc, fc;	sector_t stride, size;	if (mddev->level != 10) {		printk(KERN_ERR "raid10: %s: raid level not set correctly... (%d)\n",		       mdname(mddev), mddev->level);		goto out;	}	nc = mddev->layout & 255;	fc = (mddev->layout >> 8) & 255;	if ((nc*fc) <2 || (nc*fc) > mddev->raid_disks ||	    (mddev->layout >> 16)) {		printk(KERN_ERR "raid10: %s: unsupported raid10 layout: 0x%8x\n",		       mdname(mddev), mddev->layout);		goto out;	}	/*	 * copy the already verified devices into our private RAID10	 * bookkeeping area. [whatever we allocate in run(),	 * should be freed in stop()]	 */	conf = kmalloc(sizeof(conf_t), GFP_KERNEL);	mddev->private = conf;	if (!conf) {		printk(KERN_ERR "raid10: couldn't allocate memory for %s\n",			mdname(mddev));		goto out;	}	memset(conf, 0, sizeof(*conf));	conf->mirrors = kmalloc(sizeof(struct mirror_info)*mddev->raid_disks,				 GFP_KERNEL);	if (!conf->mirrors) {		printk(KERN_ERR "raid10: couldn't allocate memory for %s\n",		       mdname(mddev));		goto out_free_conf;	}	memset(conf->mirrors, 0, sizeof(struct mirror_info)*mddev->raid_disks);	conf->near_copies = nc;	conf->far_copies = fc;	conf->copies = nc*fc;	conf->chunk_mask = (sector_t)(mddev->chunk_size>>9)-1;	conf->chunk_shift = ffz(~mddev->chunk_size) - 9;	stride = mddev->size >> (conf->chunk_shift-1);	sector_div(stride, fc);	conf->stride = stride << conf->chunk_shift;	conf->r10bio_pool = mempool_create(NR_RAID10_BIOS, r10bio_pool_alloc,						r10bio_pool_free, conf);	if (!conf->r10bio_pool) {		printk(KERN_ERR "raid10: couldn't allocate memory for %s\n",			mdname(mddev));		goto out_free_conf;	}	ITERATE_RDEV(mddev, rdev, tmp) {		disk_idx = rdev->raid_disk;		if (disk_idx >= mddev->raid_disks		    || disk_idx < 0)			continue;		disk = conf->mirrors + disk_idx;		disk->rdev = rdev;		blk_queue_stack_limits(mddev->queue,				       rdev->bdev->bd_disk->queue);		/* as we don't honour merge_bvec_fn, we must never risk		 * violating it, so limit ->max_sector to one PAGE, as		 * a one page request is never in violation.		 */		if (rdev->bdev->bd_disk->queue->merge_bvec_fn &&		    mddev->queue->max_sectors > (PAGE_SIZE>>9))			mddev->queue->max_sectors = (PAGE_SIZE>>9);		disk->head_position = 0;		if (!rdev->faulty && rdev->in_sync)			conf->working_disks++;	}	conf->raid_disks = mddev->raid_disks;	conf->mddev = mddev;	spin_lock_init(&conf->device_lock);	INIT_LIST_HEAD(&conf->retry_list);	spin_lock_init(&conf->resync_lock);	init_waitqueue_head(&conf->wait_idle);	init_waitqueue_head(&conf->wait_resume);	if (!conf->working_disks) {		printk(KERN_ERR "raid10: no operational mirrors for %s\n",			mdname(mddev));		goto out_free_conf;	}	mddev->degraded = 0;	for (i = 0; i < conf->raid_disks; i++) {		disk = conf->mirrors + i;		if (!disk->rdev) {			disk->head_position = 0;			mddev->degraded++;		}	}	mddev->thread = md_register_thread(raid10d, mddev, "%s_raid10");	if (!mddev->thread) {		printk(KERN_ERR		       "raid10: couldn't allocate thread for %s\n",		       mdname(mddev));		goto out_free_conf;	}	printk(KERN_INFO		"raid10: raid set %s active with %d out of %d devices\n",		mdname(mddev), mddev->raid_disks - mddev->degraded,		mddev->raid_disks);	/*	 * Ok, everything is just fine now	 */	size = conf->stride * conf->raid_disks;	sector_div(size, conf->near_copies);	mddev->array_size = size/2;	mddev->resync_max_sectors = size;	mddev->queue->unplug_fn = raid10_unplug;	mddev->queue->issue_flush_fn = raid10_issue_flush;	/* Calculate max read-ahead size.	 * We need to readahead at least twice a whole stripe....	 * maybe...	 */	{		int stripe = conf->raid_disks * mddev->chunk_size / PAGE_CACHE_SIZE;		stripe /= conf->near_copies;		if (mddev->queue->backing_dev_info.ra_pages < 2* stripe)			mddev->queue->backing_dev_info.ra_pages = 2* stripe;	}	if (conf->near_copies < mddev->raid_disks)		blk_queue_merge_bvec(mddev->queue, raid10_mergeable_bvec);	return 0;out_free_conf:	if (conf->r10bio_pool)		mempool_destroy(conf->r10bio_pool);	if (conf->mirrors)		kfree(conf->mirrors);	kfree(conf);	mddev->private = NULL;out:	return -EIO;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/990a8baf568ca1d0ae65e59783ff821794118d07/raid10.c/buggy/drivers/md/raid10.c