Commit 6593c470 by rfkelly0

FUSE: use raw_fi in an attempt to control caching, but I don't think it achieved anything much.

parent 8d556b25
...@@ -382,6 +382,7 @@ class FS(object): ...@@ -382,6 +382,7 @@ class FS(object):
chunk = data.read(1024*512) chunk = data.read(1024*512)
else: else:
f.write(data) f.write(data)
f.flush()
finally: finally:
if f is not None: if f is not None:
f.close() f.close()
......
...@@ -143,7 +143,7 @@ class FSOperations(Operations): ...@@ -143,7 +143,7 @@ class FSOperations(Operations):
def _get_file(self,fh): def _get_file(self,fh):
try: try:
return self._fhmap[fh] return self._fhmap[fh.fh]
except KeyError: except KeyError:
raise FSError("invalid file handle") raise FSError("invalid file handle")
...@@ -157,6 +157,9 @@ class FSOperations(Operations): ...@@ -157,6 +157,9 @@ class FSOperations(Operations):
finally: finally:
self._fhmap_lock.release() self._fhmap_lock.release()
def _del_file(self,fh):
del self._fhmap[fh.fh]
def init(self,conn): def init(self,conn):
if self._on_init: if self._on_init:
self._on_init() self._on_init()
...@@ -174,10 +177,10 @@ class FSOperations(Operations): ...@@ -174,10 +177,10 @@ class FSOperations(Operations):
raise UnsupportedError("chown") raise UnsupportedError("chown")
@handle_fs_errors @handle_fs_errors
def create(self,path,mode,fi=None): def create(self,path,mode,fi):
if fi is not None: fh = self._reg_file(self.fs.open(path,"w"))
raise UnsupportedError("raw_fi") fi.fh = fh
return self._reg_file(self.fs.open(path,"w")) fi.keep_cache = 0
@handle_fs_errors @handle_fs_errors
def flush(self,path,fh): def flush(self,path,fh):
...@@ -226,9 +229,11 @@ class FSOperations(Operations): ...@@ -226,9 +229,11 @@ class FSOperations(Operations):
raise UnsupportedError("mknod") raise UnsupportedError("mknod")
@handle_fs_errors @handle_fs_errors
def open(self,path,flags): def open(self,path,fi):
mode = flags_to_mode(flags) mode = flags_to_mode(fi.flags)
return self._reg_file(self.fs.open(path,mode)) fi.fh = self._reg_file(self.fs.open(path,mode))
fi.keep_cache = 0
return 0
@handle_fs_errors @handle_fs_errors
def read(self,path,size,offset,fh): def read(self,path,size,offset,fh):
...@@ -236,7 +241,8 @@ class FSOperations(Operations): ...@@ -236,7 +241,8 @@ class FSOperations(Operations):
lock.acquire() lock.acquire()
try: try:
file.seek(offset) file.seek(offset)
return file.read(size) data = file.read(size)
return data
finally: finally:
lock.release() lock.release()
...@@ -266,7 +272,7 @@ class FSOperations(Operations): ...@@ -266,7 +272,7 @@ class FSOperations(Operations):
lock.acquire() lock.acquire()
try: try:
file.close() file.close()
del self._fhmap[fh] self._del_file(fh)
finally: finally:
lock.release() lock.release()
...@@ -368,7 +374,7 @@ def mount(fs,path,foreground=False,ready_callback=None,unmount_callback=None,**k ...@@ -368,7 +374,7 @@ def mount(fs,path,foreground=False,ready_callback=None,unmount_callback=None,**k
""" """
if foreground: if foreground:
op = FSOperations(fs,on_init=ready_callback,on_destroy=unmount_callback) op = FSOperations(fs,on_init=ready_callback,on_destroy=unmount_callback)
return FUSE(op,path,foreground=foreground,**kwds) return FUSE(op,path,raw_fi=True,foreground=foreground,**kwds)
else: else:
mp = MountProcess(fs,path,kwds) mp = MountProcess(fs,path,kwds)
if ready_callback: if ready_callback:
......
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