Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Levin Zimmermann
go-fuse
Commits
0dab71c8
Commit
0dab71c8
authored
Jan 09, 2013
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Done() method to ReadResult, so splicing code manage resources.
parent
a626ad83
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
5 deletions
+22
-5
fuse/api.go
fuse/api.go
+3
-0
fuse/mountstate.go
fuse/mountstate.go
+4
-0
fuse/opcode.go
fuse/opcode.go
+4
-5
fuse/read.go
fuse/read.go
+6
-0
fuse/request.go
fuse/request.go
+5
-0
No files found.
fuse/api.go
View file @
0dab71c8
...
...
@@ -195,6 +195,9 @@ type ReadResult interface {
// Size returns how many bytes this return value takes at most.
Size
()
int
// Done() is called after sending the data to the kernel.
Done
()
}
// Wrap a File return in this to set FUSE flags. Also used internally
...
...
fuse/mountstate.go
View file @
0dab71c8
...
...
@@ -382,6 +382,7 @@ func (ms *MountState) write(req *request) Status {
if
req
.
fdData
!=
nil
{
if
err
:=
ms
.
trySplice
(
header
,
req
,
req
.
fdData
);
err
==
nil
{
req
.
readResult
.
Done
()
return
OK
}
else
{
log
.
Println
(
"trySplice:"
,
err
)
...
...
@@ -393,6 +394,9 @@ func (ms *MountState) write(req *request) Status {
}
_
,
err
:=
Writev
(
int
(
ms
.
mountFile
.
Fd
()),
[][]
byte
{
header
,
req
.
flatData
})
if
req
.
readResult
!=
nil
{
req
.
readResult
.
Done
()
}
return
ToStatus
(
err
)
}
...
...
fuse/opcode.go
View file @
0dab71c8
...
...
@@ -279,13 +279,12 @@ func doRead(state *MountState, req *request) {
in
:=
(
*
raw
.
ReadIn
)(
req
.
inData
)
buf
:=
state
.
AllocOut
(
req
,
in
.
Size
)
var
r
ReadResult
r
,
req
.
status
=
state
.
fileSystem
.
Read
(
&
req
.
context
,
in
,
buf
)
if
fd
,
ok
:=
r
.
(
*
ReadResultFd
);
ok
{
req
.
readResult
,
req
.
status
=
state
.
fileSystem
.
Read
(
&
req
.
context
,
in
,
buf
)
if
fd
,
ok
:=
req
.
readResult
.
(
*
ReadResultFd
);
ok
{
req
.
fdData
=
fd
req
.
flatData
=
nil
}
else
if
r
!=
nil
{
req
.
flatData
,
req
.
status
=
r
.
Bytes
(
buf
)
}
else
if
r
eq
.
readResult
!=
nil
{
req
.
flatData
,
req
.
status
=
r
eq
.
readResult
.
Bytes
(
buf
)
}
}
...
...
fuse/read.go
View file @
0dab71c8
...
...
@@ -15,6 +15,9 @@ func (r *ReadResultData) Size() int {
return
len
(
r
.
Data
)
}
func
(
r
*
ReadResultData
)
Done
()
{
}
func
(
r
*
ReadResultData
)
Bytes
(
buf
[]
byte
)
([]
byte
,
Status
)
{
return
r
.
Data
,
OK
}
...
...
@@ -55,3 +58,6 @@ func (r *ReadResultFd) Bytes(buf []byte) ([]byte, Status) {
func
(
r
*
ReadResultFd
)
Size
()
int
{
return
r
.
Sz
}
func
(
r
*
ReadResultFd
)
Done
()
{
}
fuse/request.go
View file @
0dab71c8
...
...
@@ -29,6 +29,10 @@ type request struct {
flatData
[]
byte
fdData
*
ReadResultFd
// In case of read, keep read result here so we can call
// Done() on it.
readResult
ReadResult
// Start timestamp for timing info.
startNs
int64
preWriteNs
int64
...
...
@@ -66,6 +70,7 @@ func (r *request) clear() {
r
.
preWriteNs
=
0
r
.
startNs
=
0
r
.
handler
=
nil
r
.
readResult
=
nil
}
func
(
r
*
request
)
InputDebug
()
string
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment