Whamcloud - gitweb
sometime we don't need gracefully flush client credential.
authorericm <ericm>
Tue, 21 Jun 2005 16:31:14 +0000 (16:31 +0000)
committerericm <ericm>
Tue, 21 Jun 2005 16:31:14 +0000 (16:31 +0000)
lustre/sec/gss/sec_gss.c
lustre/sec/sec.c

index 96d93d0..ad7bfe8 100644 (file)
@@ -1330,19 +1330,19 @@ static void destroy_gss_context(struct ptlrpc_cred *cred)
         /* cred's refcount is 0, steal one */
         atomic_inc(&cred->pc_refcount);
 
         /* cred's refcount is 0, steal one */
         atomic_inc(&cred->pc_refcount);
 
-        gcred = container_of(cred, struct gss_cred, gc_base);
-        gcred->gc_ctx->gc_proc = PTLRPC_GSS_PROC_DESTROY;
-        imp = cred->pc_sec->ps_import;
-        LASSERT(imp);
-
         if (!(cred->pc_flags & PTLRPC_CRED_UPTODATE)) {
         if (!(cred->pc_flags & PTLRPC_CRED_UPTODATE)) {
-                CDEBUG(D_SEC, "Destroy a dead gss cred %p(%u@%s)\n",
-                       gcred, cred->pc_uid, imp->imp_target_uuid.uuid);
+                CDEBUG(D_SEC, "Destroy dead cred %p(%u@%s)\n",
+                       cred, cred->pc_uid, imp->imp_target_uuid.uuid);
                 atomic_dec(&cred->pc_refcount);
                 EXIT;
                 return;
         }
 
                 atomic_dec(&cred->pc_refcount);
                 EXIT;
                 return;
         }
 
+        gcred = container_of(cred, struct gss_cred, gc_base);
+        gcred->gc_ctx->gc_proc = PTLRPC_GSS_PROC_DESTROY;
+        imp = cred->pc_sec->ps_import;
+        LASSERT(imp);
+
         CDEBUG(D_SEC, "client destroy gss cred %p(%u@%s)\n",
                gcred, cred->pc_uid, imp->imp_target_uuid.uuid);
 
         CDEBUG(D_SEC, "client destroy gss cred %p(%u@%s)\n",
                gcred, cred->pc_uid, imp->imp_target_uuid.uuid);
 
index 08c66d2..070724c 100644 (file)
@@ -209,8 +209,13 @@ void ptlrpcs_credcache_gc(struct ptlrpc_sec *sec,
         EXIT;
 }
 
         EXIT;
 }
 
+/*
+ * grace: mark cred DEAD, allow graceful destroy like notify
+ *        server side, etc.
+ * force: flush all entries, otherwise only free ones be flushed.
+ */
 static
 static
-int ptlrpcs_flush_credcache(struct ptlrpc_sec *sec, int force)
+int ptlrpcs_flush_credcache(struct ptlrpc_sec *sec, int grace, int force)
 {
         struct ptlrpc_cred *cred, *n;
         LIST_HEAD(freelist);
 {
         struct ptlrpc_cred *cred, *n;
         LIST_HEAD(freelist);
@@ -230,8 +235,9 @@ int ptlrpcs_flush_credcache(struct ptlrpc_sec *sec, int force)
                         } else
                                 list_move(&cred->pc_hash, &freelist);
 
                         } else
                                 list_move(&cred->pc_hash, &freelist);
 
-                        /* don't remove CRED_UPTODATE flag here */
                         cred->pc_flags |= PTLRPC_CRED_DEAD;
                         cred->pc_flags |= PTLRPC_CRED_DEAD;
+                        if (!grace)
+                                cred->pc_flags &= ~PTLRPC_CRED_UPTODATE;
                 }
         }
         spin_unlock(&sec->ps_lock);
                 }
         }
         spin_unlock(&sec->ps_lock);
@@ -707,7 +713,7 @@ static void ptlrpcs_sec_destroy(struct ptlrpc_sec *sec)
 void ptlrpcs_sec_put(struct ptlrpc_sec *sec)
 {
         if (atomic_dec_and_test(&sec->ps_refcount)) {
 void ptlrpcs_sec_put(struct ptlrpc_sec *sec)
 {
         if (atomic_dec_and_test(&sec->ps_refcount)) {
-                ptlrpcs_flush_credcache(sec, 1);
+                ptlrpcs_flush_credcache(sec, 1, 1);
 
                 if (atomic_read(&sec->ps_credcount) == 0) {
                         ptlrpcs_sec_destroy(sec);
 
                 if (atomic_read(&sec->ps_credcount) == 0) {
                         ptlrpcs_sec_destroy(sec);
@@ -722,7 +728,7 @@ void ptlrpcs_sec_put(struct ptlrpc_sec *sec)
 
 void ptlrpcs_sec_invalidate_cache(struct ptlrpc_sec *sec)
 {
 
 void ptlrpcs_sec_invalidate_cache(struct ptlrpc_sec *sec)
 {
-        ptlrpcs_flush_credcache(sec, 1);
+        ptlrpcs_flush_credcache(sec, 0, 1);
 }
 
 int sec_alloc_reqbuf(struct ptlrpc_sec *sec,
 }
 
 int sec_alloc_reqbuf(struct ptlrpc_sec *sec,