CEPH filesystem development
 help / color / mirror / Atom feed
From: Alex Elder <elder@inktank.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH 09/16] ceph: define ceph_auth_handshake type
Date: Thu, 17 May 2012 09:04:51 -0500	[thread overview]
Message-ID: <4FB50583.8000206@inktank.com> (raw)
In-Reply-To: <4FB50329.7010206@inktank.com>

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>
---
  fs/ceph/mds_client.c            |   32 ++++++++++++++++----------------
  fs/ceph/mds_client.h            |    5 ++---
  include/linux/ceph/auth.h       |    8 ++++++++
  include/linux/ceph/osd_client.h |   11 +++++------
  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 89971e1..42013c6 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)
  	dout("mdsc put_session %p %d -> %d\n", s,
  	     atomic_read(&s->s_ref), atomic_read(&s->s_ref)-1);
  	if (atomic_dec_and_test(&s->s_ref)) {
-		if (s->s_authorizer)
+		if (s->s_auth.authorizer)
  		     s->s_mdsc->fsc->client->monc.auth->ops->destroy_authorizer(
  			     s->s_mdsc->fsc->client->monc.auth,
-			     s->s_authorizer);
+			     s->s_auth.authorizer);
  		kfree(s);
  	}
  }
@@ -3404,29 +3404,29 @@ static int get_authorizer(struct ceph_connection 
*con,
  	struct ceph_auth_client *ac = mdsc->fsc->client->monc.auth;
  	int ret = 0;

-	if (force_new && s->s_authorizer) {
-		ac->ops->destroy_authorizer(ac, s->s_authorizer);
-		s->s_authorizer = NULL;
+	if (force_new && s->s_auth.authorizer) {
+		ac->ops->destroy_authorizer(ac, s->s_auth.authorizer);
+		s->s_auth.authorizer = NULL;
  	}
-	if (s->s_authorizer == NULL) {
+	if (s->s_auth.authorizer == NULL) {
  		if (ac->ops->create_authorizer) {
  			ret = ac->ops->create_authorizer(
  				ac, CEPH_ENTITY_TYPE_MDS,
-				&s->s_authorizer,
-				&s->s_authorizer_buf,
-				&s->s_authorizer_buf_len,
-				&s->s_authorizer_reply_buf,
-				&s->s_authorizer_reply_buf_len);
+				&s->s_auth.authorizer,
+				&s->s_auth.authorizer_buf,
+				&s->s_auth.authorizer_buf_len,
+				&s->s_auth.authorizer_reply_buf,
+				&s->s_auth.authorizer_reply_buf_len);
  			if (ret)
  				return ret;
  		}
  	}

  	*proto = ac->protocol;
-	*buf = s->s_authorizer_buf;
-	*len = s->s_authorizer_buf_len;
-	*reply_buf = s->s_authorizer_reply_buf;
-	*reply_len = s->s_authorizer_reply_buf_len;
+	*buf = s->s_auth.authorizer_buf;
+	*len = s->s_auth.authorizer_buf_len;
+	*reply_buf = s->s_auth.authorizer_reply_buf;
+	*reply_len = s->s_auth.authorizer_reply_buf_len;
  	return 0;
  }

@@ -3437,7 +3437,7 @@ static int verify_authorizer_reply(struct 
ceph_connection *con, int len)
  	struct ceph_mds_client *mdsc = s->s_mdsc;
  	struct ceph_auth_client *ac = mdsc->fsc->client->monc.auth;

-	return ac->ops->verify_authorizer_reply(ac, s->s_authorizer, len);
+	return ac->ops->verify_authorizer_reply(ac, s->s_auth.authorizer, len);
  }

  static int invalidate_authorizer(struct ceph_connection *con)
diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h
index 8c7c04e..dd26846 100644
--- a/fs/ceph/mds_client.h
+++ b/fs/ceph/mds_client.h
@@ -11,6 +11,7 @@
  #include <linux/ceph/types.h>
  #include <linux/ceph/messenger.h>
  #include <linux/ceph/mdsmap.h>
+#include <linux/ceph/auth.h>

  /*
   * Some lock dependencies:
@@ -113,9 +114,7 @@ struct ceph_mds_session {

  	struct ceph_connection s_con;

-	struct ceph_authorizer *s_authorizer;
-	void             *s_authorizer_buf, *s_authorizer_reply_buf;
-	size_t            s_authorizer_buf_len, s_authorizer_reply_buf_len;
+	struct ceph_auth_handshake s_auth;

  	/* protected by s_gen_ttl_lock */
  	spinlock_t        s_gen_ttl_lock;
diff --git a/include/linux/ceph/auth.h b/include/linux/ceph/auth.h
index aa13392..5b774d1 100644
--- a/include/linux/ceph/auth.h
+++ b/include/linux/ceph/auth.h
@@ -14,6 +14,14 @@
  struct ceph_auth_client;
  struct ceph_authorizer;

