These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / staging / lustre / lustre / llite / remote_perm.c
index a581826..fe4a722 100644 (file)
 #include "../include/lustre_param.h"
 #include "llite_internal.h"
 
-struct kmem_cache *ll_remote_perm_cachep = NULL;
-struct kmem_cache *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;
 
-       OBD_SLAB_ALLOC_PTR_GFP(lrp, ll_remote_perm_cachep, GFP_KERNEL);
+       lrp = kmem_cache_alloc(ll_remote_perm_cachep, GFP_KERNEL | __GFP_ZERO);
        if (lrp)
                INIT_HLIST_NODE(&lrp->lrp_list);
        return lrp;
@@ -74,7 +74,7 @@ static inline void free_ll_remote_perm(struct ll_remote_perm *lrp)
 
        if (!hlist_unhashed(&lrp->lrp_list))
                hlist_del(&lrp->lrp_list);
-       OBD_SLAB_FREE(lrp, ll_remote_perm_cachep, sizeof(*lrp));
+       kmem_cache_free(ll_remote_perm_cachep, lrp);
 }
 
 static struct hlist_head *alloc_rmtperm_hash(void)
@@ -82,9 +82,7 @@ static struct hlist_head *alloc_rmtperm_hash(void)
        struct hlist_head *hash;
        int i;
 
-       OBD_SLAB_ALLOC_GFP(hash, ll_rmtperm_hash_cachep,
-                          REMOTE_PERM_HASHSIZE * sizeof(*hash),
-                          GFP_IOFS);
+       hash = kmem_cache_alloc(ll_rmtperm_hash_cachep, GFP_NOFS | __GFP_ZERO);
        if (!hash)
                return NULL;
 
@@ -104,11 +102,9 @@ void free_rmtperm_hash(struct hlist_head *hash)
                return;
 
        for (i = 0; i < REMOTE_PERM_HASHSIZE; i++)
-               hlist_for_each_entry_safe(lrp, next, hash + i,
-                                             lrp_list)
+               hlist_for_each_entry_safe(lrp, next, hash + i, lrp_list)
                        free_ll_remote_perm(lrp);
-       OBD_SLAB_FREE(hash, ll_rmtperm_hash_cachep,
-                     REMOTE_PERM_HASHSIZE * sizeof(*hash));
+       kmem_cache_free(ll_rmtperm_hash_cachep, hash);
 }
 
 static inline int remote_perm_hashfunc(uid_t uid)
@@ -117,7 +113,8 @@ static inline int remote_perm_hashfunc(uid_t uid)
 }
 
 /* NB: setxid permission is not checked here, instead it's done on
- * MDT when client get remote permission. */
+ * MDT when client get remote permission.
+ */
 static int do_check_remote_perm(struct ll_inode_info *lli, int mask)
 {
        struct hlist_head *head;
@@ -184,7 +181,7 @@ int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm)
 
        if (!lli->lli_remote_perms) {
                perm_hash = alloc_rmtperm_hash();
-               if (perm_hash == NULL) {
+               if (!perm_hash) {
                        CERROR("alloc lli_remote_perms failed!\n");
                        return -ENOMEM;
                }
@@ -249,7 +246,6 @@ int lustre_check_remote_perm(struct inode *inode, int mask)
        struct ll_sb_info *sbi = ll_i2sbi(inode);
        struct ptlrpc_request *req = NULL;
        struct mdt_remote_perm *perm;
-       struct obd_capa *oc;
        unsigned long save;
        int i = 0, rc;
 
@@ -276,10 +272,8 @@ int lustre_check_remote_perm(struct inode *inode, int mask)
                        LBUG();
                }
 
-               oc = ll_mdscapa_get(inode);
-               rc = md_get_remote_perm(sbi->ll_md_exp, ll_inode2fid(inode), oc,
+               rc = md_get_remote_perm(sbi->ll_md_exp, ll_inode2fid(inode),
                                        ll_i2suppgid(inode), &req);
-               capa_put(oc);
                if (rc) {
                        mutex_unlock(&lli->lli_rmtperm_mutex);
                        break;
@@ -287,7 +281,7 @@ int lustre_check_remote_perm(struct inode *inode, int mask)
 
                perm = req_capsule_server_swab_get(&req->rq_pill, &RMF_ACL,
                                                   lustre_swab_mdt_remote_perm);
-               if (unlikely(perm == NULL)) {
+               if (unlikely(!perm)) {
                        mutex_unlock(&lli->lli_rmtperm_mutex);
                        rc = -EPROTO;
                        break;
@@ -321,8 +315,7 @@ void ll_free_remote_perms(struct inode *inode)
        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)
+               hlist_for_each_entry_safe(lrp, node, next, hash + i, lrp_list)
                        free_ll_remote_perm(lrp);
        }