 ITERATE_RDEV(mddev,rdev,tmp) if (rdev->raid_disk >= 0) { char nm[20]; sprintf(nm, "rd%d", rdev->raid_disk); sysfs_create_link(&mddev->kobj, &rdev->kobj, nm); } 
static int do_md_run(mddev_t * mddev){	int pnum, err;	int chunk_size;	struct list_head *tmp;	mdk_rdev_t *rdev;	struct gendisk *disk;	char b[BDEVNAME_SIZE];	if (list_empty(&mddev->disks))		/* cannot run an array with no devices.. */		return -EINVAL;	if (mddev->pers)		return -EBUSY;	/*	 * Analyze all RAID superblock(s)	 */	if (!mddev->raid_disks)		analyze_sbs(mddev);	chunk_size = mddev->chunk_size;	pnum = level_to_pers(mddev->level);	if ((pnum != MULTIPATH) && (pnum != RAID1)) {		if (!chunk_size) {			/*			 * 'default chunksize' in the old md code used to			 * be PAGE_SIZE, baaad.			 * we abort here to be on the safe side. We don't			 * want to continue the bad practice.			 */			printk(KERN_ERR 				"no chunksize specified, see 'man raidtab'\n");			return -EINVAL;		}		if (chunk_size > MAX_CHUNK_SIZE) {			printk(KERN_ERR "too big chunk_size: %d > %d\n",				chunk_size, MAX_CHUNK_SIZE);			return -EINVAL;		}		/*		 * chunk-size has to be a power of 2 and multiples of PAGE_SIZE		 */		if ( (1 << ffz(~chunk_size)) != chunk_size) {			printk(KERN_ERR "chunk_size of %d not valid\n", chunk_size);			return -EINVAL;		}		if (chunk_size < PAGE_SIZE) {			printk(KERN_ERR "too small chunk_size: %d < %ld\n",				chunk_size, PAGE_SIZE);			return -EINVAL;		}		/* devices must have minimum size of one chunk */		ITERATE_RDEV(mddev,rdev,tmp) {			if (rdev->faulty)				continue;			if (rdev->size < chunk_size / 1024) {				printk(KERN_WARNING					"md: Dev %s smaller than chunk_size:"					" %lluk < %dk\n",					bdevname(rdev->bdev,b),					(unsigned long long)rdev->size,					chunk_size / 1024);				return -EINVAL;			}		}	}#ifdef CONFIG_KMOD	if (!pers[pnum])	{		request_module("md-personality-%d", pnum);	}#endif	/*	 * Drop all container device buffers, from now on	 * the only valid external interface is through the md	 * device.	 * Also find largest hardsector size	 */	ITERATE_RDEV(mddev,rdev,tmp) {		if (rdev->faulty)			continue;		sync_blockdev(rdev->bdev);		invalidate_bdev(rdev->bdev, 0);	}	md_probe(mddev->unit, NULL, NULL);	disk = mddev->gendisk;	if (!disk)		return -ENOMEM;	spin_lock(&pers_lock);	if (!pers[pnum] || !try_module_get(pers[pnum]->owner)) {		spin_unlock(&pers_lock);		printk(KERN_WARNING "md: personality %d is not loaded!\n",		       pnum);		return -EINVAL;	}	mddev->pers = pers[pnum];	spin_unlock(&pers_lock);	mddev->recovery = 0;	mddev->resync_max_sectors = mddev->size << 1; /* may be over-ridden by personality */	/* before we start the array running, initialise the bitmap */	err = bitmap_create(mddev);	if (err)		printk(KERN_ERR "%s: failed to create bitmap (%d)\n",			mdname(mddev), err);	else		err = mddev->pers->run(mddev);	if (err) {		printk(KERN_ERR "md: pers->run() failed ...\n");		module_put(mddev->pers->owner);		mddev->pers = NULL;		bitmap_destroy(mddev);		return err;	} 	atomic_set(&mddev->writes_pending,0);	mddev->safemode = 0;	mddev->safemode_timer.function = md_safemode_timeout;	mddev->safemode_timer.data = (unsigned long) mddev;	mddev->safemode_delay = (20 * HZ)/1000 +1; /* 20 msec delay */	mddev->in_sync = 1;		set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);	md_wakeup_thread(mddev->thread);		if (mddev->sb_dirty)		md_update_sb(mddev);	set_capacity(disk, mddev->array_size<<1);	/* If we call blk_queue_make_request here, it will	 * re-initialise max_sectors etc which may have been	 * refined inside -> run.  So just set the bits we need to set.	 * Most initialisation happended when we called	 * blk_queue_make_request(..., md_fail_request)	 * earlier.	 */	mddev->queue->queuedata = mddev;	mddev->queue->make_request_fn = mddev->pers->make_request;	mddev->changed = 1;	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/86e6ffdd243a06663713e637ee683fb27dce8e0c/md.c/clean/drivers/md/md.c