aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ocfs2/export.c65
1 files changed, 24 insertions, 41 deletions
diff --git a/fs/ocfs2/export.c b/fs/ocfs2/export.c
index c3bbc198f9ce..3ad83e34dd39 100644
--- a/fs/ocfs2/export.c
+++ b/fs/ocfs2/export.c
@@ -45,9 +45,9 @@ struct ocfs2_inode_handle
45 u32 ih_generation; 45 u32 ih_generation;
46}; 46};
47 47
48static struct dentry *ocfs2_get_dentry(struct super_block *sb, void *vobjp) 48static struct dentry *ocfs2_get_dentry(struct super_block *sb,
49 struct ocfs2_inode_handle *handle)
49{ 50{
50 struct ocfs2_inode_handle *handle = vobjp;
51 struct inode *inode; 51 struct inode *inode;
52 struct dentry *result; 52 struct dentry *result;
53 53
@@ -194,54 +194,37 @@ bail:
194 return type; 194 return type;
195} 195}
196 196
197static struct dentry *ocfs2_decode_fh(struct super_block *sb, u32 *fh_in, 197static struct dentry *ocfs2_fh_to_dentry(struct super_block *sb,
198 int fh_len, int fileid_type, 198 struct fid *fid, int fh_len, int fh_type)
199 int (*acceptable)(void *context,
200 struct dentry *de),
201 void *context)
202{ 199{
203 struct ocfs2_inode_handle handle, parent; 200 struct ocfs2_inode_handle handle;
204 struct dentry *ret = NULL;
205 __le32 *fh = (__force __le32 *) fh_in;
206
207 mlog_entry("(0x%p, 0x%p, %d, %d, 0x%p, 0x%p)\n",
208 sb, fh, fh_len, fileid_type, acceptable, context);
209
210 if (fh_len < 3 || fileid_type > 2)
211 goto bail;
212
213 if (fileid_type == 2) {
214 if (fh_len < 6)
215 goto bail;
216
217 parent.ih_blkno = (u64)le32_to_cpu(fh[3]) << 32;
218 parent.ih_blkno |= (u64)le32_to_cpu(fh[4]);
219 parent.ih_generation = le32_to_cpu(fh[5]);
220 201
221 mlog(0, "Decoding parent: blkno: %llu, generation: %u\n", 202 if (fh_len < 3 || fh_type > 2)
222 (unsigned long long)parent.ih_blkno, 203 return NULL;
223 parent.ih_generation);
224 }
225 204
226 handle.ih_blkno = (u64)le32_to_cpu(fh[0]) << 32; 205 handle.ih_blkno = (u64)le32_to_cpu(fid->raw[0]) << 32;
227 handle.ih_blkno |= (u64)le32_to_cpu(fh[1]); 206 handle.ih_blkno |= (u64)le32_to_cpu(fid->raw[1]);
228 handle.ih_generation = le32_to_cpu(fh[2]); 207 handle.ih_generation = le32_to_cpu(fid->raw[2]);
208 return ocfs2_get_dentry(sb, &handle);
209}
229 210
230 mlog(0, "Encoding fh: blkno: %llu, generation: %u\n", 211static struct dentry *ocfs2_fh_to_parent(struct super_block *sb,
231 (unsigned long long)handle.ih_blkno, handle.ih_generation); 212 struct fid *fid, int fh_len, int fh_type)
213{
214 struct ocfs2_inode_handle parent;
232 215
233 ret = ocfs2_export_ops.find_exported_dentry(sb, &handle, &parent, 216 if (fh_type != 2 || fh_len < 6)
234 acceptable, context); 217 return NULL;
235 218
236bail: 219 parent.ih_blkno = (u64)le32_to_cpu(fid->raw[3]) << 32;
237 mlog_exit_ptr(ret); 220 parent.ih_blkno |= (u64)le32_to_cpu(fid->raw[4]);
238 return ret; 221 parent.ih_generation = le32_to_cpu(fid->raw[5]);
222 return ocfs2_get_dentry(sb, &parent);
239} 223}
240 224
241struct export_operations ocfs2_export_ops = { 225struct export_operations ocfs2_export_ops = {
242 .decode_fh = ocfs2_decode_fh,
243 .encode_fh = ocfs2_encode_fh, 226 .encode_fh = ocfs2_encode_fh,
244 227 .fh_to_dentry = ocfs2_fh_to_dentry,
228 .fh_to_parent = ocfs2_fh_to_parent,
245 .get_parent = ocfs2_get_parent, 229 .get_parent = ocfs2_get_parent,
246 .get_dentry = ocfs2_get_dentry,
247}; 230};