Commit graph

46 commits

Author SHA1 Message Date
Jérôme Gardou 470ad18825 Revert "[NTOS:CC] Wake up lazy scan after inserting elements in the list."
This reverts commit 6e4f83da70.
2023-07-29 14:00:44 +03:00
Timo Kreuzer b2fcd27aaa [NTOS/CC] Fix calls to CcRosEnsureVacbResident
The function returns BOOLEAN, not NTSTATUS! Also wrap it in SEH, because it can throw an exception on failure.
2023-04-14 11:56:08 +03:00
Jérôme Gardou 6e4f83da70 [NTOS:CC] Wake up lazy scan after inserting elements in the list. 2021-03-24 15:28:04 +01:00
Jérôme Gardou edd4a985d9 [NTOS:CC] Be verbose about why we defer writes 2021-03-24 15:27:36 +01:00
Jérôme Gardou 5c54fb9179 [NTOS:CC] Rewrite CcPostDeferredWrites
This allows to post small writes if there are any, and avoid holding the list lock for a long time.
2021-03-24 11:22:28 +01:00
Jérôme Gardou 2ba1926037 [NTOS:MM][NTOS:CC] Performance improvement again
Read files by 64kb chunks instead of page-sized chunks.
2021-02-03 09:41:23 +01:00
Jérôme Gardou 5949d5095d [NTOS:CC][NTOS:MM] Try respecting ValidDataLength 2021-02-03 09:41:23 +01:00
Jérôme Gardou 9b6240ee03 [NTOS:CC] Get rid of ROS_VACB:Valid 2021-02-03 09:41:23 +01:00
Jérôme Gardou 91f6fa0259 Disable CcScheduleReadAhead call 2021-02-03 09:41:22 +01:00
Jérôme Gardou a52bc6d179 [NTOS:CC] Restore read-ahead behaviour in CcCopyRead 2021-02-03 09:41:22 +01:00
Jérôme Gardou 4441b1cd44 [NTOS:CC] Fix some tests for CcCopyRead and CcCopyWrite
Most importantly: raise the right status when provided an invalid buffer.
2021-02-03 09:41:22 +01:00
Jérôme Gardou cd23d6e19a [NTOS:CC] Honor FO_WRITE_THROUGH flag in CcCopyWrite and fix it in CcZeroData 2021-02-03 09:41:22 +01:00
Jérôme Gardou cbfc04157d [NTOS:CC] File size check fix 2021-02-03 09:41:22 +01:00
Jérôme Gardou c74cbf0c0b [NTOS/CC] Be more precise when notifying Mm about dirty pages 2021-02-03 09:41:22 +01:00
Jérôme Gardou c295d6b229 [NTOS:CC] Fix releasing VACB when an exception is raised in CcZeroData & CcCopyWrite 2021-02-03 09:41:22 +01:00
Jérôme Gardou 7f47f03296 [NTOS:CC] Rewrite the non-cached path of CcZeroData 2021-02-03 09:41:22 +01:00
Jérôme Gardou d8cdb89fb0 [NTOSKRNL] Overhaul Cc and Mm relationship
Previously, when creating a file section, Mm requested Cc to cache the file, then Cc would request pages from Mm, then Mm would request them back to serve its file-mapping role
Now, Mm does it all by itself. If file cahcing is requested by the FS driver, then Cc creates a file mapping and uses that to serve its purpose.

This is a rewrite of Cc
2021-02-03 09:41:22 +01:00
Serge Gautherie a0d2170729 [NTOS:CC] CcWriteVirtualAddress(): Do not round 'Size'
Revert 'Properly align VACB writes' part of 2a80ae2bb6.

CORE-15384 CORE-16018
2019-07-01 21:30:25 +02:00
Serge Gautherie 4d1f13cf77 [NTOS:CC] CcCanIWrite(): Use BYTES_TO_PAGES(Length) 2018-12-21 19:20:59 +01:00
Pierre Schweitzer 2a80ae2bb6
[NTOSKRNL] Properly align VACB writes
Also simplify VACB reads alignment code.
Also add some sanity ASSERTs.
2018-09-23 10:32:14 +02:00
Pierre Schweitzer 15a3ca08b0
[NTOSKRNL] Avoid integer overflow when computing VACB read/write size
This could be triggered when attempting to read/write to really big
files. It was causing an attempt to read 0 bytes in Cc, leading to
asserts failure in the kernel (and corrupted file).

