X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fllite%2Fremote_perm.c;h=8cc8c65cf327fd25cdf05433009f01d74becbd71;hb=110d8d4952a9de607cf21f648d75e0b05ef0cee1;hp=6febb2ebd0b319162a171eb24835fe4e53c25339;hpb=e3a7c58aebafce40323db54bf6056029e5af4a70;p=fs%2Flustre-release.git diff --git a/lustre/llite/remote_perm.c b/lustre/llite/remote_perm.c index 6febb2e..8cc8c65 100644 --- a/lustre/llite/remote_perm.c +++ b/lustre/llite/remote_perm.c @@ -27,7 +27,7 @@ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2012, Whamcloud, Inc. + * Copyright (c) 2012, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -55,17 +55,17 @@ #include #include "llite_internal.h" -cfs_mem_cache_t *ll_remote_perm_cachep = NULL; -cfs_mem_cache_t *ll_rmtperm_hash_cachep = NULL; +struct kmem_cache *ll_remote_perm_cachep; +struct kmem_cache *ll_rmtperm_hash_cachep; static inline struct ll_remote_perm *alloc_ll_remote_perm(void) { - struct ll_remote_perm *lrp; + struct ll_remote_perm *lrp; - OBD_SLAB_ALLOC_PTR_GFP(lrp, ll_remote_perm_cachep, GFP_KERNEL); - if (lrp) - CFS_INIT_HLIST_NODE(&lrp->lrp_list); - return lrp; + OBD_SLAB_ALLOC_PTR_GFP(lrp, ll_remote_perm_cachep, GFP_KERNEL); + if (lrp) + CFS_INIT_HLIST_NODE(&lrp->lrp_list); + return lrp; } static inline void free_ll_remote_perm(struct ll_remote_perm *lrp) @@ -83,9 +83,9 @@ cfs_hlist_head_t *alloc_rmtperm_hash(void) cfs_hlist_head_t *hash; int i; - OBD_SLAB_ALLOC(hash, ll_rmtperm_hash_cachep, GFP_KERNEL, - REMOTE_PERM_HASHSIZE * sizeof(*hash)); - + OBD_SLAB_ALLOC_GFP(hash, ll_rmtperm_hash_cachep, + REMOTE_PERM_HASHSIZE * sizeof(*hash), + GFP_IOFS); if (!hash) return NULL; @@ -127,24 +127,24 @@ static int do_check_remote_perm(struct ll_inode_info *lli, int mask) int found = 0, rc; ENTRY; - if (!lli->lli_remote_perms) - RETURN(-ENOENT); - - head = lli->lli_remote_perms + remote_perm_hashfunc(cfs_curproc_uid()); - - cfs_spin_lock(&lli->lli_lock); - cfs_hlist_for_each_entry(lrp, node, head, lrp_list) { - if (lrp->lrp_uid != cfs_curproc_uid()) - continue; - if (lrp->lrp_gid != cfs_curproc_gid()) - continue; - if (lrp->lrp_fsuid != cfs_curproc_fsuid()) - continue; - if (lrp->lrp_fsgid != cfs_curproc_fsgid()) - continue; - found = 1; - break; - } + if (!lli->lli_remote_perms) + RETURN(-ENOENT); + + head = lli->lli_remote_perms + remote_perm_hashfunc(current_uid()); + + spin_lock(&lli->lli_lock); + cfs_hlist_for_each_entry(lrp, node, head, lrp_list) { + if (lrp->lrp_uid != current_uid()) + continue; + if (lrp->lrp_gid != current_gid()) + continue; + if (lrp->lrp_fsuid != current_fsuid()) + continue; + if (lrp->lrp_fsgid != current_fsgid()) + continue; + found = 1; + break; + } if (!found) GOTO(out, rc = -ENOENT); @@ -155,8 +155,8 @@ static int do_check_remote_perm(struct ll_inode_info *lli, int mask) rc = ((lrp->lrp_access_perm & mask) == mask) ? 0 : -EACCES; out: - cfs_spin_unlock(&lli->lli_lock); - return rc; + spin_unlock(&lli->lli_lock); + return rc; } int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm) @@ -192,7 +192,7 @@ int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm) } } - cfs_spin_lock(&lli->lli_lock); + spin_lock(&lli->lli_lock); if (!lli->lli_remote_perms) lli->lli_remote_perms = perm_hash; @@ -217,16 +217,16 @@ again: break; } - if (!lrp) { - cfs_spin_unlock(&lli->lli_lock); - lrp = alloc_ll_remote_perm(); - if (!lrp) { - CERROR("alloc memory for ll_remote_perm failed!\n"); - RETURN(-ENOMEM); - } - cfs_spin_lock(&lli->lli_lock); - goto again; - } + if (!lrp) { + spin_unlock(&lli->lli_lock); + lrp = alloc_ll_remote_perm(); + if (!lrp) { + CERROR("alloc memory for ll_remote_perm failed!\n"); + RETURN(-ENOMEM); + } + spin_lock(&lli->lli_lock); + goto again; + } lrp->lrp_access_perm = perm->rp_access_perm; if (lrp != tmp) { @@ -237,7 +237,7 @@ again: cfs_hlist_add_head(&lrp->lrp_list, head); } lli->lli_rmtperm_time = cfs_time_current(); - cfs_spin_unlock(&lli->lli_lock); + spin_unlock(&lli->lli_lock); CDEBUG(D_SEC, "new remote perm@%p: %u/%u/%u/%u - %#x\n", lrp, lrp->lrp_uid, lrp->lrp_gid, lrp->lrp_fsuid, lrp->lrp_fsgid, @@ -257,23 +257,23 @@ int lustre_check_remote_perm(struct inode *inode, int mask) int i = 0, rc; ENTRY; - do { - save = lli->lli_rmtperm_time; - rc = do_check_remote_perm(lli, mask); - if (!rc || (rc != -ENOENT && i)) - break; + do { + save = lli->lli_rmtperm_time; + rc = do_check_remote_perm(lli, mask); + if (!rc || (rc != -ENOENT && i)) + break; - cfs_might_sleep(); + might_sleep(); - cfs_mutex_lock(&lli->lli_rmtperm_mutex); - /* check again */ - if (save != lli->lli_rmtperm_time) { - rc = do_check_remote_perm(lli, mask); - if (!rc || (rc != -ENOENT && i)) { - cfs_mutex_unlock(&lli->lli_rmtperm_mutex); - break; - } - } + mutex_lock(&lli->lli_rmtperm_mutex); + /* check again */ + if (save != lli->lli_rmtperm_time) { + rc = do_check_remote_perm(lli, mask); + if (!rc || (rc != -ENOENT && i)) { + mutex_unlock(&lli->lli_rmtperm_mutex); + break; + } + } if (i++ > 5) { CERROR("check remote perm falls in dead loop!\n"); @@ -285,20 +285,20 @@ int lustre_check_remote_perm(struct inode *inode, int mask) ll_i2suppgid(inode), &req); capa_put(oc); if (rc) { - cfs_mutex_unlock(&lli->lli_rmtperm_mutex); + mutex_unlock(&lli->lli_rmtperm_mutex); break; } perm = req_capsule_server_swab_get(&req->rq_pill, &RMF_ACL, lustre_swab_mdt_remote_perm); if (unlikely(perm == NULL)) { - cfs_mutex_unlock(&lli->lli_rmtperm_mutex); + mutex_unlock(&lli->lli_rmtperm_mutex); rc = -EPROTO; break; } rc = ll_update_remote_perm(inode, perm); - cfs_mutex_unlock(&lli->lli_rmtperm_mutex); + mutex_unlock(&lli->lli_rmtperm_mutex); if (rc == -ENOMEM) break; @@ -322,14 +322,14 @@ void ll_free_remote_perms(struct inode *inode) LASSERT(hash); - cfs_spin_lock(&lli->lli_lock); + spin_lock(&lli->lli_lock); - for (i = 0; i < REMOTE_PERM_HASHSIZE; i++) { - cfs_hlist_for_each_entry_safe(lrp, node, next, hash + i, - lrp_list) - free_ll_remote_perm(lrp); - } + for (i = 0; i < REMOTE_PERM_HASHSIZE; i++) { + cfs_hlist_for_each_entry_safe(lrp, node, next, hash + i, + lrp_list) + free_ll_remote_perm(lrp); + } - cfs_spin_unlock(&lli->lli_lock); + spin_unlock(&lli->lli_lock); } #endif