X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fllite%2Fremote_perm.c;h=f90de1fc93cc904ef97a2cc822b28616d08b0044;hb=a6527b28ba2082a445fbf584909a7791ce407ef3;hp=7c0694989f9337e7c0c8280624f70a1f33bdc6dc;hpb=f12cf87b8b1608002784ca68a33502b14226751a;p=fs%2Flustre-release.git diff --git a/lustre/llite/remote_perm.c b/lustre/llite/remote_perm.c index 7c06949..f90de1f 100644 --- a/lustre/llite/remote_perm.c +++ b/lustre/llite/remote_perm.c @@ -1,33 +1,50 @@ /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * - * Lustre Permission Cache for Remote Client - * Author: Lai Siyao - * Author: Fan Yong + * GPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). * - * Copyright (c) 2004-2006 Cluster File Systems, Inc. + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * This file is part of Lustre, http://www.lustre.org. + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. * - * Lustre is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. + * GPL HEADER END + */ +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Use is subject to license terms. + */ +/* + * This file is part of Lustre, http://www.lustre.org/ + * Lustre is a trademark of Sun Microsystems, Inc. * - * Lustre is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * lustre/llite/remote_perm.c + * + * Lustre Permission Cache for Remote Client * - * You should have received a copy of the GNU General Public License - * along with Lustre; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Author: Lai Siyao + * Author: Fan Yong */ #define DEBUG_SUBSYSTEM S_LLITE #include #include -#include #include #include @@ -45,9 +62,9 @@ static inline struct ll_remote_perm *alloc_ll_remote_perm(void) { struct ll_remote_perm *lrp; - OBD_SLAB_ALLOC(lrp, ll_remote_perm_cachep, GFP_KERNEL, sizeof(*lrp)); + OBD_SLAB_ALLOC_PTR_GFP(lrp, ll_remote_perm_cachep, GFP_KERNEL); if (lrp) - INIT_HLIST_NODE(&lrp->lrp_list); + CFS_INIT_HLIST_NODE(&lrp->lrp_list); return lrp; } @@ -56,14 +73,14 @@ static inline void free_ll_remote_perm(struct ll_remote_perm *lrp) if (!lrp) return; - if (!hlist_unhashed(&lrp->lrp_list)) - hlist_del(&lrp->lrp_list); + if (!cfs_hlist_unhashed(&lrp->lrp_list)) + cfs_hlist_del(&lrp->lrp_list); OBD_SLAB_FREE(lrp, ll_remote_perm_cachep, sizeof(*lrp)); } -struct hlist_head *alloc_rmtperm_hash(void) +cfs_hlist_head_t *alloc_rmtperm_hash(void) { - struct hlist_head *hash; + cfs_hlist_head_t *hash; int i; OBD_SLAB_ALLOC(hash, ll_rmtperm_hash_cachep, GFP_KERNEL, @@ -73,22 +90,23 @@ struct hlist_head *alloc_rmtperm_hash(void) return NULL; for (i = 0; i < REMOTE_PERM_HASHSIZE; i++) - INIT_HLIST_HEAD(hash + i); + CFS_INIT_HLIST_HEAD(hash + i); return hash; } -void free_rmtperm_hash(struct hlist_head *hash) +void free_rmtperm_hash(cfs_hlist_head_t *hash) { int i; struct ll_remote_perm *lrp; - struct hlist_node *node, *next; + cfs_hlist_node_t *node, *next; if(!hash) return; for (i = 0; i < REMOTE_PERM_HASHSIZE; i++) - hlist_for_each_entry_safe(lrp, node, next, hash + i, lrp_list) + cfs_hlist_for_each_entry_safe(lrp, node, next, hash + i, + lrp_list) free_ll_remote_perm(lrp); OBD_SLAB_FREE(hash, ll_rmtperm_hash_cachep, REMOTE_PERM_HASHSIZE * sizeof(*hash)); @@ -103,26 +121,26 @@ static inline int remote_perm_hashfunc(uid_t uid) * MDT when client get remote permission. */ static int do_check_remote_perm(struct ll_inode_info *lli, int mask) { - struct hlist_head *head; + cfs_hlist_head_t *head; struct ll_remote_perm *lrp; - struct hlist_node *node; + cfs_hlist_node_t *node; int found = 0, rc; ENTRY; if (!lli->lli_remote_perms) RETURN(-ENOENT); - head = lli->lli_remote_perms + remote_perm_hashfunc(current->uid); + head = lli->lli_remote_perms + remote_perm_hashfunc(cfs_curproc_uid()); - spin_lock(&lli->lli_lock); - hlist_for_each_entry(lrp, node, head, lrp_list) { - if (lrp->lrp_uid != current->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 != current->gid) + if (lrp->lrp_gid != cfs_curproc_gid()) continue; - if (lrp->lrp_fsuid != current->fsuid) + if (lrp->lrp_fsuid != cfs_curproc_fsuid()) continue; - if (lrp->lrp_fsgid != current->fsgid) + if (lrp->lrp_fsgid != cfs_curproc_fsgid()) continue; found = 1; break; @@ -137,7 +155,7 @@ static int do_check_remote_perm(struct ll_inode_info *lli, int mask) rc = ((lrp->lrp_access_perm & mask) == mask) ? 0 : -EACCES; out: - spin_unlock(&lli->lli_lock); + cfs_spin_unlock(&lli->lli_lock); return rc; } @@ -145,8 +163,8 @@ int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm) { struct ll_inode_info *lli = ll_i2info(inode); struct ll_remote_perm *lrp = NULL, *tmp = NULL; - struct hlist_head *head, *perm_hash = NULL; - struct hlist_node *node; + cfs_hlist_head_t *head, *perm_hash = NULL; + cfs_hlist_node_t *node; ENTRY; LASSERT(ll_i2sbi(inode)->ll_flags & LL_SBI_RMT_CLIENT); @@ -174,7 +192,7 @@ int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm) } } - spin_lock(&lli->lli_lock); + cfs_spin_lock(&lli->lli_lock); if (!lli->lli_remote_perms) lli->lli_remote_perms = perm_hash; @@ -184,7 +202,7 @@ int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm) head = lli->lli_remote_perms + remote_perm_hashfunc(perm->rp_uid); again: - hlist_for_each_entry(tmp, node, head, lrp_list) { + cfs_hlist_for_each_entry(tmp, node, head, lrp_list) { if (tmp->lrp_uid != perm->rp_uid) continue; if (tmp->lrp_gid != perm->rp_gid) @@ -200,13 +218,13 @@ again: } if (!lrp) { - spin_unlock(&lli->lli_lock); + cfs_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); + cfs_spin_lock(&lli->lli_lock); goto again; } @@ -216,10 +234,10 @@ again: lrp->lrp_gid = perm->rp_gid; lrp->lrp_fsuid = perm->rp_fsuid; lrp->lrp_fsgid = perm->rp_fsgid; - hlist_add_head(&lrp->lrp_list, head); + cfs_hlist_add_head(&lrp->lrp_list, head); } lli->lli_rmtperm_utime = jiffies; - spin_unlock(&lli->lli_lock); + cfs_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, @@ -245,14 +263,14 @@ int lustre_check_remote_perm(struct inode *inode, int mask) if (!rc || (rc != -ENOENT && i)) break; - might_sleep(); + cfs_might_sleep(); - down(&lli->lli_rmtperm_sem); + cfs_down(&lli->lli_rmtperm_sem); /* check again */ if (utime != lli->lli_rmtperm_utime) { rc = do_check_remote_perm(lli, mask); if (!rc || (rc != -ENOENT && i)) { - up(&lli->lli_rmtperm_sem); + cfs_up(&lli->lli_rmtperm_sem); break; } } @@ -267,20 +285,20 @@ int lustre_check_remote_perm(struct inode *inode, int mask) ll_i2suppgid(inode), &req); capa_put(oc); if (rc) { - up(&lli->lli_rmtperm_sem); + cfs_up(&lli->lli_rmtperm_sem); break; } perm = req_capsule_server_swab_get(&req->rq_pill, &RMF_ACL, lustre_swab_mdt_remote_perm); if (unlikely(perm == NULL)) { - up(&lli->lli_rmtperm_sem); + cfs_up(&lli->lli_rmtperm_sem); rc = -EPROTO; break; } rc = ll_update_remote_perm(inode, perm); - up(&lli->lli_rmtperm_sem); + cfs_up(&lli->lli_rmtperm_sem); if (rc == -ENOMEM) break; @@ -297,20 +315,21 @@ int lustre_check_remote_perm(struct inode *inode, int mask) void ll_free_remote_perms(struct inode *inode) { struct ll_inode_info *lli = ll_i2info(inode); - struct hlist_head *hash = lli->lli_remote_perms; + cfs_hlist_head_t *hash = lli->lli_remote_perms; struct ll_remote_perm *lrp; - struct hlist_node *node, *next; + cfs_hlist_node_t *node, *next; int i; LASSERT(hash); - spin_lock(&lli->lli_lock); + cfs_spin_lock(&lli->lli_lock); for (i = 0; i < REMOTE_PERM_HASHSIZE; i++) { - hlist_for_each_entry_safe(lrp, node, next, hash + i, lrp_list) + cfs_hlist_for_each_entry_safe(lrp, node, next, hash + i, + lrp_list) free_ll_remote_perm(lrp); } - spin_unlock(&lli->lli_lock); + cfs_spin_unlock(&lli->lli_lock); } #endif