aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2007-10-21 19:42:14 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-22 11:13:20 -0400
commit34c0d154243dd913c5690ae6ceb9557017429b9c (patch)
tree8e795b5d0e0833010fe3be8cf4754f864b2d07cb /fs
parentbe55caf177e14bc54d1498d599a78849b0b230bb (diff)
gfs2: new export ops
Convert gfs2 to the new ops. Uses a similar structure to the generic helpers, but gfs2 has it's own file handle formats. Signed-off-by: Christoph Hellwig <hch@lst.de> Cc: Neil Brown <neilb@suse.de> Cc: "J. Bruce Fields" <bfields@fieldses.org> Cc: Steven Whitehouse <swhiteho@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/gfs2/ops_export.c81
1 files changed, 43 insertions, 38 deletions
diff --git a/fs/gfs2/ops_export.c b/fs/gfs2/ops_export.c
index e2d1347796a9..c291005ec592 100644
--- a/fs/gfs2/ops_export.c
+++ b/fs/gfs2/ops_export.c
@@ -31,40 +31,6 @@
31#define GFS2_LARGE_FH_SIZE 8 31#define GFS2_LARGE_FH_SIZE 8
32#define GFS2_OLD_FH_SIZE 10 32#define GFS2_OLD_FH_SIZE 10
33 33
34static struct dentry *gfs2_decode_fh(struct super_block *sb,
35 __u32 *p,
36 int fh_len,
37 int fh_type,
38 int (*acceptable)(void *context,
39 struct dentry *dentry),
40 void *context)
41{
42 __be32 *fh = (__force __be32 *)p;
43 struct gfs2_inum_host inum, parent;
44
45 memset(&parent, 0, sizeof(struct gfs2_inum));
46
47 switch (fh_len) {
48 case GFS2_LARGE_FH_SIZE:
49 case GFS2_OLD_FH_SIZE:
50 parent.no_formal_ino = ((u64)be32_to_cpu(fh[4])) << 32;
51 parent.no_formal_ino |= be32_to_cpu(fh[5]);
52 parent.no_addr = ((u64)be32_to_cpu(fh[6])) << 32;
53 parent.no_addr |= be32_to_cpu(fh[7]);
54 case GFS2_SMALL_FH_SIZE:
55 inum.no_formal_ino = ((u64)be32_to_cpu(fh[0])) << 32;
56 inum.no_formal_ino |= be32_to_cpu(fh[1]);
57 inum.no_addr = ((u64)be32_to_cpu(fh[2])) << 32;
58 inum.no_addr |= be32_to_cpu(fh[3]);
59 break;
60 default:
61 return NULL;
62 }
63
64 return gfs2_export_ops.find_exported_dentry(sb, &inum, &parent,
65 acceptable, context);
66}
67
68static int gfs2_encode_fh(struct dentry *dentry, __u32 *p, int *len, 34static int gfs2_encode_fh(struct dentry *dentry, __u32 *p, int *len,
69 int connectable) 35 int connectable)
70{ 36{
@@ -189,10 +155,10 @@ static struct dentry *gfs2_get_parent(struct dentry *child)
189 return dentry; 155 return dentry;
190} 156}
191 157
192static struct dentry *gfs2_get_dentry(struct super_block *sb, void *inum_obj) 158static struct dentry *gfs2_get_dentry(struct super_block *sb,
159 struct gfs2_inum_host *inum)
193{ 160{
194 struct gfs2_sbd *sdp = sb->s_fs_info; 161 struct gfs2_sbd *sdp = sb->s_fs_info;
195 struct gfs2_inum_host *inum = inum_obj;
196 struct gfs2_holder i_gh, ri_gh, rgd_gh; 162 struct gfs2_holder i_gh, ri_gh, rgd_gh;
197 struct gfs2_rgrpd *rgd; 163 struct gfs2_rgrpd *rgd;
198 struct inode *inode; 164 struct inode *inode;
@@ -289,11 +255,50 @@ fail:
289 return ERR_PTR(error); 255 return ERR_PTR(error);
290} 256}
291 257
258static struct dentry *gfs2_fh_to_dentry(struct super_block *sb, struct fid *fid,
259 int fh_len, int fh_type)
260{
261 struct gfs2_inum_host this;
262 __be32 *fh = (__force __be32 *)fid->raw;
263
264 switch (fh_type) {
265 case GFS2_SMALL_FH_SIZE:
266 case GFS2_LARGE_FH_SIZE:
267 case GFS2_OLD_FH_SIZE:
268 this.no_formal_ino = ((u64)be32_to_cpu(fh[0])) << 32;
269 this.no_formal_ino |= be32_to_cpu(fh[1]);
270 this.no_addr = ((u64)be32_to_cpu(fh[2])) << 32;
271 this.no_addr |= be32_to_cpu(fh[3]);
272 return gfs2_get_dentry(sb, &this);
273 default:
274 return NULL;
275 }
276}
277
278static struct dentry *gfs2_fh_to_parent(struct super_block *sb, struct fid *fid,
279 int fh_len, int fh_type)
280{
281 struct gfs2_inum_host parent;
282 __be32 *fh = (__force __be32 *)fid->raw;
283
284 switch (fh_type) {
285 case GFS2_LARGE_FH_SIZE:
286 case GFS2_OLD_FH_SIZE:
287 parent.no_formal_ino = ((u64)be32_to_cpu(fh[4])) << 32;
288 parent.no_formal_ino |= be32_to_cpu(fh[5]);
289 parent.no_addr = ((u64)be32_to_cpu(fh[6])) << 32;
290 parent.no_addr |= be32_to_cpu(fh[7]);
291 return gfs2_get_dentry(sb, &parent);
292 default:
293 return NULL;
294 }
295}
296
292struct export_operations gfs2_export_ops = { 297struct export_operations gfs2_export_ops = {
293 .decode_fh = gfs2_decode_fh,
294 .encode_fh = gfs2_encode_fh, 298 .encode_fh = gfs2_encode_fh,
299 .fh_to_dentry = gfs2_fh_to_dentry,
300 .fh_to_parent = gfs2_fh_to_parent,
295 .get_name = gfs2_get_name, 301 .get_name = gfs2_get_name,
296 .get_parent = gfs2_get_parent, 302 .get_parent = gfs2_get_parent,
297 .get_dentry = gfs2_get_dentry,
298}; 303};
299 304