]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
libcephfs: get replication factor of a file handle/path
authorAndras Elso <elso.andras@gmail.com>
Mon, 6 May 2013 23:28:12 +0000 (01:28 +0200)
committerAndras Elso <elso.andras@gmail.com>
Fri, 17 May 2013 19:45:47 +0000 (21:45 +0200)
Signed-off-by: Andras Elso <elso.andras@gmail.com>
src/include/cephfs/libcephfs.h
src/libcephfs.cc

index 5ceaced2222a10eca4cc4242555f572142779f4b..bd4f9fca816df4bebf88a205543434bf3c10062f 100644 (file)
@@ -953,13 +953,23 @@ int ceph_get_file_layout(struct ceph_mount_info *cmount, int fh, int *stripe_uni
 int ceph_get_path_layout(struct ceph_mount_info *cmount, const char *path, int *stripe_unit, int *stripe_count, int *object_size, int *pg_pool);
 
 /**
- * Get the file replication information.
+ * Get the file replication information from an open file descriptor.
+ *
  * @param cmount the ceph mount handle to use.
  * @param fh the open file descriptor referring to the file to get the replication information of.
  * @returns the replication factor of the file.
  */
 int ceph_get_file_replication(struct ceph_mount_info *cmount, int fh);
 
+/**
+ * Get the file replication information.
+ *
+ * @param cmount the ceph mount handle to use.
+ * @param path the path of the file/directory get the replication information of.
+ * @returns the replication factor of the file.
+ */
+int ceph_get_path_replication(struct ceph_mount_info *cmount, const char *path);
+
 /**
  * Get the id of the named pool.
  *
index 9487b6c227fd21e14dfa08ce6e6b8f2b1c18ada1..e1b4c287a3739b1751ec1707b5317333b41ba138 100644 (file)
@@ -894,6 +894,20 @@ extern "C" int ceph_get_file_replication(struct ceph_mount_info *cmount, int fh)
   return rep;
 }
 
+extern "C" int ceph_get_path_replication(struct ceph_mount_info *cmount, const char *path)
+{
+  struct ceph_file_layout l;
+  int r;
+
+  if (!cmount->is_mounted())
+    return -ENOTCONN;
+  r = cmount->get_client()->describe_layout(path, &l);
+  if (r < 0)
+    return r;
+  int rep = cmount->get_client()->get_pool_replication(l.fl_pg_pool);
+  return rep;
+}
+
 extern "C" int ceph_set_default_file_stripe_unit(struct ceph_mount_info *cmount,
                                                 int stripe)
 {