Ejemplo n.º 1
0
            public void Dispose()
            {
                foreach (var page in _state.LoadedPages)
                {
                    var loadedPage = page.Value;
                    // we have to do this here because we need to verify that this is actually written to disk
                    // afterward, we can call flush on this
                    var result = Syscall.msync(new IntPtr(loadedPage.Pointer), (UIntPtr)(loadedPage.NumberOfPages * Constants.Storage.PageSize), MsyncFlags.MS_SYNC);
                    if (result == -1)
                    {
                        var err = Marshal.GetLastWin32Error();
                        Syscall.ThrowLastError(err, "msync on " + loadedPage);
                    }
                }

                var canCleanup = false;

                foreach (var addr in _state.AddressesToUnload)
                {
                    canCleanup |= Interlocked.Decrement(ref addr.Usages) == 0;
                }
                if (canCleanup)
                {
                    _parent.CleanupMemory(_state);
                }
            }
Ejemplo n.º 2
0
        public override void Sync(long totalUnsynced)
        {
            var currentState = GetPagerStateAndAddRefAtomically();

            try
            {
                using (var metric = Options.IoMetrics.MeterIoRate(FileName.FullPath, IoMetrics.MeterType.DataSync, 0))
                {
                    foreach (var alloc in currentState.AllocationInfos)
                    {
                        metric.IncrementFileSize(alloc.Size);
                        var result = Syscall.msync(new IntPtr(alloc.BaseAddress), (UIntPtr)alloc.Size, MsyncFlags.MS_SYNC);
                        if (result == -1)
                        {
                            var err = Marshal.GetLastWin32Error();
                            Syscall.ThrowLastError(err, "msync on " + FileName);
                        }
                    }
                    metric.IncrementSize(totalUnsynced);
                }
            }
            finally
            {
                currentState.Release();
            }
        }
Ejemplo n.º 3
0
        public override void Sync()
        {
            //TODO: Is it worth it to change to just one call for msync for the entire file?
            var currentState = GetPagerStateAndAddRefAtomically();

            try
            {
                using (var metric = Options.IoMetrics.MeterIoRate(FileName, IoMetrics.MeterType.DataSync, 0))
                {
                    foreach (var alloc in currentState.AllocationInfos)
                    {
                        metric.IncrementSize(alloc.Size);
                        var result = Syscall.msync(new IntPtr(alloc.BaseAddress), (UIntPtr)alloc.Size, MsyncFlags.MS_SYNC);
                        if (result == -1)
                        {
                            var err = Marshal.GetLastWin32Error();
                            PosixHelper.ThrowLastError(err, "msync on " + FileName);
                        }
                    }
                }
            }
            finally
            {
                currentState.Release();
            }
        }
 public override void Sync()
 {
     //TODO: Is it worth it to change to just one call for msync for the entire file?
     foreach (var alloc in PagerState.AllocationInfos)
     {
         var result = Syscall.msync(new IntPtr(alloc.BaseAddress), (ulong)alloc.Size, MsyncFlags.MS_SYNC);
         if (result == -1)
         {
             PosixHelper.ThrowLastError(Marshal.GetLastWin32Error());
         }
     }
 }