linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <greg@kroah.com>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Sage Weil <sage@inktank.com>,
	Alex Elder <elder@inktank.com>
Subject: [ 37/48] libceph: wrap auth ops in wrapper functions
Date: Tue, 18 Jun 2013 09:18:03 -0700	[thread overview]
Message-ID: <20130618161731.290191358@linuxfoundation.org> (raw)
In-Reply-To: <20130618161725.912524266@linuxfoundation.org>

From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

3.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Sage Weil <sage@inktank.com>

commit 27859f9773e4a0b2042435b13400ee2c891a61f4 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/ceph/mds_client.c      |   26 +++++++++++--------------
 include/linux/ceph/auth.h |   13 ++++++++++++
 net/ceph/auth.c           |   47 ++++++++++++++++++++++++++++++++++++++++++++++
 net/ceph/auth_x.c         |    1 
 net/ceph/mon_client.c     |    7 ++----
 net/ceph/osd_client.c     |   26 ++++++++-----------------
 6 files changed, 84 insertions(+), 36 deletions(-)

--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -364,9 +364,9 @@ void ceph_put_mds_session(struct ceph_md
 	     atomic_read(&s->s_ref), atomic_read(&s->s_ref)-1);
 	if (atomic_dec_and_test(&s->s_ref)) {
 		if (s->s_auth.authorizer)
-		     s->s_mdsc->fsc->client->monc.auth->ops->destroy_authorizer(
-			     s->s_mdsc->fsc->client->monc.auth,
-			     s->s_auth.authorizer);
+			ceph_auth_destroy_authorizer(
+				s->s_mdsc->fsc->client->monc.auth,
+				s->s_auth.authorizer);
 		kfree(s);
 	}
 }
@@ -3438,18 +3438,17 @@ static struct ceph_auth_handshake *get_a
 	struct ceph_auth_handshake *auth = &s->s_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_MDS,
-						     auth);
+	if (!auth->authorizer) {
+		int ret = ceph_auth_create_authorizer(ac, CEPH_ENTITY_TYPE_MDS,
+						      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_MDS,
-						     auth);
+	} else {
+		int ret = ceph_auth_update_authorizer(ac, CEPH_ENTITY_TYPE_MDS,
+						      auth);
 		if (ret)
 			return ERR_PTR(ret);
 	}
@@ -3465,7 +3464,7 @@ static int verify_authorizer_reply(struc
 	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_auth.authorizer, len);
+	return ceph_auth_verify_authorizer_reply(ac, s->s_auth.authorizer, len);
 }
 
 static int invalidate_authorizer(struct ceph_connection *con)
@@ -3474,8 +3473,7 @@ static int invalidate_authorizer(struct
 	struct ceph_mds_client *mdsc = s->s_mdsc;
 	struct ceph_auth_client *ac = mdsc->fsc->client->monc.auth;
 
-	if (ac->ops->invalidate_authorizer)
-		ac->ops->invalidate_authorizer(ac, CEPH_ENTITY_TYPE_MDS);
+	ceph_auth_invalidate_authorizer(ac, CEPH_ENTITY_TYPE_MDS);
 
 	return ceph_monc_validate_auth(&mdsc->fsc->client->monc);
 }
--- a/include/linux/ceph/auth.h
+++ b/include/linux/ceph/auth.h
@@ -97,5 +97,18 @@ extern int ceph_build_auth(struct ceph_a
 		    void *msg_buf, size_t msg_len);
 
 extern int ceph_auth_is_authenticated(struct ceph_auth_client *ac);
+extern int ceph_auth_create_authorizer(struct ceph_auth_client *ac,
+				       int peer_type,
+				       struct ceph_auth_handshake *auth);
+extern void ceph_auth_destroy_authorizer(struct ceph_auth_client *ac,
+					 struct ceph_authorizer *a);
+extern int ceph_auth_update_authorizer(struct ceph_auth_client *ac,
+				       int peer_type,
+				       struct ceph_auth_handshake *a);
+extern int ceph_auth_verify_authorizer_reply(struct ceph_auth_client *ac,
+					     struct ceph_authorizer *a,
+					     size_t len);
+extern void ceph_auth_invalidate_authorizer(struct ceph_auth_client *ac,
+					    int peer_type);
 
 #endif
