X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fsec%2Fsec.c;h=b2e8b6484fca1a7c54630a37e65919b5b8b7e537;hp=754f968502558b6dc31101e194e80a3665c302a2;hb=165aa6adfd492618257f7fa24e0bcf2c716c1977;hpb=39af058487819f43ee3b0555dd2cb03d774e41fe diff --git a/lustre/sec/sec.c b/lustre/sec/sec.c index 754f968..b2e8b64 100644 --- a/lustre/sec/sec.c +++ b/lustre/sec/sec.c @@ -280,7 +280,7 @@ void ptlrpcs_credcache_gc(struct ptlrpc_sec *sec, * @force: flush all entries, otherwise only free ones be flushed. */ static -int flush_credcache(struct ptlrpc_sec *sec, uid_t uid, +int flush_credcache(struct ptlrpc_sec *sec, unsigned long pag, uid_t uid, int grace, int force) { struct ptlrpc_cred *cred, *n; @@ -296,8 +296,14 @@ int flush_credcache(struct ptlrpc_sec *sec, uid_t uid, pc_hash) { LASSERT(atomic_read(&cred->pc_refcount) >= 0); - if (uid != -1 && uid != cred->pc_uid) - continue; + if (sec->ps_flags & PTLRPC_SEC_FL_PAG) { + if (pag != -1 && pag != cred->pc_pag) + continue; + } else { + if (uid != -1 && uid != cred->pc_uid) + continue; + } + if (atomic_read(&cred->pc_refcount)) { busy = 1; if (!force) @@ -412,14 +418,15 @@ static struct ptlrpc_cred *get_cred(struct ptlrpc_sec *sec) struct vfs_cred vcred; LASSERT(sec); - /* XXX - * for now we simply let PAG == real uid - */ + if (sec->ps_flags & (PTLRPC_SEC_FL_MDS | PTLRPC_SEC_FL_REVERSE)) { vcred.vc_pag = 0; vcred.vc_uid = 0; } else { - vcred.vc_pag = (__u64) current->uid; + if (sec->ps_flags & PTLRPC_SEC_FL_PAG) + vcred.vc_pag = (__u64) current->pag; + else + vcred.vc_pag = (__u64) current->uid; vcred.vc_uid = current->uid; } @@ -826,7 +833,7 @@ void ptlrpcs_sec_put(struct ptlrpc_sec *sec) int ncred; if (atomic_dec_and_test(&sec->ps_refcount)) { - flush_credcache(sec, -1, 1, 1); + flush_credcache(sec, -1, -1, 1, 1); /* this spinlock is protect against ptlrpcs_cred_destroy() */ spin_lock(&sec->ps_lock); @@ -846,7 +853,7 @@ void ptlrpcs_sec_put(struct ptlrpc_sec *sec) void ptlrpcs_sec_invalidate_cache(struct ptlrpc_sec *sec) { - flush_credcache(sec, -1, 0, 1); + flush_credcache(sec, -1, -1, 0, 1); } int sec_alloc_reqbuf(struct ptlrpc_sec *sec, @@ -1029,10 +1036,9 @@ int ptlrpcs_import_get_sec(struct obd_import *imp) RETURN(0); /* find actual flavor for client obd. right now server side - * obd (reverse imp, etc) will simply use NULL. - */ - if (!strcmp(imp->imp_obd->obd_type->typ_name, "mdc") || - !strcmp(imp->imp_obd->obd_type->typ_name, "osc")) { + * obd (reverse imp, etc) will simply use NULL. */ + if (!strcmp(imp->imp_obd->obd_type->typ_name, OBD_MDC_DEVICENAME) || + !strcmp(imp->imp_obd->obd_type->typ_name, OBD_OSC_DEVICENAME)) { struct client_obd *cli = &imp->imp_obd->u.cli; switch (SEC_FLAVOR_MAJOR(cli->cl_sec_flavor)) { @@ -1050,7 +1056,8 @@ int ptlrpcs_import_get_sec(struct obd_import *imp) pipedir = imp->imp_obd->obd_name; break; default: - CWARN("unknown security flavor for %s(%s), use null\n", + CWARN("unknown security flavor for %s(%s), " + "use null\n", imp->imp_obd->obd_type->typ_name, imp->imp_obd->obd_name); } @@ -1075,13 +1082,13 @@ void ptlrpcs_import_drop_sec(struct obd_import *imp) EXIT; } -void ptlrpcs_import_flush_creds(struct obd_import *imp, uid_t uid) +void ptlrpcs_import_flush_current_creds(struct obd_import *imp) { LASSERT(imp); class_import_get(imp); if (imp->imp_sec) - flush_credcache(imp->imp_sec, uid, 1, 1); + flush_credcache(imp->imp_sec, current->pag, current->uid, 1, 1); class_import_put(imp); } @@ -1119,7 +1126,7 @@ EXPORT_SYMBOL(ptlrpcs_sec_put); EXPORT_SYMBOL(ptlrpcs_sec_invalidate_cache); EXPORT_SYMBOL(ptlrpcs_import_get_sec); EXPORT_SYMBOL(ptlrpcs_import_drop_sec); -EXPORT_SYMBOL(ptlrpcs_import_flush_creds); +EXPORT_SYMBOL(ptlrpcs_import_flush_current_creds); EXPORT_SYMBOL(ptlrpcs_cred_lookup); EXPORT_SYMBOL(ptlrpcs_cred_put); EXPORT_SYMBOL(ptlrpcs_req_get_cred);