Commit Graph

315 Commits

Author SHA1 Message Date
Vincent Povirk 4ad114cfae ole32: Use the cached information in BlockChainStream_GetCount. 2010-05-07 12:46:39 +02:00
Vincent Povirk e40afcb2b6 ole32: Always move unmodified streams instead of copying on commit. 2010-05-06 17:55:43 +02:00
Vincent Povirk d07a4868a1 ole32: Rewrite transacted storage to be more lazy.
When creating a new transacted storage object (or reverting an
existing one), rather than copy the original storage, we simply create
a "stub directory entry" for the root. As stub entries are accessed,
we fill in their data from the parent and create new stubs for any
linked entries. The streams have copy on write semantics - reads are
from the original entry until a change is made, then we make a copy in
the scratch file.

When committing transacted storages, we have to create a new tree with
the new data so that the storage entry can be modified in one step,
but unmodified sections of the tree can now be shared between the new
tree and the old. An entry can be shared if it and all entries
reachable from it are unmodified. In the trivial case where nothing
has been modified, we don't have to make a new tree at all.
2010-05-06 17:55:34 +02:00
Vincent Povirk 42550953a6 ole32: Store the location of all blocks in a big block chain in memory.
A big block chain is a linked list, and we pretty much need random
access to them. This should theoretically make accessing a random
point in the chain O(log2 n) instead of O(n) (with disk access scaling
based on the size of the read/write, not its location). It
theoretically takes O(n) memory based on the size, but it can do
better if the chain isn't very fragmented (which I believe will
generally be the case for long chains). It also involves fetching all
the big block locations when we open the chain, but we already do that
anyway (and it should be faster to read it all in one go than
piecemeal).
2010-05-05 10:41:57 +02:00
Vincent Povirk 93cc582a8d ole32: Remove some assumptions about the internals of BlockChainStream. 2010-05-05 10:41:26 +02:00
Vincent Povirk 0b149df987 ole32: Create storage files with 4096-byte blocks when asked. 2010-04-13 11:30:48 +02:00
Konstantin Kondratyuk eab89da812 ole32: Add missed initialization of virtual function table. 2010-03-29 15:50:22 +02:00
Vincent Povirk 49a817c064 ole32: Check the small block size limit of storage files.
This value is stored in the storage file header. We currently hard-code it to
0x1000. I don't expect to see files in the wild with other values, but
according to MS this is a valid configuration. For now, just fail if we see
another value.

