debug_client: 0,
debug_osd: 0,
debug_ebofs: 1,
+ debug_fakestore: 1,
+ debug_journal: 1,
debug_bdev: 1, // block device
debug_ns: 0,
debug_ms: 0,
// --- fakestore ---
- fakestore_fake_sync: 2, // seconds
- fakestore_fsync: false,//true,
- fakestore_writesync: false,
- fakestore_syncthreads: 4,
+ fakestore_sync_interval: 2, // seconds
fakestore_fake_attrs: false,
fakestore_fake_collections: false,
fakestore_dev: 0,
ebofs_max_prefetch: 1000, // 4k blocks
ebofs_realloc: false, // hrm, this can cause bad fragmentation, don't use!
ebofs_verify_csum_on_read: true,
- ebofs_journal_dio: false,
- ebofs_journal_max_write_bytes: 0,
- ebofs_journal_max_write_entries: 10,
+
+ // journal
+ journal_dio: false,
+ journal_max_write_bytes: 0,
+ journal_max_write_entries: 10,
// --- block device ---
bdev_lock: true,
g_conf.debug_ebofs = atoi(args[++i]);
else
g_debug_after_conf.debug_ebofs = atoi(args[++i]);
+ else if (strcmp(args[i], "--debug_fakestore") == 0)
+ if (!g_conf.debug_after)
+ g_conf.debug_fakestore = atoi(args[++i]);
+ else
+ g_debug_after_conf.debug_fakestore = atoi(args[++i]);
+ else if (strcmp(args[i], "--debug_journal") == 0)
+ if (!g_conf.debug_after)
+ g_conf.debug_journal = atoi(args[++i]);
+ else
+ g_debug_after_conf.debug_journal = atoi(args[++i]);
else if (strcmp(args[i], "--debug_bdev") == 0)
if (!g_conf.debug_after)
g_conf.debug_bdev = atoi(args[++i]);
g_conf.ebofs_max_prefetch = atoi(args[++i]);
else if (strcmp(args[i], "--ebofs_realloc") == 0)
g_conf.ebofs_realloc = atoi(args[++i]);
- else if (strcmp(args[i], "--ebofs_journal_dio") == 0)
- g_conf.ebofs_journal_dio = atoi(args[++i]);
- else if (strcmp(args[i], "--ebofs_journal_max_write_entries") == 0)
- g_conf.ebofs_journal_max_write_entries = atoi(args[++i]);
- else if (strcmp(args[i], "--ebofs_journal_max_write_bytes") == 0)
- g_conf.ebofs_journal_max_write_bytes = atoi(args[++i]);
+\
+ else if (strcmp(args[i], "--journal_dio") == 0)
+ g_conf.journal_dio = atoi(args[++i]);
+ else if (strcmp(args[i], "--journal_max_write_entries") == 0)
+ g_conf.journal_max_write_entries = atoi(args[++i]);
+ else if (strcmp(args[i], "--journal_max_write_bytes") == 0)
+ g_conf.journal_max_write_bytes = atoi(args[++i]);
else if (strcmp(args[i], "--fakestore") == 0) {
g_conf.ebofs = 0;
//g_conf.osd_pg_bits = 5;
//g_conf.osd_maxthreads = 1; // fucking hell
}
- else if (strcmp(args[i], "--fakestore_fsync") == 0)
- g_conf.fakestore_fsync = atoi(args[++i]);
- else if (strcmp(args[i], "--fakestore_writesync") == 0)
- g_conf.fakestore_writesync = atoi(args[++i]);
+ else if (strcmp(args[i], "--fakestore_sync_interval") == 0)
+ g_conf.fakestore_sync_interval = atoi(args[++i]);
else if (strcmp(args[i], "--fakestore_dev") == 0)
g_conf.fakestore_dev = args[++i];
else if (strcmp(args[i], "--fakestore_fake_attrs") == 0)
int debug_client;
int debug_osd;
int debug_ebofs;
+ int debug_fakestore;
+ int debug_journal;
int debug_bdev;
int debug_ns;
int debug_ms;
bool osd_hack_fast_startup;
- double fakestore_fake_sync;
- bool fakestore_fsync;
- bool fakestore_writesync;
- int fakestore_syncthreads; // such crap
+ // fakestore
+ double fakestore_sync_interval;
bool fakestore_fake_attrs;
bool fakestore_fake_collections;
const char *fakestore_dev;
unsigned ebofs_max_prefetch;
bool ebofs_realloc;
bool ebofs_verify_csum_on_read;
- bool ebofs_journal_dio;
- bool ebofs_journal_max_write_bytes;
- bool ebofs_journal_max_write_entries;
+ // journal
+ bool journal_dio;
+ bool journal_max_write_bytes;
+ bool journal_max_write_entries;
+
// block device
bool bdev_lock;
int bdev_iothreads;
// open journal
if (journalfn) {
- journal = new FileJournal(sb->fsid, &finisher, journalfn, g_conf.ebofs_journal_dio);
+ journal = new FileJournal(sb->fsid, &finisher, journalfn, g_conf.journal_dio);
int err = journal->open(super_epoch);
if (err < 0) {
dout(3) << "mount journal " << journalfn << " open failed" << dendl;
// create journal?
if (journalfn) {
- Journal *journal = new FileJournal(super_fsid, &finisher, journalfn, g_conf.ebofs_journal_dio);
+ Journal *journal = new FileJournal(super_fsid, &finisher, journalfn, g_conf.journal_dio);
if (journal->create() < 0) {
dout(3) << "mount journal " << journalfn << " created failed" << dendl;
} else {
dout(3) << "mount journal " << journalfn << " created" << dendl;
}
delete journal;
+ journal = 0;
}
dout(2) << "mkfs: " << dev.get_device_name() << " " << dev.get_num_blocks() << " blocks, " << nice_blocks(dev.get_num_blocks()) << dendl;
}
return false;
}
-/*
-int OSDMonitor::do_command(vector<string>& cmd, bufferlist& data,
- bufferlist& rdata, string &rs)
-{
- if (cmd[1] == "getmap") {
- osdmap.encode(rdata);
- rs = "ok";
- return 0;
- }
- if (cmd[1] == "getcrushmap") {
- osdmap.crush._encode(rdata);
- rs = "ok";
- return 0;
- }
- if (cmd[1] == "setcrushmap") {
- return -EAGAIN;
- }
- rs = "unknown command";
- return -EINVAL;
-}
-*/
#include "FakeStore.h"
#include "include/types.h"
+#include "FileJournal.h"
+
#include "common/Timer.h"
#include <unistd.h>
#include "config.h"
-#define dout(l) if (l<=g_conf.debug) *_dout << dbeginl << g_clock.now() << " fakestore(" << basedir << ") "
-#define derr(l) if (l<=g_conf.debug) *_derr << dbeginl << g_clock.now() << " fakestore(" << basedir << ") "
+#define dout(l) if (l<=g_conf.debug_fakestore) *_dout << dbeginl << g_clock.now() << " fakestore(" << basedir << ") "
+#define derr(l) if (l<=g_conf.debug_fakestore) *_derr << dbeginl << g_clock.now() << " fakestore(" << basedir << ") "
#include "include/buffer.h"
#include <map>
-
int FakeStore::statfs(struct statfs *buf)
{
return ::statfs(basedir.c_str(), buf);
*/
void FakeStore::get_oname(pobject_t oid, char *s)
{
- //static hash<pobject_t> H;
assert(sizeof(oid) == 24);
#ifdef __LP64__
- //sprintf(s, "%s/objects/%02lx/%016lx.%016lx", basedir.c_str(), H(oid) & HASH_MASK,
sprintf(s, "%s/objects/%04x.%04x.%016lx.%016lx", basedir.c_str(),
oid.volume, oid.rank,
*((uint64_t*)&oid.oid),
*(((uint64_t*)&oid.oid) + 1));
#else
- //sprintf(s, "%s/objects/%02x/%016llx.%016llx", basedir.c_str(), H(oid) & HASH_MASK,
sprintf(s, "%s/objects/%04x.%04x.%016llx.%016llx", basedir.c_str(),
oid.volume, oid.rank,
- *((uint64_t*)&oid),
- *(((uint64_t*)&oid) + 1));
+ *((uint64_t*)&oid.oid),
+ *(((uint64_t*)&oid.oid) + 1));
#endif
}
dout(5) << "wipe: " << cmd << dendl;
system(cmd);
- // hashed bits too
- /*
- for (int i=0; i<HASH_DIRS; i++) {
- char s[4];
- sprintf(s, "%02x", i);
- string subdir = basedir + "/objects/" + s;
-
- dout(15) << " creating " << subdir << dendl;
- int r = ::mkdir(subdir.c_str(), 0755);
- if (r != 0) {
- derr(0) << "couldnt create subdir, r = " << r << dendl;
- return r;
+ // fsid
+ fsid = rand();
+ char fn[100];
+ sprintf(fn, "%s/fsid", basedir.c_str());
+ int fd = ::open(fn, O_CREAT|O_TRUNC|O_WRONLY);
+ ::write(fd, &fsid, sizeof(fsid));
+ ::fchmod(fd, 666);
+ ::close(fd);
+
+ // journal?
+ struct stat st;
+ sprintf(fn, "%s/journal", basedir.c_str());
+ if (::stat(fn, &st) == 0) {
+ journal = new FileJournal(fsid, &finisher, fn, g_conf.journal_dio);
+ if (journal->create() < 0) {
+ dout(0) << "mkfs error creating journal on " << fn << dendl;
+ } else {
+ dout(0) << "mkfs created journal on " << fn << dendl;
}
+ delete journal;
+ journal = 0;
}
- */
if (g_conf.fakestore_dev) {
char cmd[100];
// fake attrs?
// let's test to see if they work.
-#ifndef __CYGWIN__
if (g_conf.fakestore_fake_attrs) {
-#endif
dout(0) << "faking attrs (in memory)" << dendl;
fake_attrs = true;
-#ifndef __CYGWIN__
} else {
char names[1000];
r = ::listxattr(basedir.c_str(), names, 1000);
assert(0);
}
}
-#endif
- // get epoch
char fn[100];
+ int fd;
+
+ // get fsid
+ sprintf(fn, "%s/fsid", basedir.c_str());
+ fd = ::open(fn, O_RDONLY);
+ ::read(fd, &fsid, sizeof(fsid));
+ ::close(fd);
+
+ // get epoch
sprintf(fn, "%s/commit_epoch", basedir.c_str());
- int fd = ::open(fn, O_RDONLY);
+ fd = ::open(fn, O_RDONLY);
::read(fd, &super_epoch, sizeof(super_epoch));
- ::fsync(fd); // this should cause the fs's journal to commit.
::close(fd);
dout(5) << "mount epoch is " << super_epoch << dendl;
-
+
+ // journal
+ sprintf(fn, "%s/journal", basedir.c_str());
+ if (::stat(fn, &st) == 0)
+ journal = new FileJournal(fsid, &finisher, fn, g_conf.journal_dio);
r = journal_replay();
if (r == -EINVAL) {
dout(0) << "mount got EINVAL on journal open, not mounting" << dendl;
return r;
}
-
journal_start();
sync_thread.create();
}
-int FakeStore::stat(pobject_t oid,
- struct stat *st)
+int FakeStore::stat(pobject_t oid, struct stat *st)
{
dout(20) << "stat " << oid << dendl;
char fn[200];
get_oname(oid,fn);
int r = ::stat(fn, st);
+ dout(20) << "stat " << oid << " at " << fn << " = " << r << dendl;
return r;
}
-
int FakeStore::remove(pobject_t oid, Context *onsafe)
{
dout(20) << "remove " << oid << dendl;
{
lock.Lock();
utime_t interval;
- interval.set_from_double(g_conf.fakestore_fake_sync); // rename me
+ interval.set_from_double(g_conf.fakestore_sync_interval);
while (!stop) {
dout(10) << "sync_entry waiting for " << interval << dendl;
sync_cond.WaitInterval(lock, interval);
sprintf(fn, "%s/commit_epoch", basedir.c_str());
int fd = ::open(fn, O_CREAT|O_WRONLY);
::write(fd, &super_epoch, sizeof(super_epoch));
+ ::fchmod(fd, 0664);
::fsync(fd); // this should cause the fs's journal to commit.
::close(fd);
class FakeStore : public JournalingObjectStore {
string basedir;
-
+ __u64 fsid;
+
// fake attrs?
FakeStoreAttrs attrs;
bool fake_attrs;
#include "config.h"
-#define dout(x) if (x <= g_conf.debug_ebofs) *_dout << dbeginl << g_clock.now() << " ebofs(" << fn << ").journal "
-#define derr(x) if (x <= g_conf.debug_ebofs) *_derr << dbeginl << g_clock.now() << " ebofs(" << fn << ").journal "
+#define dout(x) if (x <= g_conf.debug_journal) *_dout << dbeginl << g_clock.now() << " journal "
+#define derr(x) if (x <= g_conf.debug_journal) *_derr << dbeginl << g_clock.now() << " journal "
int FileJournal::_open(bool forwrite)
// gather queued writes
off64_t queue_pos = write_pos;
- int eleft = g_conf.ebofs_journal_max_write_entries;
- int bleft = g_conf.ebofs_journal_max_write_bytes;
+ int eleft = g_conf.journal_max_write_entries;
+ int bleft = g_conf.journal_max_write_bytes;
while (!writeq.empty()) {
// grab next item
int JournalingObjectStore::journal_replay()
{
+ if (!journal)
+ return 0;
+
int err = journal->open(super_epoch);
if (err < 0) {
dout(3) << "journal_replay open failed with" << err