--- a/net/ceph/auth.c
+++ b/net/ceph/auth.c
@@ -257,3 +257,50 @@ int ceph_auth_is_authenticated(struct ce
 		return 0;
 	return ac->ops->is_authenticated(ac);
 }
+EXPORT_SYMBOL(ceph_auth_is_authenticated);
+
+int ceph_auth_create_authorizer(struct ceph_auth_client *ac,
+				int peer_type,
+				struct ceph_auth_handshake *auth)
+{
+	if (ac->ops && ac->ops->create_authorizer)
+		return ac->ops->create_authorizer(ac, peer_type, auth);
+	return 0;
+}
+EXPORT_SYMBOL(ceph_auth_create_authorizer);
+
+void ceph_auth_destroy_authorizer(struct ceph_auth_client *ac,
+				  struct ceph_authorizer *a)
+{
+	if (ac->ops && ac->ops->destroy_authorizer)
+		ac->ops->destroy_authorizer(ac, a);
+}
+EXPORT_SYMBOL(ceph_auth_destroy_authorizer);
+
+int ceph_auth_update_authorizer(struct ceph_auth_client *ac,
+				int peer_type,
+				struct ceph_auth_handshake *a)
+{
+	int ret = 0;
+
+	if (ac->ops && ac->ops->update_authorizer)
+		ret = ac->ops->update_authorizer(ac, peer_type, a);
+	return ret;
+}
+EXPORT_SYMBOL(ceph_auth_update_authorizer);
+
+int ceph_auth_verify_authorizer_reply(struct ceph_auth_client *ac,
+				      struct ceph_authorizer *a, size_t len)
+{
+	if (ac->ops && ac->ops->verify_authorizer_reply)
+		return ac->ops->verify_authorizer_reply(ac, a, len);
+	return 0;
+}
+EXPORT_SYMBOL(ceph_auth_verify_authorizer_reply);
+
+void ceph_auth_invalidate_authorizer(struct ceph_auth_client *ac, int peer_type)
+{
+	if (ac->ops && ac->ops->invalidate_authorizer)
+		ac->ops->invalidate_authorizer(ac, peer_type);
+}
+EXPORT_SYMBOL(ceph_auth_invalidate_authorizer);
--- a/net/ceph/auth_x.c
+++ b/net/ceph/auth_x.c
@@ -562,7 +562,6 @@ static int ceph_x_update_authorizer(
 {
 	struct ceph_x_authorizer *au;
 	struct ceph_x_ticket_handler *th;
-	int ret;
 
 	th = get_ticket_handler(ac, peer_type);
 	if (IS_ERR(th))
--- a/net/ceph/mon_client.c
+++ b/net/ceph/mon_client.c
@@ -737,7 +737,7 @@ static void delayed_work(struct work_str
 
 		__validate_auth(monc);
 
-		if (monc->auth->ops->is_authenticated(monc->auth))
+		if (ceph_auth_is_authenticated(monc->auth))
 			__send_subscribe(monc);
 	}
 	__schedule_delayed(monc);
@@ -892,8 +892,7 @@ static void handle_auth_reply(struct cep
 
 	mutex_lock(&monc->mutex);
 	had_debugfs_info = have_debugfs_info(monc);
-	if (monc->auth->ops)
-		was_auth = monc->auth->ops->is_authenticated(monc->auth);
+	was_auth = ceph_auth_is_authenticated(monc->auth);
 	monc->pending_auth = 0;
 	ret = ceph_handle_auth_reply(monc->auth, msg->front.iov_base,
 				     msg->front.iov_len,
@@ -904,7 +903,7 @@ static void handle_auth_reply(struct cep
 		wake_up_all(&monc->client->auth_wq);
 	} else if (ret > 0) {
 		__send_prepared_auth_request(monc, ret);
-	} else if (!was_auth && monc->auth->ops->is_authenticated(monc->auth)) {
+	} else if (!was_auth && ceph_auth_is_authenticated(monc->auth)) {
 		dout("authenticated, starting session\n");
 
 		monc->client->msgr.inst.name.type = CEPH_ENTITY_TYPE_CLIENT;
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -654,8 +654,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);
 	}
 }
@@ -2168,17 +2167,16 @@ static struct ceph_auth_handshake *get_a
 	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);
@@ -2195,11 +2193,7 @@ static int verify_authorizer_reply(struc
 	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)
@@ -2208,9 +2202,7 @@ static int invalidate_authorizer(struct
 	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);
 }
 



  parent reply	other threads:[~2013-06-18 16:18 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-18 16:17 [ 00/48] 3.9.7-stable review Greg Kroah-Hartman
2013-06-18 16:17 ` [ 01/48] audit: wait_for_auditd() should use TASK_UNINTERRUPTIBLE Greg Kroah-Hartman
2013-06-18 16:17 ` [ 02/48] b43: stop format string leaking into error msgs Greg Kroah-Hartman
2013-06-18 16:17 ` [ 03/48] ACPI / video: Do not bind to device objects with a scan handler Greg Kroah-Hartman
2013-06-18 16:17 ` [ 04/48] libceph: must hold mutex for reset_changed_osds() Greg Kroah-Hartman
2013-06-18 16:17 ` [ 05/48] ceph: add cpu_to_le32() calls when encoding a reconnect capability Greg Kroah-Hartman
2013-06-18 16:17 ` [ 06/48] ceph: ceph_pagelist_append might sleep while atomic Greg Kroah-Hartman
2013-06-18 16:17 ` [ 07/48] rbd: dont destroy ceph_opts in rbd_add() Greg Kroah-Hartman
2013-06-18 16:17 ` [ 08/48] drivers/rtc/rtc-twl.c: fix missing device_init_wakeup() when booted with device tree Greg Kroah-Hartman
2013-06-18 16:17 ` [ 09/48] drm/gma500/psb: Unpin framebuffer on crtc disable Greg Kroah-Hartman
2013-06-18 16:17 ` [ 10/48] drm/gma500/cdv: " Greg Kroah-Hartman
2013-06-18 16:17 ` [ 11/48] Bluetooth: Fix missing length checks for L2CAP signalling PDUs Greg Kroah-Hartman
2013-06-18 16:17 ` [ 12/48] Bluetooth: Fix mgmt handling of power on failures Greg Kroah-Hartman
2013-06-18 16:17 ` [ 13/48] s390/pci: Implement IRQ functions if !PCI Greg Kroah-Hartman
2013-06-18 17:35   ` Ben Hutchings
2013-06-18 17:42     ` Greg Kroah-Hartman
2013-06-18 21:35       ` Ben Hutchings
2013-06-19  7:09     ` Martin Schwidefsky
2013-06-20 19:21     ` Greg Kroah-Hartman
2013-06-18 16:17 ` [ 14/48] ath9k: Disable PowerSave by default Greg Kroah-Hartman
2013-06-18 16:17 ` [ 15/48] Revert "ath9k_hw: Update rx gain initval to improve rx sensitivity" Greg Kroah-Hartman
2013-06-18 16:17 ` [ 16/48] ath9k: Use minstrel rate control by default Greg Kroah-Hartman
2013-06-18 16:17 ` [ 17/48] CPU hotplug: provide a generic helper to disable/enable CPU hotplug Greg Kroah-Hartman
2013-06-18 16:17 ` [ 18/48] reboot: rigrate shutdown/reboot to boot cpu Greg Kroah-Hartman
2013-06-18 16:17 ` [ 19/48] kmsg: honor dmesg_restrict sysctl on /dev/kmsg Greg Kroah-Hartman
2013-06-18 16:17 ` [ 20/48] cciss: fix broken mutex usage in ioctl Greg Kroah-Hartman
2013-06-18 16:17 ` [ 21/48] memcg: dont initialize kmem-cache destroying work for root caches Greg Kroah-Hartman
2013-06-18 16:17 ` [ 22/48] wl12xx: fix minimum required firmware version for wl127x multirole Greg Kroah-Hartman
2013-06-18 16:17 ` [ 23/48] drm/i915: prefer VBT modes for SVDO-LVDS over EDID Greg Kroah-Hartman
2013-06-18 16:17 ` [ 24/48] swap: avoid read_swap_cache_async() race to deadlock while waiting on discard I/O completion Greg Kroah-Hartman
2013-06-18 16:17 ` [ 25/48] md/raid1: consider WRITE as successful only if at least one non-Faulty and non-rebuilding drive completed it Greg Kroah-Hartman
2013-06-18 16:17 ` [ 26/48] md/raid1,5,10: Disable WRITE SAME until a recovery strategy is in place Greg Kroah-Hartman
2013-06-18 16:17 ` [ 27/48] md/raid1,raid10: use freeze_array in place of raise_barrier in various places Greg Kroah-Hartman
2013-06-18 16:17 ` [ 28/48] mm/page_alloc.c: fix watermark check in __zone_watermark_ok() Greg Kroah-Hartman
2013-06-18 16:17 ` [ 29/48] mm: migration: add migrate_entry_wait_huge() Greg Kroah-Hartman
2013-06-20  9:52   ` Satoru Takeuchi
2013-06-20 17:02     ` Greg Kroah-Hartman
2013-06-21 11:42       ` Satoru Takeuchi
2013-06-21 12:47     ` Michal Hocko
2013-06-21 22:56       ` Satoru Takeuchi
2013-06-22 12:28         ` Satoru Takeuchi
2013-06-27 18:48     ` Naoya Horiguchi
2013-06-18 16:17 ` [ 30/48] x86: Fix adjust_range_size_mask calling position Greg Kroah-Hartman
2013-06-18 16:17 ` [ 31/48] x86: Fix typo in kexec register clearing Greg Kroah-Hartman
2013-06-18 16:17 ` [ 32/48] drm/nv50/disp: force dac power state during load detect Greg Kroah-Hartman
2013-06-18 16:17 ` [ 33/48] drm/nv50/kms: use dac loadval from vbios, where its available Greg Kroah-Hartman
2013-06-18 16:18 ` [ 34/48] libceph: clear messenger auth_retry flag when we authenticate Greg Kroah-Hartman
2013-06-18 16:18 ` [ 35/48] libceph: fix authorizer invalidation Greg Kroah-Hartman
2013-06-18 16:18 ` [ 36/48] libceph: add update_authorizer auth method Greg Kroah-Hartman
2013-06-18 16:18 ` Greg Kroah-Hartman [this message]
2013-06-18 16:18 ` [ 38/48] libceph: wrap auth methods in a mutex Greg Kroah-Hartman
2013-06-18 16:18 ` [ 39/48] Modify UEFI anti-bricking code Greg Kroah-Hartman
2013-06-18 16:18 ` [ 40/48] powerpc: Fix stack overflow crash in resume_kernel when ftracing Greg Kroah-Hartman
2013-06-18 16:18 ` [ 41/48] powerpc: Fix emulation of illegal instructions on PowerNV platform Greg Kroah-Hartman
2013-06-18 16:18 ` [ 42/48] powerpc: Fix missing/delayed calls to irq_work Greg Kroah-Hartman
2013-06-18 16:18 ` [ 43/48] usb: chipidea: fix id change handling Greg Kroah-Hartman
2013-06-18 16:18 ` [ 44/48] USB: pl2303: fix device initialisation at open Greg Kroah-Hartman
2013-06-18 16:18 ` [ 45/48] USB: f81232: " Greg Kroah-Hartman
2013-06-18 16:18 ` [ 46/48] USB: spcp8x5: " Greg Kroah-Hartman
2013-06-18 16:18 ` [ 47/48] tg3: Wait for boot code to finish after power on Greg Kroah-Hartman
2013-06-18 16:18 ` [ 48/48] ARM: Kirkwood: handle mv88f6282 cpu in __kirkwood_variant() Greg Kroah-Hartman
2013-06-18 21:55 ` [ 00/48] 3.9.7-stable review Shuah Khan
2013-06-18 22:11   ` Greg Kroah-Hartman
2013-06-18 22:58 ` Guenter Roeck
2013-06-18 23:26   ` Greg Kroah-Hartman
2013-06-20 10:02 ` Satoru Takeuchi
2013-06-20 17:01   ` Greg Kroah-Hartman

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=20130618161731.290191358@linuxfoundation.org \
    --to=greg@kroah.com \
    --cc=elder@inktank.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sage@inktank.com \
    --cc=stable@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;
as well as URLs for NNTP newsgroup(s).