Whamcloud - gitweb
b=16488
[fs/lustre-release.git] / lustre / lvfs / upcall_cache.c
index 71a0022..084e6ef 100644 (file)
@@ -1,29 +1,46 @@
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
- *  Supplementary groups cache.
+ * GPL HEADER START
  *
- *  Copyright (c) 2004 Cluster File Systems, Inc.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- *   This file is part of Lustre, http://www.lustre.org.
+ * 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.
  *
- *   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.
+ * 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 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.
+ * 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
  *
- *   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.
+ * 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.
+ *
+ * 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/lvfs/upcall_cache.c
+ *
+ * Supplementary groups cache.
  */
 
 #define DEBUG_SUBSYSTEM S_SEC
 
-#ifdef HAVE_KERNEL_CONFIG_H
+#ifndef AUTOCONF_INCLUDED
 #include <linux/config.h>
 #endif
 #include <linux/module.h>
 #include <linux/stat.h>
 #include <asm/uaccess.h>
 #include <linux/slab.h>
-#include <asm/segment.h>
 
 #include <obd_support.h>
 #include <lustre_lib.h>
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,4)
-struct group_info *groups_alloc(int ngroups)
-{
-        struct group_info *ginfo;
-
-        LASSERT(ngroups <= NGROUPS_SMALL);
-
-        OBD_ALLOC(ginfo, sizeof(*ginfo) + 1 * sizeof(gid_t *));
-        if (!ginfo)
-                return NULL;
-        ginfo->ngroups = ngroups;
-        ginfo->nblocks = 1;
-        ginfo->blocks[0] = ginfo->small_block;
-        atomic_set(&ginfo->usage, 1);
-
-        return ginfo;
-}
-
-void groups_free(struct group_info *ginfo)
-{
-        LASSERT(ginfo->ngroups <= NGROUPS_SMALL);
-        LASSERT(ginfo->nblocks == 1);
-        LASSERT(ginfo->blocks[0] == ginfo->small_block);
-
-        OBD_FREE(ginfo, sizeof(*ginfo) + 1 * sizeof(gid_t *));
-}
-#endif
-
 static struct upcall_cache_entry *alloc_entry(struct upcall_cache *cache,
                                               __u64 key, void *args)
 {
@@ -236,6 +224,10 @@ find_again:
                 if (rc < 0) {
                         UC_CACHE_CLEAR_ACQUIRING(entry);
                         UC_CACHE_SET_INVALID(entry);
+                        if (unlikely(rc == -EREMCHG)) {
+                                put_entry(cache, entry);
+                                GOTO(out, entry = ERR_PTR(rc));
+                        }
                 }
                 /* fall through */
         }
@@ -350,7 +342,7 @@ int upcall_cache_downcall(struct upcall_cache *cache, __u32 err, __u64 key,
         }
 
         if (!UC_CACHE_IS_ACQUIRING(entry)) {
-                CDEBUG(D_HA, "%s: found uptodate entry %p (key "LPU64")\n",
+                CDEBUG(D_RPCTRACE,"%s: found uptodate entry %p (key "LPU64")\n",
                        cache->uc_name, entry, entry->ue_key);
                 GOTO(out, rc = 0);
         }
@@ -464,6 +456,7 @@ struct upcall_cache *upcall_cache_init(const char *name, const char *upcall,
                 RETURN(ERR_PTR(-ENOMEM));
 
         spin_lock_init(&cache->uc_lock);
+        rwlock_init(&cache->uc_upcall_rwlock);
         for (i = 0; i < UC_CACHE_HASH_SIZE; i++)
                 INIT_LIST_HEAD(&cache->uc_hashtable[i]);
         strncpy(cache->uc_name, name, sizeof(cache->uc_name) - 1);