Exemple #1
0
void CMirrorWorkThread::RebindMirror()
{
	// Get list of disks involved in the previous mirroring.
	// NOTE : Because disks aggregated can also be mirrored,
	//	there can be more than two disks involved in the mirroring.
	CDiskObjectPtr aggregationRoot;
	aggregationRoot = m_pSource->GetParent();
	while ( !aggregationRoot->GetParent()->IsRoot() )
	{
		aggregationRoot = aggregationRoot->GetParent();
	}

	// Mark all the bitmaps dirty.
	m_pSource->OpenExclusive();
	m_pDest->OpenExclusive();
	m_pSource->MarkAllBitmap();

	CUnitDiskInfoHandlerPtr pHandler = m_pSource->GetInfoHandler();
	aggregationRoot->Rebind( 
						m_pDest, 
						pHandler->GetPosInBind() ^ 0x01
						);
	aggregationRoot->CommitDiskInfo(TRUE);


	// Write binding information to the destination disk
	m_pDest->Mirror(m_pSource);
	m_pDest->CommitDiskInfo(TRUE);
	m_bRebound = TRUE;

	m_pSource->Close();
	m_pDest->Close();
}
Exemple #2
0
BOOL CUnitDiskUIHandler::OnCommand(CDiskObjectPtr obj, UINT nCommandID) const
{
	ATLASSERT( dynamic_cast<CUnitDiskObject*>(obj.get()) != NULL);

	switch( nCommandID )
	{
	case IDM_TOOL_SYNCHRONIZE:
		{
			// Delegate command to parent
			const CObjectUIHandler *phandler = 
				CObjectUIHandler::GetUIHandler( obj->GetParent() );
			return phandler->OnCommand( obj->GetParent(), nCommandID );
		}
	case IDM_TOOL_PROPERTY:
		return OnProperty( obj );
	}

	return FALSE;
}
Exemple #3
0
CCommandSet CUnitDiskUIHandler::GetCommandSet(CDiskObjectPtr obj) const
{
	ATLASSERT( dynamic_cast<CUnitDiskObject*>(obj.get()) != NULL);
	CCommandSet setCommand;
	CUnitDiskObjectPtr unitDisk =
		boost::dynamic_pointer_cast<CUnitDiskObject>(obj);
	CUnitDiskInfoHandlerPtr handler = unitDisk->GetInfoHandler();
	BOOL bCanWrite;

	if ( handler->IsBound() )
	{
		CDiskObjectPtr aggrRoot = unitDisk->GetParent();
		if ( aggrRoot->IsRoot() )
		{
			// This can occur when the tree is updated just after
			// the disk is bound.
			// This additional if code prevents error.
			setCommand.push_back( CCommand(IDM_TOOL_UNBIND) ); 
		}
		else
		{
			while ( !aggrRoot->GetParent()->IsRoot() )
				aggrRoot = aggrRoot->GetParent();
			// To Unbind, we should have write privilege to all the disks in bind
			setCommand.push_back( CCommand(IDM_TOOL_UNBIND, 
				aggrRoot->GetAccessMask() & GENERIC_WRITE) );
		}
	}
	else
	{
		bCanWrite =  unitDisk->GetAccessMask() & GENERIC_WRITE;
		setCommand.push_back( CCommand(IDM_TOOL_ADDMIRROR, bCanWrite) );
	}

	if ( handler->IsMirrored() )
	{
		CMirDiskObjectPtr parent = 
			boost::dynamic_pointer_cast<CMirDiskObject>(unitDisk->GetParent());
		if ( parent.get() != NULL )
		{
			// To synchronize, we have write privilege to the two disks in mirroring
			setCommand.push_back( CCommand(IDM_TOOL_SYNCHRONIZE, 
									(parent->GetAccessMask() & GENERIC_WRITE) &&
									parent->IsDirty() && !parent->IsBroken() &&
									parent->HasWriteAccess()
									) 
								);
		}
		CDiskObjectPtr aggrRoot = unitDisk->GetParent();
		if ( aggrRoot->IsRoot() )
		{
			// This can occur when the tree is updated just after
			// the disk is bound.
			// This additional if code prevents error.
			setCommand.push_back( CCommand(IDM_TOOL_UNBIND) ); 
		}
		else
		{
			while ( !aggrRoot->GetParent()->IsRoot() )
				aggrRoot = aggrRoot->GetParent();
		}
	}
	else if(NMT_RAID4 == handler->GetNDASMediaType())
	{
		CRAID4DiskObjectPtr parent = 
			boost::dynamic_pointer_cast<CRAID4DiskObject>(unitDisk->GetParent());

		if ( parent.get() != NULL )
		{
			// To synchronize, we have write privilege to the two disks in mirroring
			setCommand.push_back( CCommand(IDM_TOOL_SYNCHRONIZE, 
				(parent->GetAccessMask() & GENERIC_WRITE)
				&& parent->IsDirty() && !parent->IsBroken() 
				) 
				);
		}
	}

	if(unitDisk->IsUnitDisk())
	{
		setCommand.push_back( CCommand(IDM_TOOL_SINGLE) );
	}
	return setCommand;
}
//////////////////////////////////////////////////////////////////////////
// Page 1
//////////////////////////////////////////////////////////////////////////
LRESULT CDiskPropertyPage1::OnInitDialog(HWND /*hWndFocus*/, LPARAM /*lParam*/)
{
	WTL::CString strCaption;
	strCaption.LoadString(IDS_DISKPROPERTYPAGE_CAPTION);
	GetParent().SetWindowText(strCaption);

	CDiskObjectPtr disk = GetParentSheet()->GetDiskObject();
	const CObjectUIHandler *phandler = CObjectUIHandler::GetUIHandler( disk );
	WTL::CString strText;

	if(disk->IsUnitDisk())
	{
		GetDlgItem(IDC_EDIT_NAME).SetWindowText( disk->GetTitle() );
		GetDlgItem(IDC_EDIT_ID).SetWindowText( 
			phandler->GetStringID(disk) );
	}
	else
	{
		GetDlgItem(IDC_EDIT_NAME).SetWindowText(phandler->GetTitle(disk));
		GetDlgItem(IDC_DEVICE_ID).ShowWindow(SW_HIDE);
		GetDlgItem(IDC_EDIT_ID).ShowWindow(SW_HIDE);
	}

	if ( (disk->GetAccessMask() & GENERIC_WRITE) != 0 )
	{
		strText.LoadString( IDS_DISKPROPERTYPAGE_WRITEKEY_PRESENT );
		GetDlgItem(IDC_EDIT_WRITEKEY).SetWindowText( strText );
	}
	else
	{
		strText.LoadString( IDS_DISKPROPERTYPAGE_WRITEKEY_NOT_PRESENT );
		GetDlgItem(IDC_EDIT_WRITEKEY).SetWindowText( strText );
	}
	WTL::CString strCapacity;
	strCapacity.FormatMessage( 
			IDS_DISKPROPERTYPAGE_SIZE_IN_GB,
			phandler->GetSizeInMB( disk ) / 1024,
			(phandler->GetSizeInMB( disk ) % 1024) / 10 
			);
	GetDlgItem(IDC_EDIT_CAPACITY).SetWindowText( strCapacity );

	//
	// If the object is composite disk with 2 mirrored disk of DIB V1,
	// display 'Migrate' button and message.
	//
	if(!disk->IsUnitDisk() && // bound disk
		disk->GetParent()->IsRoot() && // top disk
		2 == disk->GetDiskCount()) // 2 disks only
	{
		CDiskObjectCompositePtr pDiskObjectComposite = 
            boost::dynamic_pointer_cast<CDiskObjectComposite>(disk);
		if(NMT_MIRROR == pDiskObjectComposite->GetNDASMediaType())
		{
			GetDlgItem(IDC_TEXT_MIGRATE).ShowWindow( SW_SHOW );
			GetDlgItem(IDC_BTN_MIGRATE).ShowWindow( SW_SHOW );
			GetDlgItem(IDC_ST_MIGRATE).ShowWindow( SW_SHOW );
		}
	}

	return 0;
}