Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ceph: have get_authorizer methods return pointers

Have the get_authorizer auth_client method return a ceph_auth
pointer rather than an integer, pointer-encoding any returned
error value. This is to pave the way for making use of the
returned value in an upcoming patch.

Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>

authored by

Alex Elder and committed by
Alex Elder
a3530df3 a255651d

+34 -21
+13 -7
fs/ceph/mds_client.c
··· 3395 3395 /* 3396 3396 * authentication 3397 3397 */ 3398 - static int get_authorizer(struct ceph_connection *con, 3399 - void **buf, int *len, int *proto, 3400 - void **reply_buf, int *reply_len, int force_new) 3398 + 3399 + /* 3400 + * Note: returned pointer is the address of a structure that's 3401 + * managed separately. Caller must *not* attempt to free it. 3402 + */ 3403 + static struct ceph_auth_handshake *get_authorizer(struct ceph_connection *con, 3404 + void **buf, int *len, int *proto, 3405 + void **reply_buf, int *reply_len, 3406 + int force_new) 3401 3407 { 3402 3408 struct ceph_mds_session *s = con->private; 3403 3409 struct ceph_mds_client *mdsc = s->s_mdsc; 3404 3410 struct ceph_auth_client *ac = mdsc->fsc->client->monc.auth; 3405 3411 struct ceph_auth_handshake *auth = &s->s_auth; 3406 - int ret = 0; 3407 3412 3408 3413 if (force_new && auth->authorizer) { 3409 3414 if (ac->ops && ac->ops->destroy_authorizer) ··· 3416 3411 auth->authorizer = NULL; 3417 3412 } 3418 3413 if (!auth->authorizer && ac->ops && ac->ops->create_authorizer) { 3419 - ret = ac->ops->create_authorizer(ac, CEPH_ENTITY_TYPE_MDS, auth); 3414 + int ret = ac->ops->create_authorizer(ac, CEPH_ENTITY_TYPE_MDS, 3415 + auth); 3420 3416 if (ret) 3421 - return ret; 3417 + return ERR_PTR(ret); 3422 3418 } 3423 3419 3424 3420 *proto = ac->protocol; ··· 3428 3422 *reply_buf = auth->authorizer_reply_buf; 3429 3423 *reply_len = auth->authorizer_reply_buf_len; 3430 3424 3431 - return 0; 3425 + return auth; 3432 3426 } 3433 3427 3434 3428
+5 -3
include/linux/ceph/messenger.h
··· 25 25 void (*dispatch) (struct ceph_connection *con, struct ceph_msg *m); 26 26 27 27 /* authorize an outgoing connection */ 28 - int (*get_authorizer) (struct ceph_connection *con, 29 - void **buf, int *len, int *proto, 30 - void **reply_buf, int *reply_len, int force_new); 28 + struct ceph_auth_handshake *(*get_authorizer) ( 29 + struct ceph_connection *con, 30 + void **buf, int *len, int *proto, 31 + void **reply_buf, int *reply_len, 32 + int force_new); 31 33 int (*verify_authorizer_reply) (struct ceph_connection *con, int len); 32 34 int (*invalidate_authorizer)(struct ceph_connection *con); 33 35
+4 -4
net/ceph/messenger.c
··· 658 658 void *auth_buf; 659 659 int auth_len; 660 660 int auth_protocol; 661 - int ret; 661 + struct ceph_auth_handshake *auth; 662 662 663 663 if (!con->ops->get_authorizer) { 664 664 con->out_connect.authorizer_protocol = CEPH_AUTH_UNKNOWN; ··· 674 674 auth_buf = NULL; 675 675 auth_len = 0; 676 676 auth_protocol = CEPH_AUTH_UNKNOWN; 677 - ret = con->ops->get_authorizer(con, &auth_buf, &auth_len, 677 + auth = con->ops->get_authorizer(con, &auth_buf, &auth_len, 678 678 &auth_protocol, &con->auth_reply_buf, 679 679 &con->auth_reply_buf_len, con->auth_retry); 680 680 mutex_lock(&con->mutex); 681 681 682 - if (ret) 683 - return ret; 682 + if (IS_ERR(auth)) 683 + return PTR_ERR(auth); 684 684 685 685 if (test_bit(CLOSED, &con->state) || test_bit(OPENING, &con->state)) 686 686 return -EAGAIN;
+12 -7
net/ceph/osd_client.c
··· 2108 2108 /* 2109 2109 * authentication 2110 2110 */ 2111 - static int get_authorizer(struct ceph_connection *con, 2112 - void **buf, int *len, int *proto, 2113 - void **reply_buf, int *reply_len, int force_new) 2111 + /* 2112 + * Note: returned pointer is the address of a structure that's 2113 + * managed separately. Caller must *not* attempt to free it. 2114 + */ 2115 + static struct ceph_auth_handshake *get_authorizer(struct ceph_connection *con, 2116 + void **buf, int *len, int *proto, 2117 + void **reply_buf, int *reply_len, 2118 + int force_new) 2114 2119 { 2115 2120 struct ceph_osd *o = con->private; 2116 2121 struct ceph_osd_client *osdc = o->o_osdc; 2117 2122 struct ceph_auth_client *ac = osdc->client->monc.auth; 2118 2123 struct ceph_auth_handshake *auth = &o->o_auth; 2119 - int ret = 0; 2120 2124 2121 2125 if (force_new && auth->authorizer) { 2122 2126 if (ac->ops && ac->ops->destroy_authorizer) ··· 2128 2124 auth->authorizer = NULL; 2129 2125 } 2130 2126 if (!auth->authorizer && ac->ops && ac->ops->create_authorizer) { 2131 - ret = ac->ops->create_authorizer(ac, CEPH_ENTITY_TYPE_OSD, auth); 2127 + int ret = ac->ops->create_authorizer(ac, CEPH_ENTITY_TYPE_OSD, 2128 + auth); 2132 2129 if (ret) 2133 - return ret; 2130 + return ERR_PTR(ret); 2134 2131 } 2135 2132 2136 2133 *proto = ac->protocol; ··· 2140 2135 *reply_buf = auth->authorizer_reply_buf; 2141 2136 *reply_len = auth->authorizer_reply_buf_len; 2142 2137 2143 - return 0; 2138 + return auth; 2144 2139 } 2145 2140 2146 2141