Skip to content
This repository has been archived by the owner on Dec 13, 2021. It is now read-only.

Commit

Permalink
inspectors/fs: implement Fsync
Browse files Browse the repository at this point in the history
Required by TiKV community: tikv/tikv#846
  • Loading branch information
AkihiroSuda committed Jul 17, 2016
1 parent 2f8d65f commit 7e27406
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
22 changes: 22 additions & 0 deletions nmz/inspector/fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,25 @@ func (this *FilesystemInspector) PostRmdir(realRetCode int32, ctx hookfs.HookCon
log.Debugf("PostRmdir %s", ctx)
return nil, false
}

// implements hookfs.HookOnFsync
func (this *FilesystemInspector) PreFsync(path string, flags uint32) (error, bool, hookfs.HookContext) {
ctx := EQFSHookContext{Path: path}
log.Debugf("PreFsync %s", ctx)
err, hooked := this.commonHook(PreFsync, path, map[string]interface{}{})
if hooked {
return err, true, ctx
} else {
if err != nil {
log.Error(err)
}
return nil, false, ctx
}
// NOTREACHED
}

// implements hookfs.HookOnFsync
func (this *FilesystemInspector) PostFsync(realRetCode int32, ctx hookfs.HookContext) (error, bool) {
log.Debugf("PostFsync %s", ctx)
return nil, false
}
1 change: 1 addition & 0 deletions nmz/inspector/fs/fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func TestFilesystemInspectorInterfaceImpl(t *testing.T) {
func(x hookfs.HookOnMkdir) {}(h)
func(x hookfs.HookOnRmdir) {}(h)
func(x hookfs.HookOnOpenDir) {}(h)
func(x hookfs.HookOnFsync) {}(h)
}

func newFUSEServer(t *testing.T, fs *hookfs.HookFs) *fuse.Server {
Expand Down
1 change: 1 addition & 0 deletions nmz/signal/event_filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const (
PreWrite = "pre-write"
PreMkdir = "pre-mkdir"
PreRmdir = "pre-rmdir"
PreFsync = "pre-fsync"
)

func NewFilesystemEvent(entityID string, op FilesystemOp, path string, m map[string]interface{}) (Event, error) {
Expand Down

0 comments on commit 7e27406

Please sign in to comment.