]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
libcephfs: get stripe_unit/stripe_count/object_size/pool_id by file handle/path
authorAndras Elso <elso.andras@gmail.com>
Mon, 6 May 2013 23:24:29 +0000 (01:24 +0200)
committerAndras Elso <elso.andras@gmail.com>
Fri, 17 May 2013 19:39:37 +0000 (21:39 +0200)
Signed-off-by: Andras Elso <elso.andras@gmail.com>
src/include/cephfs/libcephfs.h
src/libcephfs.cc

index 64b6ac184b478e9b6cb1996e4c96934527b9bbb4..c12a8f1d9fa7b7fe64b4146901b9439412564f19 100644 (file)
@@ -841,7 +841,7 @@ int ceph_lsetxattr(struct ceph_mount_info *cmount, const char *path, const char
  */
 
 /**
- * Get the file striping unit.
+ * Get the file striping unit 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 striping unit of.
@@ -850,7 +850,52 @@ int ceph_lsetxattr(struct ceph_mount_info *cmount, const char *path, const char
 int ceph_get_file_stripe_unit(struct ceph_mount_info *cmount, int fh);
 
 /**
- * Get the file pool information.
+ * Get the file striping unit.
+ *
+ * @param cmount the ceph mount handle to use.
+ * @param path the path of the file/directory get the striping unit of.
+ * @returns the striping unit of the file or a negative error code on failure.
+ */
+int ceph_get_path_stripe_unit(struct ceph_mount_info *cmount, const char *path);
+
+/**
+ * Get the file striping count 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 striping count of.
+ * @returns the striping count of the file or a negative error code on failure.
+ */
+int ceph_get_file_stripe_count(struct ceph_mount_info *cmount, int fh);
+
+/**
+ * Get the file striping count.
+ *
+ * @param cmount the ceph mount handle to use.
+ * @param path the path of the file/directory get the striping count of.
+ * @returns the striping count of the file or a negative error code on failure.
+ */
+int ceph_get_path_stripe_count(struct ceph_mount_info *cmount, const char *path);
+
+/**
+ * Get the file object size 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 object size of.
+ * @returns the object size of the file or a negative error code on failure.
+ */
+int ceph_get_file_object_size(struct ceph_mount_info *cmount, int fh);
+
+/**
+ * Get the file object size.
+ *
+ * @param cmount the ceph mount handle to use.
+ * @param path the path of the file/directory get the object size of.
+ * @returns the object size of the file or a negative error code on failure.
+ */
+int ceph_get_path_object_size(struct ceph_mount_info *cmount, const char *path);
+
+/**
+ * Get the file pool 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 pool information of.
@@ -858,6 +903,15 @@ int ceph_get_file_stripe_unit(struct ceph_mount_info *cmount, int fh);
  */
 int ceph_get_file_pool(struct ceph_mount_info *cmount, int fh);
 
+/**
+ * Get the file pool information.
+ *
+ * @param cmount the ceph mount handle to use.
+ * @param path the path of the file/directory get the pool information of.
+ * @returns the ceph pool id that the file is in
+ */
+int ceph_get_path_pool(struct ceph_mount_info *cmount, const char *path);
+
 /**
  * Get the name of the pool a file is stored in,
  *
index d0997c8f4cce99b9bbfdc9194fd3b187af54bcf0..1db188930d5a8296838b809627cbb3c3849b612d 100644 (file)
@@ -728,6 +728,71 @@ extern "C" int ceph_get_file_stripe_unit(struct ceph_mount_info *cmount, int fh)
   return l.fl_stripe_unit;
 }
 
+extern "C" int ceph_get_path_stripe_unit(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;
+  return l.fl_stripe_unit;
+}
+
+extern "C" int ceph_get_file_stripe_count(struct ceph_mount_info *cmount, int fh)
+{
+  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;
+  return l.fl_stripe_count;
+}
+
+extern "C" int ceph_get_path_stripe_count(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;
+  return l.fl_stripe_count;
+}
+
+extern "C" int ceph_get_file_object_size(struct ceph_mount_info *cmount, int fh)
+{
+  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;
+  return l.fl_object_size;
+}
+
+extern "C" int ceph_get_path_object_size(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;
+  return l.fl_object_size;
+}
+
 extern "C" int ceph_get_file_pool(struct ceph_mount_info *cmount, int fh)
 {
   struct ceph_file_layout l;
@@ -741,6 +806,19 @@ extern "C" int ceph_get_file_pool(struct ceph_mount_info *cmount, int fh)
   return l.fl_pg_pool;
 }
 
+extern "C" int ceph_get_path_pool(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;
+  return l.fl_pg_pool;
+}
+
 extern "C" int ceph_get_file_pool_name(struct ceph_mount_info *cmount, int fh, char *buf, size_t len)
 {
   struct ceph_file_layout l;