Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
osv
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Verlässliche Systemsoftware
projects
osv
Commits
8d1dd7a3
Commit
8d1dd7a3
authored
12 years ago
by
Avi Kivity
Browse files
Options
Downloads
Patches
Plain Diff
fs: directory entry cache
Store directory entries in a hash table for future lookup.
parent
27c32e95
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
fs/bootfs.cc
+1
-1
1 addition, 1 deletion
fs/bootfs.cc
fs/bootfs.hh
+1
-1
1 addition, 1 deletion
fs/bootfs.hh
fs/fs.cc
+25
-0
25 additions, 0 deletions
fs/fs.cc
fs/fs.hh
+13
-1
13 additions, 1 deletion
fs/fs.hh
with
40 additions
and
3 deletions
fs/bootfs.cc
+
1
−
1
View file @
8d1dd7a3
...
...
@@ -53,7 +53,7 @@ bootfs::dir::dir(bootfs& fs, std::string path)
{
}
fileref
bootfs
::
dir
::
open
(
std
::
string
name
)
fileref
bootfs
::
dir
::
do_
open
(
std
::
string
name
)
{
return
_fs
.
do_open
(
_path
+
name
);
}
...
...
This diff is collapsed.
Click to expand it.
fs/bootfs.hh
+
1
−
1
View file @
8d1dd7a3
...
...
@@ -33,7 +33,7 @@ private:
class
bootfs
::
dir
:
public
::
dir
{
public:
dir
(
bootfs
&
fs
,
std
::
string
path
);
virtual
fileref
open
(
std
::
string
name
);
virtual
fileref
do_
open
(
std
::
string
name
);
virtual
uint64_t
size
();
virtual
void
read
(
void
*
buffer
,
uint64_t
offset
,
uint64_t
len
);
private:
...
...
This diff is collapsed.
Click to expand it.
fs/fs.cc
+
25
−
0
View file @
8d1dd7a3
...
...
@@ -2,6 +2,18 @@
filesystem
*
rootfs
;
namespace
std
{
template
<
>
struct
hash
<
file
::
cache_key
>
{
size_t
operator
()(
file
::
cache_key
k
)
const
{
return
reinterpret_cast
<
uintptr_t
>
(
k
.
first
.
get
())
^
std
::
hash
<
std
::
string
>
()(
k
.
second
);
}
};
}
file
::
file
()
:
_refs
(
0
)
{
...
...
@@ -43,8 +55,21 @@ fileref filesystem::open(std::string name)
return
d
->
open
(
name
.
substr
(
s
,
name
.
npos
));
}
fileref
dir
::
open
(
std
::
string
name
)
{
cache_key
key
(
this
,
name
);
auto
ret
=
_cache
.
find
(
key
);
if
(
ret
==
_cache
.
end
())
{
auto
f
=
do_open
(
name
);
ret
=
_cache
.
insert
(
cache_type
::
value_type
(
key
,
f
)).
first
;
}
return
ret
->
second
;
}
dirref
dir
::
subdir
(
std
::
string
name
)
{
// trivial implementation, can be overridden
return
boost
::
dynamic_pointer_cast
<
dir
>
(
open
(
name
));
}
file
::
cache_type
file
::
_cache
;
This diff is collapsed.
Click to expand it.
fs/fs.hh
+
13
−
1
View file @
8d1dd7a3
...
...
@@ -4,6 +4,7 @@
#include
<string>
#include
<cstdint>
#include
<boost/intrusive_ptr.hpp>
#include
<unordered_map>
class
file
;
class
dir
;
...
...
@@ -24,12 +25,23 @@ private:
unsigned
_refs
;
// FIXME: make atomic
friend
void
intrusive_ptr_add_ref
(
file
*
f
)
{
f
->
ref
();
}
friend
void
intrusive_ptr_release
(
file
*
f
)
{
f
->
unref
();
}
friend
class
dir
;
private
:
typedef
std
::
pair
<
dirref
,
std
::
string
>
cache_key
;
// FIXME: an intrusive container
typedef
std
::
unordered_map
<
cache_key
,
fileref
>
cache_type
;
static
cache_type
_cache
;
friend
struct
std
::
hash
<
cache_key
>
;
};
class
dir
:
public
file
{
public:
virtual
fileref
open
(
std
::
string
name
)
=
0
;
fileref
open
(
std
::
string
name
);
virtual
fileref
do_open
(
std
::
string
name
)
=
0
;
dirref
subdir
(
std
::
string
name
);
private:
dirref
_parent
;
std
::
string
_name
;
};
class
filesystem
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment