libceph: wrap auth ops in wrapper functions
Use wrapper functions that check whether the auth op exists so that callers do not need a bunch of conditional checks. Simplifies the external interface. Signed-off-by: Sage Weil <sage@inktank.com> Reviewed-by: Alex Elder <elder@inktank.com>
This commit is contained in:
@@ -666,8 +666,7 @@ static void put_osd(struct ceph_osd *osd)
|
||||
if (atomic_dec_and_test(&osd->o_ref) && osd->o_auth.authorizer) {
|
||||
struct ceph_auth_client *ac = osd->o_osdc->client->monc.auth;
|
||||
|
||||
if (ac->ops && ac->ops->destroy_authorizer)
|
||||
ac->ops->destroy_authorizer(ac, osd->o_auth.authorizer);
|
||||
ceph_auth_destroy_authorizer(ac, osd->o_auth.authorizer);
|
||||
kfree(osd);
|
||||
}
|
||||
}
|
||||
@@ -2211,17 +2210,16 @@ static struct ceph_auth_handshake *get_authorizer(struct ceph_connection *con,
|
||||
struct ceph_auth_handshake *auth = &o->o_auth;
|
||||
|
||||
if (force_new && auth->authorizer) {
|
||||
if (ac->ops && ac->ops->destroy_authorizer)
|
||||
ac->ops->destroy_authorizer(ac, auth->authorizer);
|
||||
ceph_auth_destroy_authorizer(ac, auth->authorizer);
|
||||
auth->authorizer = NULL;
|
||||
}
|
||||
if (!auth->authorizer && ac->ops && ac->ops->create_authorizer) {
|
||||
int ret = ac->ops->create_authorizer(ac, CEPH_ENTITY_TYPE_OSD,
|
||||
auth);
|
||||
if (!auth->authorizer) {
|
||||
int ret = ceph_auth_create_authorizer(ac, CEPH_ENTITY_TYPE_OSD,
|
||||
auth);
|
||||
if (ret)
|
||||
return ERR_PTR(ret);
|
||||
} else if (ac->ops && ac->ops->update_authorizer) {
|
||||
int ret = ac->ops->update_authorizer(ac, CEPH_ENTITY_TYPE_OSD,
|
||||
} else {
|
||||
int ret = ceph_auth_update_authorizer(ac, CEPH_ENTITY_TYPE_OSD,
|
||||
auth);
|
||||
if (ret)
|
||||
return ERR_PTR(ret);
|
||||
@@ -2238,11 +2236,7 @@ static int verify_authorizer_reply(struct ceph_connection *con, int len)
|
||||
struct ceph_osd_client *osdc = o->o_osdc;
|
||||
struct ceph_auth_client *ac = osdc->client->monc.auth;
|
||||
|
||||
/*
|
||||
* XXX If ac->ops or ac->ops->verify_authorizer_reply is null,
|
||||
* XXX which do we do: succeed or fail?
|
||||
*/
|
||||
return ac->ops->verify_authorizer_reply(ac, o->o_auth.authorizer, len);
|
||||
return ceph_auth_verify_authorizer_reply(ac, o->o_auth.authorizer, len);
|
||||
}
|
||||
|
||||
static int invalidate_authorizer(struct ceph_connection *con)
|
||||
@@ -2251,9 +2245,7 @@ static int invalidate_authorizer(struct ceph_connection *con)
|
||||
struct ceph_osd_client *osdc = o->o_osdc;
|
||||
struct ceph_auth_client *ac = osdc->client->monc.auth;
|
||||
|
||||
if (ac->ops && ac->ops->invalidate_authorizer)
|
||||
ac->ops->invalidate_authorizer(ac, CEPH_ENTITY_TYPE_OSD);
|
||||
|
||||
ceph_auth_invalidate_authorizer(ac, CEPH_ENTITY_TYPE_OSD);
|
||||
return ceph_monc_validate_auth(&osdc->client->monc);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user