Browse Source

mount: return IO error for mkdir

pull/1189/head
Chris Lu 5 years ago
parent
commit
9d93c83654
  1. 4
      weed/filesys/dir.go
  2. 15
      weed/filesys/filehandle.go

4
weed/filesys/dir.go

@ -174,7 +174,7 @@ func (dir *Dir) Mkdir(ctx context.Context, req *fuse.MkdirRequest) (fs.Node, err
glog.V(1).Infof("mkdir: %v", request) glog.V(1).Infof("mkdir: %v", request)
if _, err := client.CreateEntry(ctx, request); err != nil { if _, err := client.CreateEntry(ctx, request); err != nil {
glog.V(0).Infof("mkdir %s/%s: %v", dir.Path, req.Name, err) glog.V(0).Infof("mkdir %s/%s: %v", dir.Path, req.Name, err)
return fuse.EIO
return err
} }
return nil return nil
@ -185,7 +185,7 @@ func (dir *Dir) Mkdir(ctx context.Context, req *fuse.MkdirRequest) (fs.Node, err
return node, nil return node, nil
} }
return nil, err
return nil, fuse.EIO
} }
func (dir *Dir) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse.LookupResponse) (node fs.Node, err error) { func (dir *Dir) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse.LookupResponse) (node fs.Node, err error) {

15
weed/filesys/filehandle.go

@ -65,6 +65,7 @@ func (fh *FileHandle) Read(ctx context.Context, req *fuse.ReadRequest, resp *fus
if err != nil { if err != nil {
glog.Errorf("file handle read %s: %v", fh.f.fullpath(), err) glog.Errorf("file handle read %s: %v", fh.f.fullpath(), err)
return fuse.EIO
} }
return err return err
@ -103,11 +104,12 @@ func (fh *FileHandle) Write(ctx context.Context, req *fuse.WriteRequest, resp *f
// write the request to volume servers // write the request to volume servers
fh.f.entry.Attributes.FileSize = uint64(max(req.Offset+int64(len(req.Data)), int64(fh.f.entry.Attributes.FileSize))) fh.f.entry.Attributes.FileSize = uint64(max(req.Offset+int64(len(req.Data)), int64(fh.f.entry.Attributes.FileSize)))
glog.V(0).Infof("%v write [%d,%d)", fh.f.fullpath(), req.Offset, req.Offset+int64(len(req.Data)))
chunks, err := fh.dirtyPages.AddPage(ctx, req.Offset, req.Data) chunks, err := fh.dirtyPages.AddPage(ctx, req.Offset, req.Data)
if err != nil { if err != nil {
glog.Errorf("%+v/%v write fh %d: [%d,%d): %v", fh.f.dir.Path, fh.f.Name, fh.handle, req.Offset, req.Offset+int64(len(req.Data)), err)
return fmt.Errorf("write %s/%s at [%d,%d): %v", fh.f.dir.Path, fh.f.Name, req.Offset, req.Offset+int64(len(req.Data)), err)
glog.Errorf("%v write fh %d: [%d,%d): %v", fh.f.fullpath(), fh.handle, req.Offset, req.Offset+int64(len(req.Data)), err)
return fuse.EIO
} }
resp.Size = len(req.Data) resp.Size = len(req.Data)
@ -155,7 +157,7 @@ func (fh *FileHandle) Flush(ctx context.Context, req *fuse.FlushRequest) error {
chunks, err := fh.dirtyPages.FlushToStorage(ctx) chunks, err := fh.dirtyPages.FlushToStorage(ctx)
if err != nil { if err != nil {
glog.Errorf("flush %s/%s: %v", fh.f.dir.Path, fh.f.Name, err) glog.Errorf("flush %s/%s: %v", fh.f.dir.Path, fh.f.Name, err)
return fmt.Errorf("flush %s/%s: %v", fh.f.dir.Path, fh.f.Name, err)
return fuse.EIO
} }
fh.f.addChunks(chunks) fh.f.addChunks(chunks)
@ -209,5 +211,10 @@ func (fh *FileHandle) Flush(ctx context.Context, req *fuse.FlushRequest) error {
fh.dirtyMetadata = false fh.dirtyMetadata = false
} }
return err
if err != nil {
glog.Errorf("%v fh %d flush: %v", fh.f.fullpath(), fh.handle, err)
return fuse.EIO
}
return nil
} }
Loading…
Cancel
Save