diff options
author | Sage Weil <sage@newdream.net> | 2012-04-05 15:07:36 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-05-29 23:28:33 -0400 |
commit | c862868bb455694704c255481369c40d7185eb25 (patch) | |
tree | 6b0f0c0a9b252e1f526742bf7cb777b47320e49a /fs/ceph | |
parent | b0b0382bb4904965a9e9fca77ad87514dfda0d1c (diff) |
ceph: move encode_fh to new API
Use parent_inode has a flag for whether nfsd wants a connectable fh, but
generate one opportunistically so that we can take advantage of the
additional info in there.
Signed-off-by: Sage Weil <sage@newdream.net>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ceph')
-rw-r--r-- | fs/ceph/export.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/fs/ceph/export.c b/fs/ceph/export.c index 4f9234c6da61..8e1b60e557b6 100644 --- a/fs/ceph/export.c +++ b/fs/ceph/export.c | |||
@@ -40,38 +40,49 @@ struct ceph_nfs_confh { | |||
40 | u32 parent_name_hash; | 40 | u32 parent_name_hash; |
41 | } __attribute__ ((packed)); | 41 | } __attribute__ ((packed)); |
42 | 42 | ||
43 | static int ceph_encode_fh(struct dentry *dentry, u32 *rawfh, int *max_len, | 43 | /* |
44 | int connectable) | 44 | * The presence of @parent_inode here tells us whether NFS wants a |
45 | * connectable file handle. However, we want to make a connectionable | ||
46 | * file handle unconditionally so that the MDS gets as much of a hint | ||
47 | * as possible. That means we only use @parent_dentry to indicate | ||
48 | * whether nfsd wants a connectable fh, and whether we should indicate | ||
49 | * failure from a too-small @max_len. | ||
50 | */ | ||
51 | static int ceph_encode_fh(struct inode *inode, u32 *rawfh, int *max_len, | ||
52 | struct inode *parent_inode) | ||
45 | { | 53 | { |
46 | int type; | 54 | int type; |
47 | struct ceph_nfs_fh *fh = (void *)rawfh; | 55 | struct ceph_nfs_fh *fh = (void *)rawfh; |
48 | struct ceph_nfs_confh *cfh = (void *)rawfh; | 56 | struct ceph_nfs_confh *cfh = (void *)rawfh; |
49 | struct dentry *parent; | ||
50 | struct inode *inode = dentry->d_inode; | ||
51 | int connected_handle_length = sizeof(*cfh)/4; | 57 | int connected_handle_length = sizeof(*cfh)/4; |
52 | int handle_length = sizeof(*fh)/4; | 58 | int handle_length = sizeof(*fh)/4; |
59 | struct dentry *dentry = d_find_alias(inode); | ||
60 | struct dentry *parent; | ||
53 | 61 | ||
54 | /* don't re-export snaps */ | 62 | /* don't re-export snaps */ |
55 | if (ceph_snap(inode) != CEPH_NOSNAP) | 63 | if (ceph_snap(inode) != CEPH_NOSNAP) |
56 | return -EINVAL; | 64 | return -EINVAL; |
57 | 65 | ||
58 | spin_lock(&dentry->d_lock); | 66 | /* if we found an alias, generate a connectable fh */ |
59 | parent = dentry->d_parent; | 67 | if (*max_len >= connected_handle_length && dentry) { |
60 | if (*max_len >= connected_handle_length) { | ||
61 | dout("encode_fh %p connectable\n", dentry); | 68 | dout("encode_fh %p connectable\n", dentry); |
62 | cfh->ino = ceph_ino(dentry->d_inode); | 69 | spin_lock(&dentry->d_lock); |
70 | parent = dentry->d_parent; | ||
71 | cfh->ino = ceph_ino(inode); | ||
63 | cfh->parent_ino = ceph_ino(parent->d_inode); | 72 | cfh->parent_ino = ceph_ino(parent->d_inode); |
64 | cfh->parent_name_hash = ceph_dentry_hash(parent->d_inode, | 73 | cfh->parent_name_hash = ceph_dentry_hash(parent->d_inode, |
65 | dentry); | 74 | dentry); |
66 | *max_len = connected_handle_length; | 75 | *max_len = connected_handle_length; |
67 | type = 2; | 76 | type = 2; |
77 | spin_unlock(&dentry->d_lock); | ||
68 | } else if (*max_len >= handle_length) { | 78 | } else if (*max_len >= handle_length) { |
69 | if (connectable) { | 79 | if (parent_inode) { |
80 | /* nfsd wants connectable */ | ||
70 | *max_len = connected_handle_length; | 81 | *max_len = connected_handle_length; |
71 | type = 255; | 82 | type = 255; |
72 | } else { | 83 | } else { |
73 | dout("encode_fh %p\n", dentry); | 84 | dout("encode_fh %p\n", dentry); |
74 | fh->ino = ceph_ino(dentry->d_inode); | 85 | fh->ino = ceph_ino(inode); |
75 | *max_len = handle_length; | 86 | *max_len = handle_length; |
76 | type = 1; | 87 | type = 1; |
77 | } | 88 | } |
@@ -79,7 +90,6 @@ static int ceph_encode_fh(struct dentry *dentry, u32 *rawfh, int *max_len, | |||
79 | *max_len = handle_length; | 90 | *max_len = handle_length; |
80 | type = 255; | 91 | type = 255; |
81 | } | 92 | } |
82 | spin_unlock(&dentry->d_lock); | ||
83 | return type; | 93 | return type; |
84 | } | 94 | } |
85 | 95 | ||
@@ -247,9 +257,7 @@ static struct dentry *ceph_fh_to_parent(struct super_block *sb, | |||
247 | } | 257 | } |
248 | 258 | ||
249 | const struct export_operations ceph_export_ops = { | 259 | const struct export_operations ceph_export_ops = { |
250 | #ifdef CEPH_BREAKAGE_FIXED | ||
251 | .encode_fh = ceph_encode_fh, | 260 | .encode_fh = ceph_encode_fh, |
252 | #endif | ||
253 | .fh_to_dentry = ceph_fh_to_dentry, | 261 | .fh_to_dentry = ceph_fh_to_dentry, |
254 | .fh_to_parent = ceph_fh_to_parent, | 262 | .fh_to_parent = ceph_fh_to_parent, |
255 | }; | 263 | }; |