Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-fuse
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
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Antoine Lambert
swh-fuse
Commits
c1bfbcec
Commit
c1bfbcec
authored
4 years ago
by
Thibault Allançon
Browse files
Options
Downloads
Patches
Plain Diff
fuse: remove unnecessary fd maps (use inode instead)
parent
34c5d37c
No related branches found
Branches containing commit
Tags
swh-lister-20241203.1
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
swh/fuse/fuse.py
+12
-26
12 additions, 26 deletions
swh/fuse/fuse.py
with
12 additions
and
26 deletions
swh/fuse/fuse.py
+
12
−
26
View file @
c1bfbcec
...
...
@@ -32,13 +32,10 @@ class Fuse(pyfuse3.Operations):
super
(
Fuse
,
self
).
__init__
()
self
.
_next_inode
:
int
=
pyfuse3
.
ROOT_INODE
self
.
_next_fd
:
int
=
0
self
.
_inode2entry
:
Dict
[
int
,
FuseEntry
]
=
{}
self
.
root
=
Root
(
fuse
=
self
)
self
.
_inode2fd
:
Dict
[
int
,
int
]
=
{}
self
.
_fd2inode
:
Dict
[
int
,
int
]
=
{}
self
.
_inode2path
:
Dict
[
int
,
Path
]
=
{
self
.
root
.
inode
:
root_path
}
self
.
time_ns
:
int
=
time
.
time_ns
()
# start time, used as timestamp
...
...
@@ -65,18 +62,6 @@ class Fuse(pyfuse3.Operations):
return
inode
def
_alloc_fd
(
self
,
inode
:
int
)
->
int
:
"""
Return a unique file descriptor integer for a given inode
"""
try
:
return
self
.
_inode2fd
[
inode
]
except
KeyError
:
fd
=
self
.
_next_fd
self
.
_next_fd
+=
1
self
.
_inode2fd
[
inode
]
=
fd
self
.
_fd2inode
[
fd
]
=
inode
return
fd
def
inode2entry
(
self
,
inode
:
int
)
->
FuseEntry
:
"""
Return the entry matching a given inode
"""
...
...
@@ -157,10 +142,13 @@ class Fuse(pyfuse3.Operations):
return
inode
async
def
readdir
(
self
,
inode
:
int
,
offset
:
int
,
token
:
pyfuse3
.
ReaddirToken
self
,
fh
:
int
,
offset
:
int
,
token
:
pyfuse3
.
ReaddirToken
)
->
None
:
"""
Read entries in an open directory
"""
# opendir() uses inode as directory handle
inode
=
fh
direntry
=
self
.
inode2entry
(
inode
)
path
=
self
.
inode2path
(
inode
)
...
...
@@ -184,20 +172,18 @@ class Fuse(pyfuse3.Operations):
async
def
open
(
self
,
inode
:
int
,
_flags
:
int
,
_ctx
:
pyfuse3
.
RequestContext
)
->
pyfuse3
.
FileInfo
:
"""
Open an inode and return a unique file
descriptor
"""
"""
Open an inode and return a unique file
handle
"""
fd
=
self
.
_alloc_fd
(
inode
)
return
pyfuse3
.
FileInfo
(
fh
=
fd
,
keep_cache
=
True
)
# Re-use inode as file handle
return
pyfuse3
.
FileInfo
(
fh
=
inode
,
keep_cache
=
True
)
async
def
read
(
self
,
f
d
:
int
,
offset
:
int
,
length
:
int
)
->
bytes
:
"""
Read `length` bytes from file
descriptor
`f
d
` at position `offset`
"""
async
def
read
(
self
,
f
h
:
int
,
offset
:
int
,
length
:
int
)
->
bytes
:
"""
Read `length` bytes from file
handle
`f
h
` at position `offset`
"""
try
:
inode
=
self
.
_fd2inode
[
fd
]
entry
=
self
.
inode2entry
(
inode
)
except
KeyError
:
raise
pyfuse3
.
FUSEError
(
errno
.
ENOENT
)
# open() uses inode as file handle
inode
=
fh
entry
=
self
.
inode2entry
(
inode
)
data
=
await
entry
.
content
()
return
data
[
offset
:
offset
+
length
]
...
...
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