patch-2.4.20 linux-2.4.20/fs/intermezzo/cache.c

Next file: linux-2.4.20/fs/intermezzo/dcache.c
Previous file: linux-2.4.20/fs/intermezzo/Makefile
Back to the patch index
Back to the overall index

diff -urN linux-2.4.19/fs/intermezzo/cache.c linux-2.4.20/fs/intermezzo/cache.c
@@ -1,10 +1,23 @@
-/*
- *
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
  *
  *  Copyright (C) 2000 Stelias Computing, Inc.
  *  Copyright (C) 2000 Red Hat, Inc.
  *
+ *   This file is part of InterMezzo, http://www.inter-mezzo.org.
+ *
+ *   InterMezzo 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.
+ *
+ *   InterMezzo 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
+ *   along with InterMezzo; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
 #define __NO_VERSION__
@@ -27,7 +40,6 @@
 #include <linux/init.h>
 
 #include <linux/intermezzo_fs.h>
-#include <linux/intermezzo_upcall.h>
 #include <linux/intermezzo_psdev.h>
 
 /*
@@ -38,6 +50,8 @@
    The methods for the cache are set up in methods.
 */
 
+extern kmem_cache_t * presto_dentry_slab;
+
 /* the intent of this hash is to have collision chains of length 1 */
 #define CACHES_BITS 8
 #define CACHES_SIZE (1 << CACHES_BITS)
@@ -56,7 +70,7 @@
         cache->cache_dev = dev;
 }
 