I've also upgraded the message for unexpected values in storage file headers
to a fixme, since they are valid according to MS.
2010-03-22 10:47:58 +01:00
Vincent Povirk e05b8416b8 ole32: Track the lowest possibly-free small block in storage files.
This makes creating small block chains O(n) instead of O(n**2) because we
don't have to keep rechecking the first blocks in the file.
2010-03-22 10:47:42 +01:00
Vincent Povirk 93c2256cff ole32: Allow storage files with a block size of 4096 to open. 2010-03-15 13:46:59 +01:00
Vincent Povirk 5ceb003a24 ole32: Remove knowledge of block sizes from the BigBlockFile object.
We can't determine the correct block size until we read the header, and we
can't create the BigBlockFile until we know the correct block size. To
solve this dilemma, have StorageImpl calculate the file size it needs instead
of asking the BigBlockFile to "ensure a big block exists".
2010-03-15 13:46:48 +01:00
Vincent Povirk 926669741e ole32: Remove the NUM_BLOCKS_PER_DEPOT_BLOCK define.
This should always be calculated based on the big block size.
2010-03-15 13:46:31 +01:00
Vincent Povirk 7b43123762 ole32: Remove the BIG_BLOCK_SIZE define.
Big block sizes can be 512 or 4096, so we define arrays that are large
enough in either case.
2010-03-15 13:46:19 +01:00
Vincent Povirk 4b7e7bd77f ole32: Fix the big block offset calculation.
Use the actual big block size from the open storage file. Also, remove a
special case that was only used for reading/writing the header.
2010-03-15 13:45:55 +01:00
Vincent Povirk f3db25fc25 ole32: Don't treat the header as a big block in StorageImpl_SaveFileHeader. 2010-03-15 13:45:36 +01:00
Vincent Povirk 7f3211f383 ole32: Don't treat the header as a big block in StorageImpl_LoadFileHeader.
The header is always 512 bytes, regardless of the big block size.
2010-03-15 13:45:30 +01:00
Vincent Povirk 8d58a91fa3 ole32: Allow CopyTo to succeed in spite of already open source streams. 2010-03-15 13:17:34 +01:00
Vincent Povirk 24ff704835 ole32: Clear the sibling links when reinserting a renamed element. 2010-03-02 16:44:12 +01:00
Vincent Povirk d420a858da ole32: Add error checking to StorageBaseImpl_CreateStorage. 2010-02-15 12:20:01 +01:00
Vincent Povirk 1fab6e3515 ole32: Add error checking to StorageBaseImpl_CreateStream. 2010-02-15 12:20:00 +01:00
Vincent Povirk 35b800dc92 ole32: Only warn about storage share mode once. 2010-02-12 11:54:36 +01:00
Vincent Povirk da250c9afe ole32: IStorage_Revert has no effect for non-transacted storages. 2010-01-25 12:58:22 +01:00
Andrew Eikum 7fe78c14e9 ole32: Downgrade StgIsStorageFile debug info from WARN to TRACE. 2010-01-07 09:25:51 +01:00
Vincent Povirk 0debd2fef4 ole32: Remove fixme for transacted mode. 2010-01-04 11:41:28 +01:00
Alexander Kochetkov 56bc0515c2 ole32/storage32: Fix return value for invalid access mode in OpenStream. 2009-12-30 16:13:57 +01:00
Vincent Povirk ffc4a49bcb ole32: Always allow changes to read-only transacted storages.
The only time the write permissions of transacted storages matter is when
committing.
2009-12-28 11:54:49 +01:00
Vincent Povirk b3511ebb70 ole32: Reread the stream entry after setting the size in StreamWriteAt.
In simple mode, StreamWriteAt would assume that StreamSetSize uses the size
it asks for, but in some cases the size would be pushed above the small block
limit. StreamWriteAt would then attempt to write using a small block chain,
even though a big block chain was created.
2009-12-21 15:01:24 +01:00
Vincent Povirk fc50ff07d6 ole32: Store the most recent item name in IEnumSTATSTG instead of a stack. 2009-12-21 15:01:24 +01:00
Vincent Povirk 4492850200 ole32: Make IEnumSTATSTG functions fail when the parent is invalid. 2009-12-21 15:01:23 +01:00
Vincent Povirk 5d9fd1b716 ole32: Compare upper character values directly in entryNameCmp.
The sort function used by native is not entirely consistent with lstrcmpiW,
even on Windows.
2009-12-18 11:43:34 +01:00
Vincent Povirk 393c5af205 ole32: Add a cache for block chain streams in StorageImpl. 2009-12-16 12:24:27 +01:00
Vincent Povirk 3ac34f7416 ole32: Properly free temporary objects when StorageBaseImpl_CopyTo fails. 2009-12-14 12:06:35 +01:00
Vincent Povirk 6afe24c38d ole32: Remove an unnecessary special case in StorageBaseImpl_CopyTo.
Opening a storage when it has already been opened now fails with
STG_E_ACCESSDENIED. If we attempt to copy a storage to its own child, this
will happen during the copy.
2009-12-14 12:06:25 +01:00
Vincent Povirk 0ad48797f8 ole32: Fix a memory leak in StorageBaseImpl_CopyTo.
Spotted by valgrind.
2009-12-14 12:06:17 +01:00
Vincent Povirk 3ff33e9303 ole32: Implement Revert for transacted storage objects. 2009-12-11 12:16:26 +01:00
Vincent Povirk 226363f5df ole32: Implement transacted storage. 2009-12-11 12:16:26 +01:00
Vincent Povirk d799f7e189 ole32: Add a stub transacted storage type.
TransactedSnapshotImpl acts as a proxy between the user and the storage
interfaces that modify the file directly (or another transacted storage).
Currently, it does not change the operations.
2009-12-11 12:16:26 +01:00
Vincent Povirk 42142200d5 ole32: Add Invalidate to the storage vtable. 2009-12-11 12:16:26 +01:00
Vincent Povirk 75fe621192 ole32: Create internal storage objects with a refcount of 1.
For consistency with StorageImpl_Construct.
2009-12-11 12:16:25 +01:00
Vincent Povirk 8b3ff9d179 ole32: Remove the ancestorStorage attribute. 2009-12-10 11:51:39 +01:00
Vincent Povirk 5d39c31bff ole32: Make IEnumSTATSTGImpl reference the parent storage. 2009-12-10 11:51:29 +01:00
Vincent Povirk 43184aaf52 ole32: Make findElement take a StorageBaseImpl. 2009-12-10 11:51:21 +01:00
Vincent Povirk 55b3a6e59f ole32: Don't use ancestorStorage to decide if a storage is transacted. 2009-12-10 11:51:10 +01:00
Vincent Povirk df0ef756b3 ole32: Add an attribute to StorageBaseImpl to track its reverted status. 2009-12-09 12:03:40 +01:00
Vincent Povirk 5b79c5a5e4 ole32: Store the parent of internal storage objects. 2009-12-09 12:03:30 +01:00
Vincent Povirk 8518323e07 ole32: Don't track the stream size in storage stream objects.
We can't do this safely when there are multiple objects for a single stream.
2009-12-09 12:03:18 +01:00
Vincent Povirk 6d06c43e53 ole32: Use the storage vtable to resize streams. 2009-12-09 12:03:10 +01:00
Vincent Povirk 1d4c698ef3 ole32: Use the storage vtable to write to streams. 2009-12-09 12:02:59 +01:00
Vincent Povirk 62e54bacba ole32: Use the storage vtable to read streams. 2009-12-08 12:35:33 +01:00
Vincent Povirk ee39a21d2b ole32: Add DestroyDirEntry to the storage vtable. 2009-12-08 12:35:17 +01:00