(rdev->faulty || ! rdev->in_sync) && 
(test_bit(Faulty, &rdev->flags) || ! test_bit(In_sync, &rdev->flags)) && 
void md_check_recovery(mddev_t *mddev){	mdk_rdev_t *rdev;	struct list_head *rtmp;	if (mddev->bitmap)		bitmap_daemon_work(mddev->bitmap);	if (mddev->ro)		return;	if (signal_pending(current)) {		if (mddev->pers->sync_request) {			printk(KERN_INFO "md: %s in immediate safe mode\n",			       mdname(mddev));			mddev->safemode = 2;		}		flush_signals(current);	}	if ( ! (		mddev->sb_dirty ||		test_bit(MD_RECOVERY_NEEDED, &mddev->recovery) ||		test_bit(MD_RECOVERY_DONE, &mddev->recovery) ||		(mddev->safemode == 1) ||		(mddev->safemode == 2 && ! atomic_read(&mddev->writes_pending)		 && !mddev->in_sync && mddev->recovery_cp == MaxSector)		))		return;	if (mddev_trylock(mddev)==0) {		int spares =0;		spin_lock(&mddev->write_lock);		if (mddev->safemode && !atomic_read(&mddev->writes_pending) &&		    !mddev->in_sync && mddev->recovery_cp == MaxSector) {			mddev->in_sync = 1;			mddev->sb_dirty = 1;		}		if (mddev->safemode == 1)			mddev->safemode = 0;		spin_unlock(&mddev->write_lock);		if (mddev->sb_dirty)			md_update_sb(mddev);		if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) &&		    !test_bit(MD_RECOVERY_DONE, &mddev->recovery)) {			/* resync/recovery still happening */			clear_bit(MD_RECOVERY_NEEDED, &mddev->recovery);			goto unlock;		}		if (mddev->sync_thread) {			/* resync has finished, collect result */			md_unregister_thread(mddev->sync_thread);			mddev->sync_thread = NULL;			if (!test_bit(MD_RECOVERY_ERR, &mddev->recovery) &&			    !test_bit(MD_RECOVERY_INTR, &mddev->recovery)) {				/* success...*/				/* activate any spares */				mddev->pers->spare_active(mddev);			}			md_update_sb(mddev);			/* if array is no-longer degraded, then any saved_raid_disk			 * information must be scrapped			 */			if (!mddev->degraded)				ITERATE_RDEV(mddev,rdev,rtmp)					rdev->saved_raid_disk = -1;			mddev->recovery = 0;			/* flag recovery needed just to double check */			set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);			goto unlock;		}		/* Clear some bits that don't mean anything, but		 * might be left set		 */		clear_bit(MD_RECOVERY_NEEDED, &mddev->recovery);		clear_bit(MD_RECOVERY_ERR, &mddev->recovery);		clear_bit(MD_RECOVERY_INTR, &mddev->recovery);		clear_bit(MD_RECOVERY_DONE, &mddev->recovery);		/* no recovery is running.		 * remove any failed drives, then		 * add spares if possible.		 * Spare are also removed and re-added, to allow		 * the personality to fail the re-add.		 */		ITERATE_RDEV(mddev,rdev,rtmp)			if (rdev->raid_disk >= 0 &&			    (rdev->faulty || ! rdev->in_sync) &&			    atomic_read(&rdev->nr_pending)==0) {				if (mddev->pers->hot_remove_disk(mddev, rdev->raid_disk)==0) {					char nm[20];					sprintf(nm,"rd%d", rdev->raid_disk);					sysfs_remove_link(&mddev->kobj, nm);					rdev->raid_disk = -1;				}			}		if (mddev->degraded) {			ITERATE_RDEV(mddev,rdev,rtmp)				if (rdev->raid_disk < 0				    && !rdev->faulty) {					if (mddev->pers->hot_add_disk(mddev,rdev)) {						char nm[20];						sprintf(nm, "rd%d", rdev->raid_disk);						sysfs_create_link(&mddev->kobj, &rdev->kobj, nm);						spares++;					} else						break;				}		}		if (spares) {			clear_bit(MD_RECOVERY_SYNC, &mddev->recovery);			clear_bit(MD_RECOVERY_CHECK, &mddev->recovery);		} else if (mddev->recovery_cp < MaxSector) {			set_bit(MD_RECOVERY_SYNC, &mddev->recovery);		} else if (!test_bit(MD_RECOVERY_SYNC, &mddev->recovery))			/* nothing to be done ... */			goto unlock;		if (mddev->pers->sync_request) {			set_bit(MD_RECOVERY_RUNNING, &mddev->recovery);			if (spares && mddev->bitmap && ! mddev->bitmap->file) {				/* We are adding a device or devices to an array				 * which has the bitmap stored on all devices.				 * So make sure all bitmap pages get written				 */				bitmap_write_all(mddev->bitmap);			}			mddev->sync_thread = md_register_thread(md_do_sync,								mddev,								"%s_resync");			if (!mddev->sync_thread) {				printk(KERN_ERR "%s: could not start resync"					" thread...\n", 					mdname(mddev));				/* leave the spares where they are, it shouldn't hurt */				mddev->recovery = 0;			} else {				md_wakeup_thread(mddev->sync_thread);			}		}	unlock:		mddev_unlock(mddev);	}}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/b2d444d7ad975d555bb919601bcdc0e58975a40e/md.c/buggy/drivers/md/md.c