Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-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
jacobsa-fuse
Commits
873ca974
Commit
873ca974
authored
Mar 20, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Plain Diff
Added FileSystem.SyncFile.
For GoogleCloudPlatform/gcsfuse#13.
parents
c1e8f4d4
b856e4e7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
1 deletion
+75
-1
file_system.go
file_system.go
+30
-1
fuseutil/not_implemented_file_system.go
fuseutil/not_implemented_file_system.go
+6
-0
samples/flushfs/flush_fs.go
samples/flushfs/flush_fs.go
+13
-0
server.go
server.go
+26
-0
No files found.
file_system.go
View file @
873ca974
...
@@ -211,7 +211,25 @@ type FileSystem interface {
...
@@ -211,7 +211,25 @@ type FileSystem interface {
ctx
context
.
Context
,
ctx
context
.
Context
,
req
*
WriteFileRequest
)
(
*
WriteFileResponse
,
error
)
req
*
WriteFileRequest
)
(
*
WriteFileResponse
,
error
)
// Flush the current state of an open file to storage.
// Synchronize the current contents of an open file to storage.
//
// vfs.txt documents this as being called for by the fsync(2) system call
// (cf. http://goo.gl/j9X8nB). Code walk for that case:
//
// * (http://goo.gl/IQkWZa) sys_fsync calls do_fsync, calls vfs_fsync, calls
// vfs_fsync_range.
// * (http://goo.gl/5L2SMy) vfs_fsync_range calls f_op->fsync.
//
// Note that this is also called by fdatasync(2) (cf. http://goo.gl/01R7rF).
//
// See also: FlushFile, which may perform a similar purpose when closing a
// file (but which is not used in "real" file systems).
SyncFile
(
ctx
context
.
Context
,
req
*
SyncFileRequest
)
(
*
SyncFileResponse
,
error
)
// Flush the current state of an open file to storage upon closing a file
// descriptor.
//
//
// vfs.txt documents this as being called for each close(2) system call (cf.
// vfs.txt documents this as being called for each close(2) system call (cf.
// http://goo.gl/FSkbrq). Code walk for that case:
// http://goo.gl/FSkbrq). Code walk for that case:
...
@@ -823,6 +841,17 @@ type WriteFileRequest struct {
...
@@ -823,6 +841,17 @@ type WriteFileRequest struct {
type
WriteFileResponse
struct
{
type
WriteFileResponse
struct
{
}
}
type
SyncFileRequest
struct
{
Header
RequestHeader
// The file and handle being sync'd.
Inode
InodeID
Handle
HandleID
}
type
SyncFileResponse
struct
{
}
type
FlushFileRequest
struct
{
type
FlushFileRequest
struct
{
Header
RequestHeader
Header
RequestHeader
...
...
fuseutil/not_implemented_file_system.go
View file @
873ca974
...
@@ -118,6 +118,12 @@ func (fs *NotImplementedFileSystem) WriteFile(
...
@@ -118,6 +118,12 @@ func (fs *NotImplementedFileSystem) WriteFile(
return
nil
,
fuse
.
ENOSYS
return
nil
,
fuse
.
ENOSYS
}
}
func
(
fs
*
NotImplementedFileSystem
)
SyncFile
(
ctx
context
.
Context
,
req
*
fuse
.
SyncFileRequest
)
(
*
fuse
.
SyncFileResponse
,
error
)
{
return
nil
,
fuse
.
ENOSYS
}
func
(
fs
*
NotImplementedFileSystem
)
FlushFile
(
func
(
fs
*
NotImplementedFileSystem
)
FlushFile
(
ctx
context
.
Context
,
ctx
context
.
Context
,
req
*
fuse
.
FlushFileRequest
)
(
*
fuse
.
FlushFileResponse
,
error
)
{
req
*
fuse
.
FlushFileRequest
)
(
*
fuse
.
FlushFileResponse
,
error
)
{
...
...
samples/flushfs/flush_fs.go
View file @
873ca974
...
@@ -176,6 +176,19 @@ func (fs *flushFS) WriteFile(
...
@@ -176,6 +176,19 @@ func (fs *flushFS) WriteFile(
return
return
}
}
func
(
fs
*
flushFS
)
SyncFile
(
ctx
context
.
Context
,
req
*
fuse
.
SyncFileRequest
)
(
resp
*
fuse
.
SyncFileResponse
,
err
error
)
{
resp
=
&
fuse
.
SyncFileResponse
{}
fs
.
mu
.
Lock
()
defer
fs
.
mu
.
Unlock
()
err
=
fs
.
reportFsync
(
string
(
fs
.
fooContents
))
return
}
func
(
fs
*
flushFS
)
FlushFile
(
func
(
fs
*
flushFS
)
FlushFile
(
ctx
context
.
Context
,
ctx
context
.
Context
,
req
*
fuse
.
FlushFileRequest
)
(
req
*
fuse
.
FlushFileRequest
)
(
...
...
server.go
View file @
873ca974
...
@@ -427,6 +427,32 @@ func (s *server) handleFuseRequest(fuseReq bazilfuse.Request) {
...
@@ -427,6 +427,32 @@ func (s *server) handleFuseRequest(fuseReq bazilfuse.Request) {
typed
.
Respond
(
fuseResp
)
typed
.
Respond
(
fuseResp
)
}
}
case
*
bazilfuse
.
FsyncRequest
:
// We don't currently support this for directories.
if
typed
.
Dir
{
s
.
logger
.
Println
(
"fsyncdir not supported. Returning ENOSYS."
)
typed
.
RespondError
(
ENOSYS
)
return
}
// Convert the request.
req
:=
&
SyncFileRequest
{
Header
:
convertHeader
(
typed
.
Header
),
Inode
:
InodeID
(
typed
.
Header
.
Node
),
Handle
:
HandleID
(
typed
.
Handle
),
}
// Call the file system.
_
,
err
:=
s
.
fs
.
SyncFile
(
ctx
,
req
)
if
err
!=
nil
{
s
.
logger
.
Println
(
"Responding:"
,
err
)
typed
.
RespondError
(
err
)
return
}
s
.
logger
.
Println
(
"Responding OK."
)
typed
.
Respond
()
case
*
bazilfuse
.
FlushRequest
:
case
*
bazilfuse
.
FlushRequest
:
// Convert the request.
// Convert the request.
req
:=
&
FlushFileRequest
{
req
:=
&
FlushFileRequest
{
...
...
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