From 37fdc19299563e82e8d9f95259f3492acec797cb Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Tue, 9 Jun 2009 16:17:34 +0000 Subject: [PATCH] - Implement a helper for updating IO transfer counters. Based on a patch by Dmitry Chapyshev. svn path=/trunk/; revision=41358 --- reactos/ntoskrnl/include/internal/io_x.h | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/reactos/ntoskrnl/include/internal/io_x.h b/reactos/ntoskrnl/include/internal/io_x.h index 4372aca3933..e5d437c5955 100644 --- a/reactos/ntoskrnl/include/internal/io_x.h +++ b/reactos/ntoskrnl/include/internal/io_x.h @@ -89,6 +89,44 @@ IopUpdateOperationCount(IN IOP_TRANSFER_TYPE Type) } } +static +__inline +VOID +IopUpdateTransferCount(IN IOP_TRANSFER_TYPE Type, IN ULONG TransferCount) +{ + PLARGE_INTEGER CountToChange; + PLARGE_INTEGER TransferToChange; + + /* Make sure I/O operations are being counted */ + if (IoCountOperations) + { + if (Type == IopReadTransfer) + { + /* Increase read count */ + CountToChange = &PsGetCurrentProcess()->ReadTransferCount; + TransferToChange = &IoReadTransferCount; + } + else if (Type == IopWriteTransfer) + { + /* Increase write count */ + CountToChange = &PsGetCurrentProcess()->WriteTransferCount; + TransferToChange = &IoWriteTransferCount; + } + else + { + /* Increase other count */ + CountToChange = &PsGetCurrentProcess()->OtherTransferCount; + TransferToChange = &IoOtherTransferCount; + } + + /* Increase the process-wide count */ + ExInterlockedAddLargeStatistic(CountToChange, TransferCount); + + /* Increase global count */ + ExInterlockedAddLargeStatistic(TransferToChange, TransferCount); + } +} + static __inline BOOLEAN