CORE-15067
2018-09-21 08:37:20 +02:00
Pierre Schweitzer 0075c2a02d
[NTOSKRNL] Be noisy when deferring writes. 2018-07-15 09:57:16 +02:00
Pierre Schweitzer 1b672981e2 [NTOSKRNL] Map the VACB in kernel space before inserting it in lists.
The avoids race conditions where attempts to read from disk to
not fully initialized VACB were performed.
Also, added more debug prints in such situations.

CORE-14349
2018-04-15 22:52:53 +02:00
Pierre Schweitzer c4f58bbfd8
[NTOKSRNL] Don't blindly schedule read-ahead on CcCopyRead() call.
This avoids locking Cc for too long by trying to read-ahead data which
is already in cache.
We now will only schedule a read ahead if next read should bring us
to a new VACB (perhaps not in cache).

This notably fixes Inkscape setup which was slown down by read-ahead
due to continous 1 byte reads.

Thanks to Thomas for his help on this issue.

CORE-14395
2018-02-28 20:58:36 +01:00
Pierre Schweitzer 9ac2e9855a
[NTOSKRNL] Add the CcDataFlushes and CcDataPages counters 2018-02-24 14:52:04 +01:00
Thomas Faber a2f77ee3fb
[NTOS:CC] Don't read past the end of the file in CcPerformReadAhead. 2018-02-22 14:03:05 +01:00
Thomas Faber 56e2bf2f92
[NTOS:CC] Avoid some magic numbers. 2018-02-22 14:03:03 +01:00
Pierre Schweitzer dd392b9d6c
[NTOSKRNL] Fix mismatching spinlock release in CcPerformReadAhead() 2018-02-18 19:32:08 +01:00
Pierre Schweitzer 5d93941d31
[NTOSKRNL] Modified CcCanIWrite to handle Mm throttling limits 2018-02-09 14:22:00 +01:00
Pierre Schweitzer 945ff8ea2e
[NTOSKRNL] Rewrite CcCanIWrite() to make it more accurate and handle specific callers 2018-02-09 13:56:16 +01:00
Pierre Schweitzer f51b74ca61
[NTOSKRNL] Don't defer write through write operations 2018-02-09 12:25:58 +01:00
Pierre Schweitzer c5139563db
[NTOSKRNL] Bring an initial (and not perfect ;-)) implementation of read ahead to our Cc!
This halfplements CcScheduleReadAhead() which is responsible for finding the next reads
to perform given last read and previous reads. I made it very basic for now, at least
to test the whole process.
This also introduces the CcExpressWorkQueue in the lazy writer which is responsible
for dealing with read ahead items and which is dealt with before the regular queue.
In CcCopyData(), if read was fine, schedule read ahead so that it can happen in background
without the FSD to notice it! Also, update the read history so that scheduling as a
bit of data.
Implement (à la "old Cc" ;-)) CcPerformReadAhead() which is responsible for performing
the read. It's only to be called by the worker thread.

Side note on the modifications done in CcRosReleaseFileCache(). Private cache map
is tied to a handle. If it goes away, private cache map gets deleted. Read ahead
can run after the handle was closed (and thus, private cache map deleted), so
it is mandatory to always lock the master lock before accessing the structure in
read ahead or before deleting it in CcRosReleaseFileCache(). Otherwise, you'll
just break everything. You've been warned!

This commit also partly reverts f8b5d27.

CORE-14312
2018-02-09 10:14:11 +01:00
Pierre Schweitzer 323f71a551
[NTOSKRNL] Use the LockQueueMasterLock where appropriate 2018-02-07 21:37:17 +01:00
Pierre Schweitzer 19c822341b
[NTOSKRNL] Handle FSRTL_FLAG_LIMIT_MODIFIED_PAGES flag in CcDeferWrite().
Util now, CcDeferWrite() was ignoring limits per file object.
2018-02-07 21:37:17 +01:00
Pierre Schweitzer c11e947f61
[NTOSKRNL] Add wait support in CcCanIWrite() 2018-02-07 21:37:17 +01:00
Pierre Schweitzer 92e64a6c9b
[NTOSKRNL] Implement CcPostDeferredWrites() that executes deferred writes.
Make use of it in the lazy writer
2018-02-07 21:37:17 +01:00
Pierre Schweitzer f4e67aa837
[NTOSKRNL] Properly implement lazy writer activity watching.
We get rid of the old iLazyWriterNotify event in favor of work items
that contain an event that lazy writer will set once its done.
To implement this, we rely on the newly introduced CcPostTickWorkQueue work queue
that will contain work items that are to be queued once lazy writer is done.

