 mddev->queue->unplug_fn = multipath_unplug; mddev->queue->issue_flush_fn = multipath_issue_flush;  
static int multipath_run (mddev_t *mddev){	multipath_conf_t *conf;	int disk_idx;	struct multipath_info *disk;	mdk_rdev_t *rdev;	struct list_head *tmp;	if (mddev->level != LEVEL_MULTIPATH) {		printk("multipath: %s: raid level not set to multipath IO (%d)\n",		       mdname(mddev), mddev->level);		goto out;	}	/*	 * copy the already verified devices into our private MULTIPATH	 * bookkeeping area. [whatever we allocate in multipath_run(),	 * should be freed in multipath_stop()]	 */	conf = kmalloc(sizeof(multipath_conf_t), GFP_KERNEL);	mddev->private = conf;	if (!conf) {		printk(KERN_ERR 			"multipath: couldn't allocate memory for %s\n",			mdname(mddev));		goto out;	}	memset(conf, 0, sizeof(*conf));	conf->multipaths = kmalloc(sizeof(struct multipath_info)*mddev->raid_disks,				   GFP_KERNEL);	if (!conf->multipaths) {		printk(KERN_ERR 			"multipath: couldn't allocate memory for %s\n",			mdname(mddev));		goto out_free_conf;	}	memset(conf->multipaths, 0, sizeof(struct multipath_info)*mddev->raid_disks);	mddev->queue->unplug_fn = multipath_unplug;	mddev->queue->issue_flush_fn = multipath_issue_flush;	conf->working_disks = 0;	ITERATE_RDEV(mddev,rdev,tmp) {		disk_idx = rdev->raid_disk;		if (disk_idx < 0 ||		    disk_idx >= mddev->raid_disks)			continue;		disk = conf->multipaths + 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, not that we ever expect a device with		 * a merge_bvec_fn to be involved in multipath */		if (rdev->bdev->bd_disk->queue->merge_bvec_fn &&		    mddev->queue->max_sectors > (PAGE_SIZE>>9))			blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);		if (!rdev->faulty) 			conf->working_disks++;	}	conf->raid_disks = mddev->raid_disks;	mddev->sb_dirty = 1;	conf->mddev = mddev;	spin_lock_init(&conf->device_lock);	INIT_LIST_HEAD(&conf->retry_list);	if (!conf->working_disks) {		printk(KERN_ERR "multipath: no operational IO paths for %s\n",			mdname(mddev));		goto out_free_conf;	}	mddev->degraded = conf->raid_disks = conf->working_disks;	conf->pool = mempool_create(NR_RESERVED_BUFS,				    mp_pool_alloc, mp_pool_free,				    NULL);	if (conf->pool == NULL) {		printk(KERN_ERR 			"multipath: couldn't allocate memory for %s\n",			mdname(mddev));		goto out_free_conf;	}	{		mddev->thread = md_register_thread(multipathd, mddev, "%s_multipath");		if (!mddev->thread) {			printk(KERN_ERR "multipath: couldn't allocate thread"				" for %s\n", mdname(mddev));			goto out_free_conf;		}	}	printk(KERN_INFO 		"multipath: array %s active with %d out of %d IO paths\n",		mdname(mddev), conf->working_disks, mddev->raid_disks);	/*	 * Ok, everything is just fine now	 */	mddev->array_size = mddev->size;	return 0;out_free_conf:	if (conf->pool)		mempool_destroy(conf->pool);	if (conf->multipaths)		kfree(conf->multipaths);	kfree(conf);	mddev->private = NULL;out:	return -EIO;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/7a5febe9ffeecd1e78c5b505260ccc1ef18021b4/multipath.c/buggy/drivers/md/multipath.c