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
Kirill Smelkov
go-fuse
Commits
fe0c36a5
Commit
fe0c36a5
authored
May 26, 2012
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanups.
parent
c8a1ba96
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
88 deletions
+26
-88
fuse/loopback_test.go
fuse/loopback_test.go
+11
-71
fuse/mountstate.go
fuse/mountstate.go
+13
-15
fuse/request.go
fuse/request.go
+2
-2
No files found.
fuse/loopback_test.go
View file @
fe0c36a5
...
@@ -135,25 +135,6 @@ func TestTouch(t *testing.T) {
...
@@ -135,25 +135,6 @@ func TestTouch(t *testing.T) {
}
}
}
}
func
TestReadLarge
(
t
*
testing
.
T
)
{
ts
:=
NewTestCase
(
t
)
defer
ts
.
Cleanup
()
// Add a bit more to test the splicing at the end.
content
:=
make
([]
byte
,
1024
*
1024
+
43
)
for
i
:=
range
content
{
content
[
i
]
=
byte
(
i
)
}
err
:=
ioutil
.
WriteFile
(
ts
.
origFile
,
[]
byte
(
content
),
0644
)
CheckSuccess
(
err
)
back
,
err
:=
ioutil
.
ReadFile
(
ts
.
mountFile
)
CheckSuccess
(
err
)
if
bytes
.
Compare
(
content
,
back
)
!=
0
{
t
.
Errorf
(
"content comparison failed"
)
}
}
func
TestReadThrough
(
t
*
testing
.
T
)
{
func
TestReadThrough
(
t
*
testing
.
T
)
{
ts
:=
NewTestCase
(
t
)
ts
:=
NewTestCase
(
t
)
defer
ts
.
Cleanup
()
defer
ts
.
Cleanup
()
...
@@ -545,63 +526,22 @@ func TestFSync(t *testing.T) {
...
@@ -545,63 +526,22 @@ func TestFSync(t *testing.T) {
f
.
Close
()
f
.
Close
()
}
}
func
TestLargeRead
(
t
*
testing
.
T
)
{
func
TestReadLarge
(
t
*
testing
.
T
)
{
tc
:=
NewTestCase
(
t
)
ts
:=
NewTestCase
(
t
)
defer
tc
.
Cleanup
()
defer
ts
.
Cleanup
()
t
.
Log
(
"Testing large read."
)
name
:=
filepath
.
Join
(
tc
.
orig
,
"large"
)
f
,
err
:=
os
.
OpenFile
(
name
,
os
.
O_WRONLY
|
os
.
O_CREATE
,
0777
)
CheckSuccess
(
err
)
b
:=
bytes
.
NewBuffer
(
nil
)
for
i
:=
0
;
i
<
20
*
1024
;
i
++
{
b
.
WriteString
(
"bla"
)
}
b
.
WriteString
(
"something extra to not be round"
)
slice
:=
b
.
Bytes
()
n
,
err
:=
f
.
Write
(
slice
)
CheckSuccess
(
err
)
err
=
f
.
Close
()
CheckSuccess
(
err
)
// Read in one go.
// Add a bit more to test the splicing at the end.
g
,
err
:=
os
.
Open
(
filepath
.
Join
(
tc
.
mnt
,
"large"
))
content
:=
make
([]
byte
,
1024
*
1024
+
43
)
CheckSuccess
(
err
)
for
i
:=
range
content
{
readSlice
:=
make
([]
byte
,
len
(
slice
))
content
[
i
]
=
byte
(
i
)
m
,
err
:=
g
.
Read
(
readSlice
)
if
m
!=
n
{
t
.
Errorf
(
"read mismatch %v %v"
,
m
,
n
)
}
for
i
,
v
:=
range
readSlice
{
if
slice
[
i
]
!=
v
{
t
.
Errorf
(
"char mismatch %v %v %v"
,
i
,
slice
[
i
],
v
)
break
}
}
}
err
:=
ioutil
.
WriteFile
(
ts
.
origFile
,
[]
byte
(
content
),
0644
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
g
.
Close
()
// Read in chunks
back
,
err
:=
ioutil
.
ReadFile
(
ts
.
mountFile
)
g
,
err
=
os
.
Open
(
filepath
.
Join
(
tc
.
mnt
,
"large"
))
CheckSuccess
(
err
)
defer
g
.
Close
()
readSlice
=
make
([]
byte
,
4096
)
total
:=
0
for
{
m
,
err
:=
g
.
Read
(
readSlice
)
if
m
==
0
&&
err
==
io
.
EOF
{
break
}
CheckSuccess
(
err
)
CheckSuccess
(
err
)
total
+=
m
if
bytes
.
Compare
(
content
,
back
)
!=
0
{
}
t
.
Errorf
(
"content comparison failed"
)
if
total
!=
len
(
slice
)
{
t
.
Errorf
(
"slice error %d"
,
total
)
}
}
}
}
...
...
fuse/mountstate.go
View file @
fe0c36a5
...
@@ -342,7 +342,7 @@ func (ms *MountState) write(req *request) Status {
...
@@ -342,7 +342,7 @@ func (ms *MountState) write(req *request) Status {
return
OK
return
OK
}
}
header
:=
req
.
serializeHeader
()
header
:=
req
.
serializeHeader
(
req
.
flatData
.
Size
()
)
if
ms
.
Debug
{
if
ms
.
Debug
{
log
.
Println
(
req
.
OutputDebug
())
log
.
Println
(
req
.
OutputDebug
())
}
}
...
@@ -361,13 +361,13 @@ func (ms *MountState) write(req *request) Status {
...
@@ -361,13 +361,13 @@ func (ms *MountState) write(req *request) Status {
}
}
if
req
.
flatData
.
FdSize
>
0
{
if
req
.
flatData
.
FdSize
>
0
{
if
err
:=
ms
.
TrySplice
(
header
,
req
);
err
==
nil
{
if
err
:=
ms
.
TrySplice
(
header
,
req
,
req
.
flatData
.
Fd
,
req
.
flatData
.
FdSize
,
req
.
flatData
.
FdOff
);
err
==
nil
{
return
OK
return
OK
}
else
{
}
else
{
log
.
Println
(
"Splice error"
,
err
)
log
.
Println
(
"Splice error"
,
err
)
buf
:=
ms
.
AllocOut
(
req
,
uint32
(
req
.
flatData
.
FdSize
))
buf
:=
ms
.
AllocOut
(
req
,
uint32
(
req
.
flatData
.
FdSize
))
req
.
flatData
.
Read
(
buf
)
req
.
flatData
.
Read
(
buf
)
header
=
req
.
serializeHeader
()
header
=
req
.
serializeHeader
(
req
.
flatData
.
Size
()
)
}
}
}
}
...
@@ -375,14 +375,15 @@ func (ms *MountState) write(req *request) Status {
...
@@ -375,14 +375,15 @@ func (ms *MountState) write(req *request) Status {
return
ToStatus
(
err
)
return
ToStatus
(
err
)
}
}
func
(
ms
*
MountState
)
TrySplice
(
header
[]
byte
,
req
*
request
)
error
{
func
(
ms
*
MountState
)
TrySplice
(
header
[]
byte
,
req
*
request
,
fd
uintptr
,
size
int
,
off
int64
)
error
{
finalSplice
,
err
:=
splice
.
Get
()
finalSplice
,
err
:=
splice
.
Get
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
defer
splice
.
Done
(
finalSplice
)
defer
splice
.
Done
(
finalSplice
)
total
:=
len
(
header
)
+
req
.
flatData
.
FdS
ize
total
:=
len
(
header
)
+
s
ize
if
!
finalSplice
.
Grow
(
total
)
{
if
!
finalSplice
.
Grow
(
total
)
{
return
fmt
.
Errorf
(
"splice.Grow failed."
)
return
fmt
.
Errorf
(
"splice.Grow failed."
)
}
}
...
@@ -393,12 +394,12 @@ func (ms *MountState) TrySplice(header []byte, req *request) error {
...
@@ -393,12 +394,12 @@ func (ms *MountState) TrySplice(header []byte, req *request) error {
}
}
var
n
int
var
n
int
if
req
.
flatData
.
FdO
ff
<
0
{
if
o
ff
<
0
{
n
,
err
=
finalSplice
.
LoadFrom
(
req
.
flatData
.
Fd
,
req
.
flatData
.
FdS
ize
)
n
,
err
=
finalSplice
.
LoadFrom
(
fd
,
s
ize
)
}
else
{
}
else
{
n
,
err
=
finalSplice
.
LoadFromAt
(
req
.
flatData
.
Fd
,
req
.
flatData
.
FdSize
,
req
.
flatData
.
FdO
ff
)
n
,
err
=
finalSplice
.
LoadFromAt
(
fd
,
size
,
o
ff
)
}
}
if
err
==
io
.
EOF
||
(
err
==
nil
&&
n
<
req
.
flatData
.
FdS
ize
&&
n
>
0
)
{
if
err
==
io
.
EOF
||
(
err
==
nil
&&
n
<
s
ize
&&
n
>
0
)
{
discard
:=
make
([]
byte
,
len
(
header
))
discard
:=
make
([]
byte
,
len
(
header
))
_
,
err
=
finalSplice
.
Read
(
discard
)
_
,
err
=
finalSplice
.
Read
(
discard
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -406,11 +407,8 @@ func (ms *MountState) TrySplice(header []byte, req *request) error {
...
@@ -406,11 +407,8 @@ func (ms *MountState) TrySplice(header []byte, req *request) error {
}
}
// TODO - fix debug output.
// TODO - fix debug output.
req
.
flatData
.
FdSize
=
n
header
=
req
.
serializeHeader
(
n
)
req
.
flatData
.
Fd
=
finalSplice
.
ReadFd
()
return
ms
.
TrySplice
(
header
,
req
,
fd
,
n
,
-
1
)
req
.
flatData
.
FdOff
=
-
1
header
=
req
.
serializeHeader
()
return
ms
.
TrySplice
(
header
,
req
)
}
}
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -418,7 +416,7 @@ func (ms *MountState) TrySplice(header []byte, req *request) error {
...
@@ -418,7 +416,7 @@ func (ms *MountState) TrySplice(header []byte, req *request) error {
return
err
return
err
}
}
if
n
!=
req
.
flatData
.
FdS
ize
{
if
n
!=
s
ize
{
return
fmt
.
Errorf
(
"splice: wrote %d, want %d"
,
n
,
req
.
flatData
.
FdSize
)
return
fmt
.
Errorf
(
"splice: wrote %d, want %d"
,
n
,
req
.
flatData
.
FdSize
)
}
}
...
...
fuse/request.go
View file @
fe0c36a5
...
@@ -179,7 +179,7 @@ func (r *request) parse() {
...
@@ -179,7 +179,7 @@ func (r *request) parse() {
r
.
outData
=
unsafe
.
Pointer
(
&
r
.
outBuf
[
sizeOfOutHeader
])
r
.
outData
=
unsafe
.
Pointer
(
&
r
.
outBuf
[
sizeOfOutHeader
])
}
}
func
(
r
*
request
)
serializeHeader
()
(
header
[]
byte
)
{
func
(
r
*
request
)
serializeHeader
(
dataSize
int
)
(
header
[]
byte
)
{
dataLength
:=
r
.
handler
.
OutputSize
dataLength
:=
r
.
handler
.
OutputSize
if
r
.
outData
==
nil
||
r
.
status
>
OK
{
if
r
.
outData
==
nil
||
r
.
status
>
OK
{
dataLength
=
0
dataLength
=
0
...
@@ -191,7 +191,7 @@ func (r *request) serializeHeader() (header []byte) {
...
@@ -191,7 +191,7 @@ func (r *request) serializeHeader() (header []byte) {
o
.
Unique
=
r
.
inHeader
.
Unique
o
.
Unique
=
r
.
inHeader
.
Unique
o
.
Status
=
int32
(
-
r
.
status
)
o
.
Status
=
int32
(
-
r
.
status
)
o
.
Length
=
uint32
(
o
.
Length
=
uint32
(
int
(
sizeOfOutHeader
)
+
int
(
dataLength
)
+
r
.
flatData
.
Size
()
)
int
(
sizeOfOutHeader
)
+
int
(
dataLength
)
+
dataSize
)
var
asSlice
[]
byte
var
asSlice
[]
byte
toSlice
(
&
asSlice
,
r
.
outData
,
dataLength
)
toSlice
(
&
asSlice
,
r
.
outData
,
dataLength
)
...
...
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