/* -*- 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 <lsy@clusterfs.com>
- * Author: Fan Yong <fanyong@clusterfs.com>
+ * GPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
- * Copyright (c) 2004-2006 Cluster File Systems, Inc.
+ * 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 file is part of Lustre, http://www.lustre.org.
+ * 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).
*
- * 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.
+ * 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
*
- * 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.
+ * 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.
*
- * 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.
+ * GPL HEADER END
+ */
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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/llite/remote_perm.c
+ *
+ * Lustre Permission Cache for Remote Client
+ *
+ * Author: Lai Siyao <lsy@clusterfs.com>
+ * Author: Fan Yong <fanyong@clusterfs.com>
*/
#define DEBUG_SUBSYSTEM S_LLITE
{
struct ll_remote_perm *lrp;
- OBD_SLAB_ALLOC(lrp, ll_remote_perm_cachep, SLAB_KERNEL, sizeof(*lrp));
+ OBD_SLAB_ALLOC(lrp, ll_remote_perm_cachep, GFP_KERNEL, sizeof(*lrp));
if (lrp)
INIT_HLIST_NODE(&lrp->lrp_list);
return lrp;
struct hlist_head *hash;
int i;
- OBD_SLAB_ALLOC(hash, ll_rmtperm_hash_cachep, SLAB_KERNEL,
+ OBD_SLAB_ALLOC(hash, ll_rmtperm_hash_cachep, GFP_KERNEL,
REMOTE_PERM_HASHSIZE * sizeof(*hash));
if (!hash)
}
/* NB: setxid permission is not checked here, instead it's done on
- * MDT when client get remote permission. (lookup/mdc_get_remote_perm). */
+ * MDT when client get remote permission. */
static int do_check_remote_perm(struct ll_inode_info *lli, int mask)
{
struct hlist_head *head;
int i = 0, rc;
ENTRY;
-check:
- utime = lli->lli_rmtperm_utime;
- rc = do_check_remote_perm(lli, mask);
- if (!rc || ((rc != -ENOENT) && i))
- RETURN(rc);
+ do {
+ utime = lli->lli_rmtperm_utime;
+ rc = do_check_remote_perm(lli, mask);
+ if (!rc || (rc != -ENOENT && i))
+ break;
+
+ might_sleep();
+
+ 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);
+ break;
+ }
+ }
- might_sleep();
+ if (i++ > 5) {
+ CERROR("check remote perm falls in dead loop!\n");
+ LBUG();
+ }
- 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)) {
+ oc = ll_mdscapa_get(inode);
+ rc = md_get_remote_perm(sbi->ll_md_exp, ll_inode2fid(inode), oc,
+ ll_i2suppgid(inode), &req);
+ capa_put(oc);
+ if (rc) {
up(&lli->lli_rmtperm_sem);
- RETURN(rc);
+ break;
}
- }
- if (i++ > 5) {
- CERROR("check remote perm falls in dead loop!\n");
- LBUG();
- }
+ 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);
+ rc = -EPROTO;
+ break;
+ }
- oc = ll_mdscapa_get(inode);
- rc = md_get_remote_perm(sbi->ll_md_exp, ll_inode2fid(inode), oc,
- ll_i2suppgid(inode), &req);
- capa_put(oc);
- if (rc) {
+ rc = ll_update_remote_perm(inode, perm);
up(&lli->lli_rmtperm_sem);
- RETURN(rc);
- }
-
- perm = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF + 1, sizeof(*perm));
- LASSERT(perm);
- LASSERT(lustre_rep_swabbed(req, REPLY_REC_OFF + 1));
-
- rc = ll_update_remote_perm(inode, perm);
- up(&lli->lli_rmtperm_sem);
+ if (rc == -ENOMEM)
+ break;
+ ptlrpc_req_finished(req);
+ req = NULL;
+ } while (1);
ptlrpc_req_finished(req);
-
- if (rc == -ENOMEM)
- RETURN(rc);
-
- goto check;
+ RETURN(rc);
}
#if 0 /* NB: remote perms can't be freed in ll_mdc_blocking_ast of UPDATE lock,