Commit a36a24a0 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 862d57af
......@@ -121,10 +121,12 @@ error _Conn::close() {
wconn._atMu.RLock();
defer([&]() {
wconn._atMu.RUnlock();
wconn._atMu.RUnlock();
});
xerr::Contextf E("wcfs %s: close conn @%s", v(wconn._wc->mountpoint), v(wconn.at));
xerr::Contextf E("%s: close", v(wconn));
// xerr::Contextf E("wcfs %s: close %s", v(wconn._wc->mountpoint), v(wconn.at));
// XXX + conn # e.g. from wconn._wlink.id? or wlink.close should include its id itself?
// (or ._wlink._f.fd() ?)
......@@ -793,6 +795,36 @@ static error mmap_into_ro(void *addr, size_t size, os::File f, off_t offset) {
}
// _assertVMAOk() verifies that mmap and vma are related to each other and cover
// exactly the same virtual memory rane.
//
// It panics if mmap and vma do not exactly relate to each other or cover
// different virtual memory range.
void _Mapping::_assertVMAOk() {
_Mapping* mmap = this;
VMA *vma = mmap->vma;
if (!(vma->mmap_overlay_server == static_cast<void*>(mmap)))
panic("BUG: mmap and vma do not link to each other");
if (!(vma->addr_start == uintptr_t(mmap->mem_start) &&
vma->addr_stop == uintptr_t(mmap->mem_stop)))
panic("BUG: mmap and vma cover different virtual memory ranges");
// verified ok
}
string WCFS::String() const {
const WCFS& wc = *this;
return fmt::sprintf("wcfs %s", v(wc.mountpoint));
}
string _Conn::String() const {
const _Conn& wconn = *this;
return ""; // XXX temp
//return fmt::sprintf("%s: conn%d @%s", v(wconn._wc), wconn._wlink->_f.fd(), v(wconn.at));
}
_Conn::_Conn() {}
_Conn::~_Conn() {}
void _Conn::decref() {
......@@ -814,24 +846,6 @@ void _Mapping::decref() {
delete this;
}
// _assertVMAOk() verifies that mmap and vma are related to each other and cover
// exactly the same virtual memory rane.
//
// It panics if mmap and vma do not exactly relate to each other or cover
// different virtual memory range.
void _Mapping::_assertVMAOk() {
_Mapping* mmap = this;
VMA *vma = mmap->vma;
if (!(vma->mmap_overlay_server == static_cast<void*>(mmap)))
panic("BUG: mmap and vma do not link to each other");
if (!(vma->addr_start == uintptr_t(mmap->mem_start) &&
vma->addr_stop == uintptr_t(mmap->mem_stop)))
panic("BUG: mmap and vma cover different virtual memory ranges");
// verified ok
}
dict<int64_t, zodb::Tid> _tfileh_pinned(FileH fileh) {
return fileh->_pinned;
}
......
......@@ -149,6 +149,8 @@ struct WCFS {
string _path(const string &obj);
tuple<os::File, error> _open(const string &path, int flags=O_RDONLY);
pair<WatchLink, error> _openwatch();
string String() const;
};
// Conn represents logical connection that provides view of data on wcfs
......@@ -202,6 +204,8 @@ public:
error close();
error resync(zodb::Tid at);
string String() const;
private:
error _pinner(context::Context ctx);
error __pinner(context::Context ctx);
......
......@@ -282,12 +282,12 @@ void __Logf(const char *file, int line, char level, const char *format, ...) {
// wcfs::
namespace wcfs {
template<> string v_(error err) {
template<> string v_(const error& err) {
return (err != nil) ? err->Error() : "nil";
}
static string h016(uint64_t v) { return fmt::sprintf("%016lx", v); }
template<> string v_(zodb::Tid tid) { return h016(tid); }
static string h016(uint64_t v) { return fmt::sprintf("%016lx", v); }
template<> string v_(const zodb::Tid& tid) { return h016(tid); }
//template<> string v_(zodb::Oid oid) { return h016(oid); }
// XXX Tid and Oid are typedefs for uint64_t and C++ reduces template
// specializations to the underlying type. This providing specialization for
......
......@@ -190,23 +190,23 @@ const zodb::Tid TidHead = -1ULL;
// NOTE returned char* pointer is guaranteed to stay valid only till end of
// current expression. For example
//
// printf("hello %s", v(obj))
// printf("hello %s", v(obj))
//
// is valid, while
//
// x = v(obj);
// use(x);
// x = v(obj);
// use(x);
//
// is not valid.
#define v(obj) (wcfs::v_(obj).c_str())
template<typename T> string v_(T obj) {
return obj.String();
}
template<> inline string v_(string s) { return s; } // XXX -> const string& ?
template<> string v_(error);
template<> string v_(zodb::Tid);
template<> string v_(zodb::Oid);
#define v(obj) (wcfs::v_(obj).c_str())
template<typename T> string v_(T* obj) { return obj->String(); }
template<typename T> string v_(const T* obj) { return obj->String(); }
template<typename T> string v_(const T& obj) { return obj.String(); }
template<> inline string v_(const string& s) { return s; }
template<> string v_(const error&);
template<> string v_(const zodb::Tid&);
template<> string v_(const zodb::Oid&);
} // wcfs::
......
......@@ -42,7 +42,7 @@ void _WatchLink::decref() {
// _openwatch opens new watch link on wcfs.
pair<WatchLink, error> WCFS::_openwatch() {
WCFS *wc = this;
xerr::Contextf E("wcfs %s: openwatch", v(wc->mountpoint));
xerr::Contextf E("%s: openwatch", v(wc));
// head/watch handle.
os::File f;
......
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