Commit 83ef7688 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent e48a8eaf
...@@ -263,8 +263,6 @@ def _tpywlinkwrite(PyWatchLink pywlink, bytes pypkt): ...@@ -263,8 +263,6 @@ def _tpywlinkwrite(PyWatchLink pywlink, bytes pypkt):
# pyerr converts error into python error. # pyerr converts error into python error.
cdef object pyerr(error err): cdef object pyerr(error err):
if err == nil:
return None
return pyerror.from_error(err) return pyerror.from_error(err)
......
...@@ -79,7 +79,7 @@ static error mmap_into_ro(void *addr, size_t size, os::File f, off_t offset); ...@@ -79,7 +79,7 @@ static error mmap_into_ro(void *addr, size_t size, os::File f, off_t offset);
// connect creates new Conn viewing WCFS state as of @at. // connect creates new Conn viewing WCFS state as of @at.
pair<Conn, error> WCFS::connect(zodb::Tid at) { pair<Conn, error> WCFS::connect(zodb::Tid at) {
WCFS *wc = this; WCFS *wc = this;
xerr::Contextf E("connect @%s", v(at)); // XXX +wc path? xerr::Contextf E("wcfs %s: connect @%s", v(wc->mountpoint), v(at));
// TODO support !isolated mode // TODO support !isolated mode
...@@ -112,7 +112,6 @@ static global<error> errConnClosed = errors::New("connection closed"); ...@@ -112,7 +112,6 @@ static global<error> errConnClosed = errors::New("connection closed");
// opened fileh and mappings becomes invalid to use except close and unmap. // opened fileh and mappings becomes invalid to use except close and unmap.
error _Conn::close() { error _Conn::close() {
_Conn& wconn = *this; _Conn& wconn = *this;
//xerr::Contextf E("close conn @%s", v(wconn.at));
xerr::Contextf E("wcfs %s: close conn @%s", v(wconn._wc->mountpoint), v(wconn.at)); xerr::Contextf E("wcfs %s: close conn @%s", v(wconn._wc->mountpoint), v(wconn.at));
// XXX + conn # e.g. from wconn._wlink.id? or wlink.close should include its id itself? // XXX + conn # e.g. from wconn._wlink.id? or wlink.close should include its id itself?
...@@ -296,7 +295,7 @@ error _Conn::__pin1(PinReq *req) { ...@@ -296,7 +295,7 @@ error _Conn::__pin1(PinReq *req) {
pair<FileH, error> _Conn::open(zodb::Oid foid) { pair<FileH, error> _Conn::open(zodb::Oid foid) {
_Conn& wconn = *this; _Conn& wconn = *this;
error err; error err;
xerr::Contextf E("conn @%s: open f<%s>", v(wconn.at), v(foid)); xerr::Contextf E("wcfs %s: conn @%s: open f<%s>", v(wconn._wc->mountpoint), v(wconn.at), v(foid));
wconn._filehmu.lock(); wconn._filehmu.lock();
defer([&]() { defer([&]() {
...@@ -354,7 +353,7 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) { ...@@ -354,7 +353,7 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) {
error _FileH::close() { error _FileH::close() {
_FileH& fileh = *this; _FileH& fileh = *this;
Conn wconn = fileh.wconn; Conn wconn = fileh.wconn;
xerr::Contextf E("conn @%s: close f<%s>", v(wconn->at), v(fileh.foid)); // XXX + wcfs path? xerr::Contextf E("wcfs %s: conn @%s: close f<%s>", v(wconn->_wc->mountpoint), v(wconn->at), v(fileh.foid));
// remove fileh from wconn._filehtab // remove fileh from wconn._filehtab
// fileh.close can be called several times and after first call another // fileh.close can be called several times and after first call another
...@@ -373,8 +372,8 @@ error _FileH::close() { ...@@ -373,8 +372,8 @@ error _FileH::close() {
// If vma != nil, created mapping is associated with that vma of user-space virtual memory manager. // If vma != nil, created mapping is associated with that vma of user-space virtual memory manager.
pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma) { pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma) {
_FileH& f = *this; _FileH& f = *this;
xerr::Contextf E("conn @%s: mmap f<%s> [blk%ld +blk%ld)", xerr::Contextf E("wcfs %s: conn @%s: mmap f<%s> [blk%ld +blk%ld)",
v(f.wconn->at), v(f.foid), blk_start, blk_len); // XXX +wcfs path? v(f.wconn->_wc->mountpoint), v(f.wconn->at), v(f.foid), blk_start, blk_len);
// XXX (blk_start + blk_len) * blk_size overflow // XXX (blk_start + blk_len) * blk_size overflow
error err; error err;
...@@ -432,7 +431,7 @@ pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma) ...@@ -432,7 +431,7 @@ pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma)
// resync resyncs connection and its mappings onto different database view. // resync resyncs connection and its mappings onto different database view.
error _Conn::resync(zodb::Tid at) { error _Conn::resync(zodb::Tid at) {
_Conn& wconn = *this; _Conn& wconn = *this;
xerr::Contextf E("conn @%s: resync -> @%s", v(wconn.at), v(at)); // XXX +wcfs path? xerr::Contextf E("wcfs %s: conn @%s: resync -> @%s", v(wconn._wc->mountpoint), v(wconn.at), v(at));
// XXX locking // XXX locking
error err; error err;
...@@ -500,13 +499,13 @@ error _Conn::resync(zodb::Tid at) { ...@@ -500,13 +499,13 @@ error _Conn::resync(zodb::Tid at) {
// at=TidHead means unpin to head/ . // at=TidHead means unpin to head/ .
// NOTE this does not check whether virtmem already mapped blk as RW. // NOTE this does not check whether virtmem already mapped blk as RW.
error _Mapping::_remmapblk(int64_t blk, zodb::Tid at) { error _Mapping::_remmapblk(int64_t blk, zodb::Tid at) {
// XXX err context? blk #<blk> @<at>
_Mapping *mmap = this; _Mapping *mmap = this;
xerr::Contextf E("conn @%s: f<%s>: remmapblk #%ld @%s", FileH f = mmap->fileh;
v(mmap->fileh->wconn->at), v(mmap->fileh->foid), blk, v(at)); // XXX +wcfs path? xerr::Contextf E("wcfs %s: conn @%s: f<%s>: remmapblk #%ld @%s",
v(f->wconn->_wc->mountpoint), v(f->wconn->at), v(f->foid), blk, v(at));
ASSERT(mmap->blk_start <= blk && blk < mmap->blk_stop()); ASSERT(mmap->blk_start <= blk && blk < mmap->blk_stop());
FileH f = mmap->fileh;
error err; error err;
uint8_t *blkmem = mmap->mem_start + (blk - mmap->blk_start)*f->blksize; uint8_t *blkmem = mmap->mem_start + (blk - mmap->blk_start)*f->blksize;
......
...@@ -42,14 +42,14 @@ ...@@ -42,14 +42,14 @@
// ─── ───── ────────────────────────── ───── /head/bigfile/X // ─── ───── ────────────────────────── ───── /head/bigfile/X
// //
// where @revR mmaps are being dynamically added/removed by this client package // where @revR mmaps are being dynamically added/removed by this client package
// to maintain X@at data view according to WCFS invalidation protocol(*). // to maintain X@at data view according to WCFS isolation protocol(*).
// //
// //
// Integration with wendelin.core virtmem layer // Integration with wendelin.core virtmem layer
// //
// This client package can be used standalone, but additionally provides // This client package can be used standalone, but additionally provides
// integration with wendelin.core userspace virtual memory manager: when a // integration with wendelin.core userspace virtual memory manager: when a
// Mapping is created it can be associated as serving base layer for a // Mapping is created, it can be associated as serving base layer for a
// particular virtmem VMA via FileH.mmap(vma=...). In that case, since virtmem // particular virtmem VMA via FileH.mmap(vma=...). In that case, since virtmem
// itself adds another layer of dirty pages over read-only base provided by // itself adds another layer of dirty pages over read-only base provided by
// Mapping(+) // Mapping(+)
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
// ─── ───── ────────────────────────── ───── /head/bigfile/X // ─── ───── ────────────────────────── ───── /head/bigfile/X
// //
// the Mapping will interact with virtmem layer to coordinate // the Mapping will interact with virtmem layer to coordinate
// mapping memory updates. // updates to mapping virtual memory.
// //
// //
// API overview // API overview
...@@ -99,18 +99,9 @@ ...@@ -99,18 +99,9 @@
#include <golang/libgolang.h> #include <golang/libgolang.h>
#include <golang/cxx.h> #include <golang/cxx.h>
#include <golang/sync.h> #include <golang/sync.h>
using namespace golang;
using cxx::dict;
using cxx::set;
#include <string>
using std::string;
#include <tuple> #include <tuple>
using std::tuple;
#include <utility> #include <utility>
using std::pair;
#include "wcfs_misc.h" #include "wcfs_misc.h"
#include <wendelin/bug.h> #include <wendelin/bug.h>
...@@ -124,6 +115,13 @@ struct VMA; ...@@ -124,6 +115,13 @@ struct VMA;
// wcfs:: // wcfs::
namespace wcfs { namespace wcfs {
using namespace golang;
using cxx::dict;
using cxx::set;
using std::tuple;
using std::pair;
typedef refptr<struct _Conn> Conn; typedef refptr<struct _Conn> Conn;
typedef refptr<struct _Mapping> Mapping; typedef refptr<struct _Mapping> Mapping;
typedef refptr<struct _FileH> FileH; typedef refptr<struct _FileH> FileH;
...@@ -176,8 +174,8 @@ struct _Conn : object { ...@@ -176,8 +174,8 @@ struct _Conn : object {
sync::Mutex _filehmu; sync::Mutex _filehmu;
dict<zodb::Oid, FileH> _filehtab; // {} foid -> fileh dict<zodb::Oid, FileH> _filehtab; // {} foid -> fileh
sync::WorkGroup _pinWG; sync::WorkGroup _pinWG; // pin/unpin messages from wcfs are served by _pinner
func<void()> _pinCancel; func<void()> _pinCancel; // spawned under _pinWG.
// don't new - create via WCFS.connect // don't new - create via WCFS.connect
private: private:
...@@ -203,7 +201,7 @@ private: ...@@ -203,7 +201,7 @@ private:
// //
// The file view is maintained to be as of @Conn.at database state even in the // The file view is maintained to be as of @Conn.at database state even in the
// presence of simultaneous database changes. The file view uses // presence of simultaneous database changes. The file view uses
// /head/<file>/data primarily and @revX/<file>/data pin overrides. // /head/<file>/data primarily and /@revX/<file>/data pin overrides.
// //
// Use .mmap to map file view into memory. // Use .mmap to map file view into memory.
typedef refptr<struct _FileH> FileH; typedef refptr<struct _FileH> FileH;
...@@ -231,6 +229,8 @@ public: ...@@ -231,6 +229,8 @@ public:
}; };
// Mapping represents one memory mapping of FileH. // Mapping represents one memory mapping of FileH.
//
// The mapped memory is [.mem_start, .mem_stop)
typedef refptr<struct _Mapping> Mapping; typedef refptr<struct _Mapping> Mapping;
struct _Mapping : object { struct _Mapping : object {
FileH fileh; FileH fileh;
......
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