Whamcloud - gitweb
Branch:HEAD
[fs/lustre-release.git] / lustre / snapfs / cache.c
index bb1ed30..62cb15b 100644 (file)
@@ -54,11 +54,11 @@ inline void snap_init_cache_hash(void)
 struct snap_cache *snap_find_cache(kdev_t dev)
 {
        struct snap_cache *cache;
-       struct list_head *lh, *tmp;
+       struct list_head *lh;
 
-       lh = tmp = &(snap_caches[snap_cache_hash(dev)]);
+       lh = &(snap_caches[snap_cache_hash(dev)]);
         list_for_each_entry(cache, lh, cache_chain) { 
-               if ( cache->cache_dev == dev )
+               if (cache->cache_dev == dev)
                        return cache;
        }
        return NULL;
@@ -72,18 +72,29 @@ struct snap_cache *snap_init_cache(void)
        /* make a snap_cache structure for the hash */
        SNAP_ALLOC(cache,  sizeof(struct snap_cache));
        if ( cache ) {
-               int i;
-                
                 memset(cache, 0, sizeof(struct snap_cache));
                INIT_LIST_HEAD(&cache->cache_chain);
                INIT_LIST_HEAD(&cache->cache_clone_list);
-                               
-                for (i = 0; i < SNAP_MAX_TABLES; i++) {
-                        init_MUTEX(&snap_tables[i].tbl_sema); 
-                }
         }
        return cache;
 }
+/*walk through the cache structure*/
+int snap_cache_process(snap_cache_cb_t cb, void* in, unsigned long* out)
+{
+       int i = 0;
+
+       for (i = 0; i < CACHES_SIZE; i++) {
+               struct snap_cache *cache;
+               struct list_head *lh = &(snap_caches[i]);
+               list_for_each_entry(cache, lh, cache_chain) {   
+                       if (cb(cache, in, out))
+                               goto exit;
+               }
+       }
+exit:
+       return 0;
+}
+
 
 /* free a cache structure and all of the memory it is pointing to */
 inline void snap_free_cache(struct snap_cache *cache)