diff options
author | Alex Elder <elder@inktank.com> | 2012-05-16 16:16:38 -0400 |
---|---|---|
committer | Alex Elder <elder@dreamhost.com> | 2012-05-17 09:18:12 -0400 |
commit | 6c4a19158b96ea1fb8acbe0c1d5493d9dcd2f147 (patch) | |
tree | 5fe6418eb57bf4e84f1eda9606a4a045ff08dcba | |
parent | ed96af646011412c2bf1ffe860db170db355fae5 (diff) |
ceph: define ceph_auth_handshake type
The definitions for the ceph_mds_session and ceph_osd both contain
five fields related only to "authorizers." Encapsulate those fields
into their own struct type, allowing for better isolation in some
upcoming patches.
Fix the #includes in "linux/ceph/osd_client.h" to lay out their more
complete canonical path.
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
-rw-r--r-- | fs/ceph/mds_client.c | 32 | ||||
-rw-r--r-- | fs/ceph/mds_client.h | 5 | ||||
-rw-r--r-- | include/linux/ceph/auth.h | 8 | ||||
-rw-r--r-- | include/linux/ceph/osd_client.h | 11 | ||||
-rw-r--r-- | net/ceph/osd_client.c | 32 |
5 files changed, 47 insertions, 41 deletions
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 89971e137aab..42013c620488 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c | |||
@@ -334,10 +334,10 @@ void ceph_put_mds_session(struct ceph_mds_session *s) | |||
334 | dout("mdsc put_session %p %d -> %d\n", s, | 334 | dout("mdsc put_session %p %d -> %d\n", s, |
335 | atomic_read(&s->s_ref), atomic_read(&s->s_ref)-1); | 335 | atomic_read(&s->s_ref), atomic_read(&s->s_ref)-1); |
336 | if (atomic_dec_and_test(&s->s_ref)) { | 336 | if (atomic_dec_and_test(&s->s_ref)) { |
337 | if (s->s_authorizer) | 337 | if (s->s_auth.authorizer) |
338 | s->s_mdsc->fsc->client->monc.auth->ops->destroy_authorizer( | 338 | s->s_mdsc->fsc->client->monc.auth->ops->destroy_authorizer( |
339 | s->s_mdsc->fsc->client->monc.auth, | 339 | s->s_mdsc->fsc->client->monc.auth, |
340 | s->s_authorizer); | 340 | s->s_auth.authorizer); |
341 | kfree(s); | 341 | kfree(s); |
342 | } | 342 | } |
343 | } | 343 | } |
@@ -3404,29 +3404,29 @@ static int get_authorizer(struct ceph_connection *con, | |||
3404 | struct ceph_auth_client *ac = mdsc->fsc->client->monc.auth; | 3404 | struct ceph_auth_client *ac = mdsc->fsc->client->monc.auth; |
3405 | int ret = 0; | 3405 | int ret = 0; |
3406 | 3406 | ||
3407 | if (force_new && s->s_authorizer) { | 3407 | if (force_new && s->s_auth.authorizer) { |
3408 | ac->ops->destroy_authorizer(ac, s->s_authorizer); | 3408 | ac->ops->destroy_authorizer(ac, s->s_auth.authorizer); |
3409 | s->s_authorizer = NULL; | 3409 | s->s_auth.authorizer = NULL; |
3410 | } | 3410 | } |
3411 | if (s->s_authorizer == NULL) { | 3411 | if (s->s_auth.authorizer == NULL) { |
3412 | if (ac->ops->create_authorizer) { | 3412 | if (ac->ops->create_authorizer) { |
3413 | ret = ac->ops->create_authorizer( | 3413 | ret = ac->ops->create_authorizer( |
3414 | ac, CEPH_ENTITY_TYPE_MDS, | 3414 | ac, CEPH_ENTITY_TYPE_MDS, |
3415 | &s->s_authorizer, | 3415 | &s->s_auth.authorizer, |
3416 | &s->s_authorizer_buf, | 3416 | &s->s_auth.authorizer_buf, |
3417 | &s->s_authorizer_buf_len, | 3417 | &s->s_auth.authorizer_buf_len, |
3418 | &s->s_authorizer_reply_buf, | 3418 | &s->s_auth.authorizer_reply_buf, |
3419 | &s->s_authorizer_reply_buf_len); | 3419 | &s->s_auth.authorizer_reply_buf_len); |
3420 | if (ret) | 3420 | if (ret) |
3421 | return ret; | 3421 | return ret; |
3422 | } | 3422 | } |
3423 | } | 3423 | } |
3424 | 3424 | ||
3425 | *proto = ac->protocol; | 3425 | *proto = ac->protocol; |
3426 | *buf = s->s_authorizer_buf; | 3426 | *buf = s->s_auth.authorizer_buf; |
3427 | *len = s->s_authorizer_buf_len; | 3427 | *len = s->s_auth.authorizer_buf_len; |
3428 | *reply_buf = s->s_authorizer_reply_buf; | 3428 | *reply_buf = s->s_auth.authorizer_reply_buf; |
3429 | *reply_len = s->s_authorizer_reply_buf_len; | 3429 | *reply_len = s->s_auth.authorizer_reply_buf_len; |
3430 | return 0; | 3430 | return 0; |
3431 | } | 3431 | } |
3432 | 3432 | ||
@@ -3437,7 +3437,7 @@ static int verify_authorizer_reply(struct ceph_connection *con, int len) | |||
3437 | struct ceph_mds_client *mdsc = s->s_mdsc; | 3437 | struct ceph_mds_client *mdsc = s->s_mdsc; |
3438 | struct ceph_auth_client *ac = mdsc->fsc->client->monc.auth; | 3438 | struct ceph_auth_client *ac = mdsc->fsc->client->monc.auth; |
3439 | 3439 | ||
3440 | return ac->ops->verify_authorizer_reply(ac, s->s_authorizer, len); | 3440 | return ac->ops->verify_authorizer_reply(ac, s->s_auth.authorizer, len); |
3441 | } | 3441 | } |
3442 | 3442 | ||
3443 | static int invalidate_authorizer(struct ceph_connection *con) | 3443 | static int invalidate_authorizer(struct ceph_connection *con) |
diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h index 8c7c04ebb595..dd26846dd71d 100644 --- a/fs/ceph/mds_client.h +++ b/fs/ceph/mds_client.h | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/ceph/types.h> | 11 | #include <linux/ceph/types.h> |
12 | #include <linux/ceph/messenger.h> | 12 | #include <linux/ceph/messenger.h> |
13 | #include <linux/ceph/mdsmap.h> | 13 | #include <linux/ceph/mdsmap.h> |
14 | #include <linux/ceph/auth.h> | ||
14 | 15 | ||
15 | /* | 16 | /* |
16 | * Some lock dependencies: | 17 | * Some lock dependencies: |
@@ -113,9 +114,7 @@ struct ceph_mds_session { | |||
113 | 114 | ||
114 | struct ceph_connection s_con; | 115 | struct ceph_connection s_con; |
115 | 116 | ||
116 | struct ceph_authorizer *s_authorizer; | 117 | struct ceph_auth_handshake s_auth; |
117 | void *s_authorizer_buf, *s_authorizer_reply_buf; | ||
118 | size_t s_authorizer_buf_len, s_authorizer_reply_buf_len; | ||
119 | 118 | ||
120 | /* protected by s_gen_ttl_lock */ | 119 | /* protected by s_gen_ttl_lock */ |
121 | spinlock_t s_gen_ttl_lock; | 120 | spinlock_t s_gen_ttl_lock; |
diff --git a/include/linux/ceph/auth.h b/include/linux/ceph/auth.h index aa13392a7efb..5b774d141e09 100644 --- a/include/linux/ceph/auth.h +++ b/include/linux/ceph/auth.h | |||
@@ -14,6 +14,14 @@ | |||
14 | struct ceph_auth_client; | 14 | struct ceph_auth_client; |
15 | struct ceph_authorizer; | 15 | struct ceph_authorizer; |
16 | 16 | ||
17 | struct ceph_auth_handshake { | ||
18 | struct ceph_authorizer *authorizer; | ||
19 | void *authorizer_buf; | ||
20 | size_t authorizer_buf_len; | ||
21 | void *authorizer_reply_buf; | ||
22 | size_t authorizer_reply_buf_len; | ||
23 | }; | ||
24 | |||
17 | struct ceph_auth_client_ops { | 25 | struct ceph_auth_client_ops { |
18 | const char *name; | 26 | const char *name; |
19 | 27 | ||
diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h index 7c05ac202d90..cedfb1a8434a 100644 --- a/include/linux/ceph/osd_client.h +++ b/include/linux/ceph/osd_client.h | |||
@@ -6,9 +6,10 @@ | |||
6 | #include <linux/mempool.h> | 6 | #include <linux/mempool.h> |
7 | #include <linux/rbtree.h> | 7 | #include <linux/rbtree.h> |
8 | 8 | ||
9 | #include "types.h" | 9 | #include <linux/ceph/types.h> |
10 | #include "osdmap.h" | 10 | #include <linux/ceph/osdmap.h> |
11 | #include "messenger.h" | 11 | #include <linux/ceph/messenger.h> |
12 | #include <linux/ceph/auth.h> | ||
12 | 13 | ||
13 | /* | 14 | /* |
14 | * Maximum object name size | 15 | * Maximum object name size |
@@ -40,9 +41,7 @@ struct ceph_osd { | |||
40 | struct list_head o_requests; | 41 | struct list_head o_requests; |
41 | struct list_head o_linger_requests; | 42 | struct list_head o_linger_requests; |
42 | struct list_head o_osd_lru; | 43 | struct list_head o_osd_lru; |
43 | struct ceph_authorizer *o_authorizer; | 44 | struct ceph_auth_handshake o_auth; |
44 | void *o_authorizer_buf, *o_authorizer_reply_buf; | ||
45 | size_t o_authorizer_buf_len, o_authorizer_reply_buf_len; | ||
46 | unsigned long lru_ttl; | 45 | unsigned long lru_ttl; |
47 | int o_marked_for_keepalive; | 46 | int o_marked_for_keepalive; |
48 | struct list_head o_keepalive_item; | 47 | struct list_head o_keepalive_item; |
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index daa2716a0c30..66b09d6a1531 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c | |||
@@ -667,8 +667,8 @@ static void put_osd(struct ceph_osd *osd) | |||
667 | if (atomic_dec_and_test(&osd->o_ref)) { | 667 | if (atomic_dec_and_test(&osd->o_ref)) { |
668 | struct ceph_auth_client *ac = osd->o_osdc->client->monc.auth; | 668 | struct ceph_auth_client *ac = osd->o_osdc->client->monc.auth; |
669 | 669 | ||
670 | if (osd->o_authorizer) | 670 | if (osd->o_auth.authorizer) |
671 | ac->ops->destroy_authorizer(ac, osd->o_authorizer); | 671 | ac->ops->destroy_authorizer(ac, osd->o_auth.authorizer); |
672 | kfree(osd); | 672 | kfree(osd); |
673 | } | 673 | } |
674 | } | 674 | } |
@@ -2117,27 +2117,27 @@ static int get_authorizer(struct ceph_connection *con, | |||
2117 | struct ceph_auth_client *ac = osdc->client->monc.auth; | 2117 | struct ceph_auth_client *ac = osdc->client->monc.auth; |
2118 | int ret = 0; | 2118 | int ret = 0; |
2119 | 2119 | ||
2120 | if (force_new && o->o_authorizer) { | 2120 | if (force_new && o->o_auth.authorizer) { |
2121 | ac->ops->destroy_authorizer(ac, o->o_authorizer); | 2121 | ac->ops->destroy_authorizer(ac, o->o_auth.authorizer); |
2122 | o->o_authorizer = NULL; | 2122 | o->o_auth.authorizer = NULL; |
2123 | } | 2123 | } |
2124 | if (o->o_authorizer == NULL) { | 2124 | if (o->o_auth.authorizer == NULL) { |
2125 | ret = ac->ops->create_authorizer( | 2125 | ret = ac->ops->create_authorizer( |
2126 | ac, CEPH_ENTITY_TYPE_OSD, | 2126 | ac, CEPH_ENTITY_TYPE_OSD, |
2127 | &o->o_authorizer, | 2127 | &o->o_auth.authorizer, |
2128 | &o->o_authorizer_buf, | 2128 | &o->o_auth.authorizer_buf, |
2129 | &o->o_authorizer_buf_len, | 2129 | &o->o_auth.authorizer_buf_len, |
2130 | &o->o_authorizer_reply_buf, | 2130 | &o->o_auth.authorizer_reply_buf, |
2131 | &o->o_authorizer_reply_buf_len); | 2131 | &o->o_auth.authorizer_reply_buf_len); |
2132 | if (ret) | 2132 | if (ret) |
2133 | return ret; | 2133 | return ret; |
2134 | } | 2134 | } |
2135 | 2135 | ||
2136 | *proto = ac->protocol; | 2136 | *proto = ac->protocol; |
2137 | *buf = o->o_authorizer_buf; | 2137 | *buf = o->o_auth.authorizer_buf; |
2138 | *len = o->o_authorizer_buf_len; | 2138 | *len = o->o_auth.authorizer_buf_len; |
2139 | *reply_buf = o->o_authorizer_reply_buf; | 2139 | *reply_buf = o->o_auth.authorizer_reply_buf; |
2140 | *reply_len = o->o_authorizer_reply_buf_len; | 2140 | *reply_len = o->o_auth.authorizer_reply_buf_len; |
2141 | return 0; | 2141 | return 0; |
2142 | } | 2142 | } |
2143 | 2143 | ||
@@ -2148,7 +2148,7 @@ static int verify_authorizer_reply(struct ceph_connection *con, int len) | |||
2148 | struct ceph_osd_client *osdc = o->o_osdc; | 2148 | struct ceph_osd_client *osdc = o->o_osdc; |
2149 | struct ceph_auth_client *ac = osdc->client->monc.auth; | 2149 | struct ceph_auth_client *ac = osdc->client->monc.auth; |
2150 | 2150 | ||
2151 | return ac->ops->verify_authorizer_reply(ac, o->o_authorizer, len); | 2151 | return ac->ops->verify_authorizer_reply(ac, o->o_auth.authorizer, len); |
2152 | } | 2152 | } |
2153 | 2153 | ||
2154 | static int invalidate_authorizer(struct ceph_connection *con) | 2154 | static int invalidate_authorizer(struct ceph_connection *con) |