4 #include <linux/slab.h>
5 #include <asm/unaligned.h>
51 static int ceph_encode_fh(
struct inode *
inode,
u32 *rawfh,
int *max_len,
52 struct inode *parent_inode)
57 int connected_handle_length =
sizeof(*cfh)/4;
58 int handle_length =
sizeof(*fh)/4;
67 if (*max_len >= connected_handle_length && dentry) {
68 dout(
"encode_fh %p connectable\n", dentry);
69 spin_lock(&dentry->
d_lock);
71 cfh->
ino = ceph_ino(inode);
75 *max_len = connected_handle_length;
77 spin_unlock(&dentry->
d_lock);
78 }
else if (*max_len >= handle_length) {
81 *max_len = connected_handle_length;
84 dout(
"encode_fh %p\n", dentry);
85 fh->
ino = ceph_ino(inode);
86 *max_len = handle_length;
90 *max_len = handle_length;
112 if (fh_len <
sizeof(*fh) / 4)
115 dout(
"__fh_to_dentry %llx\n", fh->
ino);
118 inode = ceph_find_inode(sb, vino);
125 return ERR_CAST(req);
133 ceph_mdsc_put_request(req);
139 if (IS_ERR(dentry)) {
140 pr_err(
"fh_to_dentry %llx -- inode %p but ENOMEM\n",
150 dout(
"__fh_to_dentry %llx %p dentry %p\n", fh->
ino, inode, dentry);
157 static struct dentry *__cfh_to_dentry(
struct super_block *sb,
162 struct dentry *dentry;
166 if (fh_len <
sizeof(*cfh) / 4)
169 dout(
"__cfh_to_dentry %llx (%llx/%x)\n",
174 inode = ceph_find_inode(sb, vino);
181 return ERR_CAST(req);
193 ceph_mdsc_put_request(req);
195 return ERR_PTR(err ? err : -
ESTALE);
199 if (IS_ERR(dentry)) {
200 pr_err(
"cfh_to_dentry %llx -- inode %p but ENOMEM\n",
210 dout(
"__cfh_to_dentry %llx %p dentry %p\n", cfh->
ino, inode, dentry);
215 int fh_len,
int fh_type)
231 static struct dentry *ceph_fh_to_parent(
struct super_block *sb,
233 int fh_len,
int fh_type)
238 struct dentry *dentry;
243 if (fh_len <
sizeof(*cfh) / 4)
251 inode = ceph_find_inode(sb, vino);
256 if (IS_ERR(dentry)) {
257 pr_err(
"fh_to_parent %llx -- inode %p but ENOMEM\n",
267 dout(
"fh_to_parent %llx %p dentry %p\n", cfh->
ino, inode, dentry);
272 .encode_fh = ceph_encode_fh,
273 .fh_to_dentry = ceph_fh_to_dentry,
274 .fh_to_parent = ceph_fh_to_parent,