Commit 6cd01d61 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 8b5e9340
...@@ -233,7 +233,12 @@ setup( ...@@ -233,7 +233,12 @@ setup(
_bigfile, _bigfile,
PyGoExt('wcfs.internal._wcfs', PyGoExt('wcfs.internal._wcfs',
['wcfs/internal/_wcfs.pyx', 'wcfs/internal/wcfs_virtmem.cpp']), ['wcfs/internal/_wcfs.pyx', 'wcfs/internal/wcfs_virtmem.cpp'],
include_dirs = [ # XXX -> common place
'./include',
'./3rdparty/ccan',
'./3rdparty/include'
]),
PyGoExt('wcfs.internal.wcfs_test', PyGoExt('wcfs.internal.wcfs_test',
['wcfs/internal/wcfs_test.pyx']), ['wcfs/internal/wcfs_test.pyx']),
......
...@@ -24,15 +24,17 @@ ...@@ -24,15 +24,17 @@
#include <golang/libgolang.h> #include <golang/libgolang.h>
using namespace golang; using namespace golang;
#include <wendelin/bug.h>
#include <unordered_map> #include <unordered_map>
#include <vector>
#include <stdint.h>
template<typename Key, typename Value> template<typename Key, typename Value>
using dict = std::unordered_map<Key, Value>; using dict = std::unordered_map<Key, Value>;
#include <vector>
using std::vector; using std::vector;
#include <stdint.h>
typedef uint64_t Tid; // XXX ok? typedef uint64_t Tid; // XXX ok?
typedef uint64_t Oid; // XXX ok? typedef uint64_t Oid; // XXX ok?
...@@ -77,8 +79,8 @@ private: ...@@ -77,8 +79,8 @@ private:
// XXX doc // XXX doc
struct _File { struct _File {
Conn *wconn; Conn *wconn;
Oid foid; // hex of ZBigFile root object ID Oid foid; // hex of ZBigFile root object ID
// .blksize block size of this file int64_t blksize; // block size of this file
// .headf file object of head/file // .headf file object of head/file
// .headfsize head/file size is known to be at least headfsize (size ↑=) // .headfsize head/file size is known to be at least headfsize (size ↑=)
dict<int64_t, Tid> pinned; // {} blk -> rev that wcfs already sent us for this file dict<int64_t, Tid> pinned; // {} blk -> rev that wcfs already sent us for this file
...@@ -89,7 +91,13 @@ struct _File { ...@@ -89,7 +91,13 @@ struct _File {
struct _Mapping { struct _Mapping {
_File *file; _File *file;
int blk_start; // offset of this mapping in file int blk_start; // offset of this mapping in file
// .mem mmaped memory uint8_t *mem_start; // mmapped memory [mem_start, mem_stop)
uint8_t *mem_stop;
int64_t blk_stop() const {
ASSERT((mem_stop - mem_start) % file->blksize == 0);
return blk_start + (mem_stop - mem_start) / file->blksize;
}
}; };
...@@ -167,5 +175,10 @@ void Conn::_pin1(SrvReq *req) { ...@@ -167,5 +175,10 @@ void Conn::_pin1(SrvReq *req) {
// XXX relock wconn -> f ? // XXX relock wconn -> f ?
for (auto mmap : f->mmaps) { // XXX use ↑blk_start for binary search
if (!(mmap->blk_start <= req->blk && req->blk < mmap->blk_stop()))
continue; // blk ∉ mmap
}
wconn->_filemu.unlock(); wconn->_filemu.unlock();
} }
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