示例#1
0
        protected MarvellVolume MakeVolume(MvApi.MvApi.LD_Info ldInfo)
        {
            byte          b             = 0;
            MarvellVolume marvellVolume = new MarvellVolume(ldInfo.ID, this);

            marvellVolume.Name       = MarvellUtil.GetApiString(ldInfo.Name, 16);
            marvellVolume.RaidLevel  = MarvellUtil.ToStorApiRaidLevel(ldInfo.RaidMode);
            marvellVolume.StripeSize = (ulong)((long)(ldInfo.StripeBlockSize * 1024));
            marvellVolume.Status     = MarvellUtil.ToStorApiVolumeStatus(ldInfo.Status);
            marvellVolume.Capacity   = ldInfo.Size.ToUlong() * 1024UL;
            for (byte b2 = 0; b2 < ldInfo.HDCount; b2 += 1)
            {
                marvellVolume.BlockIds.Add(ldInfo.BlockIDs[(int)b2]);
            }
            short[] id = new short[]
            {
                ldInfo.ID
            };
            lock (MarvellUtil.mvApiLock)
            {
                try
                {
                    b = MvApi.MvApi.MV_DiskHasOS(this.AdapterId, 0, 1, id);
                }
                catch (Exception ex)
                {
                    Logger.Warn("MakeVolume MV_DiskHasOS exception: {0}", new object[]
                    {
                        ex
                    });
                    throw ex;
                }
            }
            if (b == 158)
            {
                marvellVolume.IsSystem = true;
            }
            if (ldInfo.BGAStatus != 0)
            {
                MvApi.MvApi.LD_Status_Request ld_Status_Request = default(MvApi.MvApi.LD_Status_Request);
                ld_Status_Request.header.Init();
                ld_Status_Request.header.requestType       = 2;
                ld_Status_Request.header.startingIndexOrId = ldInfo.ID;
                ld_Status_Request.header.numRequested      = 1;
                lock (MarvellUtil.mvApiLock)
                {
                    try
                    {
                        b = MvApi.MvApi.MV_LD_GetStatus(this.AdapterId, ref ld_Status_Request);
                    }
                    catch (Exception ex2)
                    {
                        Logger.Warn("MV_LD_GetStatus exception: {0}", new object[]
                        {
                            ex2
                        });
                        throw ex2;
                    }
                }
                if (b == 0)
                {
                    marvellVolume.Progress = (float)ld_Status_Request.ldStatus[0].BgaPercentage;
                    if (ld_Status_Request.ldStatus[0].Bga != 0 && marvellVolume.Status != VolumeStatus.VOLUME_FAILED)
                    {
                        VolumeStatus volumeStatus = MarvellUtil.ToStorApiVolumeStatusBGA(ld_Status_Request.ldStatus[0].Bga);
                        if (volumeStatus != VolumeStatus.VOLUME_UNKNOWN)
                        {
                            marvellVolume.Status = volumeStatus;
                        }
                    }
                    if (ld_Status_Request.ldStatus[0].Bga == 32)
                    {
                        MvApi.MvApi.LD_Info ld_Info = default(MvApi.MvApi.LD_Info);
                        lock (MarvellUtil.mvApiLock)
                        {
                            try
                            {
                                b = MvApi.MvApi.MV_LD_GetTargetLDInfo(this.AdapterId, ldInfo.ID, ref ld_Info);
                            }
                            catch (Exception ex3)
                            {
                                Logger.Warn("MV_LD_GetTargetLDInfo exception: {0}", new object[]
                                {
                                    ex3
                                });
                                throw ex3;
                            }
                        }
                        if (b == 0)
                        {
                            marvellVolume.RaidLevel  = MarvellUtil.ToStorApiRaidLevel(ld_Info.RaidMode);
                            marvellVolume.StripeSize = (ulong)ld_Info.StripeBlockSize;
                            marvellVolume.BlockIds.Clear();
                            for (byte b3 = 0; b3 < ld_Info.HDCount; b3 += 1)
                            {
                                marvellVolume.BlockIds.Add(ld_Info.BlockIDs[(int)b3]);
                            }
                        }
                    }
                }
            }
            return(marvellVolume);
        }
示例#2
0
        protected MarvellDrive MakeDrive(MvApi.MvApi.HD_Info hdInfo)
        {
            byte          b            = 0;
            StorApiStatus a            = StorApiStatusEnum.STOR_NO_ERROR;
            MarvellDrive  marvellDrive = new MarvellDrive(hdInfo.Link.Self.DevID, this);

            marvellDrive.Port           = this.GetDrivePort(hdInfo);
            marvellDrive.Model          = MarvellUtil.GetApiString(hdInfo.Model, 40);
            marvellDrive.Serial         = MarvellUtil.GetApiString(hdInfo.SerialNo, 20);
            marvellDrive.Revision       = MarvellUtil.GetApiString(hdInfo.FWVersion, 8);
            marvellDrive.SectorSize     = (ulong)((hdInfo.BlockSize == 0u) ? 512u : hdInfo.BlockSize);
            marvellDrive.SectorCount    = hdInfo.Size.ToUlong() * 1024UL / marvellDrive.SectorSize;
            marvellDrive.IsSmartEnabled = false;
            marvellDrive.IsSystem       = false;
            marvellDrive.Status         = DriveStatus.DRIVE_UNKNOWN;
            marvellDrive.Domain         = DriveDomain.DRIVE_DOMAIN_UNKNOWN;
            short[] id = new short[]
            {
                hdInfo.Link.Self.DevID
            };
            lock (MarvellUtil.mvApiLock)
            {
                try
                {
                    b = MvApi.MvApi.MV_DiskHasOS(this.AdapterId, 1, 1, id);
                }
                catch (Exception ex)
                {
                    Logger.Warn("MV_DiskHasOS exception: {0}", new object[]
                    {
                        ex
                    });
                    throw ex;
                }
            }
            if (b == 159)
            {
                marvellDrive.IsSystem = true;
            }
            MvApi.MvApi.HD_Config_Request hd_Config_Request = default(MvApi.MvApi.HD_Config_Request);
            hd_Config_Request.header.Init();
            hd_Config_Request.header.requestType       = 2;
            hd_Config_Request.header.startingIndexOrId = hdInfo.Link.Self.DevID;
            hd_Config_Request.header.numRequested      = 1;
            lock (MarvellUtil.mvApiLock)
            {
                try
                {
                    b = MvApi.MvApi.MV_PD_GetConfig(this.AdapterId, ref hd_Config_Request);
                }
                catch (Exception ex2)
                {
                    Logger.Warn("MV_PD_GetConfig exception: {0}", new object[]
                    {
                        ex2
                    });
                    throw ex2;
                }
            }
            marvellDrive.IsSmartEnabled = (hd_Config_Request.hdConfig[0].SMARTOn == 1);
            if (!marvellDrive.IsSmartEnabled)
            {
                a = marvellDrive.EnableSmart();
                if (a == StorApiStatusEnum.STOR_NO_ERROR)
                {
                    marvellDrive.IsSmartEnabled = true;
                }
            }
            return(marvellDrive);
        }