internal IRP(IoFlowRuntime ioFlow, SafeFileHandle hPort) { this.runtime = ioFlow; this.hPort = hPort; Data = new byte[SIZEOF_IRP_USER_IO_BUFFER]; gcDataBuffer = GCHandle.Alloc(Data, GCHandleType.Pinned); pDataBuffer = (ulong)gcDataBuffer.AddrOfPinnedObject().ToInt64(); lpMessageBuffer = gcDataBuffer.AddrOfPinnedObject(); hEvent = CreateEvent(IntPtr.Zero, false, false, IntPtr.Zero); overlapped = new OVERLAPPED(); gcOVERLAPPED = GCHandle.Alloc(overlapped, GCHandleType.Pinned); addrOverlapped = gcOVERLAPPED.AddrOfPinnedObject(); overlapped.hEvent = hEvent; BackupHeaderBuffer = new byte[IOFLOW_HEADER.SIZEOF_IOFLOW_HEADER]; ioFlowHeader = new IOFLOW_HEADER(BackupHeaderBuffer); }
public bool Start() { string thisMachine = System.Environment.MachineName.ToLower(); // // Initialize IoFlow runtime. // IoFlowRuntime runtime = new IoFlowRuntime((uint)Mpl); string line; // get info from config file Debug.Assert(inputConfig != null && File.Exists(inputConfig)); string[] separators = new string[] { " ", "\t" }; System.IO.StreamReader f = new System.IO.StreamReader(inputConfig); // line has entries SRV_NAME, VM_NAME, VHD_NAME, cacheSizeMB, IO_req_size, write-back/write-through, noCacheWrites/cacheWrites while ((line = f.ReadLine()) != null) { string[] tokens = line.Split(separators, StringSplitOptions.RemoveEmptyEntries); if (tokens.Length == 0) continue; else if (tokens[0].StartsWith(@"#") || tokens[0].StartsWith(@"//")) continue; if (tokens.Length < 7) { throw new ApplicationException(String.Format("invalid config file")); } if (!(tokens[5].Equals("write-through") || tokens[5].Equals("write-back"))) { throw new ApplicationException(String.Format("invalid config file")); } if (!(tokens[6].Equals("cacheWrites") || tokens[6].Equals("noCacheWrites"))) { throw new ApplicationException(String.Format("invalid config file")); } Console.WriteLine("Got tokens {0}, {1}, {2}, {3}, {4}, {5}, {6}", tokens[0], tokens[1], tokens[2], tokens[3], tokens[4], tokens[5], tokens[6]); if (thisMachine.StartsWith(tokens[0].ToLower())) { IoFlow f1 = runtime.CreateFlow(runtime.GetNextFreeFlowId(), tokens[1].ToLower(), tokens[2].ToLower(), PreCreate, null, PreRead, PostRead, PreWrite, PostWrite, PreCleanup, null, null, null); cache.CacheSetFlowSize(f1.FlowId, Convert.ToUInt64(tokens[3])); //cache.CacheCreateGhostCache(f1.FlowId, Convert.ToUInt32(tokens[4])); //XXXIS: this should come from the controller... cache.AlignedBlockSize = Convert.ToUInt32(tokens[4]); switch (tokens[5]) { case "write-through": cache.SetCacheWritePolicy(CacheWritePolicy.WriteThrough); break; } switch (tokens[6]) { case "cacheWrites": cache.SetCacheWriteBuffering(CacheWriteBuffer.Cache); break; case "noCacheWrites": cache.SetCacheWriteBuffering(CacheWriteBuffer.noCache); break; } } } runtime.Start(false); CacheThreadBlocked.WaitOne(); runtime.Close(); return true; }