Whamcloud - gitweb
git://git.whamcloud.com
/
fs
/
lustre-release.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
LU-1812 ext4: ec_type has been dropped from ext4_ext_cache
[fs/lustre-release.git]
/
lustre
/
llite
/
remote_perm.c
diff --git
a/lustre/llite/remote_perm.c
b/lustre/llite/remote_perm.c
index
420d0fa
..
ddba291
100644
(file)
--- a/
lustre/llite/remote_perm.c
+++ b/
lustre/llite/remote_perm.c
@@
-1,6
+1,4
@@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
* GPL HEADER START
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* GPL HEADER START
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@
-26,8
+24,10
@@
* GPL HEADER END
*/
/*
* GPL HEADER END
*/
/*
- * Copyright
2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright
(c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
* Use is subject to license terms.
+ *
+ * Copyright (c) 2011, 2012, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
*/
/*
* This file is part of Lustre, http://www.lustre.org/
@@
-45,7
+45,6
@@
#include <linux/module.h>
#include <linux/types.h>
#include <linux/module.h>
#include <linux/types.h>
-#include <linux/random.h>
#include <linux/version.h>
#include <lustre_lite.h>
#include <linux/version.h>
#include <lustre_lite.h>
@@
-61,12
+60,12
@@
cfs_mem_cache_t *ll_rmtperm_hash_cachep = NULL;
static inline struct ll_remote_perm *alloc_ll_remote_perm(void)
{
static inline struct ll_remote_perm *alloc_ll_remote_perm(void)
{
-
struct ll_remote_perm *lrp;
+ struct ll_remote_perm *lrp;
-
OBD_SLAB_ALLOC(lrp, ll_remote_perm_cachep, GFP_KERNEL, sizeof(*lrp)
);
-
if (lrp)
-
INIT_HLIST_NODE(&lrp->lrp_list);
-
return lrp;
+
OBD_SLAB_ALLOC_PTR_GFP(lrp, ll_remote_perm_cachep, CFS_ALLOC_KERNEL
);
+ if (lrp)
+
CFS_
INIT_HLIST_NODE(&lrp->lrp_list);
+ return lrp;
}
static inline void free_ll_remote_perm(struct ll_remote_perm *lrp)
}
static inline void free_ll_remote_perm(struct ll_remote_perm *lrp)
@@
-74,39
+73,40
@@
static inline void free_ll_remote_perm(struct ll_remote_perm *lrp)
if (!lrp)
return;
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));
}
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;
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),
+ CFS_ALLOC_STD);
if (!hash)
return NULL;
for (i = 0; i < REMOTE_PERM_HASHSIZE; i++)
if (!hash)
return NULL;
for (i = 0; i < REMOTE_PERM_HASHSIZE; i++)
- INIT_HLIST_HEAD(hash + i);
+
CFS_
INIT_HLIST_HEAD(hash + i);
return hash;
}
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;
{
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++)
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));
free_ll_remote_perm(lrp);
OBD_SLAB_FREE(hash, ll_rmtperm_hash_cachep,
REMOTE_PERM_HASHSIZE * sizeof(*hash));
@@
-121,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)
{
* 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 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);
int found = 0, rc;
ENTRY;
if (!lli->lli_remote_perms)
RETURN(-ENOENT);
- head = lli->lli_remote_perms + remote_perm_hashfunc(c
urrent->uid
);
+ head = lli->lli_remote_perms + remote_perm_hashfunc(c
fs_curproc_uid()
);
-
spin_lock(&lli->lli_lock);
- hlist_for_each_entry(lrp, node, head, lrp_list) {
- if (lrp->lrp_uid != c
urrent->uid
)
+ spin_lock(&lli->lli_lock);
+
cfs_
hlist_for_each_entry(lrp, node, head, lrp_list) {
+ if (lrp->lrp_uid != c
fs_curproc_uid()
)
continue;
continue;
- if (lrp->lrp_gid != c
urrent->gid
)
+ if (lrp->lrp_gid != c
fs_curproc_gid()
)
continue;
continue;
- if (lrp->lrp_fsuid != c
urrent->fsuid
)
+ if (lrp->lrp_fsuid != c
fs_curproc_fsuid()
)
continue;
continue;
- if (lrp->lrp_fsgid != c
urrent->fsgid
)
+ if (lrp->lrp_fsgid != c
fs_curproc_fsgid()
)
continue;
found = 1;
break;
continue;
found = 1;
break;
@@
-155,16
+155,16
@@
static int do_check_remote_perm(struct ll_inode_info *lli, int mask)
rc = ((lrp->lrp_access_perm & mask) == mask) ? 0 : -EACCES;
out:
rc = ((lrp->lrp_access_perm & mask) == mask) ? 0 : -EACCES;
out:
-
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)
{
struct ll_inode_info *lli = ll_i2info(inode);
struct ll_remote_perm *lrp = NULL, *tmp = NULL;
}
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);
ENTRY;
LASSERT(ll_i2sbi(inode)->ll_flags & LL_SBI_RMT_CLIENT);
@@
-192,7
+192,7
@@
int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm)
}
}
}
}
-
spin_lock(&lli->lli_lock);
+ spin_lock(&lli->lli_lock);
if (!lli->lli_remote_perms)
lli->lli_remote_perms = perm_hash;
if (!lli->lli_remote_perms)
lli->lli_remote_perms = perm_hash;
@@
-202,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:
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)
if (tmp->lrp_uid != perm->rp_uid)
continue;
if (tmp->lrp_gid != perm->rp_gid)
@@
-217,16
+217,16
@@
again:
break;
}
break;
}
-
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;
-
}
+ 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) {
lrp->lrp_access_perm = perm->rp_access_perm;
if (lrp != tmp) {
@@
-234,10
+234,10
@@
again:
lrp->lrp_gid = perm->rp_gid;
lrp->lrp_fsuid = perm->rp_fsuid;
lrp->lrp_fsgid = perm->rp_fsgid;
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);
+ lli->lli_rmtperm_
time = cfs_time_current()
;
+ 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,
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,
@@
-253,24
+253,24
@@
int lustre_check_remote_perm(struct inode *inode, int mask)
struct ptlrpc_request *req = NULL;
struct mdt_remote_perm *perm;
struct obd_capa *oc;
struct ptlrpc_request *req = NULL;
struct mdt_remote_perm *perm;
struct obd_capa *oc;
-
unsigned long utim
e;
+
cfs_time_t sav
e;
int i = 0, rc;
ENTRY;
do {
int i = 0, rc;
ENTRY;
do {
-
utime = lli->lli_rmtperm_u
time;
+
save = lli->lli_rmtperm_
time;
rc = do_check_remote_perm(lli, mask);
if (!rc || (rc != -ENOENT && i))
break;
rc = do_check_remote_perm(lli, mask);
if (!rc || (rc != -ENOENT && i))
break;
- might_sleep();
+
cfs_
might_sleep();
-
down(&lli->lli_rmtperm_sem
);
+
mutex_lock(&lli->lli_rmtperm_mutex
);
/* check again */
/* check again */
- if (
utime != lli->lli_rmtperm_u
time) {
+ if (
save != lli->lli_rmtperm_
time) {
rc = do_check_remote_perm(lli, mask);
if (!rc || (rc != -ENOENT && i)) {
rc = do_check_remote_perm(lli, mask);
if (!rc || (rc != -ENOENT && i)) {
-
up(&lli->lli_rmtperm_sem
);
+
mutex_unlock(&lli->lli_rmtperm_mutex
);
break;
}
}
break;
}
}
@@
-285,20
+285,20
@@
int lustre_check_remote_perm(struct inode *inode, int mask)
ll_i2suppgid(inode), &req);
capa_put(oc);
if (rc) {
ll_i2suppgid(inode), &req);
capa_put(oc);
if (rc) {
-
up(&lli->lli_rmtperm_sem
);
+
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)) {
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
);
+
mutex_unlock(&lli->lli_rmtperm_mutex
);
rc = -EPROTO;
break;
}
rc = ll_update_remote_perm(inode, perm);
rc = -EPROTO;
break;
}
rc = ll_update_remote_perm(inode, perm);
-
up(&lli->lli_rmtperm_sem
);
+
mutex_unlock(&lli->lli_rmtperm_mutex
);
if (rc == -ENOMEM)
break;
if (rc == -ENOMEM)
break;
@@
-315,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);
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 ll_remote_perm *lrp;
-
struct hlist_node
*node, *next;
+
cfs_hlist_node_t
*node, *next;
int i;
LASSERT(hash);
int i;
LASSERT(hash);
-
spin_lock(&lli->lli_lock);
+ 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)
- 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);
+ }
-
spin_unlock(&lli->lli_lock);
+ spin_unlock(&lli->lli_lock);
}
#endif
}
#endif