Move the CcWaitForCurrentLazyWriterActivity() implementation to the
lazy writer file, and reimplemented it using the new support mechanisms
2018-02-07 21:37:17 +01:00
Pierre Schweitzer 7e550edb26
[NTOSKRNL] Drop the always running thread for lazy writer.
Instead move to a threading model like the Windows one.
We'll queue several work items to be executed in a system thread (Cc worker)
when there are VACB that have been marked as dirty. Furthermore, some delay
will be observed before action to avoid killing the system with IOs.
This new threading model opens way for read ahead and write behind implementation.

Also, moved the initialization of the lazy writer to CcInitializeCacheManager()
it has nothing to do with views and shouldn't be initialized there.

Also, moved the lazy writer implementation to its own file.

Modified CcDeferWrite() and CcRosMarkDirtyVacb() to take into account the new threading model.

Introduced new functions:
- CcPostWorkQueue(): post an item to be handled by Cc worker and spawn a worker if required
- CcScanDpc(): called after some time (not to have lazy writer always running) to queue a lazy scan
- CcLazyWriteScan(): the lazy writer we used to have
- CcScheduleLazyWriteScan(): function to call when you want to start a lazy writer run. It will make a DPC after some time and queue execution
- CcWorkerThread(): the worker thread that will handle lazy write, read ahead, and so on
2018-02-07 21:37:17 +01:00
Pierre Schweitzer f8d58bba38
[NTOSKRNL] Don't let CcWriteVirtualAddress() deal with VACB dirty status
CORE-14263
2018-01-31 21:47:20 +01:00
Pierre Schweitzer b49a2d6356
[NTOSKRNL] Drop ROS_DEFERRED_WRITE_CONTEXT in favor of DEFERRED_WRITE
that was introduced in d3e0eb2.

CORE-14235
2018-01-28 11:55:40 +01:00
Pierre Schweitzer dc85171674
[NTOSKRNL] Simplify (and speedup!) CcCanIWrite() using the dirty pages count in cache map. 2018-01-26 10:50:13 +01:00
Pierre Schweitzer f93acd806a
[NTOSKRNL] Implement per-file dirty page threshold.
Namely, implement CcSetDirtyPageThreshold() and add support for it
in CcCanIWrite().

Also added my name in the headers of the few files I touched tonight.

CORE-14235
2018-01-23 23:25:26 +01:00
Pierre Schweitzer 9a07c71eef
[NTOSKRNL] Implement support for deferred writes in Cc.
Namely, implement CcCanIWrite() (very basic, and likely wrong).
And implement CcDeferWrite() which will queue the write operation.

In CciLazyWriter() (which may be renamed CcWorkerThread() ;-)),
handle the queued write operations one by one. This is likely
not to be accurate, but, given we have only on FS supporting
this for now (NFS / RDBSS / Shares), this is OK.

CORE-14235
2018-01-23 23:25:26 +01:00
Pierre Schweitzer c7ad200f8b
[NTOSKRNL] Reimplement the lazy writer in Cc and remove the "basic" one in Mm.
This removes the "modified page writer" thread in Mm that was regularly blindly
attempting to flush dirty pages to the disk.
Instead, this commit introduces a lazy writer that will monitor dirty pages count
and will flush them to disk when this count is above a threshold. The threshold is
computed on Cc init.
Compared to what was done previously, this lazy writer will only write down files
that are not marked as temporary.
The mechanisms involved in this lazy writer worker are well described in Windows
Internals 4th editions (constants are coming from it ;-)).
Also fixed a bad (and old!) bug in CcRosFlushDirtyPages() where target count could
be overflow and the function would spin forever while holding the VACBs lock. This is
mandatory as now lazy writer will call it with "random" values.
This also allows implementing CcWaitForCurrentLazyWriterActivity() :-).
Also renamed DirtyPageCount to its MS equivalent.

CORE-14235
2018-01-23 19:33:59 +01:00
Pierre Schweitzer e88eeb21af
[NTOSKRNL] Make the CcWaitForCurrentLazyWriterActivity() stub return success instead of hacking FSDs.
Suggested by Thomas
2017-11-06 21:45:55 +01:00
Colin Finck c2c66aff7d Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
Renamed from reactos/ntoskrnl/cc/copy.c (Browse further)