From: Andras Elso Date: Fri, 17 May 2013 19:40:03 +0000 (+0200) Subject: libcephfs: get file handle/path layout info X-Git-Tag: v0.64~102^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=877fcf0be0b9620c1e7c59ff2147483e3431d008;p=ceph.git libcephfs: get file handle/path layout info Signed-off-by: Andras Elso --- diff --git a/src/include/cephfs/libcephfs.h b/src/include/cephfs/libcephfs.h index c12a8f1d9fa7..5ceaced2222a 100644 --- a/src/include/cephfs/libcephfs.h +++ b/src/include/cephfs/libcephfs.h @@ -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. diff --git a/src/libcephfs.cc b/src/libcephfs.cc index 1db188930d5a..9487b6c227fd 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -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;