add it to libceph.
int Client::get_file_replication(int fd)
{
- return 0;
+ int pool;
+ Mutex::Locker lock(client_lock);
+
+ assert(fd_map.count(fd));
+ Fh *f = fd_map[fd];
+ Inode *in = f->inode;
+
+ pool = ceph_file_layout_pg_pool(in->layout);
+ return osdmap->get_pg_pool(pool).get_size();
}
int Client::get_file_stripe_address(int fd, loff_t offset, string& address)
return client->get_file_stripe_unit(fh);
}
+extern "C" int ceph_get_file_replication(const char *path) {
+ int fd = client->open(path, O_RDONLY);
+ int rep = client->get_file_replication(fd);
+ client->close(fd);
+ return rep;
+}
+
int ceph_getdir(const char *relpath, std::list<std::string>& names)
{
return client->getdir(relpath, names);
int ceph_sync_fs();
int ceph_get_file_stripe_unit(int fh);
+int ceph_get_file_replication(const char *path);
#ifdef __cplusplus
//not for C, sorry!
int ceph_getdir(const char *relpath, std::list<std::string>& names);
((__s32)le32_to_cpu((l).fl_object_stripe_unit))
#define ceph_file_layout_pg_preferred(l) \
((__s32)le32_to_cpu((l).fl_pg_preferred))
+#define ceph_file_layout_pg_pool(l) \
+ ((__s32)le32_to_cpu((l).fl_pg_pool))
#define ceph_file_layout_stripe_width(l) (le32_to_cpu((l).fl_stripe_unit) * \
le32_to_cpu((l).fl_stripe_count))