Inode *in = add_update_inode(&ist, from, mds);
Dentry *dn = insert_dentry_inode(dir, dname, &dlease, in, from, mds, false);
- dn->offset = DirResult::make_fpos(request->readdir_frag, i + request->readdir_offset);
+ dn->offset = ceph_dir_result_t::make_fpos(request->readdir_frag, i + request->readdir_offset);
// remove any extra names
while (pd != dir->dentry_map.end() && pd->first <= dname) {
}
-int Client::opendir(const char *relpath, DIR **dirpp)
+int Client::opendir(const char *relpath, ceph_dir_result_t **dirpp)
{
Mutex::Locker lock(client_lock);
tout << "opendir" << std::endl;
int r = path_walk(path, &in);
if (r < 0)
return r;
- r = _opendir(in, (DirResult**)dirpp);
+ r = _opendir(in, dirpp);
tout << (unsigned long)*dirpp << std::endl;
return r;
}
-int Client::_opendir(Inode *in, DirResult **dirpp, int uid, int gid)
+int Client::_opendir(Inode *in, ceph_dir_result_t **dirpp, int uid, int gid)
{
- *dirpp = new DirResult(in);
+ *dirpp = new ceph_dir_result_t(in);
if (!in->is_dir())
return -ENOTDIR;
(*dirpp)->set_frag(in->dirfragtree[0]);
}
-int Client::closedir(DIR *dir)
+int Client::closedir(ceph_dir_result_t *dir)
{
Mutex::Locker lock(client_lock);
tout << "closedir" << std::endl;
tout << (unsigned long)dir << std::endl;
dout(3) << "closedir(" << dir << ") = 0" << dendl;
- _closedir((DirResult*)dir);
+ _closedir(dir);
return 0;
}
-void Client::_closedir(DirResult *dirp)
+void Client::_closedir(ceph_dir_result_t *dirp)
{
dout(10) << "_closedir(" << dirp << ")" << dendl;
if (dirp->inode) {
delete dirp;
}
-void Client::rewinddir(DIR *dirp)
+void Client::rewinddir(ceph_dir_result_t *dirp)
{
dout(3) << "rewinddir(" << dirp << ")" << dendl;
- DirResult *d = (DirResult*)dirp;
+ ceph_dir_result_t *d = (ceph_dir_result_t*)dirp;
d->reset();
}
-loff_t Client::telldir(DIR *dirp)
+loff_t Client::telldir(ceph_dir_result_t *dirp)
{
- DirResult *d = (DirResult*)dirp;
+ ceph_dir_result_t *d = (ceph_dir_result_t*)dirp;
dout(3) << "telldir(" << dirp << ") = " << d->offset << dendl;
return d->offset;
}
-void Client::seekdir(DIR *dirp, loff_t offset)
+void Client::seekdir(ceph_dir_result_t *dirp, loff_t offset)
{
dout(3) << "seekdir(" << dirp << ", " << offset << ")" << dendl;
- DirResult *d = (DirResult*)dirp;
+ ceph_dir_result_t *d = (ceph_dir_result_t*)dirp;
if (offset == 0 ||
- DirResult::fpos_frag(offset) != d->frag() ||
- DirResult::fpos_off(offset) < d->fragpos()) {
+ ceph_dir_result_t::fpos_frag(offset) != d->frag() ||
+ ceph_dir_result_t::fpos_off(offset) < d->fragpos()) {
d->reset();
}
#endif
}
-void Client::_readdir_next_frag(DirResult *dirp)
+void Client::_readdir_next_frag(ceph_dir_result_t *dirp)
{
frag_t fg = dirp->frag();
}
}
-void Client::_readdir_rechoose_frag(DirResult *dirp)
+void Client::_readdir_rechoose_frag(ceph_dir_result_t *dirp)
{
assert(dirp->inode);
frag_t cur = dirp->frag();
}
}
-void Client::_readdir_drop_dirp_buffer(DirResult *dirp)
+void Client::_readdir_drop_dirp_buffer(ceph_dir_result_t *dirp)
{
dout(10) << "_readdir_drop_dirp_buffer " << dirp << dendl;
if (dirp->buffer) {
}
}
-int Client::_readdir_get_frag(DirResult *dirp)
+int Client::_readdir_get_frag(ceph_dir_result_t *dirp)
{
// get the current frag.
frag_t fg = dirp->frag();
}
if (res == 0) {
- // stuff dir contents to cache, DirResult
+ // stuff dir contents to cache, ceph_dir_result_t
assert(diri);
_readdir_drop_dirp_buffer(dirp);
return res;
}
-int Client::_readdir_cache_cb(DirResult *dirp, add_dirent_cb_t cb, void *p)
+int Client::_readdir_cache_cb(ceph_dir_result_t *dirp, add_dirent_cb_t cb, void *p)
{
dout(10) << "_readdir_cache_cb " << dirp << " on " << dirp->inode->ino
<< " at_cache_name " << dirp->at_cache_name << " offset " << hex << dirp->offset << dec
uint64_t next_off = dn->offset + 1;
pd++;
if (pd == dir->dentry_map.end())
- next_off = DirResult::END;
+ next_off = ceph_dir_result_t::END;
int r = cb(p, &de, &st, stmask, next_off); // _next_ offset
dout(15) << " de " << de.d_name << " off " << hex << dn->offset << dec
return 1;
}
-int Client::readdir_r_cb(DIR *d, add_dirent_cb_t cb, void *p)
+int Client::readdir_r_cb(ceph_dir_result_t *d, add_dirent_cb_t cb, void *p)
{
- DirResult *dirp = (DirResult*)d;
+ ceph_dir_result_t *dirp = (ceph_dir_result_t*)d;
dout(10) << "readdir_r_cb " << *dirp->inode << " offset " << hex << dirp->offset << dec
<< " frag " << dirp->frag() << " fragpos " << hex << dirp->fragpos() << dec
<< " frag " << fg << dendl;
while (off >= dirp->this_offset &&
off - dirp->this_offset < dirp->buffer->size()) {
- uint64_t pos = DirResult::make_fpos(fg, off);
+ uint64_t pos = ceph_dir_result_t::make_fpos(fg, off);
pair<string,Inode*>& ent = (*dirp->buffer)[off - dirp->this_offset];
int stmask = fill_stat(ent.second, &st);
-int Client::readdir_r(DIR *d, struct dirent *de)
+int Client::readdir_r(ceph_dir_result_t *d, struct dirent *de)
{
return readdirplus_r(d, de, 0, 0);
}
return 0;
}
-int Client::readdirplus_r(DIR *d, struct dirent *de, struct stat *st, int *stmask)
+int Client::readdirplus_r(ceph_dir_result_t *d, struct dirent *de, struct stat *st, int *stmask)
{
single_readdir sr;
sr.de = de;
return 0;
}
-int Client::_getdents(DIR *dir, char *buf, int buflen, bool fullent)
+int Client::_getdents(ceph_dir_result_t *dir, char *buf, int buflen, bool fullent)
{
getdents_result gr;
gr.buf = buf;
tout << relpath << std::endl;
}
- DIR *d;
+ ceph_dir_result_t *d;
int r = opendir(relpath, &d);
if (r < 0)
return r;
int r = 0;
if (vino.snapid == CEPH_SNAPDIR) {
- *dirpp = new DirResult(diri);
+ *dirpp = new ceph_dir_result_t(diri);
} else {
- r = _opendir(diri, (DirResult**)dirpp);
+ r = _opendir(diri, (ceph_dir_result_t**)dirpp);
}
tout << (unsigned long)*dirpp << std::endl;
dout(3) << "ll_releasedir " << dirp << dendl;
tout << "ll_releasedir" << std::endl;
tout << (unsigned long)dirp << std::endl;
- _closedir((DirResult*)dirp);
+ _closedir((ceph_dir_result_t*)dirp);
}
int Client::ll_open(vinodeno_t vino, int flags, Fh **fhp, int uid, int gid)
// ========================================================
// client interface
-class Client : public Dispatcher {
- public:
-
- struct DirResult {
- static const int SHIFT = 28;
- static const int64_t MASK = (1 << SHIFT) - 1;
- static const loff_t END = 1ULL << (SHIFT + 32);
+struct ceph_dir_result_t {
+ static const int SHIFT = 28;
+ static const int64_t MASK = (1 << SHIFT) - 1;
+ static const loff_t END = 1ULL << (SHIFT + 32);
- static uint64_t make_fpos(unsigned frag, unsigned off) {
- return ((uint64_t)frag << SHIFT) | (uint64_t)off;
- }
- static unsigned fpos_frag(uint64_t p) {
- return p >> SHIFT;
- }
- static unsigned fpos_off(uint64_t p) {
- return p & MASK;
- }
+ static uint64_t make_fpos(unsigned frag, unsigned off) {
+ return ((uint64_t)frag << SHIFT) | (uint64_t)off;
+ }
+ static unsigned fpos_frag(uint64_t p) {
+ return p >> SHIFT;
+ }
+ static unsigned fpos_off(uint64_t p) {
+ return p & MASK;
+ }
- Inode *inode;
+ Inode *inode;
- int64_t offset; // high bits: frag_t, low bits: an offset
+ int64_t offset; // high bits: frag_t, low bits: an offset
- uint64_t this_offset; // offset of last chunk, adjusted for . and ..
- uint64_t next_offset; // offset of next chunk (last_name's + 1)
- string last_name; // last entry in previous chunk
+ uint64_t this_offset; // offset of last chunk, adjusted for . and ..
+ uint64_t next_offset; // offset of next chunk (last_name's + 1)
+ string last_name; // last entry in previous chunk
- uint64_t release_count;
+ uint64_t release_count;
- frag_t buffer_frag;
- vector<pair<string,Inode*> > *buffer;
+ frag_t buffer_frag;
+ vector<pair<string,Inode*> > *buffer;
- string at_cache_name; // last entry we successfully returned
+ string at_cache_name; // last entry we successfully returned
- DirResult(Inode *in) : inode(in), offset(0), next_offset(2),
- release_count(0),
- buffer(0) {
- inode->get();
- }
+ ceph_dir_result_t(Inode *in) : inode(in), offset(0), next_offset(2),
+ release_count(0),
+ buffer(0) {
+ inode->get();
+ }
- frag_t frag() { return frag_t(offset >> SHIFT); }
- unsigned fragpos() { return offset & MASK; }
+ frag_t frag() { return frag_t(offset >> SHIFT); }
+ unsigned fragpos() { return offset & MASK; }
- void next_frag() {
- frag_t fg = offset >> SHIFT;
- if (fg.is_rightmost())
- set_end();
- else
- set_frag(fg.next());
- }
- void set_frag(frag_t f) {
- offset = (uint64_t)f << SHIFT;
- assert(sizeof(offset) == 8);
- }
- void set_end() { offset = END; }
- bool at_end() { return (offset == END); }
-
- void reset() {
- last_name.clear();
- next_offset = 2;
- this_offset = 0;
- offset = 0;
- delete buffer;
- buffer = 0;
- }
- };
+ void next_frag() {
+ frag_t fg = offset >> SHIFT;
+ if (fg.is_rightmost())
+ set_end();
+ else
+ set_frag(fg.next());
+ }
+ void set_frag(frag_t f) {
+ offset = (uint64_t)f << SHIFT;
+ assert(sizeof(offset) == 8);
+ }
+ void set_end() { offset = END; }
+ bool at_end() { return (offset == END); }
+
+ void reset() {
+ last_name.clear();
+ next_offset = 2;
+ this_offset = 0;
+ offset = 0;
+ delete buffer;
+ buffer = 0;
+ }
+};
+class Client : public Dispatcher {
+ public:
+
// **** WARNING: be sure to update the struct in libceph.h too! ****
struct stat_precise {
ino_t st_ino;
// some readdir helpers
typedef int (*add_dirent_cb_t)(void *p, struct dirent *de, struct stat *st, int stmask, off_t off);
- int _opendir(Inode *in, DirResult **dirpp, int uid=-1, int gid=-1);
- void _readdir_drop_dirp_buffer(DirResult *dirp);
- bool _readdir_have_frag(DirResult *dirp);
- void _readdir_next_frag(DirResult *dirp);
- void _readdir_rechoose_frag(DirResult *dirp);
- int _readdir_get_frag(DirResult *dirp);
- int _readdir_cache_cb(DirResult *dirp, add_dirent_cb_t cb, void *p);
- void _closedir(DirResult *dirp);
+ int _opendir(Inode *in, ceph_dir_result_t **dirpp, int uid=-1, int gid=-1);
+ void _readdir_drop_dirp_buffer(ceph_dir_result_t *dirp);
+ bool _readdir_have_frag(ceph_dir_result_t *dirp);
+ void _readdir_next_frag(ceph_dir_result_t *dirp);
+ void _readdir_rechoose_frag(ceph_dir_result_t *dirp);
+ int _readdir_get_frag(ceph_dir_result_t *dirp);
+ int _readdir_cache_cb(ceph_dir_result_t *dirp, add_dirent_cb_t cb, void *p);
+ void _closedir(ceph_dir_result_t *dirp);
// other helpers
void _ll_get(Inode *in);
void getcwd(std::string& cwd);
// namespace ops
- int opendir(const char *name, DIR **dirpp);
- int closedir(DIR *dirp);
+ int opendir(const char *name, ceph_dir_result_t **dirpp);
+ int closedir(ceph_dir_result_t *dirp);
- int readdir_r_cb(DIR *dirp, add_dirent_cb_t cb, void *p);
+ int readdir_r_cb(ceph_dir_result_t *dirp, add_dirent_cb_t cb, void *p);
- int readdir_r(DIR *dirp, struct dirent *de);
- int readdirplus_r(DIR *dirp, struct dirent *de, struct stat *st, int *stmask);
+ int readdir_r(ceph_dir_result_t *dirp, struct dirent *de);
+ int readdirplus_r(ceph_dir_result_t *dirp, struct dirent *de, struct stat *st, int *stmask);
int getdir(const char *relpath, list<string>& names); // get the whole dir at once.
- int _getdents(DIR *dirp, char *buf, int buflen, bool ful); // get a bunch of dentries at once
- int getdents(DIR *dirp, char *buf, int buflen) {
+ int _getdents(ceph_dir_result_t *dirp, char *buf, int buflen, bool ful); // get a bunch of dentries at once
+ int getdents(ceph_dir_result_t *dirp, char *buf, int buflen) {
return _getdents(dirp, buf, buflen, true);
}
- int getdnames(DIR *dirp, char *buf, int buflen) {
+ int getdnames(ceph_dir_result_t *dirp, char *buf, int buflen) {
return _getdents(dirp, buf, buflen, false);
}
- void rewinddir(DIR *dirp);
- loff_t telldir(DIR *dirp);
- void seekdir(DIR *dirp, loff_t offset);
+ void rewinddir(ceph_dir_result_t *dirp);
+ loff_t telldir(ceph_dir_result_t *dirp);
+ void seekdir(ceph_dir_result_t *dirp, loff_t offset);
int link(const char *existing, const char *newname);
int unlink(const char *path);
utime_t start = g_clock.now();
hash_map<int64_t, int64_t> open_files;
- hash_map<int64_t, DIR*> open_dirs;
+ hash_map<int64_t, ceph_dir_result_t*> open_dirs;
hash_map<int64_t, Fh*> ll_files;
hash_map<int64_t, void*> ll_dirs;
} else if (strcmp(op, "opendir") == 0) {
const char *a = t.get_string(buf, p);
int64_t b = t.get_int();
- DIR *dirp;
+ ceph_dir_result_t *dirp;
client->opendir(a, &dirp);
if (dirp) open_dirs[b] = dirp;
} else if (strcmp(op, "closedir") == 0) {
dout(1) << "leftover close " << fi->second << dendl;
if (fi->second > 0) client->close(fi->second);
}
- for (hash_map<int64_t, DIR*>::iterator fi = open_dirs.begin();
+ for (hash_map<int64_t, ceph_dir_result_t*>::iterator fi = open_dirs.begin();
fi != open_dirs.end();
fi++) {
dout(1) << "leftover closedir " << fi->second << dendl;
{
(void) fi;
- DIR *dirp = (DIR*)fi->fh;
+ ceph_dir_result_t *dirp = (ceph_dir_result_t*)fi->fh;
client->seekdir(dirp, off);
struct readdir_context rc;
static void ceph_ll_releasedir(fuse_req_t req, fuse_ino_t ino,
struct fuse_file_info *fi)
{
- DIR *dirp = (DIR*)fi->fh;
+ ceph_dir_result_t *dirp = (ceph_dir_result_t*)fi->fh;
client->ll_releasedir(dirp);
fuse_reply_err(req, 0);
}
#include <utime.h>
#include <sys/types.h>
-#include <dirent.h>
struct stat_precise {
ino_t st_ino;
extern "C" {
#endif
-struct ceph_cluster_t;
+struct ceph_mount_t;
+struct ceph_dir_result_t;
const char *ceph_version(int *major, int *minor, int *patch);
/* initialization */
-int ceph_create(ceph_cluster_t **cluster, const char * const id);
+int ceph_create(ceph_mount_t **cmount, const char * const id);
/* initialization with an existing configuration */
-int ceph_create_with_config(ceph_cluster_t **cluster, struct md_config_t *conf);
+int ceph_create_with_config(ceph_mount_t **cmount, struct md_config_t *conf);
-/* Connect to the cluster */
-int ceph_connect(ceph_cluster_t *cluster);
+/* Activate the mount */
+int ceph_mount(ceph_mount_t *cmount, const char *root);
-/* Destroy the cluster instance */
-void ceph_shutdown(ceph_cluster_t *cluster);
+/* Destroy the ceph mount instance */
+void ceph_shutdown(ceph_mount_t *cmount);
/* Config
*
* Functions for manipulating the Ceph configuration at runtime.
*/
-int ceph_conf_read_file(ceph_cluster_t *cluster, const char *path);
+int ceph_conf_read_file(ceph_mount_t *cmount, const char *path);
-void ceph_conf_parse_argv(ceph_cluster_t *cluster, int argc, const char **argv);
+void ceph_conf_parse_argv(ceph_mount_t *cmount, int argc, const char **argv);
/* Sets a configuration value from a string.
* Returns 0 on success, error code otherwise. */
-int ceph_conf_set(ceph_cluster_t *cluster, const char *option, const char *value);
+int ceph_conf_set(ceph_mount_t *cmount, const char *option, const char *value);
/* Returns a configuration value as a string.
* If len is positive, that is the maximum number of bytes we'll write into the
* buffer. If len == -1, we'll call malloc() and set *buf.
* Returns 0 on success, error code otherwise. Returns ENAMETOOLONG if the
* buffer is too short. */
-int ceph_conf_get(ceph_cluster_t *cluster, const char *option, char *buf, size_t len);
+int ceph_conf_get(ceph_mount_t *cmount, const char *option, char *buf, size_t len);
-int ceph_mount(ceph_cluster_t *cluster, const char *root);
-void ceph_umount(ceph_cluster_t *cluster);
-
-int ceph_statfs(ceph_cluster_t *cluster, const char *path, struct statvfs *stbuf);
-int ceph_get_local_osd(ceph_cluster_t *cluster);
+int ceph_statfs(ceph_mount_t *cmount, const char *path, struct statvfs *stbuf);
+int ceph_get_local_osd(ceph_mount_t *cmount);
/* Get the current working directory.
*
* The pointer you get back from this function will continue to be valid until
* the *next* call you make to ceph_getcwd, at which point it will be invalidated.
*/
-const char* ceph_getcwd(ceph_cluster_t *cluster);
+const char* ceph_getcwd(ceph_mount_t *cmount);
-int ceph_chdir(ceph_cluster_t *cluster, const char *s);
+int ceph_chdir(ceph_mount_t *cmount, const char *s);
-int ceph_opendir(ceph_cluster_t *cluster, const char *name, DIR **dirpp);
-int ceph_closedir(ceph_cluster_t *cluster, DIR *dirp);
-int ceph_readdir_r(ceph_cluster_t *cluster, DIR *dirp, struct dirent *de);
-int ceph_readdirplus_r(ceph_cluster_t *cluster, DIR *dirp, struct dirent *de,
+int ceph_opendir(ceph_mount_t *cmount, const char *name, ceph_dir_result_t **dirpp);
+int ceph_closedir(ceph_mount_t *cmount, ceph_dir_result_t *dirp);
+int ceph_readdir_r(ceph_mount_t *cmount, ceph_dir_result_t *dirp, struct dirent *de);
+int ceph_readdirplus_r(ceph_mount_t *cmount, ceph_dir_result_t *dirp, struct dirent *de,
struct stat *st, int *stmask);
-int ceph_getdents(ceph_cluster_t *cluster, DIR *dirp, char *name, int buflen);
-int ceph_getdnames(ceph_cluster_t *cluster, DIR *dirp, char *name, int buflen);
-void ceph_rewinddir(ceph_cluster_t *cluster, DIR *dirp);
-loff_t ceph_telldir(ceph_cluster_t *cluster, DIR *dirp);
-void ceph_seekdir(ceph_cluster_t *cluster, DIR *dirp, loff_t offset);
+int ceph_getdents(ceph_mount_t *cmount, ceph_dir_result_t *dirp, char *name, int buflen);
+int ceph_getdnames(ceph_mount_t *cmount, ceph_dir_result_t *dirp, char *name, int buflen);
+void ceph_rewinddir(ceph_mount_t *cmount, ceph_dir_result_t *dirp);
+loff_t ceph_telldir(ceph_mount_t *cmount, ceph_dir_result_t *dirp);
+void ceph_seekdir(ceph_mount_t *cmount, ceph_dir_result_t *dirp, loff_t offset);
-int ceph_link(ceph_cluster_t *cluster, const char *existing, const char *newname);
-int ceph_unlink(ceph_cluster_t *cluster, const char *path);
-int ceph_rename(ceph_cluster_t *cluster, const char *from, const char *to);
+int ceph_link(ceph_mount_t *cmount, const char *existing, const char *newname);
+int ceph_unlink(ceph_mount_t *cmount, const char *path);
+int ceph_rename(ceph_mount_t *cmount, const char *from, const char *to);
// dirs
-int ceph_mkdir(ceph_cluster_t *cluster, const char *path, mode_t mode);
-int ceph_mkdirs(ceph_cluster_t *cluster, const char *path, mode_t mode);
-int ceph_rmdir(ceph_cluster_t *cluster, const char *path);
+int ceph_mkdir(ceph_mount_t *cmount, const char *path, mode_t mode);
+int ceph_mkdirs(ceph_mount_t *cmount, const char *path, mode_t mode);
+int ceph_rmdir(ceph_mount_t *cmount, const char *path);
// symlinks
-int ceph_readlink(ceph_cluster_t *cluster, const char *path, char *buf, loff_t size);
-int ceph_symlink(ceph_cluster_t *cluster, const char *existing, const char *newname);
+int ceph_readlink(ceph_mount_t *cmount, const char *path, char *buf, loff_t size);
+int ceph_symlink(ceph_mount_t *cmount, const char *existing, const char *newname);
// inode stuff
-int ceph_lstat(ceph_cluster_t *cluster, const char *path, struct stat *stbuf);
-int ceph_lstat_precise(ceph_cluster_t *cluster, const char *path, struct stat_precise *stbuf);
+int ceph_lstat(ceph_mount_t *cmount, const char *path, struct stat *stbuf);
+int ceph_lstat_precise(ceph_mount_t *cmount, const char *path, struct stat_precise *stbuf);
-int ceph_setattr(ceph_cluster_t *cluster, const char *relpath, struct stat *attr, int mask);
-int ceph_setattr_precise (ceph_cluster_t *cluster, const char *relpath,
+int ceph_setattr(ceph_mount_t *cmount, const char *relpath, struct stat *attr, int mask);
+int ceph_setattr_precise (ceph_mount_t *cmount, const char *relpath,
struct stat_precise *stbuf, int mask);
-int ceph_chmod(ceph_cluster_t *cluster, const char *path, mode_t mode);
-int ceph_chown(ceph_cluster_t *cluster, const char *path, uid_t uid, gid_t gid);
-int ceph_utime(ceph_cluster_t *cluster, const char *path, struct utimbuf *buf);
-int ceph_truncate(ceph_cluster_t *cluster, const char *path, loff_t size);
+int ceph_chmod(ceph_mount_t *cmount, const char *path, mode_t mode);
+int ceph_chown(ceph_mount_t *cmount, const char *path, uid_t uid, gid_t gid);
+int ceph_utime(ceph_mount_t *cmount, const char *path, struct utimbuf *buf);
+int ceph_truncate(ceph_mount_t *cmount, const char *path, loff_t size);
// file ops
-int ceph_mknod(ceph_cluster_t *cluster, const char *path, mode_t mode, dev_t rdev);
-int ceph_open(ceph_cluster_t *cluster, const char *path, int flags, mode_t mode);
-int ceph_close(ceph_cluster_t *cluster, int fd);
-loff_t ceph_lseek(ceph_cluster_t *cluster, int fd, loff_t offset, int whence);
-int ceph_read(ceph_cluster_t *cluster, int fd, char *buf, loff_t size, loff_t offset);
-int ceph_write(ceph_cluster_t *cluster, int fd, const char *buf, loff_t size,
+int ceph_mknod(ceph_mount_t *cmount, const char *path, mode_t mode, dev_t rdev);
+int ceph_open(ceph_mount_t *cmount, const char *path, int flags, mode_t mode);
+int ceph_close(ceph_mount_t *cmount, int fd);
+loff_t ceph_lseek(ceph_mount_t *cmount, int fd, loff_t offset, int whence);
+int ceph_read(ceph_mount_t *cmount, int fd, char *buf, loff_t size, loff_t offset);
+int ceph_write(ceph_mount_t *cmount, int fd, const char *buf, loff_t size,
loff_t offset);
-int ceph_ftruncate(ceph_cluster_t *cluster, int fd, loff_t size);
-int ceph_fsync(ceph_cluster_t *cluster, int fd, int syncdataonly);
-int ceph_fstat(ceph_cluster_t *cluster, int fd, struct stat *stbuf);
-
-int ceph_sync_fs(ceph_cluster_t *cluster);
-int ceph_get_file_stripe_unit(ceph_cluster_t *cluster, int fh);
-int ceph_get_file_replication(ceph_cluster_t *cluster, const char *path);
-int ceph_get_default_preferred_pg(ceph_cluster_t *cluster, int fd);
-int ceph_get_file_stripe_address(ceph_cluster_t *cluster, int fd,
+int ceph_ftruncate(ceph_mount_t *cmount, int fd, loff_t size);
+int ceph_fsync(ceph_mount_t *cmount, int fd, int syncdataonly);
+int ceph_fstat(ceph_mount_t *cmount, int fd, struct stat *stbuf);
+
+int ceph_sync_fs(ceph_mount_t *cmount);
+int ceph_get_file_stripe_unit(ceph_mount_t *cmount, int fh);
+int ceph_get_file_replication(ceph_mount_t *cmount, const char *path);
+int ceph_get_default_preferred_pg(ceph_mount_t *cmount, int fd);
+int ceph_get_file_stripe_address(ceph_mount_t *cmount, int fd,
loff_t offset, char *buf, int buflen);
-int ceph_set_default_file_stripe_unit(ceph_cluster_t *cluster, int stripe);
-int ceph_set_default_file_stripe_count(ceph_cluster_t *cluster, int count);
-int ceph_set_default_object_size(ceph_cluster_t *cluster, int size);
-int ceph_set_default_file_replication(ceph_cluster_t *cluster, int replication);
-int ceph_set_default_preferred_pg(ceph_cluster_t *cluster, int pg);
-int ceph_localize_reads(ceph_cluster_t *cluster, int val);
+int ceph_set_default_file_stripe_unit(ceph_mount_t *cmount, int stripe);
+int ceph_set_default_file_stripe_count(ceph_mount_t *cmount, int count);
+int ceph_set_default_object_size(ceph_mount_t *cmount, int size);
+int ceph_set_default_file_replication(ceph_mount_t *cmount, int replication);
+int ceph_set_default_preferred_pg(ceph_mount_t *cmount, int pg);
+int ceph_localize_reads(ceph_mount_t *cmount, int val);
#ifdef __cplusplus
}
int main(int argc, const char **argv)
{
- ceph_cluster_t *cluster;
- int ret = ceph_create(&cluster, NULL);
+ ceph_mount_t *cmount;
+ int ret = ceph_create(&cmount, NULL);
if (ret) {
cerr << "ceph_create failed with error: " << ret << std::endl;
return 1;
}
- ceph_conf_parse_argv(cluster, argc, argv);
+ ceph_conf_parse_argv(cmount, argc, argv);
char buf[128];
- ret = ceph_conf_get(cluster, "log file", buf, sizeof(buf));
+ ret = ceph_conf_get(cmount, "log file", buf, sizeof(buf));
if (ret) {
cerr << "ceph_conf_get(\"log file\") failed with error " << ret << std::endl;
}
cout << "log_file = \"" << buf << "\"" << std::endl;
}
- ret = ceph_connect(cluster);
- if (ret) {
- cerr << "ceph_connect failed with error: " << ret << std::endl;
- return 1;
- }
-
- ret = ceph_mount(cluster, NULL);
+ ret = ceph_mount(cmount, NULL);
if (ret) {
cerr << "ceph_mount error: " << ret << std::endl;
return 1;
}
cout << "Successfully mounted Ceph!" << std::endl;
- ceph_shutdown(cluster);
+ ceph_shutdown(cmount);
return 0;
}
static bool libceph_initialized = false; // FIXME! remove this
static int nonce_seed = 0;
-class ceph_cluster_t
+class ceph_mount_t
{
public:
- ceph_cluster_t(uint64_t msgr_nonce_, md_config_t *conf)
+ ceph_mount_t(uint64_t msgr_nonce_, md_config_t *conf)
: msgr_nonce(msgr_nonce_),
mounted(false),
client(NULL),
{
}
- ~ceph_cluster_t()
+ ~ceph_mount_t()
{
try {
- disconnect();
+ shutdown();
+ // uncomment once conf is de-globalized
+// if (conf) {
+// free(conf);
+// conf = NULL;
+// }
}
catch (const std::exception& e) {
// we shouldn't get here, but if we do, we want to know about it.
- derr << "ceph_cluster_t::~ceph_cluster_t: caught exception: "
+ derr << "ceph_mount_t::~ceph_mount_t: caught exception: "
<< e.what() << dendl;
}
catch (...) {
}
}
- int connect()
+ int mount(const std::string &mount_root)
{
+ if (mounted)
+ return -EDOM;
+
//monmap
monclient = new MonClient();
if (monclient->build_initial_monmap() < 0) {
- delete monclient;
- monclient = NULL;
+ shutdown();
return -1000;
}
//network connection
messenger = new SimpleMessenger();
- messenger->register_entity(entity_name_t::CLIENT());
+ if (messenger->register_entity(entity_name_t::CLIENT())) {
+ shutdown();
+ return -1001;
+ }
//at last the client
client = new Client(messenger, monclient);
+ if (!client) {
+ shutdown();
+ return -1002;
+ }
- messenger->start(false, msgr_nonce); // do not daemonize
+ if (messenger->start(false, msgr_nonce) != 0) {
+ shutdown();
+ return -1003;
+ }
client->init();
+
+ int ret = client->mount(mount_root);
+ if (ret) {
+ shutdown();
+ return ret;
+ }
+
+ mounted = true;
return 0;
}
- void disconnect()
+ void shutdown()
{
if (mounted) {
client->unmount();
delete monclient;
monclient = NULL;
}
- // uncomment once conf is de-globalized
-// if (conf) {
-// free(conf);
-// conf = NULL;
-// }
}
int conf_read_file(const char *path)
return conf->get_val(option, &tmp, len);
}
- int mount(const std::string &mount_root)
- {
- if (mounted)
- return -EINVAL;
- int ret = client->mount(mount_root);
- if (ret)
- return ret;
- mounted = true;
- return 0;
- }
-
- void umount()
- {
- if (!mounted)
- return;
- client->unmount();
- mounted = false;
- }
-
Client *get_client()
{
return client;
return VERSION;
}
-static int ceph_create_with_config_impl(ceph_cluster_t **cluster, md_config_t *conf)
+static int ceph_create_with_config_impl(ceph_mount_t **cmount, md_config_t *conf)
{
// should hold libceph_init_mutex here
libceph_initialized = true;
uint64_t nonce = (uint64_t)++nonce_seed * 1000000ull + (uint64_t)getpid();
- *cluster = new ceph_cluster_t(nonce, conf);
+ *cmount = new ceph_mount_t(nonce, conf);
return 0;
}
-extern "C" int ceph_create(ceph_cluster_t **cluster, const char * const id)
+extern "C" int ceph_create(ceph_mount_t **cmount, const char * const id)
{
int ret;
libceph_init_mutex.Lock();
conf->parse_env(); // environment variables override
conf->apply_changes();
}
- ret = ceph_create_with_config_impl(cluster, conf);
+ ret = ceph_create_with_config_impl(cmount, conf);
libceph_init_mutex.Unlock();
return ret;
}
-extern "C" int ceph_create_with_config(ceph_cluster_t **cluster, md_config_t *conf)
+extern "C" int ceph_create_with_config(ceph_mount_t **cmount, md_config_t *conf)
{
int ret;
libceph_init_mutex.Lock();
- ret = ceph_create_with_config_impl(cluster, conf);
+ ret = ceph_create_with_config_impl(cmount, conf);
libceph_init_mutex.Unlock();
return ret;
}
-extern "C" int ceph_connect(ceph_cluster_t *cluster)
+extern "C" void ceph_shutdown(ceph_mount_t *cmount)
{
- return cluster->connect();
+ cmount->shutdown();
}
-extern "C" void ceph_shutdown(ceph_cluster_t *cluster)
+extern "C" int ceph_conf_read_file(ceph_mount_t *cmount, const char *path)
{
- cluster->disconnect();
+ return cmount->conf_read_file(path);
}
-extern "C" int ceph_conf_read_file(ceph_cluster_t *cluster, const char *path)
-{
- return cluster->conf_read_file(path);
-}
-
-extern "C" void ceph_conf_parse_argv(ceph_cluster_t *cluster, int argc,
+extern "C" void ceph_conf_parse_argv(ceph_mount_t *cmount, int argc,
const char **argv)
{
- cluster->conf_parse_argv(argc, argv);
+ cmount->conf_parse_argv(argc, argv);
}
-extern "C" int ceph_conf_set(ceph_cluster_t *cluster, const char *option,
+extern "C" int ceph_conf_set(ceph_mount_t *cmount, const char *option,
const char *value)
{
- return cluster->conf_set(option, value);
+ return cmount->conf_set(option, value);
}
-extern "C" int ceph_conf_get(ceph_cluster_t *cluster, const char *option,
+extern "C" int ceph_conf_get(ceph_mount_t *cmount, const char *option,
char *buf, size_t len)
{
- return cluster->conf_get(option, buf, len);
+ return cmount->conf_get(option, buf, len);
}
-extern "C" int ceph_mount(ceph_cluster_t *cluster, const char *root)
+extern "C" int ceph_mount(ceph_mount_t *cmount, const char *root)
{
std::string mount_root;
if (!root)
mount_root = root;
- return cluster->mount(mount_root);
-}
-
-extern "C" void ceph_umount(ceph_cluster_t *cluster)
-{
- cluster->umount();
+ return cmount->mount(mount_root);
}
-extern "C" int ceph_statfs(ceph_cluster_t *cluster, const char *path,
+extern "C" int ceph_statfs(ceph_mount_t *cmount, const char *path,
struct statvfs *stbuf)
{
- return cluster->get_client()->statfs(path, stbuf);
+ return cmount->get_client()->statfs(path, stbuf);
}
-extern "C" int ceph_get_local_osd(ceph_cluster_t *cluster)
+extern "C" int ceph_get_local_osd(ceph_mount_t *cmount)
{
- return cluster->get_client()->get_local_osd();
+ return cmount->get_client()->get_local_osd();
}
-extern "C" const char* ceph_getcwd(ceph_cluster_t *cluster)
+extern "C" const char* ceph_getcwd(ceph_mount_t *cmount)
{
- return cluster->get_cwd();
+ return cmount->get_cwd();
}
-extern "C" int ceph_chdir (ceph_cluster_t *cluster, const char *s)
+extern "C" int ceph_chdir (ceph_mount_t *cmount, const char *s)
{
- return cluster->get_client()->chdir(s);
+ return cmount->get_client()->chdir(s);
}
-extern "C" int ceph_opendir(ceph_cluster_t *cluster,
- const char *name, DIR **dirpp)
+extern "C" int ceph_opendir(ceph_mount_t *cmount,
+ const char *name, ceph_dir_result_t **dirpp)
{
- return cluster->get_client()->opendir(name, dirpp);
+ return cmount->get_client()->opendir(name, dirpp);
}
-extern "C" int ceph_closedir(ceph_cluster_t *cluster, DIR *dirp)
+extern "C" int ceph_closedir(ceph_mount_t *cmount, ceph_dir_result_t *dirp)
{
- return cluster->get_client()->closedir(dirp);
+ return cmount->get_client()->closedir(dirp);
}
-extern "C" int ceph_readdir_r(ceph_cluster_t *cluster, DIR *dirp, struct dirent *de)
+extern "C" int ceph_readdir_r(ceph_mount_t *cmount, ceph_dir_result_t *dirp, struct dirent *de)
{
- return cluster->get_client()->readdir_r(dirp, de);
+ return cmount->get_client()->readdir_r(dirp, de);
}
-extern "C" int ceph_readdirplus_r(ceph_cluster_t *cluster, DIR *dirp,
+extern "C" int ceph_readdirplus_r(ceph_mount_t *cmount, ceph_dir_result_t *dirp,
struct dirent *de, struct stat *st, int *stmask)
{
- return cluster->get_client()->readdirplus_r(dirp, de, st, stmask);
+ return cmount->get_client()->readdirplus_r(dirp, de, st, stmask);
}
-extern "C" int ceph_getdents(ceph_cluster_t *cluster, DIR *dirp,
+extern "C" int ceph_getdents(ceph_mount_t *cmount, ceph_dir_result_t *dirp,
char *buf, int buflen)
{
- return cluster->get_client()->getdents(dirp, buf, buflen);
+ return cmount->get_client()->getdents(dirp, buf, buflen);
}
-extern "C" int ceph_getdnames(ceph_cluster_t *cluster, DIR *dirp,
+extern "C" int ceph_getdnames(ceph_mount_t *cmount, ceph_dir_result_t *dirp,
char *buf, int buflen)
{
- return cluster->get_client()->getdnames(dirp, buf, buflen);
+ return cmount->get_client()->getdnames(dirp, buf, buflen);
}
-extern "C" void ceph_rewinddir(ceph_cluster_t *cluster, DIR *dirp)
+extern "C" void ceph_rewinddir(ceph_mount_t *cmount, ceph_dir_result_t *dirp)
{
- cluster->get_client()->rewinddir(dirp);
+ cmount->get_client()->rewinddir(dirp);
}
-extern "C" loff_t ceph_telldir(ceph_cluster_t *cluster, DIR *dirp)
+extern "C" loff_t ceph_telldir(ceph_mount_t *cmount, ceph_dir_result_t *dirp)
{
- return cluster->get_client()->telldir(dirp);
+ return cmount->get_client()->telldir(dirp);
}
-extern "C" void ceph_seekdir(ceph_cluster_t *cluster, DIR *dirp, loff_t offset)
+extern "C" void ceph_seekdir(ceph_mount_t *cmount, ceph_dir_result_t *dirp, loff_t offset)
{
- cluster->get_client()->seekdir(dirp, offset);
+ cmount->get_client()->seekdir(dirp, offset);
}
-extern "C" int ceph_link (ceph_cluster_t *cluster, const char *existing,
+extern "C" int ceph_link (ceph_mount_t *cmount, const char *existing,
const char *newname)
{
- return cluster->get_client()->link(existing, newname);
+ return cmount->get_client()->link(existing, newname);
}
-extern "C" int ceph_unlink(ceph_cluster_t *cluster, const char *path)
+extern "C" int ceph_unlink(ceph_mount_t *cmount, const char *path)
{
- return cluster->get_client()->unlink(path);
+ return cmount->get_client()->unlink(path);
}
-extern "C" int ceph_rename(ceph_cluster_t *cluster, const char *from,
+extern "C" int ceph_rename(ceph_mount_t *cmount, const char *from,
const char *to)
{
- return cluster->get_client()->rename(from, to);
+ return cmount->get_client()->rename(from, to);
}
// dirs
-extern "C" int ceph_mkdir(ceph_cluster_t *cluster, const char *path, mode_t mode)
+extern "C" int ceph_mkdir(ceph_mount_t *cmount, const char *path, mode_t mode)
{
- return cluster->get_client()->mkdir(path, mode);
+ return cmount->get_client()->mkdir(path, mode);
}
-extern "C" int ceph_mkdirs(ceph_cluster_t *cluster, const char *path, mode_t mode)
+extern "C" int ceph_mkdirs(ceph_mount_t *cmount, const char *path, mode_t mode)
{
- return cluster->get_client()->mkdirs(path, mode);
+ return cmount->get_client()->mkdirs(path, mode);
}
-extern "C" int ceph_rmdir(ceph_cluster_t *cluster, const char *path)
+extern "C" int ceph_rmdir(ceph_mount_t *cmount, const char *path)
{
- return cluster->get_client()->rmdir(path);
+ return cmount->get_client()->rmdir(path);
}
// symlinks
-extern "C" int ceph_readlink(ceph_cluster_t *cluster, const char *path,
+extern "C" int ceph_readlink(ceph_mount_t *cmount, const char *path,
char *buf, loff_t size)
{
- return cluster->get_client()->readlink(path, buf, size);
+ return cmount->get_client()->readlink(path, buf, size);
}
-extern "C" int ceph_symlink(ceph_cluster_t *cluster, const char *existing,
+extern "C" int ceph_symlink(ceph_mount_t *cmount, const char *existing,
const char *newname)
{
- return cluster->get_client()->symlink(existing, newname);
+ return cmount->get_client()->symlink(existing, newname);
}
// inode stuff
-extern "C" int ceph_lstat(ceph_cluster_t *cluster, const char *path,
+extern "C" int ceph_lstat(ceph_mount_t *cmount, const char *path,
struct stat *stbuf)
{
- return cluster->get_client()->lstat(path, stbuf);
+ return cmount->get_client()->lstat(path, stbuf);
}
-extern "C" int ceph_lstat_precise(ceph_cluster_t *cluster, const char *path,
+extern "C" int ceph_lstat_precise(ceph_mount_t *cmount, const char *path,
stat_precise *stbuf)
{
- return cluster->get_client()->lstat_precise(path, (Client::stat_precise*)stbuf);
+ return cmount->get_client()->lstat_precise(path, (Client::stat_precise*)stbuf);
}
-extern "C" int ceph_setattr(ceph_cluster_t *cluster, const char *relpath,
+extern "C" int ceph_setattr(ceph_mount_t *cmount, const char *relpath,
struct stat *attr, int mask)
{
Client::stat_precise p_attr = Client::stat_precise(*attr);
- return cluster->get_client()->setattr(relpath, &p_attr, mask);
+ return cmount->get_client()->setattr(relpath, &p_attr, mask);
}
-extern "C" int ceph_setattr_precise(ceph_cluster_t *cluster, const char *relpath,
+extern "C" int ceph_setattr_precise(ceph_mount_t *cmount, const char *relpath,
struct stat_precise *attr, int mask)
{
- return cluster->get_client()->setattr(relpath, (Client::stat_precise*)attr, mask);
+ return cmount->get_client()->setattr(relpath, (Client::stat_precise*)attr, mask);
}
-extern "C" int ceph_chmod(ceph_cluster_t *cluster, const char *path, mode_t mode)
+extern "C" int ceph_chmod(ceph_mount_t *cmount, const char *path, mode_t mode)
{
- return cluster->get_client()->chmod(path, mode);
+ return cmount->get_client()->chmod(path, mode);
}
-extern "C" int ceph_chown(ceph_cluster_t *cluster, const char *path,
+extern "C" int ceph_chown(ceph_mount_t *cmount, const char *path,
uid_t uid, gid_t gid)
{
- return cluster->get_client()->chown(path, uid, gid);
+ return cmount->get_client()->chown(path, uid, gid);
}
-extern "C" int ceph_utime(ceph_cluster_t *cluster, const char *path,
+extern "C" int ceph_utime(ceph_mount_t *cmount, const char *path,
struct utimbuf *buf)
{
- return cluster->get_client()->utime(path, buf);
+ return cmount->get_client()->utime(path, buf);
}
-extern "C" int ceph_truncate(ceph_cluster_t *cluster, const char *path,
+extern "C" int ceph_truncate(ceph_mount_t *cmount, const char *path,
loff_t size)
{
- return cluster->get_client()->truncate(path, size);
+ return cmount->get_client()->truncate(path, size);
}
// file ops
-extern "C" int ceph_mknod(ceph_cluster_t *cluster, const char *path,
+extern "C" int ceph_mknod(ceph_mount_t *cmount, const char *path,
mode_t mode, dev_t rdev)
{
- return cluster->get_client()->mknod(path, mode, rdev);
+ return cmount->get_client()->mknod(path, mode, rdev);
}
-extern "C" int ceph_open(ceph_cluster_t *cluster, const char *path,
+extern "C" int ceph_open(ceph_mount_t *cmount, const char *path,
int flags, mode_t mode)
{
- return cluster->get_client()->open(path, flags, mode);
+ return cmount->get_client()->open(path, flags, mode);
}
-extern "C" int ceph_close(ceph_cluster_t *cluster, int fd)
+extern "C" int ceph_close(ceph_mount_t *cmount, int fd)
{
- return cluster->get_client()->close(fd);
+ return cmount->get_client()->close(fd);
}
-extern "C" loff_t ceph_lseek(ceph_cluster_t *cluster, int fd,
+extern "C" loff_t ceph_lseek(ceph_mount_t *cmount, int fd,
loff_t offset, int whence)
{
- return cluster->get_client()->lseek(fd, offset, whence);
+ return cmount->get_client()->lseek(fd, offset, whence);
}
-extern "C" int ceph_read(ceph_cluster_t *cluster, int fd, char *buf,
+extern "C" int ceph_read(ceph_mount_t *cmount, int fd, char *buf,
loff_t size, loff_t offset)
{
- return cluster->get_client()->read(fd, buf, size, offset);
+ return cmount->get_client()->read(fd, buf, size, offset);
}
-extern "C" int ceph_write(ceph_cluster_t *cluster, int fd, const char *buf,
+extern "C" int ceph_write(ceph_mount_t *cmount, int fd, const char *buf,
loff_t size, loff_t offset)
{
- return cluster->get_client()->write(fd, buf, size, offset);
+ return cmount->get_client()->write(fd, buf, size, offset);
}
-extern "C" int ceph_ftruncate(ceph_cluster_t *cluster, int fd, loff_t size)
+extern "C" int ceph_ftruncate(ceph_mount_t *cmount, int fd, loff_t size)
{
- return cluster->get_client()->ftruncate(fd, size);
+ return cmount->get_client()->ftruncate(fd, size);
}
-extern "C" int ceph_fsync(ceph_cluster_t *cluster, int fd, int syncdataonly)
+extern "C" int ceph_fsync(ceph_mount_t *cmount, int fd, int syncdataonly)
{
- return cluster->get_client()->fsync(fd, syncdataonly);
+ return cmount->get_client()->fsync(fd, syncdataonly);
}
-extern "C" int ceph_fstat(ceph_cluster_t *cluster, int fd, struct stat *stbuf)
+extern "C" int ceph_fstat(ceph_mount_t *cmount, int fd, struct stat *stbuf)
{
- return cluster->get_client()->fstat(fd, stbuf);
+ return cmount->get_client()->fstat(fd, stbuf);
}
-extern "C" int ceph_sync_fs(ceph_cluster_t *cluster)
+extern "C" int ceph_sync_fs(ceph_mount_t *cmount)
{
- return cluster->get_client()->sync_fs();
+ return cmount->get_client()->sync_fs();
}
-extern "C" int ceph_get_file_stripe_unit(ceph_cluster_t *cluster, int fh)
+extern "C" int ceph_get_file_stripe_unit(ceph_mount_t *cmount, int fh)
{
- return cluster->get_client()->get_file_stripe_unit(fh);
+ return cmount->get_client()->get_file_stripe_unit(fh);
}
-extern "C" int ceph_get_file_replication(ceph_cluster_t *cluster,
+extern "C" int ceph_get_file_replication(ceph_mount_t *cmount,
const char *path)
{
- int fd = cluster->get_client()->open(path, O_RDONLY);
+ int fd = cmount->get_client()->open(path, O_RDONLY);
if (fd < 0)
return fd;
- int rep = cluster->get_client()->get_file_replication(fd);
- cluster->get_client()->close(fd);
+ int rep = cmount->get_client()->get_file_replication(fd);
+ cmount->get_client()->close(fd);
return rep;
}
-extern "C" int ceph_get_default_preferred_pg(ceph_cluster_t *cluster, int fd)
+extern "C" int ceph_get_default_preferred_pg(ceph_mount_t *cmount, int fd)
{
- return cluster->get_client()->get_default_preferred_pg(fd);
+ return cmount->get_client()->get_default_preferred_pg(fd);
}
-extern "C" int ceph_set_default_file_stripe_unit(ceph_cluster_t *cluster,
+extern "C" int ceph_set_default_file_stripe_unit(ceph_mount_t *cmount,
int stripe)
{
- cluster->get_client()->set_default_file_stripe_unit(stripe);
+ cmount->get_client()->set_default_file_stripe_unit(stripe);
return 0;
}
-extern "C" int ceph_set_default_file_stripe_count(ceph_cluster_t *cluster,
+extern "C" int ceph_set_default_file_stripe_count(ceph_mount_t *cmount,
int count)
{
- cluster->get_client()->set_default_file_stripe_unit(count);
+ cmount->get_client()->set_default_file_stripe_unit(count);
return 0;
}
-extern "C" int ceph_set_default_object_size(ceph_cluster_t *cluster, int size)
+extern "C" int ceph_set_default_object_size(ceph_mount_t *cmount, int size)
{
- cluster->get_client()->set_default_object_size(size);
+ cmount->get_client()->set_default_object_size(size);
return 0;
}
-extern "C" int ceph_set_default_file_replication(ceph_cluster_t *cluster,
+extern "C" int ceph_set_default_file_replication(ceph_mount_t *cmount,
int replication)
{
- cluster->get_client()->set_default_file_replication(replication);
+ cmount->get_client()->set_default_file_replication(replication);
return 0;
}
-extern "C" int ceph_set_default_preferred_pg(ceph_cluster_t *cluster, int pg)
+extern "C" int ceph_set_default_preferred_pg(ceph_mount_t *cmount, int pg)
{
- cluster->get_client()->set_default_preferred_pg(pg);
+ cmount->get_client()->set_default_preferred_pg(pg);
return 0;
}
-extern "C" int ceph_get_file_stripe_address(ceph_cluster_t *cluster, int fh,
+extern "C" int ceph_get_file_stripe_address(ceph_mount_t *cmount, int fh,
loff_t offset, char *buf, int buflen)
{
string address;
- int r = cluster->get_client()->get_file_stripe_address(fh, offset, address);
+ int r = cmount->get_client()->get_file_stripe_address(fh, offset, address);
if (r != 0) return r; //at time of writing, method ONLY returns
// 0 or -EINVAL if there are no known osds
int len = address.size()+1;
return 0;
}
-extern "C" int ceph_localize_reads(ceph_cluster_t *cluster, int val)
+extern "C" int ceph_localize_reads(ceph_mount_t *cmount, int val)
{
if (!val)
- cluster->get_client()->clear_filer_flags(CEPH_OSD_FLAG_LOCALIZE_READS);
+ cmount->get_client()->clear_filer_flags(CEPH_OSD_FLAG_LOCALIZE_READS);
else
- cluster->get_client()->set_filer_flags(CEPH_OSD_FLAG_LOCALIZE_READS);
+ cmount->get_client()->set_filer_flags(CEPH_OSD_FLAG_LOCALIZE_READS);
return 0;
}