Commit 57489834 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent ae23c2c3
...@@ -74,6 +74,8 @@ from .internal._wcfs import \ ...@@ -74,6 +74,8 @@ from .internal._wcfs import \
# Raw files on wcfs can be accessed with ._path/._read/._stat/._open . # Raw files on wcfs can be accessed with ._path/._read/._stat/._open .
# #
# WCFS logically mirrors ZODB.DB . # WCFS logically mirrors ZODB.DB .
#
# XXX kill doc instead of C++.
class WCFS(_WCFS): class WCFS(_WCFS):
# .mountpoint path to wcfs mountpoint # .mountpoint path to wcfs mountpoint
# ._fwcfs /.wcfs/zurl opened to keep the server from going away (at least cleanly) # ._fwcfs /.wcfs/zurl opened to keep the server from going away (at least cleanly)
......
...@@ -40,18 +40,33 @@ using std::pair; ...@@ -40,18 +40,33 @@ using std::pair;
#include "wcfs_misc.h" #include "wcfs_misc.h"
// from wendelin/bigfile/virtmem.h
extern "C" {
struct BigFileH;
}
// wcfs:: // wcfs::
namespace wcfs { namespace wcfs {
struct _File; typedef refptr<struct _Conn> Conn;
struct _Mapping; typedef refptr<struct _Mapping> Mapping;
typedef refptr<struct _FileH> FileH;
typedef refptr<struct _WatchLink> WatchLink;
struct PinReq; struct PinReq;
typedef refptr<class _Conn> Conn;
typedef refptr<class _WatchLink> WatchLink;
// WCFS represents filesystem-level connection to wcfs server. // WCFS represents filesystem-level connection to wcfs server.
// XXX doc //
// XXX Use join to create it?
//
// The primary way to access wcfs is to open logical connection viewing on-wcfs
// data as of particular database state, and use that logical connection to
// create base-layer mappings. See .connect and Conn for details.
//
// XXX raw files?
//
// WCFS logically mirrors ZODB.DB .
struct WCFS { struct WCFS {
string mountpoint; string mountpoint;
...@@ -69,7 +84,7 @@ struct WCFS { ...@@ -69,7 +84,7 @@ struct WCFS {
// cache in OS pagecache of /head/bigfile/*. // cache in OS pagecache of /head/bigfile/*.
// //
// Use WCFS.connect(at) to create Conn. // Use WCFS.connect(at) to create Conn.
// Use .mmap to create new Mappings. // Use .open to create new FileH.
// Use .resync to resync Conn onto different database view. // Use .resync to resync Conn onto different database view.
// //
// Conn logically mirrors ZODB.Connection . // Conn logically mirrors ZODB.Connection .
...@@ -79,8 +94,8 @@ struct _Conn : object { ...@@ -79,8 +94,8 @@ struct _Conn : object {
zodb::Tid at; zodb::Tid at;
WatchLink _wlink; // watch/receive pins for created mappings WatchLink _wlink; // watch/receive pins for created mappings
sync::Mutex _filemu; sync::Mutex _filehmu;
dict<zodb::Oid, _File*> _filetab; // {} foid -> _file dict<zodb::Oid, FileH> _filehtab; // {} foid -> fileh
sync::WorkGroup _pinWG; sync::WorkGroup _pinWG;
func<void()> _pinCancel; func<void()> _pinCancel;
...@@ -95,8 +110,8 @@ public: ...@@ -95,8 +110,8 @@ public:
public: public:
error close(); error close();
// XXX move mmap -> _FileH ? // 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);
private: private:
...@@ -104,6 +119,64 @@ private: ...@@ -104,6 +119,64 @@ private:
void _pin1(PinReq *req); void _pin1(PinReq *req);
}; };
// FileH represent isolated file view under Conn.
//
// The file view is maintained to be as of @Conn.at database state.
// The file view uses /head/<file>/data primarilty and @revX/<file>/data pin overrides.
//
// Use .mmap to map file view into memory.
typedef refptr<struct _FileH> FileH;
struct _FileH : object {
Conn wconn;
zodb::Oid _foid; // ZBigFile root object ID
size_t _blksize; // block size of this file XXX -> off_t ?
os::File _headf; // file object of head/file
off_t _headfsize; // head/file size is known to be at least headfsize (size ↑=)
dict<int64_t, zodb::Tid> _pinned; // {} blk -> rev that wcfs already sent us for this file
vector<Mapping> _mmaps; // []Mapping ↑blk_start mappings of this file
// don't new - create via Conn.open
private:
_FileH();
~_FileH();
// XXX -> friend Conn::open
friend pair<Mapping, error> _Conn::mmap(zodb::Oid foid, int64_t blk_start, int64_t blk_len);
public:
void decref();
};
// Mapping represents one mapping of FileH.
typedef refptr<struct _Mapping> Mapping;
struct _Mapping : object {
FileH fileh;
int64_t blk_start; // offset of this mapping in file
BigFileH *virt_fileh; // mmapped under this virtmem file handle XXX -> VMA XXX can be nil
uint8_t *mem_start; // mmapped memory [mem_start, mem_stop)
uint8_t *mem_stop;
int64_t blk_stop() const {
//XXX reenable
//ASSERT((mem_stop - mem_start) % file->blksize == 0);
return blk_start + (mem_stop - mem_start) / fileh->_blksize;
}
error _remmapblk(int64_t blk, zodb::Tid at);
void remmap_blk(int64_t blk);
void unmap();
// don't new - create via FileH.mmap
private:
_Mapping();
~_Mapping();
// XXX -> friend FileH.mmap
friend pair<Mapping, error> _Conn::mmap(zodb::Oid foid, int64_t blk_start, int64_t blk_len);
public:
void decref();
};
} // wcfs:: } // wcfs::
......
This diff is collapsed.
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