From: Sage Weil Date: Thu, 28 Apr 2011 18:11:14 +0000 (-0700) Subject: libceph: typedef struct mystruct *mystruct_t X-Git-Tag: v0.28~132^2~15 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1fd2784d741d18ae006b5971038580155f66cf5f;p=ceph.git libceph: typedef struct mystruct *mystruct_t Needed to drop the ceph_ prefix on the internal ceph_dir_result_t type to prevent the ceph_dir_result_t typedef from colliding. ceph_mount_info to avoid colliding with int ceph_mount(). Signed-off-by: Sage Weil --- diff --git a/src/client/Client.cc b/src/client/Client.cc index f0dc774f0f22c..1fb7283bfb0d0 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -784,7 +784,7 @@ Inode* Client::insert_trace(MetaRequest *request, utime_t from, int mds) 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) { @@ -3862,7 +3862,7 @@ int Client::utime(const char *relpath, struct utimbuf *buf) } -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; @@ -3877,9 +3877,9 @@ int Client::opendir(const char *relpath, ceph_dir_result_t **dirpp) 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]); @@ -3891,7 +3891,7 @@ int Client::_opendir(Inode *in, ceph_dir_result_t **dirpp, int uid, int gid) } -int Client::closedir(ceph_dir_result_t *dir) +int Client::closedir(dir_result_t *dir) { Mutex::Locker lock(client_lock); tout << "closedir" << std::endl; @@ -3902,7 +3902,7 @@ int Client::closedir(ceph_dir_result_t *dir) 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) { @@ -3914,28 +3914,28 @@ void Client::_closedir(ceph_dir_result_t *dirp) 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(); } @@ -3973,7 +3973,7 @@ void Client::fill_dirent(struct dirent *de, const char *name, int type, uint64_t #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(); @@ -3987,7 +3987,7 @@ void Client::_readdir_next_frag(ceph_dir_result_t *dirp) } } -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(); @@ -3998,7 +3998,7 @@ void Client::_readdir_rechoose_frag(ceph_dir_result_t *dirp) } } -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) { @@ -4009,7 +4009,7 @@ void Client::_readdir_drop_dirp_buffer(ceph_dir_result_t *dirp) } } -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(); @@ -4048,7 +4048,7 @@ int Client::_readdir_get_frag(ceph_dir_result_t *dirp) } 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); @@ -4080,7 +4080,7 @@ int Client::_readdir_get_frag(ceph_dir_result_t *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 @@ -4120,7 +4120,7 @@ int Client::_readdir_cache_cb(ceph_dir_result_t *dirp, add_dirent_cb_t cb, void 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 @@ -4141,9 +4141,9 @@ int Client::_readdir_cache_cb(ceph_dir_result_t *dirp, add_dirent_cb_t cb, void 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 @@ -4229,7 +4229,7 @@ int Client::readdir_r_cb(ceph_dir_result_t *d, add_dirent_cb_t cb, void *p) << " 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& ent = (*dirp->buffer)[off - dirp->this_offset]; int stmask = fill_stat(ent.second, &st); @@ -4278,7 +4278,7 @@ int Client::readdir_r_cb(ceph_dir_result_t *d, add_dirent_cb_t cb, void *p) -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); } @@ -4313,7 +4313,7 @@ static int _readdir_single_dirent_cb(void *p, struct dirent *de, struct stat *st 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; @@ -4360,7 +4360,7 @@ static int _readdir_getdent_cb(void *p, struct dirent *de, struct stat *st, int 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; @@ -4403,7 +4403,7 @@ int Client::getdir(const char *relpath, list& contents) tout << relpath << std::endl; } - ceph_dir_result_t *d; + dir_result_t *d; int r = opendir(relpath, &d); if (r < 0) return r; @@ -6200,9 +6200,9 @@ int Client::ll_opendir(vinodeno_t vino, void **dirpp, int uid, int gid) 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; @@ -6217,7 +6217,7 @@ void Client::ll_releasedir(void *dirp) 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) diff --git a/src/client/Client.h b/src/client/Client.h index e490c95445a71..ab21dc89e611d 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -692,7 +692,7 @@ struct Fh { // ======================================================== // 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); @@ -723,7 +723,7 @@ struct ceph_dir_result_t { 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(); @@ -1137,14 +1137,14 @@ private: // 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); @@ -1199,27 +1199,27 @@ public: 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& 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); diff --git a/src/client/SyntheticClient.cc b/src/client/SyntheticClient.cc index 40280857c9c7b..d321d7cdbc2f0 100644 --- a/src/client/SyntheticClient.cc +++ b/src/client/SyntheticClient.cc @@ -1009,7 +1009,7 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only) utime_t start = g_clock.now(); hash_map open_files; - hash_map open_dirs; + hash_map open_dirs; hash_map ll_files; hash_map ll_dirs; @@ -1139,7 +1139,7 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only) } 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) { @@ -1478,7 +1478,7 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only) dout(1) << "leftover close " << fi->second << dendl; if (fi->second > 0) client->close(fi->second); } - for (hash_map::iterator fi = open_dirs.begin(); + for (hash_map::iterator fi = open_dirs.begin(); fi != open_dirs.end(); fi++) { dout(1) << "leftover closedir " << fi->second << dendl; diff --git a/src/client/fuse_ll.cc b/src/client/fuse_ll.cc index 7ce1c45d1195c..e6420f34f614a 100644 --- a/src/client/fuse_ll.cc +++ b/src/client/fuse_ll.cc @@ -376,7 +376,7 @@ static void ceph_ll_readdir(fuse_req_t req, fuse_ino_t ino, size_t size, { (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; @@ -398,7 +398,7 @@ static void ceph_ll_readdir(fuse_req_t req, fuse_ino_t ino, size_t size, 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); } diff --git a/src/client/testceph.cc b/src/client/testceph.cc index 2dbba8df50a8b..ae8a52e5aef8c 100644 --- a/src/client/testceph.cc +++ b/src/client/testceph.cc @@ -23,7 +23,7 @@ using std::cerr; 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; @@ -49,7 +49,7 @@ int main(int argc, const char **argv) } 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: " diff --git a/src/include/ceph/libceph.h b/src/include/ceph/libceph.h index 58d4a9cf34240..e7752551267c8 100644 --- a/src/include/ceph/libceph.h +++ b/src/include/ceph/libceph.h @@ -23,120 +23,123 @@ 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 } diff --git a/src/libceph.cc b/src/libceph.cc index 0b7e44894679c..b3e97e49dc53f 100644 --- a/src/libceph.cc +++ b/src/libceph.cc @@ -32,10 +32,10 @@ static Mutex libceph_init_mutex("libceph_init_mutex"); 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), @@ -45,7 +45,7 @@ public: { } - ~ceph_mount_t() + ~ceph_mount_info() { try { shutdown(); @@ -209,16 +209,16 @@ extern "C" const char *ceph_version(int *pmajor, int *pminor, int *ppatch) 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(); @@ -241,7 +241,7 @@ extern "C" int ceph_create(ceph_mount_t **cmount, const char * const id) 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(); @@ -250,35 +250,35 @@ extern "C" int ceph_create_with_config(ceph_mount_t **cmount, md_config_t *conf) 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) @@ -286,215 +286,215 @@ extern "C" int ceph_mount(ceph_mount_t *cmount, const char *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); @@ -503,7 +503,7 @@ extern "C" int ceph_get_file_stripe_unit(ceph_mount_t *cmount, int fh) 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); @@ -512,7 +512,7 @@ extern "C" int ceph_get_file_pool(ceph_mount_t *cmount, int fh) 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); @@ -522,40 +522,40 @@ extern "C" int ceph_get_file_replication(ceph_mount_t *cmount, int fh) 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; @@ -573,7 +573,7 @@ extern "C" int ceph_get_file_stripe_address(ceph_mount_t *cmount, int fh, 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);