Simplify structures and naming related to directory metadata
Categories
(Core :: Storage: Quota Manager, task, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox88 | --- | fixed |
People
(Reporter: janv, Assigned: janv)
References
(Blocks 1 open bug)
Details
Attachments
(16 files)
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review |
This is a follow-up for bug 1679541.
First of all, these two functions can be removed:
QuotaManager::GetDirectoryMetadata2
QuotaManager::GetDirectoryMetadata2WithRestore
Those functions are similar to GetDirectoryMetadataWithQuotaInfo2
and GetDirectoryMetadataWithQuotaInfo2WithRestore
, but they only return the timestamp and the persisted flag. It was kind of an optimization to read only necessary data for specific cases.
However, the underlying streams will read entire block from the disk anyway and the additional reads from memory buffers don't cost much.
There's also a question, if partial reading of the metadata file is actually safe. The metadata file can have other records corrupted, so the file should be completely ignored and restored, because we can't trust that the timestamp and the flag is ok.
The "optimized" version of directory metadata is only used for the persistent repository which is not used much which makes it even less interesting for doing optimizations like this.
Then there's the naming of data structures and methods which is currently a bit confusing and complicated.
There are already structures which are all related to groups and origins:
GroupInfoPair
- owned by
QuotaManager
- keyed by the group name
- owns two
GroupInfo
objects, one for the default repository and one for the temporary repository
GroupInfo
- owned by
GroupInfoPair
- represents the group for given repository
- owns
OriginInfo
objects, there can be multipleOriginInfo
objects for given group
OriginInfo
- owned by
GroupInfo
, - represents the origin for given repository and group
- references
QuotaObject
objects (a bit tricky, using weak pointers)
QuotaObject
- referenced by
OriginInfo
- represents a quota tracked file given repository, group and origin
I don't want to change names of those objects, at least for now.
Then we have:
struct GroupAndOrigin {
nsCString mGroup;
nsCString mOrigin;
};
struct QuotaInfo : GroupAndOrigin {
nsCString mSuffix;
}
These were introduced only recently to reduce number of parameters of many functions.
Bug 1679541 also introduced:
struct GetDirectoryResult {
int64_t mTimestamp;
bool mPersisted;
};
struct GetDirectoryResultWithQuotaInfo : GetDirectoryResult {
QuotaInfo mQuotaInfo;
};
The first one can be removed because the related method can also be removed as I proposed above.
GetDirectoryResultWithQuotaInfo
can then be renamed to DirectoryInfo
, inherit from QuotaInfo
and add the timestamp and the persisted flag:
struct DirectoryInfo : QuotaInfo {
int64_t mTimestamp;
bool mPersisted;
}
DirectoryInfo
represents a flat view of OriginInfo
which is part of the in-memory tree structure (QuotaManager
-> GroupInfoPair
-> ...)
GetDirectoryMetadataWithQuotaInfo2
and GetDirectoryMetadataWithQuotaInfo2WithRestore
can also be renamed to
GetDirectoryInfoand
GetDirectoryInfoWithRestore` (but only those in QuotaManager, the ones related to storage upgrades should stay unchanged, at least for now)
It would be nice to find better names for GroupAndOrigin
and QuotaInfo
, I'll see if there's something more suitable.
Assignee | ||
Updated•3 years ago
|
Comment 1•3 years ago
|
||
When we improve naming of the GetDirectoryMetadata*
functions, we should also consider not using Get
as a prefix: To start with, these are no getters in a stricter sense, given they are reading from a file. GetDirectoryMetadataWithQuotaInfo2*
even writes to the metadata file. So maybe MaybeUpdateDirectoryInfo
and MaybeRestoreAndUpdateDirectoryInfo
are better names? The fact that they also return the directory info can be neglected in the name IMO.
When replacing uses of the non-WithQuotaInfo
versions with the WithQuotaInfo
versions of the functions, this not only is less efficient because more data is read from the file and returned to the call, which might be negligible, but it also involves more fallible functions, in particular overwriting the metadata file might fail. Just confirming that I understand you correctly that this is actually desirable to improve consistency?
I think when this is sorted out, a comment should list only the actions that should be taken to complete this bug, without the reasoning behind it. The current description is somewhat complex.
Assignee | ||
Comment 2•3 years ago
|
||
(In reply to Simon Giesecke [:sg] [he/him] from comment #1)
When we improve naming of the
GetDirectoryMetadata*
functions, we should also consider not usingGet
as a prefix: To start with, these are no getters in a stricter sense, given they are reading from a file.GetDirectoryMetadataWithQuotaInfo2*
even writes to the metadata file. So maybeMaybeUpdateDirectoryInfo
andMaybeRestoreAndUpdateDirectoryInfo
are better names? The fact that they also return the directory info can be neglected in the name IMO.
Ok, will consider that.
When replacing uses of the non-
WithQuotaInfo
versions with theWithQuotaInfo
versions of the functions, this not only is less efficient because more data is read from the file and returned to the call, which might be negligible, but it also involves more fallible functions, in particular overwriting the metadata file might fail. Just confirming that I understand you correctly that this is actually desirable to improve consistency?
Yes, consistency too. I think it was over-optimized. It's true that those functions are fallible, but before they are called (or rather during the first call) all data is read in one block from the disk, and size of the data is smaller than the block size.
I think when this is sorted out, a comment should list only the actions that should be taken to complete this bug, without the reasoning behind it. The current description is somewhat complex.
There will be separate patches with more concrete descriptions.
Assignee | ||
Comment 3•3 years ago
|
||
Callers of these functions have been changed to call
GetDirectoryMetadataWithQuotaInfo2 and
GetDirectoryMetadataWithQuotaInfo2WithRestore instead which fully load the
metadata file.
Comment 4•3 years ago
•
|
||
(In reply to Jan Varga [:janv] from comment #2)
(In reply to Simon Giesecke [:sg] [he/him] from comment #1)
I think when this is sorted out, a comment should list only the actions that should be taken to complete this bug, without the reasoning behind it. The current description is somewhat complex.
There will be separate patches with more concrete descriptions.
When I asked for that, I thought I would be implementing this. If you are doing it yourself, we don't need a list here :)
Assignee | ||
Comment 5•3 years ago
|
||
I'll see how it goes, we might file separate bugs for this and work on it in parallel.
Assignee | ||
Comment 6•3 years ago
|
||
Ok, I think I now have a good plan for this, but it touches many files.
Simon, my patches are based on D101183 (as you suggested), but if you plan any big refactorings in QM or quota clients, please wait a bit.
It also means that I need to review everything prior D101183 before this can land.
Comment 7•3 years ago
|
||
(In reply to Jan Varga [:janv] from comment #6)
Ok, I think I now have a good plan for this, but it touches many files.
Simon, my patches are based on D101183 (as you suggested), but if you plan any big refactorings in QM or quota clients, please wait a bit.
It also means that I need to review everything prior D101183 before this can land.
As discussed on Slack, I'll abstain from doing additional refactorings, but there are a lot of them in flight right now, also outside the stack containing D101183.
Assignee | ||
Updated•3 years ago
|
Pushed by jvarga@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/5793732d3285 Remove QuotaManager::GetDirectoryMetadata2 and QuotaManager::GetDirectoryMetadata2WithRestore; r=dom-workers-and-storage-reviewers,sg
Comment 9•3 years ago
|
||
bugherder |
Assignee | ||
Comment 10•3 years ago
|
||
(In reply to Jan Varga [:janv] from comment #0)
It would be nice to find better names for
GroupAndOrigin
andQuotaInfo
, I'll see if there's something more suitable.
I changed the plan a bit and as a first step, we need to rename GroupAndOrigin
to OriginMetadata
and then merge it with QuotaInfo
. The suffix is currently not needed in some places, but that is going to change in following patches. Even if it's not used in a few places, I think it's still better to have a unified structure which makes it all much simpler and cleaner.
I'm going to submit two patches and OriginMetadata
will look like this after that:
struct OriginMetadata {
nsCString mSuffix;
nsCString mGroup;
nsCString mOrigin;
OriginMetadata() = default;
OriginMetadata(nsCString aSuffix, nsCString aGroup, nsCString aOrigin)
: mSuffix{std::move(aSuffix)},
mGroup{std::move(aGroup)},
mOrigin{std::move(aOrigin)} {}
};
The next step will be the addition of mPersistenceType
to OriginMetadata
And finally the change of:
struct GetDirectoryResultWithOriginMetadata {
int64_t mTimestamp;
bool mPersisted;
OriginMetadata mOriginMetadata;
};
to:
struct FullOriginMetadata : OriginMetadata {
int64_t mTimestamp;
bool mPersisted;
}
We can figure out better method names after all these changes.
Assignee | ||
Comment 11•3 years ago
|
||
Assignee | ||
Comment 12•3 years ago
|
||
Depends on D104970
Comment 13•3 years ago
|
||
Pushed by jvarga@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/840c3738d147 Rename GroupAndOrigin to OriginMetadata; r=dom-storage-reviewers,sg
Comment 14•3 years ago
|
||
bugherder |
Comment 15•3 years ago
|
||
Pushed by jvarga@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/57484ffab666 Fold QuotaInfo into OriginMetadata and rename QuotaInfo.h to OriginMetadata.h; r=dom-storage-reviewers,sg
Comment 16•3 years ago
|
||
bugherder |
Assignee | ||
Comment 17•3 years ago
|
||
This fixes the two spots where we were always passing an empty suffix to
OriginMetadata.
Depends on D106019
Assignee | ||
Comment 18•3 years ago
|
||
Depends on D106131
Assignee | ||
Comment 19•3 years ago
|
||
Depends on D106394
Assignee | ||
Comment 20•3 years ago
|
||
Depends on D106395
Assignee | ||
Comment 21•3 years ago
|
||
Depends on D106396
Assignee | ||
Comment 22•3 years ago
|
||
Depends on D106397
Assignee | ||
Comment 23•3 years ago
|
||
Depends on D106398
Assignee | ||
Comment 24•3 years ago
|
||
The existing members of OriginMetadata have been extracted to a parent struct
called PrincipalMetadata. Methods like GetOriginUsage,
GetInfoFromValidatedPrincipalInfo, GetInfoFromPrincipal and GetInfoForChrome
have been changed to take/return PrincipalInfo instead of OriginMetadata.
Having the persistence type doesn't make sense in those methods because the
origin is not tight to a specific persistence type in context of the methods.
Some places temporarily pass PERSISTENCE_TYPE_INVALID and will be fixed in
following patches.
Depends on D106399
Assignee | ||
Comment 25•3 years ago
|
||
Depends on D106904
Assignee | ||
Comment 26•3 years ago
|
||
Depends on D106906
Comment 27•3 years ago
|
||
Pushed by jvarga@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/6a2d82b48f78 Add suffix to OriginInfoPair and quota info cache; r=dom-storage-reviewers,sg https://hg.mozilla.org/integration/autoland/rev/93933a2da1a7 Construct OriginMetadata with real suffix in GetOriginUsageOp::DoDirectoryWork; r=dom-storage-reviewers,sg https://hg.mozilla.org/integration/autoland/rev/7f46c92e1833 Construct OriginMetadata with real suffix in PersistedOp::DoDirectoryWork; r=dom-storage-reviewers,sg https://hg.mozilla.org/integration/autoland/rev/4f7704ba36ed Construct OriginMetadata with real suffix in DirectoryLockImpl::OriginMetadata; r=dom-storage-reviewers,sg https://hg.mozilla.org/integration/autoland/rev/7c04f2a9a365 Change SaveCacheVersion, CreateCacheTables and UpgradeCacheFrom1To2 to take a reference instead of a raw pointer; r=dom-storage-reviewers,sg https://hg.mozilla.org/integration/autoland/rev/e14e574f9f4b Move mGroup from GroupInfo to GroupInfoPair; r=dom-storage-reviewers,sg https://hg.mozilla.org/integration/autoland/rev/336c31529dbb Introduce OriginInfo::FlattenToOriginMetadata and make use of it; r=dom-storage-reviewers,sg
Comment 28•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/6a2d82b48f78
https://hg.mozilla.org/mozilla-central/rev/93933a2da1a7
https://hg.mozilla.org/mozilla-central/rev/7f46c92e1833
https://hg.mozilla.org/mozilla-central/rev/4f7704ba36ed
https://hg.mozilla.org/mozilla-central/rev/7c04f2a9a365
https://hg.mozilla.org/mozilla-central/rev/e14e574f9f4b
https://hg.mozilla.org/mozilla-central/rev/336c31529dbb
Comment 29•3 years ago
|
||
Pushed by jvarga@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/bc41e3cc6754 Add mPersistenceType to OriginMetadata; r=dom-storage-reviewers,sg
Comment 30•3 years ago
|
||
Pushed by jvarga@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c69b2c1ef6f9 Fix GetDirectoryMetadataWithOriginMetadata2 and GetDirectoryMetadataWithOriginMetadata2WithRestore to return proper persistence type; r=dom-storage-reviewers,sg
Comment 31•3 years ago
|
||
bugherder |
Comment 32•3 years ago
|
||
bugherder |
Assignee | ||
Comment 33•3 years ago
|
||
Assignee | ||
Comment 34•3 years ago
|
||
Assignee | ||
Comment 35•3 years ago
|
||
Comment 36•3 years ago
|
||
Pushed by jvarga@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/470d617d7673 Fix storage upgrades and restoration of the metadata file to use proper persistence type internally; r=dom-storage-reviewers,sg https://hg.mozilla.org/integration/autoland/rev/9be2fd0b5b6a Replace GetDirectoryResultWithOriginMetadata with FullOriginMetadata; r=dom-storage-reviewers,sg https://hg.mozilla.org/integration/autoland/rev/43a39c491548 Rename GetDirectoryMetadataWithOriginMetadata2 to LoadFullOriginMetadata and GetDirectoryMetadataWithOriginMetadata2WithRestore to LoadFullOriginMetadataWithRestore; r=dom-storage-reviewers,sg
Comment 37•3 years ago
|
||
Backed out 4 changesets (bug 1695906, bug 1686031) for causing bustages in ActorsParent.cpp
Backout link: https://hg.mozilla.org/integration/autoland/rev/7adfa8f8a78c15faf8c213963bd00826b0ea0a01
Push with failures, failure log.
Updated•3 years ago
|
Comment 38•3 years ago
|
||
Pushed by jvarga@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/913f16ccb065 Fix storage upgrades and restoration of the metadata file to use proper persistence type internally; r=dom-storage-reviewers,sg
Comment 39•3 years ago
|
||
Pushed by jvarga@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/9ef8072221e8 Replace GetDirectoryResultWithOriginMetadata with FullOriginMetadata; r=dom-storage-reviewers,sg https://hg.mozilla.org/integration/autoland/rev/f5f020daba36 Rename GetDirectoryMetadataWithOriginMetadata2 to LoadFullOriginMetadata and GetDirectoryMetadataWithOriginMetadata2WithRestore to LoadFullOriginMetadataWithRestore; r=dom-storage-reviewers,sg
Comment 40•3 years ago
|
||
bugherder |
Assignee | ||
Updated•3 years ago
|
Comment 41•3 years ago
|
||
Pushed by jvarga@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/1de71b8527c2 Rename OriginMetadata.h to CommonMetadata.h; r=dom-storage-reviewers,sg
Comment 42•3 years ago
|
||
bugherder |
Description
•