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

.

parent 8b5e9340
......@@ -233,7 +233,12 @@ setup(
_bigfile,
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',
['wcfs/internal/wcfs_test.pyx']),
......
......@@ -24,15 +24,17 @@
#include <golang/libgolang.h>
using namespace golang;
#include <wendelin/bug.h>
#include <unordered_map>
#include <vector>
#include <stdint.h>
template<typename Key, typename Value>
using dict = std::unordered_map<Key, Value>;
#include <vector>
using std::vector;
#include <stdint.h>
typedef uint64_t Tid; // XXX ok?
typedef uint64_t Oid; // XXX ok?
......@@ -77,8 +79,8 @@ private:
// XXX doc
struct _File {
Conn *wconn;
Oid foid; // hex of ZBigFile root object ID
// .blksize block size of this file
Oid foid; // hex of ZBigFile root object ID
int64_t blksize; // block size of this file
// .headf file object of head/file
// .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
......@@ -89,7 +91,13 @@ struct _File {
struct _Mapping {
_File *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) {
// 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();
}
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