Commit 0149d7c8 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 77cd4f01
...@@ -563,10 +563,13 @@ class ZBigFile(LivePersistent): ...@@ -563,10 +563,13 @@ class ZBigFile(LivePersistent):
wcfileh = None wcfileh = None
if _use_wcfs: if _use_wcfs:
# TODO maintain zconn -> wconn in sync (p_jar -> wconn)
zstor = self._p_jar.db().storage zstor = self._p_jar.db().storage
zurl = wcfs.zstor_2zurl(zstor) zurl = wcfs.zstor_2zurl(zstor)
wc = wcfs.join(zurl, shared=True) wc = wcfs.join(zurl, shared=True)
wcfileh = wc.open(self) wconn = wc.connect(p_jar.at())
wcfileh = wconn.open(self._p_oid)
#wcfileh_mmap = lambda blk_start, blk_len: wconn.mmap(self._p_oid, blk_start, blk_len)
fileh = _ZBigFileH(self, wcfileh) fileh = _ZBigFileH(self, wcfileh)
self._v_filehset.add(fileh) self._v_filehset.add(fileh)
...@@ -654,19 +657,14 @@ Connection.open = Connection_open ...@@ -654,19 +657,14 @@ Connection.open = Connection_open
@implementer(ISynchronizer) @implementer(ISynchronizer)
class _ZBigFileH(object): class _ZBigFileH(object):
# .zfile ZBigFile we were opened for # .zfile ZBigFile we were opened for
# .wcfileh handle for ZBigFile in wcfs | None # # .wcfileh handle for ZBigFile in wcfs | None
# .zfileh handle for ZBigFile (overlayed over .wcfileh if .wcfile != ø) # .zfileh handle for ZBigFile (overlayed over .wcfileh if .wcfile != ø)
def __init__(self, zfile, wcfileh): # def __init__(self, zfile, wcfileh):
def __init__(self, zfile, wc): # wc: wcfs.WCFS | None
self.zfile = zfile self.zfile = zfile
self.wcfileh = wcfileh # self.wcfileh = wcfileh
# FIXME for now we use only wcfs handle self.zfileh = zfile._v_file.fileh_open() # XXX pass wcfileh in
# TODO setup overlaying
if wcfileh is not None:
self.zfileh = wcfileh
else:
# XXX
self.zfileh = zfile._v_file.fileh_open()
# FIXME zfile._p_jar could be None (ex. ZBigFile is newly created # FIXME zfile._p_jar could be None (ex. ZBigFile is newly created
# before first commit) # before first commit)
......
...@@ -335,7 +335,7 @@ void vma_unmap(VMA *vma) ...@@ -335,7 +335,7 @@ void vma_unmap(VMA *vma)
/* unmap whole vma at once - the kernel unmaps each mapping in turn. /* unmap whole vma at once - the kernel unmaps each mapping in turn.
* NOTE error here would mean something is broken */ * NOTE error here would mean something is broken */
if (fileh->mmap_overlay) { if (fileh->mmap_overlay) {
fileh->file->file_ops->munmap(fileh->file, vma); fileh->file->file_ops->munmap(vma, fileh->file);
} else { } else {
xmunmap((void *)vma->addr_start, len); xmunmap((void *)vma->addr_start, len);
} }
......
...@@ -124,7 +124,7 @@ struct bigfile_ops { ...@@ -124,7 +124,7 @@ struct bigfile_ops {
* XXX called under virtmem lock? * XXX called under virtmem lock?
* Must not fail. * Must not fail.
*/ */
void (*munmap) (BigFile *file, VMA *vma); void (*munmap) (VMA *vma, BigFile *file);
/* release is called to release resources associated with file. /* release is called to release resources associated with file.
......
...@@ -50,11 +50,11 @@ cdef extern from "wcfs_misc.h" namespace "zodb" nogil: ...@@ -50,11 +50,11 @@ cdef extern from "wcfs_misc.h" namespace "zodb" nogil:
ctypedef uint64_t Tid ctypedef uint64_t Tid
ctypedef uint64_t Oid ctypedef uint64_t Oid
cdef extern from "wcfs_misc.h" nogil: cdef extern from "wcfs_misc.h" namespace "wcfs" nogil:
const Tid TidHead const Tid TidHead
cdef extern from "wcfs_watchlink.h" nogil: cdef extern from "wcfs_watchlink.h" namespace "wcfs" nogil:
cppclass _WatchLink: cppclass _WatchLink:
error close() error close()
error closeWrite() error closeWrite()
...@@ -85,7 +85,7 @@ cdef extern from "wcfs_watchlink.h" nogil: ...@@ -85,7 +85,7 @@ cdef extern from "wcfs_watchlink.h" nogil:
error _twlinkwrite(WatchLink wlink, const string& pkt) error _twlinkwrite(WatchLink wlink, const string& pkt)
cdef extern from "wcfs.h" nogil: cdef extern from "wcfs.h" namespace "wcfs" nogil:
cppclass WCFS: cppclass WCFS:
string mountpoint string mountpoint
......
...@@ -40,6 +40,9 @@ using std::pair; ...@@ -40,6 +40,9 @@ using std::pair;
#include "wcfs_misc.h" #include "wcfs_misc.h"
// wcfs::
namespace wcfs {
struct _File; struct _File;
struct _Mapping; struct _Mapping;
struct PinReq; struct PinReq;
...@@ -92,6 +95,7 @@ public: ...@@ -92,6 +95,7 @@ public:
public: public:
error close(); error close();
// XXX move mmap -> _FileH ?
pair<_Mapping*, error> mmap(zodb::Oid foid, int64_t blk_start, int64_t blk_len); pair<_Mapping*, error> mmap(zodb::Oid foid, int64_t blk_start, int64_t blk_len);
error resync(zodb::Tid at); error resync(zodb::Tid at);
...@@ -101,4 +105,6 @@ private: ...@@ -101,4 +105,6 @@ private:
}; };
} // wcfs::
#endif #endif
...@@ -149,7 +149,13 @@ typedef uint64_t Oid; ...@@ -149,7 +149,13 @@ typedef uint64_t Oid;
} // zodb:: } // zodb::
// wcfs::
namespace wcfs {
// TidHead is invalid Tid which is largest Tid value and means @head. // TidHead is invalid Tid which is largest Tid value and means @head.
const zodb::Tid TidHead = -1ULL; const zodb::Tid TidHead = -1ULL;
} // wcfs::
#endif #endif
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include <wendelin/bigfile/virtmem.h> #include <wendelin/bigfile/virtmem.h>
#include <wendelin/bigfile/ram.h> #include <wendelin/bigfile/ram.h>
//#include <wendelin/bug.h>
#include <golang/fmt.h> #include <golang/fmt.h>
...@@ -42,12 +41,13 @@ ...@@ -42,12 +41,13 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
using std::min; using std::min;
using std::max; using std::max;
using std::vector; using std::vector;
// wcfs::
namespace wcfs {
static string h(uint64_t v); // v -> 016x hex representation static string h(uint64_t v); // v -> 016x hex representation
#define h_(v) (h(v).c_str()) #define h_(v) (h(v).c_str())
static error mmap_zero_into_ro(void *addr, size_t size); static error mmap_zero_into_ro(void *addr, size_t size);
...@@ -570,3 +570,6 @@ void _Conn::decref() { ...@@ -570,3 +570,6 @@ void _Conn::decref() {
if (__decref()) if (__decref())
delete this; delete this;
} }
} // wcfs::
...@@ -25,6 +25,11 @@ ...@@ -25,6 +25,11 @@
#include <golang/strings.h> #include <golang/strings.h>
#include <string.h> #include <string.h>
// wcfs::
namespace wcfs {
// XXX temp, place, ok=? // XXX temp, place, ok=?
const char *v(error err) { const char *v(error err) {
if (err != nil) if (err != nil)
...@@ -468,3 +473,6 @@ string rxPkt::to_string() const { ...@@ -468,3 +473,6 @@ string rxPkt::to_string() const {
const rxPkt& pkt = *this; const rxPkt& pkt = *this;
return string(pkt.data, pkt.datalen); return string(pkt.data, pkt.datalen);
} }
} // wcfs::
...@@ -34,6 +34,9 @@ using cxx::set; ...@@ -34,6 +34,9 @@ using cxx::set;
#include "wcfs.h" #include "wcfs.h"
#include "wcfs_misc.h" #include "wcfs_misc.h"
// wcfs::
namespace wcfs {
struct PinReq; struct PinReq;
...@@ -131,4 +134,7 @@ struct PinReq { ...@@ -131,4 +134,7 @@ struct PinReq {
// for testing // for testing
error _twlinkwrite(WatchLink wlink, const string &pkt); error _twlinkwrite(WatchLink wlink, const string &pkt);
} // wcfs::
#endif #endif
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