
---

Remove the struct gss_auth level upcall bookeeping, and replace it with the
new struct rpc_upcall_info.

Signed-off-by: Andy Adamson <andros@citi.umich.edu>

---
---


diff -puN net/sunrpc/auth_gss/auth_gss.c~gss-use-upcall-info net/sunrpc/auth_gss/auth_gss.c
--- linux-2.6.18-rc5/net/sunrpc/auth_gss/auth_gss.c~gss-use-upcall-info	2006-10-17 15:22:50.000000000 -0400
+++ linux-2.6.18-rc5-andros/net/sunrpc/auth_gss/auth_gss.c	2006-10-17 15:26:28.000000000 -0400
@@ -112,12 +112,11 @@ static DEFINE_RWLOCK(gss_ctx_lock);
 
 struct gss_auth {
 	struct rpc_auth rpc_auth;
+	struct rpc_upcall_info *info;
 	struct gss_api_mech *mech;
 	enum rpc_gss_svc service;
-	struct list_head upcalls;
 	struct rpc_clnt *client;
 	struct dentry *dentry;
-	spinlock_t lock;
 	char path[48];
 	char key_name[256];
 };
@@ -327,7 +326,6 @@ struct gss_upcall_msg {
 	struct list_head list;
 	struct gss_auth *auth;
 	struct rpc_wait_queue rpc_waitqueue;
-	wait_queue_head_t waitqueue;
 	struct gss_cl_ctx *ctx;
 	char   upcall_info[256];
 };
