]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
uClient/libceph: implement get_file_replication
authorGreg Farnum <gregf@hq.newdream.net>
Wed, 5 Aug 2009 19:27:00 +0000 (12:27 -0700)
committerGreg Farnum <gregf@hq.newdream.net>
Wed, 5 Aug 2009 22:48:23 +0000 (15:48 -0700)
add it to libceph.

src/client/Client.cc
src/client/libceph.cc
src/client/libceph.h
src/include/ceph_fs.h

index ae6c86fbc49c2a70b52a7776e71920814e230657..ddbea0fa885ea3573eb12e700a850ee16d22730a 100644 (file)
@@ -5215,7 +5215,15 @@ int Client::get_file_stripe_period(int fd)
 
 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)
index a7dd4d63ccdcca591a1861404024118a8a3a3986..00661218f24ef357952c5c4730549c694ad6648c 100644 (file)
@@ -261,6 +261,13 @@ extern "C" int ceph_get_file_stripe_unit(int fh)
   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);
index 5ebb40a4ddc1cc0b68b1198597178b9d39f28e1d..0d4b9e983d80f3349619475193a248d742e506f1 100644 (file)
@@ -69,6 +69,7 @@ int ceph_fstat(int fd, struct stat *stbuf);
 
 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);
index 45e2f14a7ba8f70a1bb79e170538ac7643afc050..cd12e509089e5235fa5604fa5f4ce8ad10698ca1 100644 (file)
@@ -185,6 +185,8 @@ struct ceph_file_layout {
        ((__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))