Commit 597d424f authored by Ivan Krasin's avatar Ivan Krasin

Fixed the problem with hanging: releaseDir didn't send a reply to the kernel

parent 1589f20c
...@@ -151,6 +151,7 @@ func initFuse(fs FileSystem, h *InHeader, r io.Reader, mr chan *managerRequest) ...@@ -151,6 +151,7 @@ func initFuse(fs FileSystem, h *InHeader, r io.Reader, mr chan *managerRequest)
out.Major = FUSE_KERNEL_VERSION out.Major = FUSE_KERNEL_VERSION
out.Minor = FUSE_KERNEL_MINOR_VERSION out.Minor = FUSE_KERNEL_MINOR_VERSION
out.MaxReadAhead = in.MaxReadAhead out.MaxReadAhead = in.MaxReadAhead
out.Flags = FUSE_ASYNC_READ | FUSE_POSIX_LOCKS
out.MaxWrite = 65536 out.MaxWrite = 65536
return serialize(h, OK, out) return serialize(h, OK, out)
} }
...@@ -213,8 +214,8 @@ func readDir(h *InHeader, r io.Reader, mr chan *managerRequest) (data [][]byte, ...@@ -213,8 +214,8 @@ func readDir(h *InHeader, r io.Reader, mr chan *managerRequest) (data [][]byte,
return return
} }
dirRespChan := make(chan *dirResponse, 1) dirRespChan := make(chan *dirResponse, 1)
fmt.Printf("Sending dir request\n") fmt.Printf("Sending dir request, in.Offset: %v\n", in.Offset)
resp.dirReq <- &dirRequest{false, dirRespChan} resp.dirReq <- &dirRequest{false, in.Offset, dirRespChan}
fmt.Printf("receiving dir response\n") fmt.Printf("receiving dir response\n")
dirResp := <-dirRespChan dirResp := <-dirRespChan
fmt.Printf("received %v\n", dirResp) fmt.Printf("received %v\n", dirResp)
...@@ -232,7 +233,7 @@ func readDir(h *InHeader, r io.Reader, mr chan *managerRequest) (data [][]byte, ...@@ -232,7 +233,7 @@ func readDir(h *InHeader, r io.Reader, mr chan *managerRequest) (data [][]byte,
fmt.Printf("len(dirResp.entries): %v\n", len(dirResp.entries)) fmt.Printf("len(dirResp.entries): %v\n", len(dirResp.entries))
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
off := uint64(0) off := in.Offset
for _, entry := range dirResp.entries { for _, entry := range dirResp.entries {
off++ off++
dirent := new(Dirent) dirent := new(Dirent)
...@@ -289,7 +290,10 @@ func releaseDir(h *InHeader, r io.Reader, mr chan *managerRequest) (data [][]byt ...@@ -289,7 +290,10 @@ func releaseDir(h *InHeader, r io.Reader, mr chan *managerRequest) (data [][]byt
fmt.Printf("FUSE_RELEASEDIR: %v\n", in) fmt.Printf("FUSE_RELEASEDIR: %v\n", in)
resp := makeManagerRequest(mr, h.NodeId, in.Fh, closeDirOp, "") resp := makeManagerRequest(mr, h.NodeId, in.Fh, closeDirOp, "")
err = resp.err err = resp.err
if err != nil {
return return
}
return serialize(h, OK, nil)
} }
...@@ -339,6 +343,7 @@ type dirEntry struct { ...@@ -339,6 +343,7 @@ type dirEntry struct {
type dirRequest struct { type dirRequest struct {
isClose bool isClose bool
offset uint64
resp chan *dirResponse resp chan *dirResponse
} }
...@@ -357,8 +362,8 @@ type manager struct { ...@@ -357,8 +362,8 @@ type manager struct {
fs FileSystem fs FileSystem
dirHandles map[uint64]*dirHandle dirHandles map[uint64]*dirHandle
cnt uint64 cnt uint64
nodes map[uint64] string nodes map[uint64]string
nodesByPath map[string] uint64 nodesByPath map[string]uint64
nodeMax uint64 nodeMax uint64
} }
...@@ -477,12 +482,16 @@ func readDirRoutine(requests chan *dirRequest) { ...@@ -477,12 +482,16 @@ func readDirRoutine(requests chan *dirRequest) {
&dirEntry{"bb", S_IFDIR}, &dirEntry{"bb", S_IFDIR},
&dirEntry{"ddddd", S_IFDIR}, &dirEntry{"ddddd", S_IFDIR},
} }
i := 0 i := uint64(0)
for req := range requests { for req := range requests {
if req.offset != i {
fmt.Printf("readDirRoutine: i = %v, changing offset to %v\n", i, req.offset)
i = req.offset
}
if req.isClose { if req.isClose {
return return
} }
if i < len(entries) { if i < uint64(len(entries)) {
req.resp <- &dirResponse{[]*dirEntry{entries[i]}, nil} req.resp <- &dirResponse{[]*dirEntry{entries[i]}, nil}
i++ i++
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment