diff options
Diffstat (limited to 'fs/ceph/export.c')
-rw-r--r-- | fs/ceph/export.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/fs/ceph/export.c b/fs/ceph/export.c index 4480cb1c63e7..2297d9426992 100644 --- a/fs/ceph/export.c +++ b/fs/ceph/export.c | |||
@@ -1,10 +1,11 @@ | |||
1 | #include "ceph_debug.h" | 1 | #include <linux/ceph/ceph_debug.h> |
2 | 2 | ||
3 | #include <linux/exportfs.h> | 3 | #include <linux/exportfs.h> |
4 | #include <linux/slab.h> | 4 | #include <linux/slab.h> |
5 | #include <asm/unaligned.h> | 5 | #include <asm/unaligned.h> |
6 | 6 | ||
7 | #include "super.h" | 7 | #include "super.h" |
8 | #include "mds_client.h" | ||
8 | 9 | ||
9 | /* | 10 | /* |
10 | * NFS export support | 11 | * NFS export support |
@@ -42,32 +43,37 @@ struct ceph_nfs_confh { | |||
42 | static int ceph_encode_fh(struct dentry *dentry, u32 *rawfh, int *max_len, | 43 | static int ceph_encode_fh(struct dentry *dentry, u32 *rawfh, int *max_len, |
43 | int connectable) | 44 | int connectable) |
44 | { | 45 | { |
46 | int type; | ||
45 | struct ceph_nfs_fh *fh = (void *)rawfh; | 47 | struct ceph_nfs_fh *fh = (void *)rawfh; |
46 | struct ceph_nfs_confh *cfh = (void *)rawfh; | 48 | struct ceph_nfs_confh *cfh = (void *)rawfh; |
47 | struct dentry *parent = dentry->d_parent; | 49 | struct dentry *parent = dentry->d_parent; |
48 | struct inode *inode = dentry->d_inode; | 50 | struct inode *inode = dentry->d_inode; |
49 | int type; | 51 | int connected_handle_length = sizeof(*cfh)/4; |
52 | int handle_length = sizeof(*fh)/4; | ||
50 | 53 | ||
51 | /* don't re-export snaps */ | 54 | /* don't re-export snaps */ |
52 | if (ceph_snap(inode) != CEPH_NOSNAP) | 55 | if (ceph_snap(inode) != CEPH_NOSNAP) |
53 | return -EINVAL; | 56 | return -EINVAL; |
54 | 57 | ||
55 | if (*max_len >= sizeof(*cfh)) { | 58 | if (*max_len >= connected_handle_length) { |
56 | dout("encode_fh %p connectable\n", dentry); | 59 | dout("encode_fh %p connectable\n", dentry); |
57 | cfh->ino = ceph_ino(dentry->d_inode); | 60 | cfh->ino = ceph_ino(dentry->d_inode); |
58 | cfh->parent_ino = ceph_ino(parent->d_inode); | 61 | cfh->parent_ino = ceph_ino(parent->d_inode); |
59 | cfh->parent_name_hash = parent->d_name.hash; | 62 | cfh->parent_name_hash = parent->d_name.hash; |
60 | *max_len = sizeof(*cfh); | 63 | *max_len = connected_handle_length; |
61 | type = 2; | 64 | type = 2; |
62 | } else if (*max_len > sizeof(*fh)) { | 65 | } else if (*max_len >= handle_length) { |
63 | if (connectable) | 66 | if (connectable) { |
64 | return -ENOSPC; | 67 | *max_len = connected_handle_length; |
68 | return 255; | ||
69 | } | ||
65 | dout("encode_fh %p\n", dentry); | 70 | dout("encode_fh %p\n", dentry); |
66 | fh->ino = ceph_ino(dentry->d_inode); | 71 | fh->ino = ceph_ino(dentry->d_inode); |
67 | *max_len = sizeof(*fh); | 72 | *max_len = handle_length; |
68 | type = 1; | 73 | type = 1; |
69 | } else { | 74 | } else { |
70 | return -ENOSPC; | 75 | *max_len = handle_length; |
76 | return 255; | ||
71 | } | 77 | } |
72 | return type; | 78 | return type; |
73 | } | 79 | } |
@@ -115,7 +121,7 @@ static struct dentry *__fh_to_dentry(struct super_block *sb, | |||
115 | static struct dentry *__cfh_to_dentry(struct super_block *sb, | 121 | static struct dentry *__cfh_to_dentry(struct super_block *sb, |
116 | struct ceph_nfs_confh *cfh) | 122 | struct ceph_nfs_confh *cfh) |
117 | { | 123 | { |
118 | struct ceph_mds_client *mdsc = &ceph_sb_to_client(sb)->mdsc; | 124 | struct ceph_mds_client *mdsc = ceph_sb_to_client(sb)->mdsc; |
119 | struct inode *inode; | 125 | struct inode *inode; |
120 | struct dentry *dentry; | 126 | struct dentry *dentry; |
121 | struct ceph_vino vino; | 127 | struct ceph_vino vino; |