From: Andras Elso Date: Mon, 6 May 2013 23:20:37 +0000 (+0200) Subject: Client: get describe_layout by file handle/path X-Git-Tag: v0.64~102^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ee3d50e61e91aceffc027ed4836a7c526c1e198d;p=ceph.git Client: get describe_layout by file handle/path Signed-off-by: Andras Elso --- diff --git a/src/client/Client.cc b/src/client/Client.cc index bed2c450f2f0..a2275c5342d2 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -7654,7 +7654,23 @@ int Client::ll_release(Fh *fh) // expose file layouts -int Client::describe_layout(int fd, ceph_file_layout *lp) +int Client::describe_layout(const char *relpath, ceph_file_layout *lp) +{ + Mutex::Locker lock(client_lock); + + filepath path(relpath); + Inode *in; + int r = path_walk(path, &in); + if (r < 0) + return r; + + *lp = in->layout; + + ldout(cct, 3) << "describe_layout(" << relpath << ") = 0" << dendl; + return 0; +} + +int Client::fdescribe_layout(int fd, ceph_file_layout *lp) { Mutex::Locker lock(client_lock); @@ -7665,7 +7681,7 @@ int Client::describe_layout(int fd, ceph_file_layout *lp) *lp = in->layout; - ldout(cct, 3) << "describe_layout(" << fd << ") = 0" << dendl; + ldout(cct, 3) << "fdescribe_layout(" << fd << ") = 0" << dendl; return 0; } diff --git a/src/client/Client.h b/src/client/Client.h index 29a5020c6a63..b0bc6e0e1e4c 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -670,7 +670,8 @@ public: int lazyio_synchronize(int fd, loff_t offset, size_t count); // expose file layout - int describe_layout(int fd, ceph_file_layout* layout); + int describe_layout(const char *path, ceph_file_layout* layout); + int fdescribe_layout(int fd, ceph_file_layout* layout); int get_file_stripe_address(int fd, loff_t offset, vector& address); int get_file_extent_osds(int fd, loff_t off, loff_t *len, vector& osds); int get_osd_addr(int osd, entity_addr_t& addr); diff --git a/src/client/SyntheticClient.cc b/src/client/SyntheticClient.cc index fd2c6e57c3fe..79171da46f1d 100644 --- a/src/client/SyntheticClient.cc +++ b/src/client/SyntheticClient.cc @@ -3402,7 +3402,7 @@ int SyntheticClient::chunk_file(string &filename) inode_t inode; memset(&inode, 0, sizeof(inode)); inode.ino = st.st_ino; - ret = client->describe_layout(fd, &inode.layout); + ret = client->fdescribe_layout(fd, &inode.layout); if (ret < 0) return ret; diff --git a/src/libcephfs.cc b/src/libcephfs.cc index 9d68715e7816..d0997c8f4cce 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -722,7 +722,7 @@ extern "C" int ceph_get_file_stripe_unit(struct ceph_mount_info *cmount, int fh) if (!cmount->is_mounted()) return -ENOTCONN; - r = cmount->get_client()->describe_layout(fh, &l); + r = cmount->get_client()->fdescribe_layout(fh, &l); if (r < 0) return r; return l.fl_stripe_unit; @@ -735,7 +735,7 @@ extern "C" int ceph_get_file_pool(struct ceph_mount_info *cmount, int fh) if (!cmount->is_mounted()) return -ENOTCONN; - r = cmount->get_client()->describe_layout(fh, &l); + r = cmount->get_client()->fdescribe_layout(fh, &l); if (r < 0) return r; return l.fl_pg_pool; @@ -748,7 +748,7 @@ extern "C" int ceph_get_file_pool_name(struct ceph_mount_info *cmount, int fh, c if (!cmount->is_mounted()) return -ENOTCONN; - r = cmount->get_client()->describe_layout(fh, &l); + r = cmount->get_client()->fdescribe_layout(fh, &l); if (r < 0) return r; string name = cmount->get_client()->get_pool_name(l.fl_pg_pool); @@ -767,7 +767,7 @@ extern "C" int ceph_get_file_replication(struct ceph_mount_info *cmount, int fh) if (!cmount->is_mounted()) return -ENOTCONN; - r = cmount->get_client()->describe_layout(fh, &l); + r = cmount->get_client()->fdescribe_layout(fh, &l); if (r < 0) return r; int rep = cmount->get_client()->get_pool_replication(l.fl_pg_pool);