+struct ceph_auth_handshake {
+	struct ceph_authorizer *authorizer;
+	void *authorizer_buf;
+	size_t authorizer_buf_len;
+	void *authorizer_reply_buf;
+	size_t authorizer_reply_buf_len;
+};
+
  struct ceph_auth_client_ops {
  	const char *name;

diff --git a/include/linux/ceph/osd_client.h 
b/include/linux/ceph/osd_client.h
index 7c05ac2..cedfb1a 100644
--- a/include/linux/ceph/osd_client.h
+++ b/include/linux/ceph/osd_client.h
@@ -6,9 +6,10 @@
  #include <linux/mempool.h>
  #include <linux/rbtree.h>

-#include "types.h"
-#include "osdmap.h"
-#include "messenger.h"
+#include <linux/ceph/types.h>
+#include <linux/ceph/osdmap.h>
+#include <linux/ceph/messenger.h>
+#include <linux/ceph/auth.h>

  /*
   * Maximum object name size
@@ -40,9 +41,7 @@ struct ceph_osd {
  	struct list_head o_requests;
  	struct list_head o_linger_requests;
  	struct list_head o_osd_lru;
-	struct ceph_authorizer *o_authorizer;
-	void *o_authorizer_buf, *o_authorizer_reply_buf;
-	size_t o_authorizer_buf_len, o_authorizer_reply_buf_len;
+	struct ceph_auth_handshake o_auth;
  	unsigned long lru_ttl;
  	int o_marked_for_keepalive;
  	struct list_head o_keepalive_item;
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index daa2716..66b09d6 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)
  	if (atomic_dec_and_test(&osd->o_ref)) {
  		struct ceph_auth_client *ac = osd->o_osdc->client->monc.auth;

-		if (osd->o_authorizer)
-			ac->ops->destroy_authorizer(ac, osd->o_authorizer);
+		if (osd->o_auth.authorizer)
+			ac->ops->destroy_authorizer(ac, osd->o_auth.authorizer);
  		kfree(osd);
  	}
  }
@@ -2117,27 +2117,27 @@ static int get_authorizer(struct ceph_connection 
*con,
  	struct ceph_auth_client *ac = osdc->client->monc.auth;
  	int ret = 0;

-	if (force_new && o->o_authorizer) {
-		ac->ops->destroy_authorizer(ac, o->o_authorizer);
-		o->o_authorizer = NULL;
+	if (force_new && o->o_auth.authorizer) {
+		ac->ops->destroy_authorizer(ac, o->o_auth.authorizer);
+		o->o_auth.authorizer = NULL;
  	}
-	if (o->o_authorizer == NULL) {
+	if (o->o_auth.authorizer == NULL) {
  		ret = ac->ops->create_authorizer(
  			ac, CEPH_ENTITY_TYPE_OSD,
-			&o->o_authorizer,
-			&o->o_authorizer_buf,
-			&o->o_authorizer_buf_len,
-			&o->o_authorizer_reply_buf,
-			&o->o_authorizer_reply_buf_len);
+			&o->o_auth.authorizer,
+			&o->o_auth.authorizer_buf,
+			&o->o_auth.authorizer_buf_len,
+			&o->o_auth.authorizer_reply_buf,
+			&o->o_auth.authorizer_reply_buf_len);
  		if (ret)
  			return ret;
  	}

  	*proto = ac->protocol;
-	*buf = o->o_authorizer_buf;
-	*len = o->o_authorizer_buf_len;
-	*reply_buf = o->o_authorizer_reply_buf;
-	*reply_len = o->o_authorizer_reply_buf_len;
+	*buf = o->o_auth.authorizer_buf;
+	*len = o->o_auth.authorizer_buf_len;
+	*reply_buf = o->o_auth.authorizer_reply_buf;
+	*reply_len = o->o_auth.authorizer_reply_buf_len;
  	return 0;
  }

@@ -2148,7 +2148,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;

-	return ac->ops->verify_authorizer_reply(ac, o->o_authorizer, len);
+	return ac->ops->verify_authorizer_reply(ac, o->o_auth.authorizer, len);
  }

  static int invalidate_authorizer(struct ceph_connection *con)
-- 
1.7.5.4


  parent reply	other threads:[~2012-05-17 14:04 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-17 13:54 [PATCH 00/16] ceph: messenger cleanups and fixes Alex Elder
2012-05-17 14:03 ` [PATCH 01/16] libceph: don't reset kvec in prepare_write_banner() Alex Elder
2012-05-17 14:04 ` [PATCH 02/16] ceph: messenger: reset connection kvec caller Alex Elder
2012-05-17 14:04 ` [PATCH 03/16] ceph: messenger: send banner in process_connect() Alex Elder
2012-05-17 14:04 ` [PATCH 04/16] ceph: drop msgr argument from prepare_write_connect() Alex Elder
2012-05-17 14:04 ` [PATCH 05/16] ceph: don't set WRITE_PENDING too early Alex Elder
2012-05-17 14:04 ` [PATCH 06/16] ceph: messenger: check prepare_write_connect() result Alex Elder
2012-05-17 14:04 ` [PATCH 07/16] ceph: messenger: rework prepare_connect_authorizer() Alex Elder
2012-05-17 14:04 ` [PATCH 08/16] ceph: messenger: check return from get_authorizer Alex Elder
2012-05-17 14:04 ` Alex Elder [this message]
2012-05-17 14:04 ` [PATCH 10/16] ceph: messenger: reduce args to create_authorizer Alex Elder
2012-05-17 14:05 ` [PATCH 11/16] ceph: ensure auth ops are defined before use Alex Elder
2012-05-17 14:05 ` [PATCH 12/16] ceph: have get_authorizer methods return pointers Alex Elder
2012-05-17 14:05 ` [PATCH 13/16] ceph: use info returned by get_authorizer Alex Elder
2012-05-17 14:05 ` [PATCH 14/16] ceph: return pointer from prepare_connect_authorizer() Alex Elder
2012-05-17 14:05 ` [PATCH 15/16] ceph: rename prepare_connect_authorizer() Alex Elder
2012-05-17 14:05 ` [PATCH 16/16] ceph: add auth buf in prepare_write_connect() Alex Elder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FB50583.8000206@inktank.com \
    --to=elder@inktank.com \
    --cc=ceph-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox