Inode *in = add_update_inode(&ist, from, mds);
Dentry *dn = insert_dentry_inode(dir, dname, &dlease, in, from, mds, false);
- dn->offset = ceph_dir_result_t::make_fpos(request->readdir_frag, i + request->readdir_offset);
+ dn->offset = 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, ceph_dir_result_t **dirpp)
+int Client::opendir(const char *relpath, dir_result_t **dirpp)
{
Mutex::Locker lock(client_lock);
tout << "opendir" << std::endl;
return r;
}
-int Client::_opendir(Inode *in, ceph_dir_result_t **dirpp, int uid, int gid)
+int Client::_opendir(Inode *in, dir_result_t **dirpp, int uid, int gid)
{
- *dirpp = new ceph_dir_result_t(in);
+ *dirpp = new dir_result_t(in);
if (!in->is_dir())
return -ENOTDIR;
(*dirpp)->set_frag(in->dirfragtree[0]);
}
-int Client::closedir(ceph_dir_result_t *dir)
+int Client::closedir(dir_result_t *dir)
{
Mutex::Locker lock(client_lock);
tout << "closedir" << std::endl;
return 0;
}
-void Client::_closedir(ceph_dir_result_t *dirp)
+void Client::_closedir(dir_result_t *dirp)
{
dout(10) << "_closedir(" << dirp << ")" << dendl;
if (dirp->inode) {
delete dirp;
}
-void Client::rewinddir(ceph_dir_result_t *dirp)
+void Client::rewinddir(dir_result_t *dirp)
{
dout(3) << "rewinddir(" << dirp << ")" << dendl;
- ceph_dir_result_t *d = (ceph_dir_result_t*)dirp;
+ dir_result_t *d = (dir_result_t*)dirp;
d->reset();
}
-loff_t Client::telldir(ceph_dir_result_t *dirp)
+loff_t Client::telldir(dir_result_t *dirp)
{
- ceph_dir_result_t *d = (ceph_dir_result_t*)dirp;
+ dir_result_t *d = (dir_result_t*)dirp;
dout(3) << "telldir(" << dirp << ") = " << d->offset << dendl;
return d->offset;
}
-void Client::seekdir(ceph_dir_result_t *dirp, loff_t offset)
+void Client::seekdir(dir_result_t *dirp, loff_t offset)
{
dout(3) << "seekdir(" << dirp << ", " << offset << ")" << dendl;
- ceph_dir_result_t *d = (ceph_dir_result_t*)dirp;
+ dir_result_t *d = (dir_result_t*)dirp;
if (offset == 0 ||
- ceph_dir_result_t::fpos_frag(offset) != d->frag() ||
- ceph_dir_result_t::fpos_off(offset) < d->fragpos()) {
+ dir_result_t::fpos_frag(offset) != d->frag() ||
+ dir_result_t::fpos_off(offset) < d->fragpos()) {
d->reset();
}
#endif
}
-void Client::_readdir_next_frag(ceph_dir_result_t *dirp)
+void Client::_readdir_next_frag(dir_result_t *dirp)
{
frag_t fg = dirp->frag();
}
}
-void Client::_readdir_rechoose_frag(ceph_dir_result_t *dirp)
+void Client::_readdir_rechoose_frag(dir_result_t *dirp)
{
assert(dirp->inode);
frag_t cur = dirp->frag();
}
}
-void Client::_readdir_drop_dirp_buffer(ceph_dir_result_t *dirp)
+void Client::_readdir_drop_dirp_buffer(dir_result_t *dirp)
{
dout(10) << "_readdir_drop_dirp_buffer " << dirp << dendl;
if (dirp->buffer) {
}
}
-int Client::_readdir_get_frag(ceph_dir_result_t *dirp)
+int Client::_readdir_get_frag(dir_result_t *dirp)
{
// get the current frag.
frag_t fg = dirp->frag();
}
if (res == 0) {
- // stuff dir contents to cache, ceph_dir_result_t
+ // stuff dir contents to cache, dir_result_t
assert(diri);
_readdir_drop_dirp_buffer(dirp);
return res;
}
-int Client::_readdir_cache_cb(ceph_dir_result_t *dirp, add_dirent_cb_t cb, void *p)
+int Client::_readdir_cache_cb(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 = ceph_dir_result_t::END;
+ next_off = 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(ceph_dir_result_t *d, add_dirent_cb_t cb, void *p)
+int Client::readdir_r_cb(dir_result_t *d, add_dirent_cb_t cb, void *p)
{
- ceph_dir_result_t *dirp = (ceph_dir_result_t*)d;
+ dir_result_t *dirp = (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 = ceph_dir_result_t::make_fpos(fg, off);
+ uint64_t pos = 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(ceph_dir_result_t *d, struct dirent *de)
+int Client::readdir_r(dir_result_t *d, struct dirent *de)
{
return readdirplus_r(d, de, 0, 0);
}
return 0;
}
-int Client::readdirplus_r(ceph_dir_result_t *d, struct dirent *de, struct stat *st, int *stmask)
+int Client::readdirplus_r(dir_result_t *d, struct dirent *de, struct stat *st, int *stmask)
{
single_readdir sr;
sr.de = de;
return 0;
}
-int Client::_getdents(ceph_dir_result_t *dir, char *buf, int buflen, bool fullent)
+int Client::_getdents(dir_result_t *dir, char *buf, int buflen, bool fullent)
{
getdents_result gr;
gr.buf = buf;
tout << relpath << std::endl;
}
- ceph_dir_result_t *d;
+ dir_result_t *d;
int r = opendir(relpath, &d);
if (r < 0)
return r;
int r = 0;
if (vino.snapid == CEPH_SNAPDIR) {
- *dirpp = new ceph_dir_result_t(diri);
+ *dirpp = new dir_result_t(diri);
} else {
- r = _opendir(diri, (ceph_dir_result_t**)dirpp);
+ r = _opendir(diri, (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((ceph_dir_result_t*)dirp);
+ _closedir((dir_result_t*)dirp);
}
int Client::ll_open(vinodeno_t vino, int flags, Fh **fhp, int uid, int gid)
// ========================================================
// client interface
-struct ceph_dir_result_t {
+struct dir_result_t {
static const int SHIFT = 28;
static const int64_t MASK = (1 << SHIFT) - 1;
static const loff_t END = 1ULL << (SHIFT + 32);
string at_cache_name; // last entry we successfully returned
- ceph_dir_result_t(Inode *in) : inode(in), offset(0), next_offset(2),
+ dir_result_t(Inode *in) : inode(in), offset(0), next_offset(2),
release_count(0),
buffer(0) {
inode->get();
// 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, 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);
+ int _opendir(Inode *in, dir_result_t **dirpp, int uid=-1, int gid=-1);
+ void _readdir_drop_dirp_buffer(dir_result_t *dirp);
+ bool _readdir_have_frag(dir_result_t *dirp);
+ void _readdir_next_frag(dir_result_t *dirp);
+ void _readdir_rechoose_frag(dir_result_t *dirp);
+ int _readdir_get_frag(dir_result_t *dirp);
+ int _readdir_cache_cb(dir_result_t *dirp, add_dirent_cb_t cb, void *p);
+ void _closedir(dir_result_t *dirp);
// other helpers
void _ll_get(Inode *in);
void getcwd(std::string& cwd);
// namespace ops
- int opendir(const char *name, ceph_dir_result_t **dirpp);
- int closedir(ceph_dir_result_t *dirp);
+ int opendir(const char *name, dir_result_t **dirpp);
+ int closedir(dir_result_t *dirp);
- int readdir_r_cb(ceph_dir_result_t *dirp, add_dirent_cb_t cb, void *p);
+ int readdir_r_cb(dir_result_t *dirp, add_dirent_cb_t cb, void *p);
- 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 readdir_r(dir_result_t *dirp, struct dirent *de);
+ int readdirplus_r(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(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) {
+ int _getdents(dir_result_t *dirp, char *buf, int buflen, bool ful); // get a bunch of dentries at once
+ int getdents(dir_result_t *dirp, char *buf, int buflen) {
return _getdents(dirp, buf, buflen, true);
}
- int getdnames(ceph_dir_result_t *dirp, char *buf, int buflen) {
+ int getdnames(dir_result_t *dirp, char *buf, int buflen) {
return _getdents(dirp, buf, buflen, false);
}
- 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);
+ void rewinddir(dir_result_t *dirp);
+ loff_t telldir(dir_result_t *dirp);
+ void seekdir(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, ceph_dir_result_t*> open_dirs;
+ hash_map<int64_t, 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();
- ceph_dir_result_t *dirp;
+ 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, ceph_dir_result_t*>::iterator fi = open_dirs.begin();
+ for (hash_map<int64_t, dir_result_t*>::iterator fi = open_dirs.begin();
fi != open_dirs.end();
fi++) {
dout(1) << "leftover closedir " << fi->second << dendl;
{
(void) fi;
- ceph_dir_result_t *dirp = (ceph_dir_result_t*)fi->fh;
+ dir_result_t *dirp = (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)
{
- ceph_dir_result_t *dirp = (ceph_dir_result_t*)fi->fh;
+ dir_result_t *dirp = (dir_result_t*)fi->fh;
client->ll_releasedir(dirp);
fuse_reply_err(req, 0);
}
int main(int argc, const char **argv)
{
- struct ceph_mount_t *cmount;
+ ceph_mount_info_t cmount;
int ret = ceph_create(&cmount, NULL);
if (ret) {
cerr << "ceph_create failed with error: " << ret << std::endl;
}
cout << "Successfully mounted Ceph!" << std::endl;
- struct ceph_dir_result_t *foo_dir;
+ ceph_dir_result_t foo_dir;
ret = ceph_opendir(cmount, "foo", &foo_dir);
if (ret != -ENOENT) {
cerr << "ceph_opendir error: unexpected result from trying to open foo: "
extern "C" {
#endif
-struct ceph_mount_t;
-struct ceph_dir_result_t;
+struct ceph_mount_info;
+struct ceph_dir_result;
+
+typedef struct ceph_mount_info *ceph_mount_info_t;
+typedef struct ceph_dir_result *ceph_dir_result_t;
const char *ceph_version(int *major, int *minor, int *patch);
/* initialization */
-int ceph_create(struct ceph_mount_t **cmount, const char * const id);
+int ceph_create(ceph_mount_info_t *cmount, const char * const id);
/* initialization with an existing configuration */
-int ceph_create_with_config(struct ceph_mount_t **cmount, struct md_config_t *conf);
+int ceph_create_with_config(ceph_mount_info_t *cmount, struct md_config_t *conf);
/* Activate the mount */
-int ceph_mount(struct ceph_mount_t *cmount, const char *root);
+int ceph_mount(ceph_mount_info_t cmount, const char *root);
/* Destroy the ceph mount instance */
-void ceph_shutdown(struct ceph_mount_t *cmount);
+void ceph_shutdown(ceph_mount_info_t cmount);
/* Config
*
* Functions for manipulating the Ceph configuration at runtime.
*/
-int ceph_conf_read_file(struct ceph_mount_t *cmount, const char *path);
+int ceph_conf_read_file(ceph_mount_info_t cmount, const char *path);
-void ceph_conf_parse_argv(struct ceph_mount_t *cmount, int argc, const char **argv);
+void ceph_conf_parse_argv(ceph_mount_info_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(struct ceph_mount_t *cmount, const char *option, const char *value);
+int ceph_conf_set(ceph_mount_info_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(struct ceph_mount_t *cmount, const char *option, char *buf, size_t len);
+int ceph_conf_get(ceph_mount_info_t cmount, const char *option, char *buf, size_t len);
-int ceph_statfs(struct ceph_mount_t *cmount, const char *path, struct statvfs *stbuf);
+int ceph_statfs(ceph_mount_info_t cmount, const char *path, struct statvfs *stbuf);
/* 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(struct ceph_mount_t *cmount);
+const char* ceph_getcwd(ceph_mount_info_t cmount);
-int ceph_chdir(struct ceph_mount_t *cmount, const char *s);
+int ceph_chdir(ceph_mount_info_t cmount, const char *s);
-int ceph_opendir(struct ceph_mount_t *cmount, const char *name, struct ceph_dir_result_t **dirpp);
-int ceph_closedir(struct ceph_mount_t *cmount, struct ceph_dir_result_t *dirp);
-int ceph_readdir_r(struct ceph_mount_t *cmount, struct ceph_dir_result_t *dirp, struct dirent *de);
-int ceph_readdirplus_r(struct ceph_mount_t *cmount, struct ceph_dir_result_t *dirp, struct dirent *de,
+int ceph_opendir(ceph_mount_info_t cmount, const char *name, ceph_dir_result_t *dirpp);
+int ceph_closedir(ceph_mount_info_t cmount, ceph_dir_result_t dirp);
+int ceph_readdir_r(ceph_mount_info_t cmount, ceph_dir_result_t dirp, struct dirent *de);
+int ceph_readdirplus_r(ceph_mount_info_t cmount, ceph_dir_result_t dirp, struct dirent *de,
struct stat *st, int *stmask);
-int ceph_getdents(struct ceph_mount_t *cmount, struct ceph_dir_result_t *dirp, char *name, int buflen);
-int ceph_getdnames(struct ceph_mount_t *cmount, struct ceph_dir_result_t *dirp, char *name, int buflen);
-void ceph_rewinddir(struct ceph_mount_t *cmount, struct ceph_dir_result_t *dirp);
-loff_t ceph_telldir(struct ceph_mount_t *cmount, struct ceph_dir_result_t *dirp);
-void ceph_seekdir(struct ceph_mount_t *cmount, struct ceph_dir_result_t *dirp, loff_t offset);
+int ceph_getdents(ceph_mount_info_t cmount, ceph_dir_result_t dirp, char *name, int buflen);
+int ceph_getdnames(ceph_mount_info_t cmount, ceph_dir_result_t dirp, char *name, int buflen);
+void ceph_rewinddir(ceph_mount_info_t cmount, ceph_dir_result_t dirp);
+loff_t ceph_telldir(ceph_mount_info_t cmount, ceph_dir_result_t dirp);
+void ceph_seekdir(ceph_mount_info_t cmount, ceph_dir_result_t dirp, loff_t offset);
-int ceph_link(struct ceph_mount_t *cmount, const char *existing, const char *newname);
-int ceph_unlink(struct ceph_mount_t *cmount, const char *path);
-int ceph_rename(struct ceph_mount_t *cmount, const char *from, const char *to);
+int ceph_link(ceph_mount_info_t cmount, const char *existing, const char *newname);
+int ceph_unlink(ceph_mount_info_t cmount, const char *path);
+int ceph_rename(ceph_mount_info_t cmount, const char *from, const char *to);
/* dirs */
-int ceph_mkdir(struct ceph_mount_t *cmount, const char *path, mode_t mode);
-int ceph_mkdirs(struct ceph_mount_t *cmount, const char *path, mode_t mode);
-int ceph_rmdir(struct ceph_mount_t *cmount, const char *path);
+int ceph_mkdir(ceph_mount_info_t cmount, const char *path, mode_t mode);
+int ceph_mkdirs(ceph_mount_info_t cmount, const char *path, mode_t mode);
+int ceph_rmdir(ceph_mount_info_t cmount, const char *path);
/* symlinks */
-int ceph_readlink(struct ceph_mount_t *cmount, const char *path, char *buf, loff_t size);
-int ceph_symlink(struct ceph_mount_t *cmount, const char *existing, const char *newname);
+int ceph_readlink(ceph_mount_info_t cmount, const char *path, char *buf, loff_t size);
+int ceph_symlink(ceph_mount_info_t cmount, const char *existing, const char *newname);
/* inode stuff */
-int ceph_lstat(struct ceph_mount_t *cmount, const char *path, struct stat *stbuf);
+int ceph_lstat(ceph_mount_info_t cmount, const char *path, struct stat *stbuf);
-int ceph_setattr(struct ceph_mount_t *cmount, const char *relpath, struct stat *attr, int mask);
-int ceph_chmod(struct ceph_mount_t *cmount, const char *path, mode_t mode);
-int ceph_chown(struct ceph_mount_t *cmount, const char *path, uid_t uid, gid_t gid);
-int ceph_utime(struct ceph_mount_t *cmount, const char *path, struct utimbuf *buf);
-int ceph_truncate(struct ceph_mount_t *cmount, const char *path, loff_t size);
+int ceph_setattr(ceph_mount_info_t cmount, const char *relpath, struct stat *attr, int mask);
+int ceph_chmod(ceph_mount_info_t cmount, const char *path, mode_t mode);
+int ceph_chown(ceph_mount_info_t cmount, const char *path, uid_t uid, gid_t gid);
+int ceph_utime(ceph_mount_info_t cmount, const char *path, struct utimbuf *buf);
+int ceph_truncate(ceph_mount_info_t cmount, const char *path, loff_t size);
/* file ops */
-int ceph_mknod(struct ceph_mount_t *cmount, const char *path, mode_t mode, dev_t rdev);
-int ceph_open(struct ceph_mount_t *cmount, const char *path, int flags, mode_t mode);
-int ceph_close(struct ceph_mount_t *cmount, int fd);
-loff_t ceph_lseek(struct ceph_mount_t *cmount, int fd, loff_t offset, int whence);
-int ceph_read(struct ceph_mount_t *cmount, int fd, char *buf, loff_t size, loff_t offset);
-int ceph_write(struct ceph_mount_t *cmount, int fd, const char *buf, loff_t size,
+int ceph_mknod(ceph_mount_info_t cmount, const char *path, mode_t mode, dev_t rdev);
+int ceph_open(ceph_mount_info_t cmount, const char *path, int flags, mode_t mode);
+int ceph_close(ceph_mount_info_t cmount, int fd);
+loff_t ceph_lseek(ceph_mount_info_t cmount, int fd, loff_t offset, int whence);
+int ceph_read(ceph_mount_info_t cmount, int fd, char *buf, loff_t size, loff_t offset);
+int ceph_write(ceph_mount_info_t cmount, int fd, const char *buf, loff_t size,
loff_t offset);
-int ceph_ftruncate(struct ceph_mount_t *cmount, int fd, loff_t size);
-int ceph_fsync(struct ceph_mount_t *cmount, int fd, int syncdataonly);
-int ceph_fstat(struct ceph_mount_t *cmount, int fd, struct stat *stbuf);
+int ceph_ftruncate(ceph_mount_info_t cmount, int fd, loff_t size);
+int ceph_fsync(ceph_mount_info_t cmount, int fd, int syncdataonly);
+int ceph_fstat(ceph_mount_info_t cmount, int fd, struct stat *stbuf);
-int ceph_sync_fs(struct ceph_mount_t *cmount);
+int ceph_sync_fs(ceph_mount_info_t cmount);
/* expose file layout */
-int ceph_get_file_stripe_unit(struct ceph_mount_t *cmount, int fh);
-int ceph_get_file_pool(struct ceph_mount_t *cmount, int fh);
-int ceph_get_file_replication(struct ceph_mount_t *cmount, int fh);
-int ceph_get_file_stripe_address(struct ceph_mount_t *cmount, int fd,
+int ceph_get_file_stripe_unit(ceph_mount_info_t cmount, int fh);
+int ceph_get_file_pool(ceph_mount_info_t cmount, int fh);
+int ceph_get_file_replication(ceph_mount_info_t cmount, int fh);
+int ceph_get_file_stripe_address(ceph_mount_info_t cmount, int fd,
loff_t offset, char *buf, int buflen);
/* set default layout for new files */
-int ceph_set_default_file_stripe_unit(struct ceph_mount_t *cmount, int stripe);
-int ceph_set_default_file_stripe_count(struct ceph_mount_t *cmount, int count);
-int ceph_set_default_object_size(struct ceph_mount_t *cmount, int size);
-int ceph_set_default_preferred_pg(struct ceph_mount_t *cmount, int osd);
-int ceph_set_default_file_replication(struct ceph_mount_t *cmount, int replication);
+int ceph_set_default_file_stripe_unit(ceph_mount_info_t cmount, int stripe);
+int ceph_set_default_file_stripe_count(ceph_mount_info_t cmount, int count);
+int ceph_set_default_object_size(ceph_mount_info_t cmount, int size);
+int ceph_set_default_preferred_pg(ceph_mount_info_t cmount, int osd);
+int ceph_set_default_file_replication(ceph_mount_info_t cmount, int replication);
/* read from local replicas when possible */
-int ceph_localize_reads(struct ceph_mount_t *cmount, int val);
+int ceph_localize_reads(ceph_mount_info_t cmount, int val);
/* return osd on local node, if any */
-int ceph_get_local_osd(struct ceph_mount_t *cmount);
+int ceph_get_local_osd(ceph_mount_info_t cmount);
#ifdef __cplusplus
}
static bool libceph_initialized = false; // FIXME! remove this
static int nonce_seed = 0;
-class ceph_mount_t
+class ceph_mount_info
{
public:
- ceph_mount_t(uint64_t msgr_nonce_, md_config_t *conf)
+ ceph_mount_info(uint64_t msgr_nonce_, md_config_t *conf)
: msgr_nonce(msgr_nonce_),
mounted(false),
client(NULL),
{
}
- ~ceph_mount_t()
+ ~ceph_mount_info()
{
try {
shutdown();
return VERSION;
}
-static int ceph_create_with_config_impl(ceph_mount_t **cmount, md_config_t *conf)
+static int ceph_create_with_config_impl(ceph_mount_info_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();
- *cmount = new ceph_mount_t(nonce, conf);
+ *cmount = new struct ceph_mount_info(nonce, conf);
return 0;
}
-extern "C" int ceph_create(ceph_mount_t **cmount, const char * const id)
+extern "C" int ceph_create(ceph_mount_info_t *cmount, const char * const id)
{
int ret;
libceph_init_mutex.Lock();
return ret;
}
-extern "C" int ceph_create_with_config(ceph_mount_t **cmount, md_config_t *conf)
+extern "C" int ceph_create_with_config(ceph_mount_info_t *cmount, md_config_t *conf)
{
int ret;
libceph_init_mutex.Lock();
return ret;
}
-extern "C" void ceph_shutdown(ceph_mount_t *cmount)
+extern "C" void ceph_shutdown(ceph_mount_info_t cmount)
{
cmount->shutdown();
}
-extern "C" int ceph_conf_read_file(ceph_mount_t *cmount, const char *path)
+extern "C" int ceph_conf_read_file(ceph_mount_info_t cmount, const char *path)
{
return cmount->conf_read_file(path);
}
-extern "C" void ceph_conf_parse_argv(ceph_mount_t *cmount, int argc,
+extern "C" void ceph_conf_parse_argv(ceph_mount_info_t cmount, int argc,
const char **argv)
{
cmount->conf_parse_argv(argc, argv);
}
-extern "C" int ceph_conf_set(ceph_mount_t *cmount, const char *option,
+extern "C" int ceph_conf_set(ceph_mount_info_t cmount, const char *option,
const char *value)
{
return cmount->conf_set(option, value);
}
-extern "C" int ceph_conf_get(ceph_mount_t *cmount, const char *option,
+extern "C" int ceph_conf_get(ceph_mount_info_t cmount, const char *option,
char *buf, size_t len)
{
return cmount->conf_get(option, buf, len);
}
-extern "C" int ceph_mount(ceph_mount_t *cmount, const char *root)
+extern "C" int ceph_mount(ceph_mount_info_t cmount, const char *root)
{
std::string mount_root;
if (root)
return cmount->mount(mount_root);
}
-extern "C" int ceph_statfs(ceph_mount_t *cmount, const char *path,
+extern "C" int ceph_statfs(ceph_mount_info_t cmount, const char *path,
struct statvfs *stbuf)
{
return cmount->get_client()->statfs(path, stbuf);
}
-extern "C" int ceph_get_local_osd(ceph_mount_t *cmount)
+extern "C" int ceph_get_local_osd(ceph_mount_info_t cmount)
{
return cmount->get_client()->get_local_osd();
}
-extern "C" const char* ceph_getcwd(ceph_mount_t *cmount)
+extern "C" const char* ceph_getcwd(ceph_mount_info_t cmount)
{
return cmount->get_cwd();
}
-extern "C" int ceph_chdir (ceph_mount_t *cmount, const char *s)
+extern "C" int ceph_chdir (ceph_mount_info_t cmount, const char *s)
{
return cmount->get_client()->chdir(s);
}
-extern "C" int ceph_opendir(ceph_mount_t *cmount,
- const char *name, ceph_dir_result_t **dirpp)
+extern "C" int ceph_opendir(ceph_mount_info_t cmount,
+ const char *name, ceph_dir_result_t *dirpp)
{
- return cmount->get_client()->opendir(name, dirpp);
+ return cmount->get_client()->opendir(name, (dir_result_t **)dirpp);
}
-extern "C" int ceph_closedir(ceph_mount_t *cmount, ceph_dir_result_t *dirp)
+extern "C" int ceph_closedir(ceph_mount_info_t cmount, ceph_dir_result_t dirp)
{
- return cmount->get_client()->closedir(dirp);
+ return cmount->get_client()->closedir((dir_result_t*)dirp);
}
-extern "C" int ceph_readdir_r(ceph_mount_t *cmount, ceph_dir_result_t *dirp, struct dirent *de)
+extern "C" int ceph_readdir_r(ceph_mount_info_t cmount, ceph_dir_result_t dirp, struct dirent *de)
{
- return cmount->get_client()->readdir_r(dirp, de);
+ return cmount->get_client()->readdir_r((dir_result_t*)dirp, de);
}
-extern "C" int ceph_readdirplus_r(ceph_mount_t *cmount, ceph_dir_result_t *dirp,
+extern "C" int ceph_readdirplus_r(ceph_mount_info_t cmount, ceph_dir_result_t dirp,
struct dirent *de, struct stat *st, int *stmask)
{
- return cmount->get_client()->readdirplus_r(dirp, de, st, stmask);
+ return cmount->get_client()->readdirplus_r((dir_result_t*)dirp, de, st, stmask);
}
-extern "C" int ceph_getdents(ceph_mount_t *cmount, ceph_dir_result_t *dirp,
+extern "C" int ceph_getdents(ceph_mount_info_t cmount, ceph_dir_result_t dirp,
char *buf, int buflen)
{
- return cmount->get_client()->getdents(dirp, buf, buflen);
+ return cmount->get_client()->getdents((dir_result_t*)dirp, buf, buflen);
}
-extern "C" int ceph_getdnames(ceph_mount_t *cmount, ceph_dir_result_t *dirp,
+extern "C" int ceph_getdnames(ceph_mount_info_t cmount, ceph_dir_result_t dirp,
char *buf, int buflen)
{
- return cmount->get_client()->getdnames(dirp, buf, buflen);
+ return cmount->get_client()->getdnames((dir_result_t*)dirp, buf, buflen);
}
-extern "C" void ceph_rewinddir(ceph_mount_t *cmount, ceph_dir_result_t *dirp)
+extern "C" void ceph_rewinddir(ceph_mount_info_t cmount, ceph_dir_result_t dirp)
{
- cmount->get_client()->rewinddir(dirp);
+ cmount->get_client()->rewinddir((dir_result_t*)dirp);
}
-extern "C" loff_t ceph_telldir(ceph_mount_t *cmount, ceph_dir_result_t *dirp)
+extern "C" loff_t ceph_telldir(ceph_mount_info_t cmount, ceph_dir_result_t dirp)
{
- return cmount->get_client()->telldir(dirp);
+ return cmount->get_client()->telldir((dir_result_t*)dirp);
}
-extern "C" void ceph_seekdir(ceph_mount_t *cmount, ceph_dir_result_t *dirp, loff_t offset)
+extern "C" void ceph_seekdir(ceph_mount_info_t cmount, ceph_dir_result_t dirp, loff_t offset)
{
- cmount->get_client()->seekdir(dirp, offset);
+ cmount->get_client()->seekdir((dir_result_t*)dirp, offset);
}
-extern "C" int ceph_link (ceph_mount_t *cmount, const char *existing,
+extern "C" int ceph_link (ceph_mount_info_t cmount, const char *existing,
const char *newname)
{
return cmount->get_client()->link(existing, newname);
}
-extern "C" int ceph_unlink(ceph_mount_t *cmount, const char *path)
+extern "C" int ceph_unlink(ceph_mount_info_t cmount, const char *path)
{
return cmount->get_client()->unlink(path);
}
-extern "C" int ceph_rename(ceph_mount_t *cmount, const char *from,
+extern "C" int ceph_rename(ceph_mount_info_t cmount, const char *from,
const char *to)
{
return cmount->get_client()->rename(from, to);
}
// dirs
-extern "C" int ceph_mkdir(ceph_mount_t *cmount, const char *path, mode_t mode)
+extern "C" int ceph_mkdir(ceph_mount_info_t cmount, const char *path, mode_t mode)
{
return cmount->get_client()->mkdir(path, mode);
}
-extern "C" int ceph_mkdirs(ceph_mount_t *cmount, const char *path, mode_t mode)
+extern "C" int ceph_mkdirs(ceph_mount_info_t cmount, const char *path, mode_t mode)
{
return cmount->get_client()->mkdirs(path, mode);
}
-extern "C" int ceph_rmdir(ceph_mount_t *cmount, const char *path)
+extern "C" int ceph_rmdir(ceph_mount_info_t cmount, const char *path)
{
return cmount->get_client()->rmdir(path);
}
// symlinks
-extern "C" int ceph_readlink(ceph_mount_t *cmount, const char *path,
+extern "C" int ceph_readlink(ceph_mount_info_t cmount, const char *path,
char *buf, loff_t size)
{
return cmount->get_client()->readlink(path, buf, size);
}
-extern "C" int ceph_symlink(ceph_mount_t *cmount, const char *existing,
+extern "C" int ceph_symlink(ceph_mount_info_t cmount, const char *existing,
const char *newname)
{
return cmount->get_client()->symlink(existing, newname);
}
// inode stuff
-extern "C" int ceph_lstat(ceph_mount_t *cmount, const char *path,
+extern "C" int ceph_lstat(ceph_mount_info_t cmount, const char *path,
struct stat *stbuf)
{
return cmount->get_client()->lstat(path, stbuf);
}
-extern "C" int ceph_setattr(ceph_mount_t *cmount, const char *relpath,
+extern "C" int ceph_setattr(ceph_mount_info_t cmount, const char *relpath,
struct stat *attr, int mask)
{
return cmount->get_client()->setattr(relpath, attr, mask);
}
-extern "C" int ceph_chmod(ceph_mount_t *cmount, const char *path, mode_t mode)
+extern "C" int ceph_chmod(ceph_mount_info_t cmount, const char *path, mode_t mode)
{
return cmount->get_client()->chmod(path, mode);
}
-extern "C" int ceph_chown(ceph_mount_t *cmount, const char *path,
+extern "C" int ceph_chown(ceph_mount_info_t cmount, const char *path,
uid_t uid, gid_t gid)
{
return cmount->get_client()->chown(path, uid, gid);
}
-extern "C" int ceph_utime(ceph_mount_t *cmount, const char *path,
+extern "C" int ceph_utime(ceph_mount_info_t cmount, const char *path,
struct utimbuf *buf)
{
return cmount->get_client()->utime(path, buf);
}
-extern "C" int ceph_truncate(ceph_mount_t *cmount, const char *path,
+extern "C" int ceph_truncate(ceph_mount_info_t cmount, const char *path,
loff_t size)
{
return cmount->get_client()->truncate(path, size);
}
// file ops
-extern "C" int ceph_mknod(ceph_mount_t *cmount, const char *path,
+extern "C" int ceph_mknod(ceph_mount_info_t cmount, const char *path,
mode_t mode, dev_t rdev)
{
return cmount->get_client()->mknod(path, mode, rdev);
}
-extern "C" int ceph_open(ceph_mount_t *cmount, const char *path,
+extern "C" int ceph_open(ceph_mount_info_t cmount, const char *path,
int flags, mode_t mode)
{
return cmount->get_client()->open(path, flags, mode);
}
-extern "C" int ceph_close(ceph_mount_t *cmount, int fd)
+extern "C" int ceph_close(ceph_mount_info_t cmount, int fd)
{
return cmount->get_client()->close(fd);
}
-extern "C" loff_t ceph_lseek(ceph_mount_t *cmount, int fd,
+extern "C" loff_t ceph_lseek(ceph_mount_info_t cmount, int fd,
loff_t offset, int whence)
{
return cmount->get_client()->lseek(fd, offset, whence);
}
-extern "C" int ceph_read(ceph_mount_t *cmount, int fd, char *buf,
+extern "C" int ceph_read(ceph_mount_info_t cmount, int fd, char *buf,
loff_t size, loff_t offset)
{
return cmount->get_client()->read(fd, buf, size, offset);
}
-extern "C" int ceph_write(ceph_mount_t *cmount, int fd, const char *buf,
+extern "C" int ceph_write(ceph_mount_info_t cmount, int fd, const char *buf,
loff_t size, loff_t offset)
{
return cmount->get_client()->write(fd, buf, size, offset);
}
-extern "C" int ceph_ftruncate(ceph_mount_t *cmount, int fd, loff_t size)
+extern "C" int ceph_ftruncate(ceph_mount_info_t cmount, int fd, loff_t size)
{
return cmount->get_client()->ftruncate(fd, size);
}
-extern "C" int ceph_fsync(ceph_mount_t *cmount, int fd, int syncdataonly)
+extern "C" int ceph_fsync(ceph_mount_info_t cmount, int fd, int syncdataonly)
{
return cmount->get_client()->fsync(fd, syncdataonly);
}
-extern "C" int ceph_fstat(ceph_mount_t *cmount, int fd, struct stat *stbuf)
+extern "C" int ceph_fstat(ceph_mount_info_t cmount, int fd, struct stat *stbuf)
{
return cmount->get_client()->fstat(fd, stbuf);
}
-extern "C" int ceph_sync_fs(ceph_mount_t *cmount)
+extern "C" int ceph_sync_fs(ceph_mount_info_t cmount)
{
return cmount->get_client()->sync_fs();
}
-extern "C" int ceph_get_file_stripe_unit(ceph_mount_t *cmount, int fh)
+extern "C" int ceph_get_file_stripe_unit(ceph_mount_info_t cmount, int fh)
{
struct ceph_file_layout l;
int r = cmount->get_client()->describe_layout(fh, &l);
return l.fl_stripe_unit;
}
-extern "C" int ceph_get_file_pool(ceph_mount_t *cmount, int fh)
+extern "C" int ceph_get_file_pool(ceph_mount_info_t cmount, int fh)
{
struct ceph_file_layout l;
int r = cmount->get_client()->describe_layout(fh, &l);
return l.fl_pg_pool;
}
-extern "C" int ceph_get_file_replication(ceph_mount_t *cmount, int fh)
+extern "C" int ceph_get_file_replication(ceph_mount_info_t cmount, int fh)
{
struct ceph_file_layout l;
int r = cmount->get_client()->describe_layout(fh, &l);
return rep;
}
-extern "C" int ceph_set_default_file_stripe_unit(ceph_mount_t *cmount,
+extern "C" int ceph_set_default_file_stripe_unit(ceph_mount_info_t cmount,
int stripe)
{
cmount->get_client()->set_default_file_stripe_unit(stripe);
return 0;
}
-extern "C" int ceph_set_default_file_stripe_count(ceph_mount_t *cmount,
+extern "C" int ceph_set_default_file_stripe_count(ceph_mount_info_t cmount,
int count)
{
cmount->get_client()->set_default_file_stripe_unit(count);
return 0;
}
-extern "C" int ceph_set_default_object_size(ceph_mount_t *cmount, int size)
+extern "C" int ceph_set_default_object_size(ceph_mount_info_t cmount, int size)
{
cmount->get_client()->set_default_object_size(size);
return 0;
}
-extern "C" int ceph_set_default_file_replication(ceph_mount_t *cmount,
+extern "C" int ceph_set_default_file_replication(ceph_mount_info_t cmount,
int replication)
{
cmount->get_client()->set_default_file_replication(replication);
return 0;
}
-extern "C" int ceph_set_default_preferred_pg(ceph_mount_t *cmount, int osd)
+extern "C" int ceph_set_default_preferred_pg(ceph_mount_info_t cmount, int osd)
{
cmount->get_client()->set_default_preferred_pg(osd);
return 0;
}
-extern "C" int ceph_get_file_stripe_address(ceph_mount_t *cmount, int fh,
+extern "C" int ceph_get_file_stripe_address(ceph_mount_info_t cmount, int fh,
loff_t offset, char *buf, int buflen)
{
string address;
return 0;
}
-extern "C" int ceph_localize_reads(ceph_mount_t *cmount, int val)
+extern "C" int ceph_localize_reads(ceph_mount_info_t cmount, int val)
{
if (!val)
cmount->get_client()->clear_filer_flags(CEPH_OSD_FLAG_LOCALIZE_READS);