aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph/export.c
diff options
context:
space:
mode:
authorYan, Zheng <zheng.z.yan@intel.com>2014-03-06 03:40:32 -0500
committerYan, Zheng <zheng.z.yan@intel.com>2014-04-02 22:33:53 -0400
commit19913b4eac4a230dccb548931358398f45dabe4c (patch)
treeba858471538ae0b32fe42ab1c73bdaf559bbf2fd /fs/ceph/export.c
parent8996f4f23db735f0f3bab34352188b1ab21d7d7f (diff)
ceph: add get_name() NFS export callback
Use the newly introduced LOOKUPNAME MDS request to connect child inode to its parent directory. Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com> Reviewed-by: Sage Weil <sage@inktank.com>
Diffstat (limited to 'fs/ceph/export.c')
-rw-r--r--fs/ceph/export.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/fs/ceph/export.c b/fs/ceph/export.c
index eb66408ff236..00d6af6a32ec 100644
--- a/fs/ceph/export.c
+++ b/fs/ceph/export.c
@@ -202,9 +202,49 @@ static struct dentry *ceph_fh_to_parent(struct super_block *sb,
202 return dentry; 202 return dentry;
203} 203}
204 204
205static int ceph_get_name(struct dentry *parent, char *name,
206 struct dentry *child)
207{
208 struct ceph_mds_client *mdsc;
209 struct ceph_mds_request *req;
210 int err;
211
212 mdsc = ceph_inode_to_client(child->d_inode)->mdsc;
213 req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_LOOKUPNAME,
214 USE_ANY_MDS);
215 if (IS_ERR(req))
216 return PTR_ERR(req);
217
218 mutex_lock(&parent->d_inode->i_mutex);
219
220 req->r_inode = child->d_inode;
221 ihold(child->d_inode);
222 req->r_ino2 = ceph_vino(parent->d_inode);
223 req->r_locked_dir = parent->d_inode;
224 req->r_num_caps = 2;
225 err = ceph_mdsc_do_request(mdsc, NULL, req);
226
227 mutex_unlock(&parent->d_inode->i_mutex);
228
229 if (!err) {
230 struct ceph_mds_reply_info_parsed *rinfo = &req->r_reply_info;
231 memcpy(name, rinfo->dname, rinfo->dname_len);
232 name[rinfo->dname_len] = 0;
233 dout("get_name %p ino %llx.%llx name %s\n",
234 child, ceph_vinop(child->d_inode), name);
235 } else {
236 dout("get_name %p ino %llx.%llx err %d\n",
237 child, ceph_vinop(child->d_inode), err);
238 }
239
240 ceph_mdsc_put_request(req);
241 return err;
242}
243
205const struct export_operations ceph_export_ops = { 244const struct export_operations ceph_export_ops = {
206 .encode_fh = ceph_encode_fh, 245 .encode_fh = ceph_encode_fh,
207 .fh_to_dentry = ceph_fh_to_dentry, 246 .fh_to_dentry = ceph_fh_to_dentry,
208 .fh_to_parent = ceph_fh_to_parent, 247 .fh_to_parent = ceph_fh_to_parent,
209 .get_parent = ceph_get_parent, 248 .get_parent = ceph_get_parent,
249 .get_name = ceph_get_name,
210}; 250};