]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
libcephfs: get file handle/path layout info
authorAndras Elso <elso.andras@gmail.com>
Fri, 17 May 2013 19:40:03 +0000 (21:40 +0200)
committerAndras Elso <elso.andras@gmail.com>
Fri, 17 May 2013 19:43:48 +0000 (21:43 +0200)
Signed-off-by: Andras Elso <elso.andras@gmail.com>
src/include/cephfs/libcephfs.h
src/libcephfs.cc

index c12a8f1d9fa7b7fe64b4146901b9439412564f19..5ceaced2222a10eca4cc4242555f572142779f4b 100644 (file)
@@ -926,6 +926,32 @@ int ceph_get_path_pool(struct ceph_mount_info *cmount, const char *path);
  */
 int ceph_get_file_pool_name(struct ceph_mount_info *cmount, int fh, char *buf, size_t buflen);
 
+/**
+ * Get the file layout 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 layout of.
+ * @param stripe_unit where to store the striping unit of the file
+ * @param stripe_count where to store the striping count of the file
+ * @param object_size where to store the object size of the file
+ * @param pg_pool where to store the ceph pool id that the file is in
+ * @returns 0 on success or a negative error code on failure.
+ */
+int ceph_get_file_layout(struct ceph_mount_info *cmount, int fh, int *stripe_unit, int *stripe_count, int *object_size, int *pg_pool);
+
+/**
+ * Get the file layout.
+ *
+ * @param cmount the ceph mount handle to use.
+ * @param path the path of the file/directory get the layout of.
+ * @param stripe_unit where to store the striping unit of the file
+ * @param stripe_count where to store the striping count of the file
+ * @param object_size where to store the object size of the file
+ * @param pg_pool where to store the ceph pool id that the file is in
+ * @returns 0 on success or a negative error code on failure.
+ */
+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.
  * @param cmount the ceph mount handle to use.
index 1db188930d5a8296838b809627cbb3c3849b612d..9487b6c227fd21e14dfa08ce6e6b8f2b1c18ada1 100644 (file)
@@ -838,6 +838,48 @@ extern "C" int ceph_get_file_pool_name(struct ceph_mount_info *cmount, int fh, c
   return name.length();
 }
 
+extern "C" int ceph_get_file_layout(struct ceph_mount_info *cmount, int fh, int *stripe_unit, int *stripe_count, int *object_size, int *pg_pool)
+{
+  struct ceph_file_layout l;
+  int r;
+
+  if (!cmount->is_mounted())
+    return -ENOTCONN;
+  r = cmount->get_client()->fdescribe_layout(fh, &l);
+  if (r < 0)
+    return r;
+  if (stripe_unit)
+    *stripe_unit = l.fl_stripe_unit;
+  if (stripe_count)
+    *stripe_count = l.fl_stripe_count;
+  if (object_size)
+    *object_size = l.fl_object_size;
+  if (pg_pool)
+    *pg_pool = l.fl_pg_pool;
+  return 0;
+}
+
+extern "C" 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)
+{
+  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;
+  if (stripe_unit)
+    *stripe_unit = l.fl_stripe_unit;
+  if (stripe_count)
+    *stripe_count = l.fl_stripe_count;
+  if (object_size)
+    *object_size = l.fl_object_size;
+  if (pg_pool)
+    *pg_pool = l.fl_pg_pool;
+  return 0;
+}
+
 extern "C" int ceph_get_file_replication(struct ceph_mount_info *cmount, int fh)
 {
   struct ceph_file_layout l;