-inline void presto_init_cache_hash(void)
+inline void presto_cache_init_hash(void)
 {
         int i;
         for ( i = 0; i < CACHES_SIZE; i++ ) {
@@ -65,7 +79,7 @@
 }
 
 /* map a device to a cache */
-struct presto_cache *presto_find_cache(kdev_t dev)
+struct presto_cache *presto_cache_find(kdev_t dev)
 {
         struct presto_cache *cache;
         struct list_head *lh, *tmp;
@@ -85,85 +99,19 @@
 struct presto_cache *presto_get_cache(struct inode *inode)
 {
         struct presto_cache *cache;
-
+        ENTRY;
         /* find the correct presto_cache here, based on the device */
-        cache = presto_find_cache(inode->i_dev);
+        cache = presto_cache_find(inode->i_dev);
         if ( !cache ) {
-                printk("WARNING: no presto cache for dev %x, ino %ld\n",
+                CERROR("WARNING: no presto cache for dev %x, ino %ld\n",
                        inode->i_dev, inode->i_ino);
                 EXIT;
                 return NULL;
         }
+        EXIT;
         return cache;
 }
 
-
-/* list cache mount points for ioctl's or /proc/fs/intermezzo/mounts */
-int presto_sprint_mounts(char *buf, int buflen, int minor)
-{
-        int len = 0;
-        int i;
-        struct list_head *head, *tmp;
-        struct presto_cache *cache;
-
-        buf[0] = '\0';
-        for (i=0 ; i<CACHES_SIZE ; i++) {
-                head = tmp = &presto_caches[i];
-                while ( (tmp = tmp->next) != head ) {
-                        cache = list_entry(tmp, struct presto_cache,
-                                            cache_chain);
-                        if ( !cache->cache_root_fileset || !cache->cache_mtpt)
-                                continue;
-                        if ((minor != -1) &&
-                            (cache->cache_psdev->uc_minor != minor))
-                                continue;
-                        if ( strlen(cache->cache_root_fileset) +
-                             strlen(cache->cache_mtpt) + 
-                             strlen(cache->cache_psdev->uc_devname) +
-                             4 > buflen - len)
-                                break;
-                        len += sprintf(buf + len, "%s %s %s\n",
-                                       cache->cache_root_fileset,
-                                       cache->cache_mtpt,
-                                       cache->cache_psdev->uc_devname);
-                }
-        }
-
-        buf[buflen-1] = '\0';
-        CDEBUG(D_SUPER, "%s\n", buf);
-        return len;
-}
-
-#ifdef CONFIG_KREINT
-/* get mount point by volname
-       Arthur Ma, 2000.12.25
- */
-int presto_get_mount (char *buf, int buflen, char *volname)
-{
-        int i;
-        struct list_head *head, *tmp;
-        struct presto_cache *cache = NULL;
-        char *path = "";
-
-        buf[0] = '\0';
-        for (i=0 ; i<CACHES_SIZE ; i++) {
-                head = tmp = &presto_caches[i];
-                while ( (tmp = tmp->next) != head ) {
-                        cache = list_entry(tmp, struct presto_cache,
-                                            cache_chain);
-                        if ( !cache->cache_root_fileset || !cache->cache_mtpt)
-                                continue;
-                        if ( strcmp(cache->cache_root_fileset, volname) == 0)
-                                break;
-                }
-        }
-        if (cache != NULL)
-                path = cache->cache_mtpt;
-        strncpy (buf, path, buflen);
-        return strlen (buf);
-}
-#endif
-
 /* another debugging routine: check fs is InterMezzo fs */
 int presto_ispresto(struct inode *inode)
 {
@@ -178,23 +126,21 @@
 }
 
 /* setup a cache structure when we need one */
-struct presto_cache *presto_init_cache(void)
+struct presto_cache *presto_cache_init(void)
 {
         struct presto_cache *cache;
 
-        /* make a presto_cache structure for the hash */
-        PRESTO_ALLOC(cache, struct presto_cache *, sizeof(struct presto_cache));
+        PRESTO_ALLOC(cache, sizeof(struct presto_cache));
         if ( cache ) {
                 memset(cache, 0, sizeof(struct presto_cache));
                 INIT_LIST_HEAD(&cache->cache_chain);
                 INIT_LIST_HEAD(&cache->cache_fset_list);
+                cache->cache_lock = SPIN_LOCK_UNLOCKED;
+                cache->cache_reserved = 0; 
         }
-	cache->cache_lock = SPIN_LOCK_UNLOCKED;
-	cache->cache_reserved = 0; 
         return cache;
 }
 
-
 /* free a cache structure and all of the memory it is pointing to */
 inline void presto_free_cache(struct presto_cache *cache)
 {
@@ -202,12 +148,12 @@
                 return;
 
         list_del(&cache->cache_chain);
-        if (cache->cache_mtpt)
-                PRESTO_FREE(cache->cache_mtpt, strlen(cache->cache_mtpt) + 1);
-        if (cache->cache_type)
-                PRESTO_FREE(cache->cache_type, strlen(cache->cache_type) + 1);
-        if (cache->cache_root_fileset)
-                PRESTO_FREE(cache->cache_root_fileset, strlen(cache->cache_root_fileset) + 1);
+        if (cache->cache_sb && cache->cache_sb->s_root &&
+                        presto_d2d(cache->cache_sb->s_root)) {
+                kmem_cache_free(presto_dentry_slab, 
+                                presto_d2d(cache->cache_sb->s_root));
+                cache->cache_sb->s_root->d_fsdata = NULL;
+        }
 
         PRESTO_FREE(cache, sizeof(struct presto_cache));
 }
@@ -216,41 +162,43 @@
 {
         struct filter_fs *filter; 
         loff_t avail; 
-	struct super_block *sb = cache->cache_sb;
+        struct super_block *sb = cache->cache_sb;
         filter = cache->cache_filter;
-	if (!filter ) {
-		EXIT;
-		return 0; 
-	}
-	if (!filter->o_trops ) {
-		EXIT;
-		return 0; 
-	}
-	if (!filter->o_trops->tr_avail ) {
-		EXIT;
-		return 0; 
-	}
+        if (!filter ) {
+                EXIT;
+                return 0; 
+        }
+        if (!filter->o_trops ) {
+                EXIT;
+                return 0; 
+        }
+        if (!filter->o_trops->tr_avail ) {
+                EXIT;
+                return 0; 
+        }
+
+        spin_lock(&cache->cache_lock);
         avail = filter->o_trops->tr_avail(cache, sb); 
         CDEBUG(D_SUPER, "ESC::%ld +++> %ld \n", (long) cache->cache_reserved,
-	         (long) (cache->cache_reserved + req)); 
+                 (long) (cache->cache_reserved + req)); 
         CDEBUG(D_SUPER, "ESC::Avail::%ld \n", (long) avail);
-	spin_lock(&cache->cache_lock);
         if (req + cache->cache_reserved > avail) {
-		spin_unlock(&cache->cache_lock);
+                spin_unlock(&cache->cache_lock);
                 EXIT;
                 return -ENOSPC;
         }
-	cache->cache_reserved += req; 
-	spin_unlock(&cache->cache_lock);
+        cache->cache_reserved += req; 
+        spin_unlock(&cache->cache_lock);
 
+        EXIT;
         return 0;
 }
 
 void presto_release_space(struct presto_cache *cache, loff_t req)
 {
         CDEBUG(D_SUPER, "ESC::%ld ---> %ld \n", (long) cache->cache_reserved,
-	         (long) (cache->cache_reserved - req)); 
-	spin_lock(&cache->cache_lock);
-	cache->cache_reserved -= req; 
-	spin_unlock(&cache->cache_lock);
+                 (long) (cache->cache_reserved - req)); 
+        spin_lock(&cache->cache_lock);
+        cache->cache_reserved -= req; 
+        spin_unlock(&cache->cache_lock);
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)