Commit f99178af authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 39f1bd67
...@@ -462,6 +462,11 @@ class tFile: ...@@ -462,6 +462,11 @@ class tFile:
t.f = tdb.wc._open(zf, at=at) t.f = tdb.wc._open(zf, at=at)
t.blksize = zf.blksize t.blksize = zf.blksize
# make sure that wcfs reports zf.blksize as preffered block size for IO.
# wcfs.py also uses .st_blksize in blk -> byte offset computation.
st = os.fstat(t.f.fileno())
assert st.st_blksize == t.blksize
# mmap the file past the end up to _max_tracked_pages and setup # mmap the file past the end up to _max_tracked_pages and setup
# invariants on which we rely to verify OS cache state: # invariants on which we rely to verify OS cache state:
# #
...@@ -551,6 +556,7 @@ class tFile: ...@@ -551,6 +556,7 @@ class tFile:
# _sizeinblk returns file size in blocks. # _sizeinblk returns file size in blocks.
def _sizeinblk(t): def _sizeinblk(t):
st = os.fstat(t.f.fileno()) st = os.fstat(t.f.fileno())
assert st.st_blksize == t.blksize # just in case
assert st.st_size % t.blksize == 0 assert st.st_size % t.blksize == 0
assert st.st_size // t.blksize <= t._max_tracked_pages assert st.st_size // t.blksize <= t._max_tracked_pages
return st.st_size // t.blksize return st.st_size // t.blksize
...@@ -700,6 +706,7 @@ class tFile: ...@@ -700,6 +706,7 @@ class tFile:
# The file size and optionally mtime are also verified. # The file size and optionally mtime are also verified.
def assertData(t, dataokv, mtime=None): def assertData(t, dataokv, mtime=None):
st = os.fstat(t.f.fileno()) st = os.fstat(t.f.fileno())
assert st.st_blksize == t.blksize
assert st.st_size == len(dataokv)*t.blksize assert st.st_size == len(dataokv)*t.blksize
if mtime is not None: if mtime is not None:
assert st.st_mtime == tidtime(mtime) assert st.st_mtime == tidtime(mtime)
...@@ -1074,10 +1081,6 @@ def test_wcfs_basic(): ...@@ -1074,10 +1081,6 @@ def test_wcfs_basic():
t.wc._stat("head/bigfile/%s" % h(t.nonzfile._p_oid)) t.wc._stat("head/bigfile/%s" % h(t.nonzfile._p_oid))
assert exc.value.errno == EINVAL assert exc.value.errno == EINVAL
# make sure that wcfs reports zf.blksize as preffered block size for IO
_ = t.wc._stat(zf)
assert _.st_blksize == zf.blksize
# >>> file initially empty # >>> file initially empty
f = t.open(zf) f = t.open(zf)
f.assertCache([]) f.assertCache([])
......
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