Ejemplo n.º 1
0
 public MirrorVdev(NvList config, Dictionary <ulong, LeafVdevInfo> leafs)
     : base(config)
 {
     this.mVdevs = config.Get <NvList[]>("children")
                   .Select(child => Vdev.Create(child, leafs))
                   .ToArray();
 }
Ejemplo n.º 2
0
        readonly int mUnitShift; //ashift
        public RaidzVdev(NvList config, Dictionary<ulong, LeafVdevInfo> leafs)
            : base(config)
        {
            this.mVdevs = config.Get<NvList[]>("children")
                .Select(child => Vdev.Create(child, leafs))
                .OrderBy(child => child.ID)
                .ToArray();

            mNparity = config.Get<UInt64>("nparity");
            mUnitShift = (int)config.Get<UInt64>("ashift");
        }
Ejemplo n.º 3
0
        public static Vdev[] CreateVdevTree(List <LeafVdevInfo> hdds)
        {
            var hddMap           = new Dictionary <ulong, LeafVdevInfo>();
            var innerVdevConfigs = new Dictionary <ulong, NvList>();

            foreach (var hdd in hdds)
            {
                hddMap.Add(hdd.Config.Get <ulong>("guid"), hdd);
                var vdevTree = hdd.Config.Get <NvList>("vdev_tree");
                innerVdevConfigs[vdevTree.Get <ulong>("guid")] = vdevTree;
            }

            var innerVdevs = new List <Vdev>();

            foreach (var kvp in innerVdevConfigs)
            {
                innerVdevs.Add(Vdev.Create(kvp.Value, hddMap));
            }

            ulong calculatedTopGuid = 0;

            for (int i = 0; i < innerVdevs.Count; i++)
            {
                calculatedTopGuid += innerVdevs[i].Guid;
            }

            var ret = innerVdevs.OrderBy(v => v.ID).ToArray();

            for (uint i = 0; i < ret.Length; i++)
            {
                if (ret[i].ID != i)
                {
                    throw new Exception("Missing vdev.");
                }
            }
            return(ret);
        }