if (!rdev->faulty && rdev->in_sync) 
if (!test_bit(Faulty, &rdev->flags) && test_bit(In_sync, &rdev->flags)) 
static int run(mddev_t *mddev){	conf_t *conf;	int i, j, disk_idx;	mirror_info_t *disk;	mdk_rdev_t *rdev;	struct list_head *tmp;	if (mddev->level != 1) {		printk("raid1: %s: raid level not set to mirroring (%d)\n",		       mdname(mddev), mddev->level);		goto out;	}	/*	 * copy the already verified devices into our private RAID1	 * bookkeeping area. [whatever we allocate in run(),	 * should be freed in stop()]	 */	conf = kmalloc(sizeof(conf_t), GFP_KERNEL);	mddev->private = conf;	if (!conf)		goto out_no_mem;	memset(conf, 0, sizeof(*conf));	conf->mirrors = kmalloc(sizeof(struct mirror_info)*mddev->raid_disks, 				 GFP_KERNEL);	if (!conf->mirrors)		goto out_no_mem;	memset(conf->mirrors, 0, sizeof(struct mirror_info)*mddev->raid_disks);	conf->poolinfo = kmalloc(sizeof(*conf->poolinfo), GFP_KERNEL);	if (!conf->poolinfo)		goto out_no_mem;	conf->poolinfo->mddev = mddev;	conf->poolinfo->raid_disks = mddev->raid_disks;	conf->r1bio_pool = mempool_create(NR_RAID1_BIOS, r1bio_pool_alloc,					  r1bio_pool_free,					  conf->poolinfo);	if (!conf->r1bio_pool)		goto out_no_mem;	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))			blk_queue_max_sectors(mddev->queue, 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);	if (conf->working_disks == 1)		mddev->recovery_cp = MaxSector;	spin_lock_init(&conf->resync_lock);	init_waitqueue_head(&conf->wait_idle);	init_waitqueue_head(&conf->wait_resume);	bio_list_init(&conf->pending_bio_list);	bio_list_init(&conf->flushing_bio_list);	if (!conf->working_disks) {		printk(KERN_ERR "raid1: 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++;		}	}	/*	 * find the first working one and use it as a starting point	 * to read balancing.	 */	for (j = 0; j < conf->raid_disks &&		     (!conf->mirrors[j].rdev ||		      !conf->mirrors[j].rdev->in_sync) ; j++)		/* nothing */;	conf->last_used = j;	mddev->thread = md_register_thread(raid1d, mddev, "%s_raid1");	if (!mddev->thread) {		printk(KERN_ERR		       "raid1: couldn't allocate thread for %s\n",		       mdname(mddev));		goto out_free_conf;	}	if (mddev->bitmap) mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ;	printk(KERN_INFO 		"raid1: raid set %s active with %d out of %d mirrors\n",		mdname(mddev), mddev->raid_disks - mddev->degraded, 		mddev->raid_disks);	/*	 * Ok, everything is just fine now	 */	mddev->array_size = mddev->size;	mddev->queue->unplug_fn = raid1_unplug;	mddev->queue->issue_flush_fn = raid1_issue_flush;	return 0;out_no_mem:	printk(KERN_ERR "raid1: couldn't allocate memory for %s\n",	       mdname(mddev));out_free_conf:	if (conf) {		if (conf->r1bio_pool)			mempool_destroy(conf->r1bio_pool);		kfree(conf->mirrors);		kfree(conf->poolinfo);		kfree(conf);		mddev->private = NULL;	}out:	return -EIO;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/b2d444d7ad975d555bb919601bcdc0e58975a40e/raid1.c/buggy/drivers/md/raid1.c