@@ -348,7 +346,7 @@ static struct gss_upcall_msg *
 __gss_find_upcall(struct gss_auth *gss_auth, uid_t uid)
 {
 	struct gss_upcall_msg *pos;
-	list_for_each_entry(pos, &gss_auth->upcalls, list) {
+	list_for_each_entry(pos, &gss_auth->info->upcalls, list) {
 		if (pos->uid != uid)
 			continue;
 		atomic_inc(&pos->count);
@@ -368,14 +366,14 @@ gss_add_msg(struct gss_auth *gss_auth, s
 {
 	struct gss_upcall_msg *old;
 
-	spin_lock(&gss_auth->lock);
+	spin_lock(&gss_auth->info->lock);
 	old = __gss_find_upcall(gss_auth, gss_msg->uid);
 	if (old == NULL) {
 		atomic_inc(&gss_msg->count);
-		list_add(&gss_msg->list, &gss_auth->upcalls);
+		list_add(&gss_msg->list, &gss_auth->info->upcalls);
 	} else
 		gss_msg = old;
-	spin_unlock(&gss_auth->lock);
+	spin_unlock(&gss_auth->info->lock);
 	return gss_msg;
 }
 
@@ -386,7 +384,7 @@ __gss_unhash_msg(struct gss_upcall_msg *
 		return;
 	list_del_init(&gss_msg->list);
 	rpc_wake_up_status(&gss_msg->rpc_waitqueue, gss_msg->msg.errno);
-	wake_up_all(&gss_msg->waitqueue);
+	wake_up_all(&gss_msg->auth->info->waitqueue);
 	atomic_dec(&gss_msg->count);
 }
 
@@ -395,9 +393,9 @@ gss_unhash_msg(struct gss_upcall_msg *gs
 {
 	struct gss_auth *gss_auth = gss_msg->auth;
 
-	spin_lock(&gss_auth->lock);
+	spin_lock(&gss_auth->info->lock);
 	__gss_unhash_msg(gss_msg);
-	spin_unlock(&gss_auth->lock);
+	spin_unlock(&gss_auth->info->lock);
 }
 
 static void
@@ -413,10 +411,10 @@ gss_upcall_callback(struct rpc_task *tas
 		gss_cred_set_ctx(task->tk_msg.rpc_cred, gss_get_ctx(gss_msg->ctx));
 	else
 		task->tk_status = gss_msg->msg.errno;
-	spin_lock(&gss_msg->auth->lock);
+	spin_lock(&gss_msg->auth->info->lock);
 	gss_cred->gc_upcall = NULL;
 	rpc_wake_up_status(&gss_msg->rpc_waitqueue, gss_msg->msg.errno);
-	spin_unlock(&gss_msg->auth->lock);
+	spin_unlock(&gss_msg->auth->info->lock);
 	gss_release_msg(gss_msg);
 }
 
@@ -487,7 +485,7 @@ gss_alloc_msg(struct gss_auth *gss_auth,
 	if (gss_msg != NULL) {
 		INIT_LIST_HEAD(&gss_msg->list);
 		rpc_init_wait_queue(&gss_msg->rpc_waitqueue, "RPCSEC_GSS upcall waitq");
-		init_waitqueue_head(&gss_msg->waitqueue);
+		init_waitqueue_head(&gss_msg->auth->info->waitqueue);
 		atomic_set(&gss_msg->count, 1);
 #ifdef CONFIG_RPCSEC_GSS_KEYRING
 		if (gss_init_msg_upcall_info(gss_msg, krinfo)) {
@@ -549,7 +547,7 @@ gss_refresh_upcall(struct rpc_task *task
 		err = PTR_ERR(gss_msg);
 		goto out;
 	}
-	spin_lock(&gss_auth->lock);
+	spin_lock(&gss_auth->info->lock);
 	if (gss_cred->gc_upcall != NULL)
 		rpc_sleep_on(&gss_cred->gc_upcall->rpc_waitqueue, task, NULL, NULL);
 	else if (gss_msg->ctx == NULL && gss_msg->msg.errno >= 0) {
@@ -560,7 +558,7 @@ gss_refresh_upcall(struct rpc_task *task
 		rpc_sleep_on(&gss_msg->rpc_waitqueue, task, gss_upcall_callback, NULL);
 	} else
 		err = gss_msg->msg.errno;
-	spin_unlock(&gss_auth->lock);
+	spin_unlock(&gss_auth->info->lock);
 	gss_release_msg(gss_msg);
 out:
 	dprintk("RPC: %4u gss_refresh_upcall for uid %u result %d\n",
@@ -585,13 +583,13 @@ gss_create_upcall(struct gss_auth *gss_a
 	}
 	dprintk("RPC:      gss_create_upcall for uid %u about to wait...\n", cred->cr_uid);
 	for (;;) {
-		prepare_to_wait(&gss_msg->waitqueue, &wait, TASK_INTERRUPTIBLE);
-		spin_lock(&gss_auth->lock);
+		prepare_to_wait(&gss_msg->auth->info->waitqueue, &wait, TASK_INTERRUPTIBLE);
+		spin_lock(&gss_auth->info->lock);
 		if (gss_msg->ctx != NULL || gss_msg->msg.errno < 0) {
-			spin_unlock(&gss_auth->lock);
+			spin_unlock(&gss_auth->info->lock);
 			break;
 		}
-		spin_unlock(&gss_auth->lock);
+		spin_unlock(&gss_auth->info->lock);
 		if (signalled()) {
 			err = -ERESTARTSYS;
 			goto out_intr;
@@ -604,7 +602,7 @@ gss_create_upcall(struct gss_auth *gss_a
 	else
 		err = gss_msg->msg.errno;
 out_intr:
-	finish_wait(&gss_msg->waitqueue, &wait);
+	finish_wait(&gss_msg->auth->info->waitqueue, &wait);
 	gss_release_msg(gss_msg);
 out:
 	dprintk("RPC:      gss_create_upcall for uid %u result %d\n", cred->cr_uid, err);
@@ -725,14 +723,14 @@ gss_pipe_downcall(struct file *filp, con
 		if (err != -EACCES)
 			goto err_put_ctx;
 	}
-	spin_lock(&gss_auth->lock);
+	spin_lock(&gss_auth->info->lock);
 	gss_msg = __gss_find_upcall(gss_auth, uid);
 	if (gss_msg) {
 		if (err == 0 && gss_msg->ctx == NULL)
 			gss_msg->ctx = gss_get_ctx(ctx);
 		gss_msg->msg.errno = err;
 		__gss_unhash_msg(gss_msg);
-		spin_unlock(&gss_auth->lock);
+		spin_unlock(&gss_auth->info->lock);
 #ifdef CONFIG_RPCSEC_GSS_KEYRING
 {
 	int err;
@@ -762,7 +760,7 @@ gss_pipe_downcall(struct file *filp, con
 		gss_release_msg(gss_msg);
 	} else {
 		struct auth_cred acred = { .uid = uid };
-		spin_unlock(&gss_auth->lock);
+		spin_unlock(&gss_auth->info->lock);
 		cred = rpcauth_lookup_credcache(clnt->cl_auth, &acred, RPCAUTH_LOOKUP_NEW);
 		if (IS_ERR(cred)) {
 			err = PTR_ERR(cred);
@@ -789,25 +787,27 @@ gss_pipe_release(struct inode *inode)
 	struct rpc_inode *rpci = RPC_I(inode);
 	struct rpc_clnt *clnt;
 	struct rpc_auth *auth;
+	struct rpc_upcall_info *info;
 	struct gss_auth *gss_auth;
 
 	clnt = rpci->private;
 	auth = clnt->cl_auth;
+	info = clnt->cl_credcache->info;
 	gss_auth = container_of(auth, struct gss_auth, rpc_auth);
-	spin_lock(&gss_auth->lock);
-	while (!list_empty(&gss_auth->upcalls)) {
+	spin_lock(&info->lock);
+	while (!list_empty(&info->upcalls)) {
 		struct gss_upcall_msg *gss_msg;
 
-		gss_msg = list_entry(gss_auth->upcalls.next,
+		gss_msg = list_entry(info->upcalls.next,
 				struct gss_upcall_msg, list);
 		gss_msg->msg.errno = -EPIPE;
 		atomic_inc(&gss_msg->count);
 		__gss_unhash_msg(gss_msg);
-		spin_unlock(&gss_auth->lock);
+		spin_unlock(&info->lock);
 		gss_release_msg(gss_msg);
-		spin_lock(&gss_auth->lock);
+		spin_lock(&info->lock);
 	}
-	spin_unlock(&gss_auth->lock);
+	spin_unlock(&info->lock);
 }
 
 static void
@@ -861,8 +861,8 @@ gss_create(struct rpc_clnt *clnt, rpc_au
 	gss_auth->service = gss_pseudoflavor_to_service(gss_auth->mech, flavor);
 	if (gss_auth->service == 0)
 		goto err_put_mech;
-	INIT_LIST_HEAD(&gss_auth->upcalls);
-	spin_lock_init(&gss_auth->lock);
+	INIT_LIST_HEAD(&gss_auth->info->upcalls);
+	spin_lock_init(&gss_auth->info->lock);
 	auth = &gss_auth->rpc_auth;
 	auth->au_cslack = GSS_CRED_SLACK >> 2;
 	auth->au_rslack = GSS_VERF_SLACK >> 2;
_
