ebofs_abp_zero: false, // zero newly allocated buffers (may shut up valgrind)
ebofs_abp_max_alloc: 4096*16, // max size of new buffers (larger -> more memory fragmentation)
- // --- obfs ---
- uofs: 0,
- uofs_fake_sync: 2, // 2 seconds
- uofs_cache_size: 1 << 28, //256MB
- uofs_onode_size: (int)1024,
- uofs_small_block_size: (int)4096, //4KB
- uofs_large_block_size: (int)524288, //512KB
- uofs_segment_size: (int)268435456, //256MB
- uofs_block_meta_ratio: (int)10,
- uofs_sync_write: (int)0,
- uofs_nr_hash_buckets: (int)1023,
- uofs_flush_interval: (int)5, //seconds
- uofs_min_flush_pages: (int)1024, //4096 4k-pages
- uofs_delay_allocation: (int)1, //true
-
// --- block device ---
bdev_lock: true,
bdev_iothreads: 1, // number of ios to queue with kernel
else if (strcmp(args[i], "--fakestore_fake_collections") == 0)
g_conf.fakestore_fake_collections = true;//atoi(args[++i]);
- else if (strcmp(args[i], "--obfs") == 0) {
- g_conf.uofs = 1;
- g_conf.osd_maxthreads = 1; // until feng merges joel's fixes
- }
-
-
else if (strcmp(args[i], "--osd_balance_reads") == 0)
g_conf.osd_balance_reads = atoi(args[++i]);
else if ( strcmp(args[i],"--osd_immediate_read_from_cache" ) == 0)
#include <cassert>
#include <errno.h>
#include <dirent.h>
-#include <sys/xattr.h>
+#ifndef __CYGWIN__
+# include <sys/xattr.h>
+#endif
//#include <sys/vfs.h>
#ifdef DARWIN
// 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)" << endl;
fake_attrs = true;
+#ifndef __CYGWIN__
} else {
char names[1000];
r = ::listxattr(basedir.c_str(), names, 1000);
assert(0);
}
}
+#endif
// all okay.
return 0;
{
if (fake_attrs) return attrs.setattr(oid, name, value, size, onsafe);
+ int r = 0;
+#ifndef __CYGWIN__
char fn[100];
get_oname(oid, fn);
- int r = ::setxattr(fn, name, value, size, 0);
+ r = ::setxattr(fn, name, value, size, 0);
+#endif
return r;
}
char fn[100];
get_oname(oid, fn);
int r = 0;
+#ifndef __CYGWIN__
for (map<string,bufferptr>::iterator p = aset.begin();
p != aset.end();
++p) {
r = ::setxattr(fn, p->first.c_str(), p->second.c_str(), p->second.length(), 0);
if (r < 0) break;
}
+#endif
return r;
}
void *value, size_t size)
{
if (fake_attrs) return attrs.getattr(oid, name, value, size);
+ int r = 0;
+#ifndef __CYGWIN__
char fn[100];
get_oname(oid, fn);
- int r = ::getxattr(fn, name, value, size);
+ r = ::getxattr(fn, name, value, size);
+#endif
return r;
}
{
if (fake_attrs) return attrs.getattrs(oid, aset);
+#ifndef __CYGWIN__
char fn[100];
get_oname(oid, fn);
aset[names].append(val, l);
name += strlen(name) + 1;
}
-
+#endif
return 0;
}
int FakeStore::rmattr(object_t oid, const char *name, Context *onsafe)
{
if (fake_attrs) return attrs.rmattr(oid, name, onsafe);
+ int r = 0;
+#ifndef __CYGWIN__
char fn[100];
get_oname(oid, fn);
- int r = ::removexattr(fn, name);
+ r = ::removexattr(fn, name);
+#endif
return r;
}
+++ /dev/null
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-/*
- * Ceph - scalable distributed file system
- *
- * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software
- * Foundation. See file COPYING.
- *
- */
-
-
-
-#include "OBFSStore.h"
-
-extern "C" {
-#include "../../uofs/uofs.h"
-}
-
-#include "common/Timer.h"
-
-#include "include/types.h"
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/file.h>
-#include <iostream>
-#include <cassert>
-#include <errno.h>
-#include <dirent.h>
-
-
-#include "config.h"
-#undef dout
-#define dout(l) if (l<=g_conf.debug) cout << "osd" << whoami << ".obfs "
-
-OBFSStore::OBFSStore(int whoami, char *param, char *dev)
-{
- this->whoami = whoami;
- this->mounted = -1;
- this->bdev_id = -1;
- this->param[0] = 0;
- this->dev[0] = 0;
- if (dev)
- strcpy(this->dev, dev);
- if (param)
- strcpy(this->param, param);
-}
-
-int OBFSStore::mount(void)
-{
- dout(0) << "OBFS init!" << endl;
- if ((this->bdev_id = device_open(this->dev, O_RDWR)) < 0) {
- dout(0) << "device open FAILED on " << this->dev << ", errno " << errno << endl;
- return -1;
- }
-
- this->mkfs();
- this->mounted = uofs_mount(this->bdev_id,
- g_conf.uofs_cache_size,
- g_conf.uofs_min_flush_pages,
- this->whoami);
- switch (this->mounted) {
- case -1:
- this->mkfs();
- //retry to mount
- dout(0) << "remount the OBFS" << endl;
- this->mounted = uofs_mount(this->bdev_id,
- g_conf.uofs_cache_size,
- g_conf.uofs_min_flush_pages,
- this->whoami);
- assert(this->mounted >= 0);
- break;
- case -2:
- //fsck
- dout(0) << "Need fsck! Simply formatted for now!" << endl;
- this->mkfs();
- this->mounted = uofs_mount(this->bdev_id,
- g_conf.uofs_cache_size,
- g_conf.uofs_min_flush_pages,
- this->whoami);
- assert(this->mounted >= 0);
- break;
- case 0:
- //success
- break;
- default:
- break;
- }
-
- if (this->mounted >= 0)
- dout(0) << "successfully mounted!" << endl;
- else
- dout(0) << "error in mounting obfsstore!" << endl;
-
- return 0;
-}
-
-int OBFSStore::mkfs(void)
-{
- /*int donode_size_byte = 1024,
- bd_ratio = 10,
- reg_size_mb = 256,
- sb_size_kb = 4,
- lb_size_kb = 1024,
- nr_hash_table_buckets = 1023,
- delay_allocation = 1,
- flush_interval = 5;
- FILE *param;
- */
-
-
- if (this->mounted >= 0)
- return 0;
-
- dout(0) << "OBFS.mkfs!" << endl;
- /*
- if (strlen(this->param) > 0) {
- param = fopen(this->param, "r");
- if (param) {
- //fscanf(param, "Block Device: %s\n", this->dev);
- fscanf(param, "Donode Size: %d\n", &donode_size_byte);
- fscanf(param, "Block vs Donode Ratio: %d\n", &bd_ratio);
- fscanf(param, "Region Size: %d MB\n", ®_size_mb);
- fscanf(param, "Small Block Size: %d KB\n", &sb_size_kb);
- fscanf(param, "Large Block Size: %d KB\n", &lb_size_kb);
- fscanf(param, "Hash Table Buckets: %d\n", &nr_hash_table_buckets);
- fscanf(param, "Delayed Allocation: %d\n", &delay_allocation);
- } else {
- dout(0) << "read open FAILED on "<< this->param <<", errno " << errno << endl;
- dout(0) << "use default parameters" << endl;
- }
- } else
- dout(0) << "use default parameters" << endl;
- */
-
- if (this->bdev_id <= 0)
- if ((this->bdev_id = device_open(this->dev, O_RDWR)) < 0) {
- dout(0) << "device open FAILED on "<< this->dev <<", errno " << errno << endl;
- return -1;
- }
-
- dout(0) << "start formating!" << endl;
-
- uofs_format(this->bdev_id,
- g_conf.uofs_onode_size,
- g_conf.uofs_block_meta_ratio,
- g_conf.uofs_segment_size,
- g_conf.uofs_small_block_size,
- g_conf.uofs_large_block_size,
- g_conf.uofs_nr_hash_buckets,
- g_conf.uofs_delay_allocation,
- 0,//g_conf.uofs_dev_force_size,
- g_conf.uofs_flush_interval,
- 0);
-
- dout(0) << "formatting complete!" << endl;
- return 0;
-}
-
-int OBFSStore::umount(void)
-{
- uofs_shutdown();
- close(this->bdev_id);
-
- return 0;
-}
-
-int OBFSStore::statfs(struct statfs *sfs)
-{
- return 0;
-}
-
-bool OBFSStore::exists(object_t oid)
-{
- //dout(0) << "calling function exists!" << endl;
- return uofs_exist(oid);
-}
-
-int OBFSStore::stat(object_t oid, struct stat *st)
-{
- dout(0) << "calling function stat!" << endl;
- if (uofs_exist(oid)) return 0;
- return -1;
-}
-
-int OBFSStore::remove(object_t oid)
-{
- dout(0) << "calling remove function!" << endl;
- return uofs_del(oid);
-}
-
-int OBFSStore::truncate(object_t oid, off_t size)
-{
- dout(0) << "calling truncate function!" << endl;
- //return uofs_truncate(oid, size);
- return -1;
-}
-
-int OBFSStore::read(object_t oid, size_t len,
- off_t offset, bufferlist &bl)
-{
- //dout(0) << "calling read function!" << endl;
- //dout(0) << oid << " 0 " << len << " " << offset << " 100" << endl;
-
- // FIXME: page-align this and we can avoid a memcpy...
- bl.push_back(new buffer(len));
- return uofs_read(oid, bl.c_str(), offset, len);
-}
-
-int OBFSStore::write(object_t oid, size_t len,
- off_t offset, bufferlist& bl, bool fsync)
-{
- int ret = 0;
-
- //dout(0) << "calling write function!" << endl;
- //if (whoami == 0)
- // dout(0) << oid << " 0 " << len << " " << offset << " 101" << endl;
-
- for (list<bufferptr>::iterator p = bl.buffers().begin();
- p != bl.buffers().end();
- p++) {
- ret += uofs_write(oid, (*p).c_str(), offset, len, 0);
- }
-
- if (fsync)
- ret += uofs_sync(oid);
-
- return ret;
-}
-
-
-int OBFSStore::write(object_t oid, size_t len,
- off_t offset, bufferlist& bl, Context *onflush)
-{
- int r = write(oid, len, offset, bl, false);
- g_timer.add_event_after((float)g_conf.uofs_fake_sync, onflush);
- return r;
-}
+++ /dev/null
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-/*
- * Ceph - scalable distributed file system
- *
- * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software
- * Foundation. See file COPYING.
- *
- */
-
-
-#ifndef _OBFSSTORE_H_
-#define _OBFSSTORE_H_
-
-#include "ObjectStore.h"
-#include "Fake.h"
-
-class OBFSStore : public ObjectStore,
- public FakeStoreAttrs,
- public FakeStoreCollections {
- int whoami;
- int bdev_id;
- int mounted;
- char dev[128];
- char param[128];
-
- public:
- OBFSStore(int whoami, char *param, char *dev);
-
- int mount(void);
- int umount(void);
- int mkfs(void);
-
- int statfs(struct statfs *);
-
- bool exists(object_t oid);
- int stat(object_t oid, struct stat *st);
-
- int remove(object_t oid);
- int truncate(object_t oid, off_t size);
-
- int read(object_t oid, size_t len,
- off_t offset, bufferlist& bl);
- int write(object_t oid, size_t len,
- off_t offset, bufferlist& bl,
- bool fsync);
- int write(object_t oid, size_t len,
- off_t offset, bufferlist& bl,
- Context *onflush);
-
-};
-
-#endif